software, business, and fun

cambodia

subversion new project quick notes

SERVER:su
su www-data
cd /var/lib/subversion/repository
svnadmin create project.name

LOCAL:cd ~/code
svn co http://svnhost/project.name
cd project.name
cp -r ../empty_svn_initial_layout/* ./
svn add *
svn ci -m 'initial project import'
rm -rf ./project.name
svn co http://svnhost/project.name/trunk ./project.name

November 30, 2007   No Comments

gem Update Getting Killed

sudo gem upgrade radiant
Bulk updating Gem source index for: http://gems.rubyforge.org
Killed

Turns out the server was out of ram (!) vmstat showed 150MB free, but the bulk update used too much ram and the kernel killed it. Wow.

To fix it, I dropped the production site down to 8 mongrels instead of 20. vmstat shows 500+MB free, update worked.

The original plan to have 20 mongrels was when that project powered the static content too, but now radiant manages that (with it’s own 4 mongrels). With site traffic being much lower than expected, and 20 being too much, dropping to 8 seemed right.

November 30, 2007   No Comments

os x cd/dvd burner info

drutil info

Vendor Product Rev
SONY DVD RW DW-U10A A43h

Interconnect: ATAPI
SupportLevel: Apple Shipping
Cache: 8192k
CD-Write: -R, -RW, BUFE, CDText, Test, IndexPts, ISRC
DVD-Write: -R, -RW, +R, +RW, BUFE, Test
Strategies: CD-TAO, CD-SAO, CD-Raw, DVD-DAO

November 28, 2007   No Comments

apt-get key problem

Aptitude was erroring about a missing key. I had to add the key manually with GPG.

http://bsd.b3ta.org/2007/03/27/apt-get-update-no_pubkey/
http://lists.netisland.net/archives/plug/plug-2007-04/msg00060.html
ex: if key A70DAF536070D3A1
was missing
gpg --keyserver wwwkeys.eu.pgp.net --recv-keys A70DAF536070D3A1
gpg --armor --export A70DAF536070D3A1 | apt-key add -

October 25, 2007   No Comments

The Debian Sarge/Etch Monstrosity

Chalk this win up to Debian being stable enough to run a few months with a Sarge/Etch kernel/userland mismatch.

What happened was one server that got ordered right around the Etch release would run Etch fine, but the hosting company still had to officially run Sarge because of the RAID controller. The upgrades were left to us, and all they would restore to is Sarge.

Anyway, cut to later this year - I noticed something wonky when aptitide was installing linux-image-2.6.18-*, but uname said I was running sarge’s 2.6.8 kernel. The real fun was that the uptime was 155 days on the old Sarge based system. What had happened was GRUB never got updated, so it kept using the old kernel.

travis@debian/etc $ cat debian_version
4.0

travis@debian/etc $ uname -mrs
Linux 2.6.8-3-k7-smp i686

travis@debian/etc $ sudo update-grub
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... Generating /boot/grub/default file and setting the default boot entry to 0
Searching for GRUB installation directory ... found: /boot/grub
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... found: /boot/grub/splash.xpm.gz
Found kernel: /vmlinuz-2.6.18-5-k7
Found kernel: /vmlinuz-2.6.18-4-k7
Found kernel: /vmlinuz-2.6.8-3-k7-smp
Updating /boot/grub/menu.lst ... done

travis@debian/etc $ sudo shutdown -r now

[wait + ping + sweating bullets]

travis@debian~ $ uname -mrs
Linux debian 2.6.18-5-k7 #1 SMP Wed Sep 26 18:29:20 UTC 2007 i686 GNU/Linux

Awesome. I was not happy to think about what would have happened if it didn’t come back online. I

If we had console access (which we didn’t at that host), I’m sure GRUB could have booted the old kernel from that, and then fix whatever happened. I have a feeling their would have been some something wrong rebooting a Sarge kernel into an Etch userland though. Would make an interesting experiment to see if it’s possible, or if some libc error botches it all.

October 2, 2007   No Comments

attachment_fu Test Troubles

rake test:plugins PLUGIN=attachment_fu TESTOPTS=”-v”

attachment_fu’s tests hate me, or at least hate my MacBook.

Problems:
1. always whines about s3 even if i don’t want to use it
2. ImageWithThumbsClassFileAttachment fails it - says full_filename doesn’t exist
3. test_should_create_file_from_uploaded_file is reading a text file as a png
4. makes a sqlite database file in my root project directoy!
5. gives a weird error: unknown IO error whilst running rake

1 and 2 are fixable. http://beast.caboo.se/forums/2/topics/1074

3: I really did not understand this test failing. Opening a text file, checking if nil height - okay. Maybe a bug in my processing since it returns 612px width! Who knows.

4. Can be fixed by hardcoded sqlite to use an in memory database, but I could not get erb to run in the yaml file to give it a dynamic location. Doh!

5: This was a real head scratcher:

class MinimalAttachment < ActiveRecord::Base
has_attachment :path_prefix => ‘vendor/plugins/attachment_fu/test/files’, :processor => :rmagick
validates_as_attachment

def filename
“#{id}_file”
end
end

That fixes it. For some reason Tempfile gives an unknown IO error if the tempfile ends in .file

Can verify by editing attachment_fu.rb:

def random_tempfile_filename
"#{rand Time.now.to_i}#{filename || 'attachment'}.file"
end

and then get the errors. What?? I dug around some but just didn’t have time to really fix that.

I figure as long as I understand why the tests fails I’m okay. The only issue I found with any changes I made was using backward compatibility :file_system_path. I don’t use that.

2008 Update:
Rick does seem to be updating the code base to include these fixes. http://pastie.textmate.org/67051 Yay.

September 21, 2007   No Comments

The meaning of life

“The meaning of life always changes, but it never ceases to be.”

Viktor E. Frankl

August 26, 2007   No Comments

VOIP Backend Posting

The project needed a minimum payload to sent over HTTP to test the VOIP service with. I ended up boiling it down to:

'username' => username,
'password' => password,
'alarm_type' => 'immediate',
'tts_or_wav' => 'tts',
'phone_recips' => '5555555',
'tts_msg' => 'this is an automated test from a ruby script. so cool.',
'deliv_type' => 'phonecall'

Sure enough, the creepy text to speech system called me up. This made testing this project pretty cool. For full testing it will send sample request to the VOIP server, and my phone rings a few seconds later.

The full extent of that project was to play an arbitrary WAV file to the receiving phone number, so there were some extra tests involving verifying the WAV, etc. If I were really lazy, I would set up a speech recognition engine over a VOIP receiver and match the test WAV to what comes in over the phone, and make sure it’s understandable.

It would be one of the strangest rake tasks I can think of.

August 22, 2007   No Comments

POST via https using http-access/httpclient

Project required periodic posting to HTTPS via http-access/httpclient.

The first issue was how to set the certficate to use. Safari does not export SSL certificates in a way useful to openssl. The .cer or .cert files give an exception of “OpenSSL::X509::StoreError”

To track that down I had to dig around the curl docs of all places - they have better documentation than http-access.

The way to do this is open with OS X keychain, export as .pem (base64 encoded version), and save .pem file in the config dir of rails.

This led to the next problem - the HTTPS server had a bum certificate, it was from a different host. I think their setup was done on the cheap. http-access kept failing with OpenSSL::SSL::SSLError - hostname not match.

The way to get around this is to set verify_mode = nil


require 'httpclient'
client = HTTPClient.new()
client.ssl_config.verify_mode = nil

http://ghouston.blogspot.com/2006/03/using-ssl-with-ruby-http-access2.html
http://curl.haxx.se/docs/faq.html#What_certificates_do_I_need_when
http://dev.ctor.org/svn/http-access2/trunk/lib/httpclient.rb
http://groups.google.co.uk/group/soap4r/browse_thread/thread/872f2f5c61ce20c6

August 22, 2007   No Comments

thoughts about debian logrotate

/etc/logrotate.d - holds all files to be run

group together in one file all rails/mongrel logs, and apache in another so you dont restart apache too much.

August 11, 2007   No Comments