I ran into an issue where a Rails 3.1 application running on Ubuntu 12.04 in a VirtualBox instance (development) was running ridiculously slow. Sometimes, before the server would register a request, it would take >5 seconds, then another 5 seconds just to load a simple view. Obviously, this is an unacceptable amount of time when […]
Author: anthony
Rails 4.0 / Postgresql / Heroku / Connection timeout
If you attempt to deploy a new application to Heroku using Rails 4.0.0, with a default postgresql configuration in your gemfile, such as: gem ‘pg’ Then, heroku will assume you are requesting PG version 0.12.2. This causes errors. Instead, to avoid connection errors (timeout, undefined constant, etc), you need a more recent version: gem ‘pg’, […]
rQRCode – Print QR codes on all browsers
There is a problem with the documented method of creating QR codes in HTML for rQRCode, as background colors are not printed. The suggested method is to use background colors to create the appropriate sequence. Instead, use a border-left on all TD elements and change the width to 0px; Additionally, change the border color of […]
Git – diff (compare) the same file on different branches
If you want to see the difference between the same file on separate branches, use the following snippet at the CLI: git diff branch1 branch2 — your-file.ext
Heroku – connect to different database and transfer data to current environment
If you run into a situation where you’ve been developing an application in a live heroku development environment and have entered a substantial amount of live data that you don’t want to reenter into your live production environment, then connecting to your development instance’s database and retrieving the specific data you are interested in might […]
Heroku postgreSQL – password authentication failed for user
If you just created a new PostgreSQL database for your Heroku App and are running into the following error: “password authentication failed for user” Try running the following command at the CLI: heroku pg:promote THE_DATABASE_NAME_HERE This should clear up the issue.
JQuery – Wait until all images load before doing something
You may want to wait until all assets have loaded (such as images and certain JSON requests) prior to performing an action in JQuery. To do this, wrap your code in the following listener: $(window).load(function(){ }); This is different than what is typically done: $(document).ready(function(){ }); This allows us to wait until the DOM has […]
Check if checkbox is checked with Jquery
To check if an HTML checkbox is checked with JQuery, do the following: if($(“#the-element).is(“:checked”)){ }
Get root domain with Rails
To retrieve the root domain within the Rails framework, use the following method: request.domain Given the following GET request: http://www.example.com/users/1/edit The above method will retrieve: example.com Caveat: This will not work within your models.
PEAR Mail with Google Business Apps SMTP
If you are using PEAR Mail with Google Business Apps SMTP and are running into connection timeout errors, with the following configuration: $smtp = Mail::factory(‘smtp’, array (‘host’ => $host, ‘port’ => ‘465’, ‘auth’ => true, ‘username’ => $username, ‘password’ => $password)); Try changing the port to 587 (Port for TLS/STARTTLS)