Timezone conversion in Ruby
The time in the feed is supplied with 2 fields - date and time. It is in UTC. The date looks like 20080605, and the time looks like 142115. I need to display the current local date and time. I could've...
View ArticleConverting from Subversion to Mercurial
Nice post about converting your Subversion (svn) code repository to Mercurial (hg):SNH
View ArticleRuby On Rails on Mac OS X
My laptop already had ruby installed (part of the standard OS install), but I decided to get the latest versions and recompile them. Thankfully this is trivial with MacPorts. To install MacPorts,...
View ArticleMySQL On Mac OS X Using MacPorts
If you only want to use the MySQL client, all you have to do is install it using the port command: sudo port install mysql5 You can now connect to remote servers with something like this: mysql5...
View ArticleCyberSource, SOAP and Ruby
CyberSource has a SOAP API. They don't officially support Ruby, but I don't see why it shouldn't work. Ruby has built-in support for SOAP. I knew absolutely nothing about SOAP or WSDL an hour ago, so...
View Article/etc/hosts and Mac OS X 10.5 Leopard
Instead of using /etc/hosts on Mac OS Leopard, the proper way to add hosts is using the dscl utility. First, let's list the hosts already there: $ dscl localhost -list /Local/Default/Hosts $ Nothing....
View ArticleConnecting to Multiple Databases in Ruby on Rails
If you keep different tables in different databases, you've probably been looking for a way to allow Rails to connect to more than one database. You've probably found that you can add another...
View ArticleTransparent TCP proxy in ruby (jruby)
This is a transparent TCP proxy. I only tested it in jruby, but I see no reason why it wouldn't work in ruby as well. The proxy is multithreaded, it starts a new thread to handle every connection, up...
View ArticleMicrosoft Dynamics CRM and PHP
I needed to use PHP for two things:Given a lead's email address, retrieve the name, title, phone and email address of this lead's owner.Insert a new lead into the system.I spent a lot of time searching...
View ArticleBinary and character set safe MySQL dump and restore
To dump some MySQL databases in a binary-safe way:mysqldump -uroot -p -hdbhost \ --skip-extended-insert \ --default-character-set=binary \ --databases dbonedbtwodbthree \ --add-drop-database...
View ArticleUsing FileMerge with Mercurial
Mac OS comes with a GUI merge tool called FileMerge. This can be used for merges in Mercurial - Mercurial will do this if its internal merge fails. The binary for FileMerge (opendiff) cannot be used as...
View ArticleDistributing a Ruby application as an archive
Let's say you have a Ruby application you've written, and it consists of multiple files that you require inside your code. You want to run this application on some remote machines. To make it easier to...
View ArticleMaking an executable Ruby archive distribution
As a follow-up to my previous post, you can even make a single executable file of your Ruby archive. It relies on the fact that zip files are pretty resilient to extra garbage data in the beginning....
View ArticleCompiling Ruby MRI on Mac OS X
EDIT: include libyamlUPDATE 2012-05-30: I have successfully installed ruby-1.9.3-p194 (latest stable) using the same procedure. Mac OS Snow Leopard comes with a pretty old Ruby:$ ruby --version ruby...
View ArticleCompiling PHP 5.4 on Mac OS X Lion
PHP 5.4 came out, but Apple hasn't updated Mac OS Lion with it yet:$ php --version PHP 5.3.8 with Suhosin-Patch (cli) (built: Nov 15 2011 15:33:15) Copyright (c) 1997-2011 The PHP Group Zend Engine...
View ArticleLogging fatal PHP errors
If you turned off the display_errors setting in your php.ini in production (as you should), then when your code dies with a fatal error, you can't see the message anywhere. It would be better to log...
View ArticleUTF-8 Regular Expressions in PHP
While PHP itself doesn't know about different character sets and treats all characters as being one byte long, the PCRE engine understands UTF-8. There's also mb_ereg_match(), but I prefer the PCRE...
View ArticleCompiling PHP 5.4.6 On OS X Mountain Lion
Mountain Lion came out, and still no PHP 5.4. It removed X11 though, which I used on Lion for the PNG and FreeType libraries when I compiled PHP 5.4 there. Instead of installing X11, I just compiled...
View ArticleEncrypted RAID Disk on OS X Mountain Lion and Mavericks
UPDATE: This works on Mavericks as well The Disk Utility application does not allow you to create an encrypted filesystem on a RAID volume. However, it is possible from the command line. WARNING: this...
View ArticleMongoDB 2.2 Aggregation And MapReduce Performance
TL;DR - 1 million documents with readings across 20 sensors (1 reading per document), find the number of readings and their average per sensor. Aggregation framework does it in 4.1 seconds, map/reduce...
View ArticlePHP vs Node.js vs Native Speed Comparison
A quick speed comparison between PHP, Node.js and native code. This is obviously an artificial benchmark. The code generates four random numbers between 0 and 100 and uses them as coordinates of two...
View ArticleConcurrent Tasks In JRuby
Sometimes you need to execute long running tasks (like database queries on multiple shards) concurrently. JRuby can easily make use of Java's built-in Executor class for this purpose.# Since...
View ArticleEncrypting Database Passwords In Ruby
Most web applications connect to a database, which means that they need to store the database password in a file. While that file should only be readable by the user running the application server,...
View ArticleTomcat SSL Hardening
If you are using SSL with your Java web application, and you are using Tomcat, the default configuration could be made more secure by by disallowing weak cipher suites. You can test your server...
View ArticleCompiling GnuPG on OS X
First make a directory to hold the compiled files:sudo mkdir /usr/local/gpg Create a text file /etc/paths.d/gpg with the following contents:/usr/local/gpg/bin Open a new terminal for the PATH changes...
View Article