Katipo
Search  
Site Blog
  About  
  Home
About Portfolio Solutions Client Area Contact Us
: : About Us
Awards
Jobs
Our People
What Is A ... ?
Working From Home
News
Photo Gallery
Katipo Blog


Archive for the 'open source' Category

OPACs for HLT – netbooting WebConverger on ASUS EEEBox b202

Friday, July 17th, 2009

The OPACs at HLT have been failing one by one, so some replacements are in order.  The previous OPACs ran Mozilla in kiosk mode on a hand modified Debian install sufficiently rickety that after ~4 years I didn’t really want to touch it.

Somewhat surprisingly, the task (taking some hardware and netbooting it into a teenage-vandal-proof web kiosk) didn’t appear to be a solved problem – there are still a lot of people rolling their own, I’ve done that once, I didn’t really want to do it again.

Webconverger almost fits the bill, with a couple of caveats: (more…)

Make Rails logger available in code normally outside of logger scope

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.

Adding Gist commands to emacs

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

“and” and “or” use versus “&&” and “||” in ruby

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

Another Development Nicety, A Web Browser Inside Aquamacs Emacs

Monday, January 14th, 2008

This is handy for reading (or cutting and pasting from) documentation that is in HTML that is included with open source software without jumping to an external browser. Check it out:

http://bc.tech.coop/blog/080110.html

How much disk space does your Rails Database use?

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

Server Setup and Deployment for Rails using Capistrano, Mongrel, and Nginx using Mac OS X for Development and Debian Etch for Production

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

Installing the Kete Stack on Mac OS X, including MacPorts, Ruby on Rails, Ruby-Zoom, and Zebra

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

ERC (emacs IRC client) Set Up in Aquamacs

Sunday, September 30th, 2007

I’m going to outline how to set up Aquamacs for my IRC requirements with the built in ERC emacs IRC client so that it automates joining the server and channels I want, with some other bells and whistles (the bell part, literally!). All of these steps have .emacs file equivalent, so you could use it as a starting pointing point for figuring out how to set them, even if you don’t use Aquamacs (Mac OS X GUI emacs).

Here are the steps:
(more…)

Installing and Configuring Aquamacs (Emacs 22 for Mac OS X) with Ruby and Ruby on Rails Development Niceties

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…)


Katipo
Rachel Snowboarding