2009-01-01から1年間の記事一覧

Rails: Using url_for in script/console or irb

Here is how to call url_for from within script/console (don't use irb, use script/console): app.url_forSimple, but took a bit of Googling to find.References: http://www.caboo.se/articles/2006/3/23/url-generations-in-script-console

College Musical

I originally never intended this site to be more than a bunch of system/programming notes for myself, but in case anyone out there stumbles upon this... the following is the coolest thing I've seen on the Internet in a while. It is a music…

Recursive grep and skipping multiple directories using --exclude-dir

I have this shell script to skip svn and log directories when doing a recursive grep: #!/bin/sh grep --color=tty -d skip --exclude-dir=.svn --exclude-dir=log -r "$1" $2There is also what looks like a good replacement for grep called ack.

Rails: How to test an OAuth Provider controller in a functional test

Suppose you have a controller that is an OAuth Provider. It rejects requests that do not have proper OAuth signatures and accepts only requests that do. You would like to test this controller in a functional test.It is not (to me, anyway) …

Eclipse: Could not initialize class org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManager

The following error message in Eclipse: An error has occurred. See error log for more details. Could not initialize class org.eclipse.wst.server.ui.internal.provisional.UIDecoratorManageris a known bug. The bug is now fixed in WTP 3.1.2. T…

SVN proxy settings

In /etc/subversion/servers, add the lines: [global] http-proxy-exceptions = localhost,*.exception.com http-proxy-host = proxy.com http-proxy-port = 8080More info here: http://svnbook.red-bean.com/en/1.1/ch07.html#svn-ch-7-sect-1.3.1Also, y…

Tomcat proxy settings

In catalina.properties, add the lines: http.proxyHost=10.25.10.25 http.proxyPort=8080 http.nonProxyHosts=localhost|127.0.0.1|*.exception.comThese are Java system properties as described here: http://java.sun.com/j2se/1.4.2/docs/guide/net/p…

Google Wave with Prosody

UPDATE: The Google Wave wiki now has Prosody installation docs here. I had some trouble getting Google Wave federation working with the XMPP servers Openfire and ejabberd on Ubuntu. Finally I tried Prosody, and it works fine! Here how I in…

Mercurial on Ubuntu behind a proxy

I tried out Mercurial on Ubuntu 8.10, and was immediately defeated by my corporate proxy: $ hg clone https://wave-protocol.googlecode.com/hg/ wave-protocol abort: HTTP Error 501: Not ImplementedHere is how I fixed this.Step 1: Configure Me…

irssi highlights in yellow on a white background

On the IRC client irssi, when your nick is included in a message, that message's nick is highlighted in yellow to alert you. Unfortunately, yellow is difficult to read on a white background.The highlight color is defined in the default the…

Rails: Routes, url_for, and slashes

Two surprises with Rails today involving URLs and escape sequences.1. Regular expressions in routes operate on the raw URL.Suppose you have these routes: map.connect 'test/:id', :controller => 'test', :id => /[^\/]*/ map.connect 'test/:hi/…

How to get the at command to work in Ubuntu

I have recently been using "sleep 6.25h; vlc alarm.mp3" as an alarm clock. Unfortunately, this approach requires me to calculate the number of hours until I have to wake up, which is error-prone late at night. I want to just specify the ti…

Rails: How to route programatically

It is not obvious how to take a URL (or more specifically a path) and figure out what controller and parameters it routes to. Here is the answer:ActionController::Routing::Routes.recognize_path("/test/where/does/this/go")Found at this link:…

Set-Cookie and Set-Cookie2 troubles

I've done more work with HTTP cookies than I care to admit. My naive assumption when beginning this adventure was that it would suffice to study the relevant RFCs (RFC 2109 and RFC 2965) and implement software compliant to them. It turns o…

Rails: How to test send_file

Suppose a controller transmits a file using send_file, and you would like an integration or functional test to test it by verifying the contents of the file. You cannot directly access the value of response.body, since it is an instance of…

Setting the body of a POST request in a Rails integration test

You might try to set the request object's RAW_POST_DATA as you do in a functional test, but this will fail.The following blog explains the solution: http://codemonky.com/post/8241251/integration-test-funBasically, you do something like thi…

Rails: Using url_for in a functional test

This post explains how to use url_for inside of a functional test.http://jotthought.com/articles/2007/05/04/using-url_for-in-ruby-on-rails-tests/EDIT: Unfortunately, doing it this way seems to break url_for in integration tests, which norm…

Commands for the package management system in Ubuntu/Debian

The command-line tools for apt/dpkg are surprisingly unintuitive, and I could not find any useful yet concise guide, so here is my attempt. (I dare to put Debian in the title, since all documentation indicates that Ubuntu's and Debian's pa…

How to stop Hatena diary from highlighting search terms

I didn't realize that when clicking through a Google search to this blog, the items from the search query appear highlighted whenever they appear on the page. This is extremely annoying for common words like "on" and has little benefit eve…

How to change Firefox's context menus (and other menus)

I have long wanted a way to disable the "Send Link as Mail" item on Firefox's context menu. Never have I meant to use this feature, and whenever I do accidentally click on it, the computer freezes while some unwanted mail client is launche…

Lack of usable WebDAV clients and servers

This is pretty frustrating. I'm just jotting these posts down as useful links.http://wooga.drbacchus.com/webdav-windows-and-frustration http://it.knightnet.org.uk/2009/05/how-to-use-webdav-on-windows-vista-and.html

How to tell what version of Ubuntu you are running.

There are (as usual) multiple ways to do this. You can run: lsb_release -aThis will give output such as: No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 8.10 Release: 8.10 Codename: intrepidLinux Standard Base (LSB…

Names of directories in output of ls are blue on green and difficult to read.

If you mount NTFS volumes, you will find that the directory names in ls output are impossible to read. They are blue text on a green background.On a default Ubuntu setup, look in your ~/.bashrc file and you will see the ls colors are deter…

Ubuntu and static IPs

It is difficult to configure an Ubuntu 8.10 Desktop to have a static IP due to some software called Gnome Network Manager smashing the relevant configuration file. The following blog post has more information: http://chrisjohnston.org/2008…

Ruby 1.9, mysql, Phusion Passenger, and rails on Ubuntu

Here are some gotchas when trying to install Ruby on Rails on Ubuntu using Ruby 1.9, mysql, and Passenger (mod_rails).The mysql gem fails. In particular, running gem install mysqlwill fail with something like this: gem install mysql Buildi…

Sound distortion in Ubuntu

This entry is more of a running notebook than an informative post intended for others.Occasionally, sound in Ubuntu 8.10 (Intrepid) gets heavily distorted: there is severe reverb and voices come out robotic and alien-like to the point of i…

Ubuntu: no sound in Flash

One of the most common problems with a fresh Ubuntu installation is sound not working, particularly with Flash videos. This is apparently due to a bad configuration of PulseAudio. The web is riddled with blog entries and forum posts about …

Adding a certificate to the Java SSL keystore

The Java SSL keystore file is typically located at: $(JAVA_HOME)/jre/lib/security/cacertsThis file contains the certificates of CAs that you want to trust. To add a certificate to this file, use the keytool program that comes with the JRE.…

in `require': no such file to load -- zlib (LoadError)

When trying to install rails on an Ubuntu 8.10, I got the following sort of error: $ sudo gem install rails ... in `require': no such file to load -- zlib (LoadError)The same error occurs when running: $ sudo gem updateTo fix this, ensure …

mod_rails and environment variables, proxy setting for ruby-openid

The ruby-openid library has support for deployments behind a corporate proxy, but you have to enable it programmatically. Place this in environment.rb after the Rails::Initializer block. ENV['HTTP_PROXY'] = "http://myproxy" ENV['HTTPS_PROX…