Friday, December 14, 2007
URLs With file_column
Run it against lib/file_column.rb
Enjoy! file_column patch.
Thursday, December 13, 2007
Rails 2.0 Screencast
http://www.akitaonrails.com/2007/12/10/the-first-rails-2-0-screencast-english
Direct links to the text versions:
http://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial
http://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial-part-2
Getting Rails 2.0 Running
$ sudo gem update sources
$ sudo gem update --system
$ sudo gem uninstall mysql
$ sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
$ sudo gem update -- --with-mysql-dir=/usr/local/mysql
$ sudo gem install rails --include-dependencies
I know there is a bit of duplicated effort there, but I had issues with that MySQL gem.
Finally Rails 2.0 joy. Now to fiddle around with it before starting a new project...
Installing the MySQL Ruby Gem for Rails MySQL Support on OSX Leopard
$ export ARCHFLAGS="-arch i386"
$ sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
I got this information from http://trac.macosforge.org/projects/ruby/wiki/Troubleshooting.
Wednesday, December 05, 2007
Netbeans 6 Final
Wednesday, November 21, 2007
Rails SQL Optimization
I have only tested this on Mac/MySQL, so your mileage may vary (it uses *NIX file paths). This script has saved me MUCH time. Of course, when optimizing queries, don't go overboard on eager loading. ActiveRecord eager loading can be slow if you use multiple nested includes.
Just run this script within your Rails application root directory, and it will create a file named explained.html. You may set the RAILS_ENV environment variable to specify production mode. The script automatically loads your database configuration from log/database.yml
Oh, and there needs to be at least 2 pageloads in your log. I haven't bothered fixing this bug.
So here is the script.
UPDATE: I came across some good tips for additional optimization here.
Friday, May 04, 2007
Dynamic DNS Setup In Ubuntu Using DynDNS
I use Dyndns.org for dynamic domain services. There is easy setup and you can update your IP via a web browser, or schedule an application to run on a regular basis. Updating your IP address is important because you will lose your domain if you don’t update your record every 30-35 days. Here is a basic guide.
In Debian/Ubuntu you can install the updater via apt:
sudo apt-get install ipcheck |
Create bin directory, dyndns directory and updater script:
mkdir ~/bin |
#!/bin/sh |
Edit your crontab:
crontab -e |
Add the following line to your crontab to run the script daily.
* 6 * * * /home/username/bin/dyndns-update.sh |
Tuesday, May 01, 2007
User Driven Sites
Thursday, March 22, 2007
A Server Monitor
You write a simple XML configuration file, and call the app via the commandline specifying where the config, output, and XSL template are (cross-domain issues with XSL are fun!).
What are you waiting for?
http://code.google.com/p/rubyservermonitor/
Tabbed Pages with CSS and Javascript
What we have here is a horizontally styled list acting as a navigation bar, and a set of hidden divs shown when appropriate.
Source here.
Monday, March 05, 2007
Must-Have DVD Apps
k9copy: DVD9 to DVD5 copier
Thoggen: Rip DVD to OGG video
Friday, March 02, 2007
Hard Drive Performance and hdparm
Well, a RAM stick went out and I am down to 512MB, can we say SWAP???. So I checked out the ouput from hdparm and I had a nasty surprise. 8.59 MB/sec!!!
hdparm to the rescue.
$ hdparm -c3 -m16 -d1 -u1 -X70 -k /dev/hdb
37.99 MB/sec!!!
That should improve performance significantly!
Note: These settings are for a Seagate Barracuda 80GB
$ sudo hdparm -I /dev/hdb
...
ATA device, with non-removable media
Model Number: ST380021A
Serial Number: 3HV291LP
Firmware Revision: 3.19
...
Friday, February 16, 2007
Gnome Startup Programs Bug
To correct:
sudo chown -R username:username /home/username/.config
Friday, February 09, 2007
Ruby HTTPS with HTTP Basic Auth
require 'net/http'
require 'net/https'
def get_feed(server,path,username,password)
req = Net::HTTP::Get.new(path)
http.use_ssl = true
req.basic_auth username, password
response = http.request(req)
return response.body
Wednesday, January 31, 2007
Complicity in Murder
Saddam Hussein's execution is still in very recent memory it is
worth remembering that the United States government has long been aware of the crimes that Saddam committed, and to a certain
extent complicit. A key quote from Barry Lando:
The US gave satellite information, more to the Iraqis, enabling them to target Iranian troop concentrations, even though the US knew that the Iraqis were using chemical weapons.
Follow the link for an enlightening interview with a former 60 Minutes producer.
Monday, January 22, 2007
SSH Public Key Authentication
(password-less SSH authentication on *nix systems)
Its a pain to enter in passwords all day. If you are like me and have a dozen or more machines and accounts to maintain, password management gets ridiculous. A great solution is public key authentication. You create a public key and a private key on a client machine, and distribute the public key to the various accounts and servers you need to access. The public key identifies you, and your private key verifies your identity. You only create your key pair once, and place your public key on all the servers you want to configure for password-less login. If you do create another new key pair on the local machine, you will again have to follow the steps for configuring the remote machines.
Keep in mind, the idea is to have a key pair for a specific local account on a specific machine. If you want to be able to use password-less login from another machine, you should create a new key pair on that machine. DON'T simply copy your key pair to another machine.
Public key authentication also makes scripted remote management possible, but thats beyond the scope of this mini-article. So let's begin:
On Local/Client Machine
# Create .ssh directory unless it already exists
cd ~/.ssh
# Create your keypair. Specifying a password will protect your private key even if the private key file is compromised. Remember, the private key file identifies you, and if that file is compromised, the server is compromised as well. Regardless of password security, set secure permissions for this file.
ssh-keygen -t dsa
chmod 600 id_dsa
# Copy your public key to the server, specifically your remote user's home directory.
scp id_dsa.pub remote_username@example.com:/home/remote_username
On Remote/Server Machine
cd ~/.ssh
# Create the authorized key file unless it already exists
touch authorized_keys2
chmod 600 authorized_keys2
# Append your public key to the authorized key file. Directly editing the key file is generally a bad idea. Then delete the public key file you copied to this machine.
cat ~/id_dsa.pub >> authorized_keys2
rm ~/id_dsa.pub
If you mess up, or your private key is compromised, there is a small amount of cleanup involved. On each of the configured servers, delete the line in the authorized_keys2 file that corresponds to your public key, and delete your local key pair as well. You can then start over.
Strip HTML Tags
#!/usr/bin/ruby -n
puts $_.gsub(/<\/?[^>]*>/, "")
Sunday, January 21, 2007
Edit A Webpage in Place
javascript:document.body.contentEditable='true'; document.designMode='on'; void 0
This is an interesting hack. It is nothing of immediate utility, but combined with some other functionailty...
Thursday, January 18, 2007
UNBELIEVABLE!!!!
Specter: Now wait a minute, wait a minute. The Constitution says you can't take it away except in the case of invasion or rebellion. Doesn't that mean you have the right of habeas corpus?
Gonzales: I meant by that comment that the Constitution doesn't say that every individual in the United States or every citizen has or is assured the right of habeas corpus. It doesn't say that. It simply says that the right of habeas corpus shall not be suspended.
http://www.dailykos.com/storyonly/2007/1/18/15219/0788
Apparently our ATTORNEY GENERAL doesn't understand the fundamental premise of the Constitution, that ALL rights not EXPLICITLY given to the government are retained by the people.
Ruby Cheat Sheets
Sunday, January 14, 2007
United States Activities Inside Iran?
When asked whether U.S. forces would cross into Iran to pursue those aiding Iraqi insurgents, he said: He said the priority "is what's going on inside Iraq. ... That's where we're going to deal with his problem." and, "Anytime you have questions about crossing international borders there are legal issues. ... We intend to deal with it by interdicting and disrupting activities in Iraq sponsored by Iran."
This response raises several questions as to whether the U.S. IS currently operating inside Iran. This administration has had a pattern of operating outside of established legal precedent (NSA wiretapping case, abuse of prisoners, suspension of habeas corpus, extraordinary rendition, etc, etc.), then dealing with the consequences (or lack of), later. In my mind, these aren't questions, but rather indications, but there is the cynicism and pragmatism.
Don't get me wrong, if people are assisting insurgents in killing our troops, they should be taken care of. Yet military incursions into a sovereign country against citizens of that country is an act of war, and war must be declared by Congress. Hence the "legal issues" mentioned by Mr. Hadley. Regardless, it has been apparent for some time that the administration's mind and direction are already set.
Just last Thursday, U.S. forces captured and detained 5 Iranian officials of relatively high rank. It has become obvious, that Iran is supporting at least the Shia side of the insurgency, and is establishing a political and military toehold in the power vacuum of Iraq.
War with Iran has already started. With politics, and on a small scale (on our side), soldiers. The battleground just happens to be Iraq.
References:
http://www.cbsnews.com/stories/2007/01/14/ap/politics/mainD8ML45IO0.shtml
http://www.washingtonpost.com/wp-dyn/content/article/2007/01/11/AR2007011100427.html
http://www.slate.com/id/2157489/fr/flyout
Friday, January 12, 2007
Disable Low Disk Space Notification in Windows XP
1. | Click Start, click Run, type regedit, and then click OK. |
2. | Locate and then click the following key in the registry: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer |
3. | On the Edit menu, point to New, and then click DWORD Value. |
4. | Type NoLowDiskSpaceChecks, and then press ENTER. |
5. | On the Edit menu, click Modify. |
6. | Type 1, and then click OK. |
From http://support.microsoft.com/kb/285107
Wednesday, January 03, 2007
Rails Development Using Vim
In my experience as a Linux administrator and desktop user, I have learned to appreciate, and now love the Vi editor. Well, more accurately Vim. If you are using a GUI, Cream is an excellent set of customizations for GVim that make Vim more accessible to the new user.
To improve the state of affairs even further, there are various Ruby and Rails specific extensions and customizations that bring Vim to the point of being nearly as good, and better in some ways, than TextMate or RadRails. We're talking autocompletion, autoindention, syntax highlighting, abbreviations, and much much more. See this post (so useful to me that I mirrored it here) for how to tweak Vim for Rails development.