precompiling assets under jruby
June 16, 2012
If you are using the asset pipeline in rails 3.1 or 3.2 to compile and minify your js and css, you may observe that it is crazy slow. On an SPA-style app I am contributing to, it was taking over an hour on my macbook air (cpu-bound). The problem ultimately is that the javascript runtime available to ruby under java (rhino) is slow. While you may think 'oh, well i'll just precompile assets under c-ruby'.. this is a nice thought, but then you would have to swap your gemfile and .bundler directories and change your ruby platform every time you just wanted to precompile your assets. I did go through this excersize to confirm that it was an issue with jruby/rhino and not a code issue, and while it went much faster, the added complexity was not worth it.
Stochastik Drum Machine for iPad Now Available!
February 24, 2012
Woot! After 6 days, Apple gave me the nod! http://itunes.apple.com/us/app/stochastik-drum-machine/id504084052?mt=8
So far, the critics like it =D
Slides for iOS music apps meetup
February 21, 2012
Just in case you came here looking for the slides, they are located here: http://bit.ly/apb-slides
The site for my app is http://stochastik.xitive.com and the youtube videos are up at http://youtube.com/xitiveinc
Principle of Least Surprise, Bathroom Edition
February 16, 2012
In the office building of a client the bathrooms are single occupancy and each has a lock. That's not surprising. When you enter the bathroom and push in the button on the handle to lock the door, the door is locked. Still sane. However, whenever the door closes, it unlocks! So, if you enter the bathroom and lock the door behind you, it will unlock itself when it finishes closing.
Implementing Korg WIST in an iOS Music App
February 13, 2012
This is for the lawyers: WIST is a trademark and software of KORG INC. All other trademarks are property of their respective owners. I am not an alien invader.
This post details my experiences implementing WIST for my amazing ipad drum machine, which will hopefully be out soon (one more feature...) I am going to refer to WIST as wist from here on out, apologies in advance.
What is wist?
From a user's perspective, wist is a way to get two iOS music apps playing in sync.
Nginx, Passenger and Rails -- a high-level overview
November 11, 2011
One of my friends is somewhat new to Rails, and certainly new to rails deployment. He was a bit unclear about what role the different parts of the rails deployment stack (Nginx, passenger and rails) were in serving the request, so I wrote up the following and figured it might help other netizens, soI posted it here. Please drop me a line or leave a comment if something is unclear.---Sometimes, we use the terms "web server" or "application server" interchangeably, but for the purposes of this email, we mean distinctly different things.
How to Kill the process listening on a specific port
October 10, 2011
When developing a service-oriented architecture, we may run into a situation where we want to kill the process that is listening on a given port.
Sometimes, you can accomplish this with the wonderful pkill utility, for instance if there is only one process with that name. Otherwise, you will have to figure out which pid represents the running service and then use that to kill the service.
It can be annoying to remember where the pidfiles are stored for each service, and sometimes you just want to use a sledghammer to whack the process.
We can easily list the processes listening on a given port with:
sudo lsof -n -P -i :22
Setting up SSL, HSTS and an http -> https redirect with node.
October 6, 2011
Step 1: Generate your SSL key and certificate signing request:
Note: you'll have to put the domain name in as the "common name".
openssl req -new -newkey rsa:2048 -nodes -keyout example.com.key -out example.com.csr
Step 2: Get your certificate
Log into GoDaddy or your friendly neighborhood certificate provider and go through their workflow. If you go with GoDaddy, you will get a zip file to download that contains an example.com.crt and a gd_bundle.crt
Step 3: Set up your node app and HSTS
Meta-Programming in JavaScript
October 6, 2011
tl;dr: meta-programming in javascript is just called “programming” because the methods used are familiar and used for non-meta-programming tasks, unlike ruby which requires a large set of specialized knowledge that is only used within the task of meta-programming.
Background:
On the node.js mailing list, it was asked “why do we not hear about meta-programming in JavaScript?”, and the answers varied from “ruby rots people’s brains” to “People in the JS community don’t care that much about being super DRY code.” to more reasoned discourse like “JavaScript is a functional language, so you don’t really need it even if you knew what it meant.”
Create a new git repo from a subdirectory
October 1, 2011
I started a project (repo/) with a number of subdirectories:
repo/
web/
ingester/
bulkendpoint/
doc/
...
This worked fine in the beginning, but then I wanted to be able to branch, merge and deploy just the "web" subdirectory.
It took a good 10 minutes of man pages and googling to put the pieces together, but here is what worked for me:
Git, OpenSSL, Node.js and npm on Slicehost and Ubuntu 10.04
September 21, 2011
Copy and paste the following into your terminal:
sudo su apt-get install -y gcc g++ git-core libssl-dev curl -lO https://raw.github.com/isaacs/nave/master/nave.sh chmod +x nave.sh ./nave.sh usemain 0.4.11 curl http://npmjs.org/install.sh | sh
After you authenticate with your password, go get a cup of your beverage of choice, this is going to take a while :-)
How to save breakpoints and display expressions in ruby-debug
August 20, 2011
Use ruby-debug 0.10.3; the newer 0.10.4 has a bug that breaks this
gem install ruby-debug -v=0.10.3
Someone on the SF Ruby mailing list asked about how to save breakpoints with ruby-debug, so I made a quick video on how to do it. No editing, one take..
Rails Maintainability Metric
June 20, 2011
grep -ir "eval\|method_missing\|define_method\|instance_variable_set" app lib/ | wc -l
A score in the double digits should give pause, the tripple digits are scary and quadruple digits? run for the hills.
Amazon EC2 Cost per GB of RAM
May 25, 2011
Working on a project for a client, I wanted to know what the most $-efficient way to keep stuff in ram on EC2-east. These boxes will only have traffic within the AZ, so there were no bandwidth costs. I compared On-Demand prices with Reserved prices (assuming 1 year commitment for reserved.)
For High-Memory instances:On-Demand:about $21 per GB per monthReserved (1yr commitment):about $14 per GB per monthnon-high-mem instances are about 50% more expensive when looking at the cost as $ per GB.Here's the google doc: http://bit.ly/kK9qbj
TNetstrings
May 14, 2011
TNetstrings (http://tnetstrings.org/) could be awesome. Its simplicity kicks the ass of BSON (http://bsonspec.org/), another JSON-inspired serialization format. Additionally, it is *very* easy to parse. Unfortunately, it requires a schema if you want to serialize JavaScript Numbers. This is entirely fixable with only a very minor addition.
I propose TNetstrings adds a "." FP64 type.Add IEEE 754 Number Type so it is isomorphic with JSON.