Recommended books

How to fix issues with missing gem specifications

Shell Script (Bash) posted 11 months ago by christian

I was getting this error after unpacking hpricot with gem unpack hpricot. I also tried rake gems:unpack hpricot but it did nothing…

   1  config.gem: Unpacked gem hpricot-0.8.1 in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this. 

The rake gems:refresh_specs command doesn’t work, and appears to have been a temporary workaround, so to fix this error I did this:

   1  cd vendor/gems/hpricot-0.8.1
   2  gem specification hpricot > .specification

I had this issue with Rails 2.3.4.

Tagged hpricot, gem, unpack, rails

How to fix irb in OSX Snow Leopard

Shell Script (Bash) posted 11 months ago by christian

This fix will enable Control+R and UTF-8, which by default don’t work on Snow Leopard because OSX’s Ruby doesn’t use readline by default. All code comes from Henrik Nyh’s blog, which explains how to fix irb on Leopard. I’ve changed the code so that it works on Snow Leopard:

   1  sudo port install readline +universal
   2  svn co http://svn.ruby-lang.org/repos/ruby/tags/v1_8_7_72/ext/readline/ readline
   3  
   4  curl http://pastie.textmate.org/pastes/168767/download | patch readline/extconf.rb
   5  
   6  cd readline
   7  ruby extconf.rb
   8  make
   9  sudo make install

Tagged irb, readline, osx, snowleopard, hack

How to write HTTP traffic to a file with tcpdump

Shell Script (Bash) posted 11 months ago by christian

Write traffic on port 80 (HTTP) to a file. Rotate log file after 10Mb. Keep 5 files.

   1  tcpdump port 80 -n -i any -w /tmp/traffic -p -C 10 -W 5 -s 1500

This gist shows how to monitor HTTP requests.

Tagged tcpdump, http

Ruby Enterprise Edition symlinks

Shell Script (Bash) posted 11 months ago by christian

This will save you from playing with PATH:

   1  sudo ln -fs /opt/ruby-enterprise-1.8.6-20090610 /opt/ruby-enterprise
   2  sudo ln -fs /opt/ruby-enterprise/bin/gem /usr/bin/gem
   3  sudo ln -fs /opt/ruby-enterprise/bin/irb /usr/bin/irb
   4  sudo ln -fs /opt/ruby-enterprise/bin/rake /usr/bin/rake
   5  sudo ln -fs /opt/ruby-enterprise/bin/rails /usr/bin/rails
   6  sudo ln -fs /opt/ruby-enterprise/bin/ruby /usr/bin/ruby

Passsenger.conf is also simplified:

   1  LoadModule passenger_module /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so
   2  PassengerRoot /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-2.2.5
   3  PassengerRuby /opt/ruby-enterprise/bin/ruby

Tagged ree, passenger, ruby, symlinks

nginx, fastcgi and wordpress

Shell Script (Bash) posted about 1 year ago by marko

Some pitfalls I ran into.

CSS is served up as text/html by fastcgi to nginx. Determine this by turning on “Net” in Firebug. Firefox in it’s standard compliance isn’t able to view the style sheet and therefore any images that may be defined in it. Solution; Serve up static stuff as static stuff through nginx:

   1  server {
   2          # ... abbreviated
   3              location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov)$ {
   4                      root /home/wordpress/wordpress;
   5              }
   6          # ... abbreviated
   7      }

You receive the error “The plain HTTP request was sent to HTTPS port”. Solution: Turn on HTTPS in fastcgi by sending the follwing parameter to it in nginx.conf.

   1  server {
   2          # ... abbreviated
   3              location / {
   4                      # ... abbreviated
   5                      fastcgi_param HTTPS on;
   6                      # ... abbreviated
   7              }
   8          # ... abbreviated
   9      }

You get the FTP dialogue when trying to upload a new theme. Solution: Check that the process which runs fastcgi has write privileges into the wordpress folder.

Tagged nginx, fastcgi and wordpress