Skip to content

Instantly share code, notes, and snippets.

View brettbuddin's full-sized avatar
🤖
Arguing with computers.

Brett Buddin brettbuddin

🤖
Arguing with computers.
View GitHub Profile
@brettbuddin
brettbuddin / gist:605007
Created September 30, 2010 17:53
Turns on and sets the password of OS X Server's VNC server
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -clientopts -setvnclegacy -vnclegacy yes -setvncpw -vncpw "YOUR_PASSWORD_HERE"
@brettbuddin
brettbuddin / grid.scss
Created October 17, 2010 17:17
My sassy CSS grid template. This is usually where I start from.
$column_width: 60px;
$gutter_width: 20px;
$columns: 12;
.container {
margin-bottom: 2em;
width: ($column_width * $columns) + ($columns - 1 * $gutter_width);
}
.clearfix, .container { display: block; }
.clearfix:after,
@brettbuddin
brettbuddin / server.rake
Created December 22, 2010 22:51
Quick web server from Rake
task :server do
require 'webrick'
include WEBrick
def start_webrick(config = {})
config.update(:Port => 3000)
server = HTTPServer.new(config)
yield server if block_given?
['INT', 'TERM'].each do |signal|
@brettbuddin
brettbuddin / server.rake
Created January 4, 2011 15:24
Simple HTTP server for static file sites
require 'webrick'
DEPLOY_TO = ''
desc "Starts an HTTP server in the current directory"
task :server do
config = {:Port => 3000, :DocumentRoot => '.'}
server = WEBrick::HTTPServer.new config
['INT', 'TERM'].each do |signal|
trap(signal) { server.shutdown }
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
@brettbuddin
brettbuddin / switch.py
Created February 7, 2011 15:16
The code that powered the Twerrible Towel (http://twerribletowel.com). It processed 44,610 relevant tweets over the course of 5 days.
#!/usr/bin/env python
import sys
import random
from ctypes import *
from Phidgets.Devices.InterfaceKit import InterfaceKit
from Phidgets.PhidgetException import PhidgetErrorCodes, PhidgetException
try:
kit = InterfaceKit()
kit.openPhidget()
@brettbuddin
brettbuddin / config.rb
Created February 16, 2011 20:34
Small config manager.
class Config
def initialize
@config = {}
end
def load_file(file_name)
instance_eval(File.read(file_name))
self
end
namespace :bundler do
task :create_symlink, :roles => :app do
shared_dir = File.join(shared_path, 'bundle')
release_dir = File.join(current_release, 'vendor/bundle')
run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}")
end
task :bundle_new_release, :roles => :app do
bundler.create_symlink
run "cd #{release_path} && bundle install --production"
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :login, :null => false
t.string :email, :null => false
t.string :crypted_password, :null => false
t.string :password_salt, :null => false
t.string :persistence_token, :null => false
t.string :single_access_token, :null => false
t.string :perishable_token, :null => false
$(document).keydown(function(e){
if (e.keyCode == 37) {
var previous = self.currentX;
self.currentX = self.limitXBounds(self.previousPageX(self.currentX));
if (self.currentX !== previous) {
self.update();
}
return false;
}else if (e.keyCode == 39) {
var previous = self.currentX;