Friday, January 8, 2010

Enable slow log on amazon rds


rds-create-db-parameter-group primary --description primary --engine MySql5.1
rds-modify-db-parameter-group primary --parameters "name=slow_query_log, value=true, method=immediate"
rds-modify-db-instance YOUR_INSTANCE --db-parameter-group-name primary

Saturday, November 21, 2009

Deploying rails assets to the Amazon CDN

Rails uses a ?timestamp in the URL for cache busting. Together with an expired header in the far future this allows you to get the maximum benefits out of browser caching.

Unfortunately this scheme does not seem to work on the Amazon CDN. I just contributed some changes to the Asset Packager that allow you to better use assets on the CDN

http://github.com/decodeideas/asset_packager

Saturday, November 7, 2009

ec2_upload_bundle and ruby 1.9: can't convert Fixnum into String

The following applies to the following scenari

- ubuntu karmic, ec2 ami
- ruby 1.9.2 installed as /usr/bin/ruby
- the latest ec2 tools

When you use ec2_upload_bundle to re-bundle an AMI that you modified you will get the error

ERROR: can't convert Fixnum into String


The trick to debug this is to pass --debug to the ec2 commands. The fix is on
line 19 of /usr/lib/ec2-ami-tools/lib/ec2/amitools/util.rb
you need to change ?A to ?A.ord to get this line:

(0..19).inject("") {|ident, n| ident+(?A.ord + Kernel.rand(26)).chr}


Before doing the change you can reproduce the problem with

ruby1.9 -r /usr/lib/ec2-ami-tools/lib/ec2/amitools/util -e 'puts
gen_ident'


After applying the patch you should get a short sequence of random
letters.

Friday, November 6, 2009

Plugin not found with ruby 1.9, rails 2.3.4

When using rails 2.3.4 with ruby 1.9.1 you cannot install plugins from git. You will get an error like the following:

script/plugin install git://github.com/giraffesoft/resource_controller.git
Plugin not found: ["git://github.com/giraffesoft/resource_controller.git"]


The simplest workaround is to use ruby 1.8 to run the above. On Snow Leopard you have it very likely as /usr/bin/ruby, so you can do

/usr/bin/ruby script/plugin install git://github.com/giraffesoft/resource_controller.git


On Ubuntu you probably have it as ruby1.8.

Monday, October 19, 2009

Using mov files in Powerpoint

I found out that .mov files play unreliably when imported into Powerpoint. I tried transforming into avi and wmv files using a plethora of tools. The most reliable workflow I found so far is:

1. in Final Cut (Express) generate the mov files in H.264, one bit rate that worked acceptably for me is 1500kbps
2. move to the vista system
3. open Windows Movie Maker
4. import the mov file, add to the history line
5. select Publish to the local system
6. select Custom format
7. select Windows Media Video, DVD 3000kbps
8. write the file, for some annoying reason you cannot use the same name as the mov file even though the file will have the extension wmv

Import the wmv file in power point

Thursday, September 3, 2009

Ruby gems on Snow Leopard

After upgrading to Snow Leopard I am getting all kind of weird errors in my ruby gems, for example:


dlopen(/Library/Ruby/Gems/1.8/gems/nokogiri-1.3.3/lib/nokogiri/nokogiri.bundle, 9): no suitable image found. Did find:
/Library/Ruby/Gems/1.8/gems/nokogiri-1.3.3/lib/nokogiri/nokogiri.bundle: mach-o, but wrong architecture - /Library/Ruby/Gems/1.8/gems/nokogiri-1.3.3/lib/nokogiri/nokogiri.bundle


I just deleted all the files under /Library/Ruby/Gems/1.8/gems and I am reinstalling the gems.

Monday, August 31, 2009

SQS connection between Ruby and Python

If you try to use Amazon SQS to connect Right_aws with Boto you have to keep in mind that Boto expects the body of the message to be encoded in base64. To make life even more interesting the Boto frameawork will crash in the XML parser for some content of the body.

Tuesday, August 4, 2009

Right scale gem on ruby 1.9

If you try to use the right_aws gem on ruby 1.9 you will encounter a couple of errors including

no such file to load -- md5

and

right_aws-1.10.0/lib/s3/right_s3_interface.rb:1133: syntax error, unexpected ':', expecting keyword_then or ',' or ';' or '\n'
when 'LastModified' : @result[:last_modified] = @text
^
right_aws-1.10.0/lib/s3/right_s3_interface.rb:1134: syntax error, unexpected keyword_when, expecting keyword_end
when 'ETag' : @result[:e_tag] = @text
^
right_aws-1.10.0/lib/s3/right_s3_interface.rb:1134: syntax error, unexpected ':', expecting keyword_end
when 'ETag' : @result[:e_tag] = @text
^
right_aws-1.10.0/lib/s3/right_s3_interface.rb:1175: syntax error, unexpected keyword_end, expecting $end


In this case you can use the following patch to port the gem to ruby 1.9. The patch may stop working as Right Scale updates their code, the changes are relatively small and you should be able to re-port the patch to the new code.



diff -crB right_aws-1.10.0-orig/lib/awsbase/right_awsbase.rb right_aws-1.10.0/lib/awsbase/right_awsbase.rb
*** right_aws-1.10.0-orig/lib/awsbase/right_awsbase.rb 2009-08-04 13:40:56.000000000 -0700
--- right_aws-1.10.0/lib/awsbase/right_awsbase.rb 2009-08-04 13:23:53.000000000 -0700
***************
*** 23,29 ****

# Test
module RightAws
! require 'md5'
require 'pp'

class AwsUtils #:nodoc:
--- 23,29 ----

# Test
module RightAws
! require 'digest/md5'
require 'pp'

class AwsUtils #:nodoc:
diff -crB right_aws-1.10.0-orig/lib/s3/right_s3.rb right_aws-1.10.0/lib/s3/right_s3.rb
*** right_aws-1.10.0-orig/lib/s3/right_s3.rb 2009-08-04 13:40:56.000000000 -0700
--- right_aws-1.10.0/lib/s3/right_s3.rb 2009-08-04 13:26:37.000000000 -0700
***************
*** 761,769 ****
@name = name
@perms = perms.to_a
case action
! when :apply: apply
! when :refresh: refresh
! when :apply_and_refresh: apply; refresh
end
end

--- 761,769 ----
@name = name
@perms = perms.to_a
case action
! when :apply then apply
! when :refresh then refresh
! when :apply_and_refresh then apply; refresh
end
end

diff -crB right_aws-1.10.0-orig/lib/s3/right_s3_interface.rb right_aws-1.10.0/lib/s3/right_s3_interface.rb
*** right_aws-1.10.0-orig/lib/s3/right_s3_interface.rb 2009-08-04 13:40:56.000000000 -0700
--- right_aws-1.10.0/lib/s3/right_s3_interface.rb 2009-08-04 13:25:39.000000000 -0700
***************
*** 1130,1137 ****
end
def tagend(name)
case name
! when 'LastModified' : @result[:last_modified] = @text
! when 'ETag' : @result[:e_tag] = @text
end
end
end
--- 1130,1137 ----
end
def tagend(name)
case name
! when 'LastModified' then @result[:last_modified] = @text
! when 'ETag' then @result[:e_tag] = @text
end
end
end


Wednesday, July 1, 2009

Postgres after mac migration

After you migrate your files to a new mac all the postgres data will be present but the postgres user won't exist. The postgres server won't start in this case. To create the user you need to figure out the postgres userid. You can run ls -l /usr/local/psql (substitute your postgres installation directory). The data subfolder needs to belong to the postgres user and you will see just a numeric userid. You will also see the postgres groupid. The example below assumes that both IDs are 103, make sure to substitute the IDs for your setup.

To create the user and group do the following as root:


dscl . -create /Users/postgres UserID 103
dscl . -create /Groups/postgres PrimaryGroupID 103
dscl / -append /Groups/postgres GroupMembership postgres

Friday, June 12, 2009

The packet8 scam

I was seldom using my packet8 account and I had a low usage account paying $14/month. They sent an email that they will automatically upgrade my account to double that price since they do not offer low usage anymore. This doesn't make sense for me since I really never use my account. I started canceling my account which you cannot do over their automated system. You have to call them and they transfer you to a voicemail. They call you back after 1 day and if you are unlucky to miss the call you have to call back, identify yourself, get transferred, identify yourself again and then listen to somebody doing their best effort to keep your account.

This is all pretty standard albeit a bit shadu. What is not standard is that in the time it took to do all this the new month started. My account got canceled on the 2nd of the month but I was charged $30 on the 3rd of the month. I called somebody there and I was informed that I am liable for that month even though it is not my fault their lengthy process let me to this situation.

Are you a happy packet8 customer or an unhappy former packet 8 customer? Leave a comment.

Marius