Skip to content

Instantly share code, notes, and snippets.

jondkinney / popen3_test
Created Sep 10, 2017 — forked from chrisn/popen3_test
Ruby example of using Open3.popen3 with a select loop to read a child process's standard output and standard error streams.
View popen3_test
#!/usr/bin/env ruby
require 'open3'
# Returns true if all files are EOF
def all_eof(files)
files.find { |f| !f.eof }.nil?
# Script to (generate a script to) fix excess use of double-quotes in HAML.
# To use:
# haml-lint app/views/ > haml_errors
# grep "you don't need string interpolation" haml_errors | awk '{print $1}' > single_quote_me
# perl
# bash
# git commit -a -m "Use single-quotes in straightforward cases"
jondkinney / edgerouter-qos
Created Apr 16, 2016 — forked from beardicus/edgerouter-qos
EdgeRouter Lite QOS Settings
View edgerouter-qos
# fair-queue based settings for EdgeRouter Lite traffic shaping
# download is typically 30 and change. everything can burst to 100%
# of bandwidth, priority rules keep the garbage in check
set traffic-policy shaper download
set traffic-policy shaper download bandwidth 30Mbit
View missing_spec_generator.rb
require 'erb'
# lib/missing_spec_generator.rb
class MissingSpecGenerator
RAILS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
def spec_file spec_path, file_name, spec_template, namespace
spec_name = file_name.gsub('.rb', '') + '_spec.rb'
if File.exist?("#{spec_path}/#{spec_name}")
puts "#{spec_path}/#{spec_name} exists"

Deploy Rails app to digitalocean with nginx, unicorn, capistrano & postgres

Create droplet of your liking (ubuntu 12.10 x32)

ssh to root in terminal with your server ip

ssh root@

Add ssh fingerprint and enter password provided in email

View gist:8759068
MyExceptions = [RangeError, RegexpError, IOError].freeze
raise IOError, "should be rescued"
rescue *MyExceptions => e
puts e
View sass_and_less_compared.markdown

Sass/Less Comparison

In this document I am using Sass's SCSS syntax. You can choose to use the indented syntax in sass, if you prefer it, it has no functional differences from the SCSS syntax.

For Less, I'm using the JavaScript version because this is what they suggest on the website. The ruby version may be different.


jondkinney /
Created May 6, 2011 — forked from napcs/
Deploying Rails to Linode

Deploying Rails to Linode

Installing Ruby Enterprise Edition, Apache, MySQL, and Passenger for deploying Rails 3.0 applications.

Get a Linode, and set it up with Ubuntu 10.04 LTS so that you have till April 2013 to get updates. Once the Linode is formatted, boot it and continue on.

Set up an 'A' record in your DNS, pointing to the IP of your Linode. I'm using here.

Initial setup

View placeholder_behavior.js
// To get this code to work, simply add a placeholder attribute to any of your inputs.
// This code requires no-conflict jQuery (var $j = jQuery.noConflict();) and Modernizr.
// Also you should add something similar to the following to your stylesheets.
// .placeholder{
// color: #666;
// }
jQuery.fn.set_placeholder = function() {
if ($j(this).attr('placeholder') && ($j(this).val() == '' || $j(this).val() == $j(this).attr('placeholder'))) {
You can’t perform that action at this time.