Skip to content

Instantly share code, notes, and snippets.

\documentclass[a4paper,abstract=on,12pt]{scrartcl}
\usepackage{amssymb,amsmath}
\usepackage[a4paper]{geometry}
\geometry{margin=1in}
\usepackage{setspace}
\onehalfspacing
% These commands keep the koma system from making sans serif section headings
Compiled jquery.tmpl.js (0ms) (pid 22675)
Compiled jquery.ui.datepicker-lb.js (1ms) (pid 22675)
Compiled jquery.ui.datepicker.js (1ms) (pid 22675)
Compiled jquery.ui.core.js (1ms) (pid 22675)
Compiled jquery.js (1ms) (pid 22675)
Compiled jquery.ui.datepicker-lv.js (1ms) (pid 22675)
Compiled jquery.ui.datepicker-vi.js (1ms) (pid 22675)
Compiled jquery.ui.datepicker-cy-GB.js (1ms) (pid 22675)
Compiled jquery.effects.clip.js (1ms) (pid 22675)
Compiled jquery.effects.core.js (0ms) (pid 22675)
@codeincontext
codeincontext / gist:2400950
Created April 16, 2012 19:31
Eager load a certain number of levels of a nested resource
def self.nested_include(nested_attribute, additional_attributes=[], nesting_level=6)
attributes = additional_attributes
nesting_level.times do
attributes = additional_attributes + [{nested_attribute => attributes}]
end
includes(attributes)
end
scope :with_nesting, nested_include(:children_ordered, [:user, :project])
@codeincontext
codeincontext / gist:2343241
Created April 9, 2012 12:58
Print the headers from a markdown document into 1.2.3 format
file = '/Users/skattyadz/Dropbox/PlainText/FYP.txt'
toc = ''
number_stack = [0]
File.readlines(file).each do |line|
if line[0] == '#'
hash_count = line.count('#')
if hash_count > number_stack.length
# down a level
@codeincontext
codeincontext / iPlayer-filter.user.js
Created April 9, 2012 11:07
UserScript to hide certain programs from the iPlayer web interface
// ==UserScript==
// @name iPlayer Filter
// @namespace http://skatty.me/
// @description Hides crap shows from BBC iPlayer
// @include http://bbc.co.uk/iplayer/*
// @include http://www.bbc.co.uk/iplayer/*
// ==/UserScript==
var load,execute,loadAndExecute;load=function(a,b,c){var d;d=document.createElement("script"),d.setAttribute("src",a),b!=null&&d.addEventListener("load",b),c!=null&&d.addEventListener("error",c),document.body.appendChild(d);return d},execute=function(a){var b,c;typeof a=="function"?b="("+a+")();":b=a,c=document.createElement("script"),c.textContent=b,document.body.appendChild(c);return c},loadAndExecute=function(a,b){return load(a,function(){return execute(b)})};
@codeincontext
codeincontext / gist:2299966
Created April 4, 2012 09:33
Show logger.debug lines in green in the Rails development log
config.after_initialize do
class<<Rails.logger
def debug_with_color(message)
message_color = "0;32;1"
colored_message = "\e[#{message_color}m#{message}\e[0m"
debug_without_color(colored_message)
end
alias_method_chain :debug, :color
end
@codeincontext
codeincontext / gist:2109123
Created March 19, 2012 11:55
log BB events
console.log("triggered: "+eventName+" for "+(this.get('name')||this.get('description')||'collection'))
@codeincontext
codeincontext / SKUserData.m
Created March 13, 2012 01:10
SKUserData singleton save-on-write dictionary subclass
#import <Foundation/Foundation.h>
@interface SKUserData : NSMutableDictionary
+ (id)sharedInstance;
@end
@codeincontext
codeincontext / gist:1831643
Created February 14, 2012 23:32
Upload a random twitter avatar from a directory
#!/usr/bin/env ruby
# Heavily based on https://github.com/ip2k/twitter-avatar-update
# ==== Gems ====
require 'twitter_oauth'
require 'oauth'
require 'nokogiri'
require 'open-uri'
require 'yaml'
Handlebars.registerHelper('numberWithCommas', function(x) {
return x.toString().replace(/\B(?=(?:\d{3})+(?!\d))/g, ",");
});