Skip to content

Instantly share code, notes, and snippets.

View nathany's full-sized avatar
🙃

Nathan Youngman nathany

🙃
View GitHub Profile
@collinvandyck
collinvandyck / alloc_test.go
Created February 13, 2014 03:27
pass by value vs pass by reference
package main
import "testing"
type Stuff struct {
Hello string
Goodbye string
Slice []string
}
@nathany
nathany / rails-4.0.10.rc1.rb
Created August 21, 2014 20:36
Test case for bug in Rails 4.0.10.rc
# Activate the gem you are reporting the issue against.
# gem 'activerecord', '4.0.9' # works
gem 'activerecord', '4.0.10.rc1'
# gem 'activerecord', '4.1.5' # works
# gem 'activerecord', '4.1.6.rc1'
gem 'pg'
require 'active_record'
@nathany
nathany / show SQL in irb console
Created March 11, 2010 17:31
Rails SQL logging from console
ActiveRecord::Base.connection.instance_variable_set :@logger, Logger.new(STDOUT)
@remy
remy / gist:330318
Created March 12, 2010 13:59
autofocus and placeholder support
/**
* Add this script to the end of your document that use <input autofocus type="text" />
* or <input type="text" placeholder="username" /> and it'll plug support for browser
* without these attributes
* Minified version at the bottom
*/
(function () {
function each(list, fn) {
var l = list.length;
require 'minitest/unit'
require 'minitest/spec'
require 'rubygems'
require 'ansi'
class MiniTest::Unit
include ANSI::Code
PADDING_SIZE = 4
@qrush
qrush / gist:532115
Created August 17, 2010 21:23
new resolver api
require 'open-uri'
require 'pp'
pp Marshal.load(open("http://localhost:3000/api/v1/dependencies?gems=rails,rack,clearance,fog,paperclip"))
# Allow RSpec assertions over the elements of a collection. For example:
#
# collection.should all_be > 0
#
# will specify that each element of the collection should be greater
# than zero. Each element of the collection that fails the test will
# be reported in the error message.
#
# Examples:
# [1,1,1].should all_be eq(1)
director routing_mesh round-robin {
{
.backend = {
.host = "...some ip...";
.port = "...some port...";
.first_byte_timeout = 90s;
.between_bytes_timeout = 90s;
}
# ...more backends...
}
@jesseproudman
jesseproudman / Auto Scale API Mashup.rb
Created March 16, 2011 18:51
Logic for simple Auto Scale setup
require 'rubygems'; require 'active_resource'; require 'new_relic_api'
servers = File.open("server_count.txt", "r").first.to_i
instances_per_server = 6
cpu_burn_for_system = 1000.0 * 0.20
NewRelicApi.api_key = "<Your API Key>"
account = NewRelicApi::Account.find(:first);
application = account.applications[3];
@teich
teich / gist:1000964
Created May 31, 2011 17:53
May 31st Heroku Updates