Skip to content

Instantly share code, notes, and snippets.

View bradfordcp's full-sized avatar

Christopher Bradford bradfordcp

View GitHub Profile
# Package Maintainer: Increment phusion_release to match latest release available
%define phusion_release 2011.03
Summary: Ruby Enterprise Edition (Release %{phusion_release})
Name: ruby-enterprise
Vendor: Phusion.nl <info@phusion.nl>
Packager: Adam Vollrath <hosting@endpoint.com>
Version: 1.8.7
Release: 8%{dist}
License: Ruby or GPL v2
module ActiveRecord
class Base
def self.random
if (c = count) != 0
find(:first, :offset =>rand(c))
end
end
end
end
namespace :deploy do
# To avoid having to add a password for sudo, visudo and add
# deployusername ALL=(ALL) NOPASSWD: /etc/init.d/unicorn reload
task :start do
sudo "/etc/init.d/unicorn start"
end
task :stop do
sudo "/etc/init.d/unicorn stop"
@TooTallNate
TooTallNate / starttls.js
Created March 1, 2011 01:40
Upgrade a regular `net.Stream` connection to a secure `tls` connection.
// Target API:
//
// var s = require('net').createStream(25, 'smtp.example.com');
// s.on('connect', function() {
// require('starttls')(s, options, function() {
// if (!s.authorized) {
// s.destroy();
// return;
// }
//
@jmblog
jmblog / 960gs.scss
Created May 18, 2011 06:57
960gs.scss
/*-----------------------------------------------------
960 Grid System ~ Core CSS.
Learn more ~ http://960.gs/
Licensed under GPL and MIT.
-------------------------------------------------------*/
/* Grid Settings
---------------------------*/
// 12-column grid
@mauricioszabo
mauricioszabo / connection_fix.rb
Created October 10, 2011 18:38 — forked from defunkt/connection_fix.rb
MySQL server has gone away fix
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
@brikis98
brikis98 / BinaryModules.js
Created December 1, 2011 00:45
Node.js performance tips
// Use built in or binary modules
var crypto = require('crypto');
var hash = crypto.createHmac("sha1",key).update(signatureBase).digest("base64");
@sontek
sontek / snowjob.py
Created December 22, 2011 04:24
Make your terminal snow with python
#!/usr/bin/env python
import os
import random
import time
import platform
snowflakes = {}
try:
# Windows Support
@soopercorp
soopercorp / findbest.py
Created February 20, 2012 23:38
bestthing.info algorithm
#!/usr/bin/env python
import cPickle as pickle
import random
# things I beat
tIB = {}
# things beat me
tBM = {}
@nsfmc
nsfmc / junkify.js
Created March 14, 2012 18:11
Junkify an inline data series on your webpage
var junkify = function( someClass ){
// requires underscore.js
var sparks = document.getElementsByClassName( someClass );
_(sparks).each(function(e,i){
var range = 16;
var origContent = e.innerHTML;
e.title = "data: "+ origContent;
var d = origContent.split(","),
max = _.max(d), min = _.min(d),
dataRange = max-min;