Skip to content

Instantly share code, notes, and snippets.

View jamesdavidson's full-sized avatar

James Davidson jamesdavidson

View GitHub Profile
@jamesdavidson
jamesdavidson / installanduse.js
Created May 8, 2012 07:42
Throw in a new font from Google WebFonts and mix it straight in with your T.Bootstrap HTML page.
function installAndUse(fontName, jQSelector)
{
WebFontConfig = {
google: { families: [ fontName ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
@jamesdavidson
jamesdavidson / install.sh
Created July 5, 2012 15:01
How to install CouchDB 1.2.0 on fresh Ubuntu 12 LTS edition.
#!/bin/bash
# @jsdavo 6th July 2012
# Derived mainly from https://onabai.wordpress.com/2012/05/10/installing-couchdb-1-2-in-ubuntu-12-04/
# For Ubuntu 12
# Get some 300MB of dependencies
sudo apt-get install automake autoconf libtool subversion-tools help2man
sudo apt-get install build-essential erlang libicu-dev
sudo apt-get install checkinstall libmozjs-dev wget
@jamesdavidson
jamesdavidson / install.sh
Created July 6, 2012 04:01
Install NodeJS 0.8.1 on fresh Ubuntu 12 installation
#!/bin/bash
sudo apt-get update
sudo apt-get install build-essential curl git
git clone git://github.com/creationix/nvm ~/nvm
. ~/nvm/nvm.sh
nvm install v0.8.1
@jamesdavidson
jamesdavidson / garden-ghost.js
Created July 7, 2012 08:47
Setting up Ubuntu's built-in upstart/monitoring for a NodeJS server script.
http://stackoverflow.com/questions/9646198/cannot-get-my-upstart-script-to-run-node-js-and-forever-when-server-restarts
@jamesdavidson
jamesdavidson / cow-chap.js
Created July 7, 2012 15:47
Cow-Chap. Versatile Javascript. Compiles web-apps from an assortment of resources. Deploys to CouchDB. More info at http://cow-chap-js.info
/* ---------------------
# NOTICE:
This script can be run in the browser or on the server.
Edit this script before you use it.
I can not stress this enough!
@jamesdavidson
jamesdavidson / README.md
Last active August 29, 2015 13:57 — forked from mbostock/.block

This simple force-directed graph shows character co-occurence in Les Misérables. A physical simulation of charged particles and springs places related characters in closer proximity, while unrelated characters are farther apart. Layout algorithm inspired by Tim Dwyer and Thomas Jakobsen. Data based on character coappearence in Victor Hugo's Les Misérables, compiled by Donald Knuth.

Compare this display to a force layout with curved links, a force layout with fisheye distortion and a matrix diagram.

(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://code.jquery.com/jquery.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
context "When I count" do
(0..10).each do |i|
puts i
let (:num) { i + 1}
it "gets cached." do
puts num
end
end
end
@jamesdavidson
jamesdavidson / monkey_patch.rb
Last active August 29, 2015 14:10
A monkey-patch for debugging mongo criteria thingies
class String
def fix(size, padstr=' ')
self[0...size].ljust(size, padstr)
end
end
class Mongoid::Criteria
# pull values out into easy-to-read columns
def interrogate(*syms)
syms = [:id,:created_at,:updated_at] if syms.empty?
@jamesdavidson
jamesdavidson / foo_spec.rb
Created December 9, 2014 04:26
rspec i'm confused
describe 'itself' do
it 'should not work but it does' do
expect(1 > 2)
end
it 'it fails as it should' do
expect(1 > 2).to be(true)
end
end