Archive for the 'ruby on rails' Category
Wednesday, March 3rd, 2010
Here at Katipo, we’re using New Relic RPM to monitor our deployed Kete applications, to help make things as fast as possible. In order to make New Relic as useful as possible, I’ve been trying out three New Relic RPM features, some available in only the latest versions of RPM, on one of those sites. These recent and little-known features aren’t enabled by default, so I’m going to run you through them and how to set them up in this post.
If you don’t yet use New Relic RPM, you can get a Lite account for free by going to newrelic.com, where you can also test drive New Relic RPM on a real application. (more…)
Posted in apache, ruby, ruby on rails | No Comments »
Tuesday, January 19th, 2010
For those of you who follow this sort of thing, Github shut down their gem building. Thankfully, a newer and easier gem hoster, Gemcutter, appeared on the scene not long before that happened. The idea behind it, for those who haven’t heard of it, is that you manage your own gem building. Gemcutter doesn’t wait for your Gem spec to change before it makes a new gem. You simply build it locally, and push it to Gemcutter, using a handy gem they provide that extends Rubygems ‘gem’ console command.
But Github was building gems for some time, and due to it’s continuing popularity, many well known Ruby on Rails developers and companies switched permanently to Github for their gem building/hosting at the time, so it’s likely that quite a few gems you’ve got installed are from Github.
To help transition over from Github to Gemcutter, Maxim Chernyak wrote a great utility called off_github, which looks at your list of gems, and tells you which ones you’re installed from Github, and whether they can be reinstalled from Gemcutter. It saves a lot of time and effort than having to do it manually. So here’s how to get started….
(more…)
Posted in ruby, ruby on rails | No Comments »
Saturday, January 24th, 2009
Here’s a quick one. Say you are debugging a bit of code in a plugin that doesn’t fall under the Rails app you are working on’s ActiveSupport context and thus “logger.debug” is not available to you.
You could write up your own logging mechanism, with or without using the Logger gem. However, if what you are working on is run by the Rails app and thus has the apps global constants available, you could simply tie it into the existing logger object in the Rails app like so in your file:
logger = RAILS_DEFAULT_LOGGER
Then you can use logger.debug, logger.info, etc. to your heart’s content. One caveat, if you are working on a gem or a something more general that won’t necessarily always be run in the context of Rails, then you will want to pull your use of logger out before distributing your code. Otherwise you add a dependency on Rails that you may not intend.
Posted in open source, random, ruby on rails | No Comments »
Thursday, January 15th, 2009
You have to give Logical Awesome credit for how much work they do to integrate GitHub’s services with tools that developers use.
The Gist service is a good example. First they added command line support for it, then they simultaneously added in-editor support in Textmate, vim, and my own personal favorite emacs. The blog post announcing gist support in emacs and vim is here.
So how do you add the gist support to emacs?
First, you’ll need an account on github.com and have set up your ~/.gitconfig as outlined in here.
Then download or clone the gist.el file from http://github.com/defunkt/gist.el, copy only the gist.el file from that repository to someplace in your emacs load path (in my case /Users/walter/Library/Preferences/Aquamacs Emacs/ because I use Aquamacs on a Mac), and add a line to your ~/.emacs file or in my case /Users/walter/Library/Preferences/Aquamacs Emacs/Preferences.el that looks like this:
(require ‘gist)
Then you have to either restart your emacs program or do M-x load-library and answer prompt with gist for the new gist commands to be available.
Now you have M-x commands like these:
- gist-view-gist
- view gists after they’re posted
- gist-region
- Post the current region as a new paste at gist.github.com
Copies the URL into the kill ring.
- gist-region-private
- Post the current region as a new private paste at gist.github.com
Copies the URL into the kill ring.
- gist-buffer
- Post the current buffer as a new paste at gist.github.com.
Copies the URL into the kill ring.
- gist-buffer-private
- Post the current buffer as a new private paste at gist.github.com.
Copies the URL into the kill ring.
- gist-region-or-buffer
- Post either the current region, or if mark is not set, the current buffer as a new paste at gist.github.com
Copies the URL into the kill ring.
- gist-region-or-buffer-private
- you can probably guess…
- gist-fetch
- Given an gist id, fetches a Gist and inserts it into a new buffer
If the Gist already exists in a buffer, switches to it.
Very useful stuff for collaboration, but without leaving your editor.
Enjoy,
Walter
Posted in open source, random, ruby on rails | No Comments »
Tuesday, September 9th, 2008
A natural inclination when one starts programming in Ruby is to use “and” and “or” instead of the “&&” and “||” to increase readability. However, “and” is not a drop in syntactic synonym with “&&” and the same goes for “or”.
James pointed out a good blog post that explains the issues around order of precedence with these operators:
http://blog.jayfields.com/2007/08/ruby-operator-precedence-of-and-which.html
It’s worth reading the comments.
It should also be noted that the Ruby on Rails source style guide has a preference for “&&” and “||”:
http://rails.lighthouseapp.com/projects/8994/source-style
Posted in kete development, open source, ruby on rails | No Comments »
Sunday, October 14th, 2007
The other day I was asked how much disk space a particular Kete project’s production database used. I didn’t have an answer, so I started searching for one.
In my case, the db software is MySQL and getting a report about various aspects of a db’s tables boils down to this query:
show table status;
The output of this query has way more information than I need, plus to get the total number of bytes used you have to add all the values up anyway, so I decided to make a rake task to make this repeatable and return something succinct.
I have added the new rake task to the Kete app’s codebase. If you aren’t a Kete user, but need this functionality for your Ruby on Rails app, you can find it here:
http://svn.kete.net.nz/projects/kete/trunk/lib/tasks/db-disk-usage-report.rake
Note there is a formatting method taken from the Rails Helpers, I would love to not duplicate this definition. If anyone has a recommendation for the best way to pull this method into this rake task, I would appreciate it. Probably a simple include statement, but I didn’t get around to figuring out the correct incantation.
I would also love to hear how best to make this handle other database software, for example PostgreSQL, too.
Cheers,
Walter
Posted in kete development, open source, random, ruby on rails, sysadmin | 1 Comment »
Sunday, October 14th, 2007
As previously mentioned, I have written a guide on how to set up Kete (also applicable to other Rails apps though Kete includes some extra required software and niceties to make it easier) for Development on Mac OS X. This guide also includes best practices for Deployment. So the following guide can be seen as the first half of the story:
http://kete.net.nz/documentation/topics/show/16-creating-a-kete-development-environment-on-mac-os-x
But what about the host that you are deploying to? I cover that for Debian Etch in the following guide:
http://kete.net.nz/documentation/topics/show/15-preparing-a-debian-etch-host-to-be-deployed-to-for-kete
You might also be curious what software Kete requires. Here’s a breakdown:
http://kete.net.nz/documentation/topics/show/19-technical-requirements
Cheers,
Walter
Posted in kete development, open source, random, ruby on rails, sysadmin | No Comments »
Sunday, October 14th, 2007
I’ve added a guide over at Kete.net.nz for how to install Kete for development on Mac OS X. You can find hit here:
http://kete.net.nz/documentation/topics/show/16-creating-a-kete-development-environment-on-mac-os-x
If anything doesn’t work for you, please let me know.
Cheers,
Walter
Posted in kete development, open source, random, ruby on rails, sysadmin | No Comments »
Tuesday, August 14th, 2007
Personally, I like a highly portable text editor that is powerful enough to use as an IDE. TextMate, from what I hear, is pretty darn great, but by being limited to only Macs, TextMate doesn’t cut it for me. Emacs being emacs, it is quite possible to set it up to be as nice if not nicer than TextMate for Rails development. A good overview can be found at http://www.credmp.org/index.php/2006/11/28/ruby-on-rails-and-emacs/.
And WOW is emacs 22’s Tramp for remote file editing via SSH/SCP awesome! More on that at the end of this post.
(more…)
Posted in kete development, open source, random, ruby on rails | 3 Comments »
Friday, June 8th, 2007
People are moving away from managing their Rails plugins with svn externals towards Piston’s easy vendor branch management approach.
But what if you want to use Piston’s easy version of Subversion’s vendor branch management for dealing with the code for an entire Rails application based on an open source project like Mephisto, Collaboa, or in my case Kete? (more…)
Posted in kete development, open source, random, ruby on rails, sysadmin | No Comments »
|