Skip to content

Instantly share code, notes, and snippets.

View andrew's full-sized avatar

Andrew Nesbitt andrew

View GitHub Profile
@jayzes
jayzes / Procfile
Created May 26, 2011 20:59
Thinking Sphinx and Foreman
sphinx: bundle exec rake ts:run_in_foreground
Gem::Specification.new do |s|
# totally generic
version_file = Dir['lib/*/{*/,}version.rb'].first
s.name = version_file.split('/')[1..-2].join('-')
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.authors = `git shortlog -sn`.scan(/[^\d\s].*/)
s.email = `git shortlog -sne`.scan(/[^<]+@[^>]+/)
s.require_paths = ["lib"]
@mperham
mperham / Go.txt
Created September 22, 2011 19:38
Network stack performance
> ab -n 10000 -c 100 http://127.0.0.1:8080/
This is ApacheBench, Version 2.3 <$Revision: 1139530 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
@rentalcustard
rentalcustard / gist:1309020
Created October 24, 2011 13:26
Web development in 2011. Apparently.
//from https://github.com/christkv/node-mongodb-native
var p_client = new Db('integration_tests_20', new Server("127.0.0.1", 27017, {}), {'pk':CustomPKFactory});
p_client.open(function(err, p_client) {
p_client.dropDatabase(function(err, done) {
p_client.createCollection('test_custom_key', function(err, collection) {
collection.insert({'a':1}, function(err, docs) {
collection.find({'_id':new ObjectID("aaaaaaaaaaaa")}, function(err, cursor) {
cursor.toArray(function(err, items) {
test.assertEquals(1, items.length);
@jcroft
jcroft / layout.sass
Created March 1, 2012 04:51
How easy responsive design can be with Sass
#content-wrapper
+container
#about
// Default (smallest screens)
+column(100%)
background-color: #ccc
// Respond to other screen widths
@lukeredpath
lukeredpath / fizzbuzz.lol
Created April 4, 2012 12:46
LOLCode fizzbuzz
HAI
CAN HAS STDIO?
I HAS A VAR IZ 0
IM IN YR LOOP
UPZ VAR!!1
IZ VAR BIGR THAN 100?
GTFO.
KTHX
IZ VAR LEFTOVAR 15 LIEK 0?
VISIBLE "FIZZBUZZ"
@jarek-foksa
jarek-foksa / safari6-webkit-inspector.md
Created October 16, 2012 08:32
How-to: Restore WebKit Web Inspector on Mountain Lion

Restore WebKit Web Inspector on Mountain Lion

  1. Download WebKit build r121872: http://builds.nightly.webkit.org/files/trunk/mac/WebKit-SVN-r121872.dmg
  2. Right-click on WebKit.app and choose Show Package Contents
  3. Navigate to ./Contents/Frameworks/10.x/WebCore.framework/Versions/Current/Resources/ and you will find a folder called inspector. This contains the HTML/CSS/JavaScript for the Web Inspector, awesome! Keep this Finder window open!
  4. Open a new Finder window and navigate to /System/Library/PrivateFrameworks/WebInspector.framework/Versions/Current/Resources. This is where the 'new' Web Inspector is located.
  5. Now copy the contents from the WebKit Web Inspector folder (from Step 3.) to the new Web Inspector folder from Step 4. Do not remove anything, but when it prompts to 'keep newer' files press the Replace button.
  6. Now there is only one thing left to do, remove of rename the Main.html file (this is the main frame for the new Web Inspector) and rename inspector.html to `Main.ht
@iangreenleaf
iangreenleaf / a_b_helper.rb
Created November 27, 2012 19:59
Helper to provide alternate configuration syntax for Split, the A/B testing tool.
module ABHelper
def split_test(name)
experiment = YAML.load_file("config/experiments.yml")[name]
given_probability, num_with_probability = experiment[:variants].inject([0,0]) do |a,v|
p, n = a
if v.kind_of?(Hash) && v[:percent]
[p + v[:percent], n + 1]
else
a
@andrew
andrew / linked_headings.coffee
Created December 4, 2012 15:17
Automatically create anchor links for headings
slugify = (text) ->
text = text.replace(/[^-a-zA-Z0-9,&\s]+/g, "")
text = text.replace(/-/g, "_")
text = text.replace(/\s/g, "-")
text.toLowerCase()
$ ->
$('h1,h2,h3,h4').each (i, elm) ->
heading = $(elm)
anchor = slugify(heading.text())