Fixing the nokogiri built against libxml warning

Just installed Mountain Lion 10.8 fresh on my Mac Mini with a new SSD. As I get my rails environment up and running I ran into this common problem:

WARNING: Nokogiri was built against LibXML version 2.9.0, but has dynamically loaded 2.7.8

I had installed nokogiri with bundler. Unfortunately I don’t know which of these things quite resolved my issue, but this is what I did:

gem uninstall nokogiri
brew update
brew uninstall libxml2
brew install libxml2 --with-xml2-config
bundle exec gem pristine nokogiri

After all this, the warning was gone. I wish I knew which of these was extraneous, if any, but I guess I’ll find out next time assuming this common problem doesn’t get smoothed out upstream.

Sources:

https://gist.github.com/devpuppy/1349681

http://stackoverflow.com/questions/6802410/warning-nokogiri-was-built-against-libxml-version-2-7-8-but-has-dynamically-lo

Rails 3 passenger nginx send_file with x accel redirect and x accel mapping

After a lot of searching as to why range headers were not working despite thinking that I had X-Accel-Redirect configured properly, I realized that I was missing something in my nginx config and so send_file was still sending via rails rather than nginx, causing range headers to fail.

In order to fix this, I had to add a bit more to my nginx config:

1
2
3
4
5
6
7
8
9
10
11
12
13
server {
listen 80;
server_name example.com;
root /home/keyvan/example_app/public;
passenger_enabled on;
passenger_set_cgi_param HTTP_X_ACCEL_MAPPING /=/sec/;
passenger_pass_header X-Accel-Redirect;
location /sec/ {
alias /;
internal;
}
}

Now it works!


http://stackoverflow.com/questions/6237016/message-x-accel-mapping-header-missing-in-nginx-error-log
http://airbladesoftware.com/notes/rails-nginx-x-accel-mapping

Mobile safari debugging jquery live workaround

Mobile Safari Debugging

In order to view the browser inspector for the Safari session on your iPad, go to Settings->Safari->Advanced and enable Web Inspector

Next, connect the iPad to your Mac and open Safari. Choose Develop from the menu bar and you will see the connected iPad and be able to open the console session.

jQuery live()

On Mobile Safari, $(element).live() appears not to work. The workaround is to add the attribute ‘onclick’ to the element. Now it works.

Install ntop in centos 6

Source: https://ryanwoon.wordpress.com/2011/08/20/install-ntop-in-centos-6/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
yum install cairo-devel libxml2-devel pango-devel pango libpng-devel
yum install freetype freetype-devel libart_lgpl-devel wget gcc make
yum install perl-ExtUtils-MakeMaker
cd /opt
wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.5.tar.gz
tar -zxvf rrdtool-1.4.5.tar.gz
cd rrdtool-1.4.5
./configure –prefix=/usr/local/rrdtool
make
make install
yum install libpcap libpcap-devel gdbm gdbm-devel
yum install libevent libevent-devel
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP-1.4.8.tar.gz
tar -zxvf GeoIP-1.4.8.tar.gz
cd GeoIP-1.4.8
./configure
make
make install
yum install libtool automake autoconf
wget http://downloads.sourceforge.net/project/ntop/ntop/Stable/ntop-4.1.0.tar.gz
tar zxvf ntop-4.1.0.tar.gz
cd ntop-4.1.0
./autogen.sh -prefix=/usr/local/ntop
make
make install
useradd -M -s /sbin/nologin -r ntop
chown ntop:root /usr/local/ntop
chown ntop:ntop /usr/local/ntop/share/ntop
cd /usr/local/ntop/bin/
ntop -A
ntop -d -L -u ntop -P /usr/local/ntop –-skip-version-check –-use-syslog=daemon

Vendoring, unpacking, freezing gems in ruby not rails no bundler

I’ve been writing a lot of utility scripts lately using CocoaDialog and its ruby wrapper to produce nice dialogs and Platypus to package them as simple Mac droplets.

Since the users of the droplets will not have any gems installed, they need to be unpacked and added to your project:

gem unpack NAME

Be sure to do this for all dependencies of the given gem(s). Bundler helps quite a bit in figuring out what those are (e.g. bundle package), however bundle package provides you the .gem files and not the actual ruby scripts, so I use gem unpack

Next, put the unpacked gems within your project, e.g. vendor/gems and add this to your script:

1
2
3
4
Dir.glob(File.join(File.dirname(__FILE__), "vendor", "gems", "*", "lib")).each do |lib|
$LOAD_PATH.unshift File.expand_path(lib)
end
require 'GEMNAME' # they are in your load path now!</code></p>

I do NOT require rubygems in these scripts, however if you will be doing this, or you suspect a gem might be doing this, you’ll want to prepare in advance, with a slight mod to the above:

1
2
3
4
5
6
require 'rubygems'
Dir.glob(File.join(File.dirname(__FILE__), "vendor", "gems", "*", "lib")).each do |lib|
$LOAD_PATH.unshift File.expand_path(lib)
Gem.path.unshift File.expand_path(lib)
end
require 'GEMNAME' # they are in your load path now! They'll also be known to rubygems within the context of your application</code></p>

Find and mount cdrom drive on centos linux

Detect the device using wodim –devices and remember the drive name, I’ll assume it was /dev/scd0

Make a directory to mount the device on with mkdir /media/cdrom

Mount it with mount -t iso9660 /dev/scd0 /media/cdrom

Drive contents can now be found at /media/cdrom. Unmount with umount /dev/sda0