Skip to content

Instantly share code, notes, and snippets.

@jedp
jedp / gist:799455
Created January 27, 2011 22:40
Gracefully handle the unavailability of Typekit
if (typeof Typekit != 'undefined') {
try {
Typekit.load({
active: function() {
// it worked. carry on ...
}
});
} catch(e) {
// probably want to fall back to no typekit
$('html').addClass('wf-inactive').removeClass('wf-loading');
@jedp
jedp / autocomplete.py
Created April 18, 2011 19:20 — forked from j4mie/autocomplete.py
autocomplete.py - redis autocompleter
"""
A redis autocomplete example for multi-word phrases.
Based on:
Ruby original: http://gist.github.com/574044
Python original: https://gist.github.com/577852
See options below for usage
Requires http://github.com/andymccurdy/redis-py/
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
# Sudoku solver in CoffeeScript based on the Python solution by Peter Norvig
# http://norvig.com/sudoku.html
# 2011-04-19 jonelf@gmail.com
#
# Throughout this program we have:
# r is a row, e.g. 'A'
# c is a column, e.g. '3'
# s is a square, e.g. 'A3'
# d is a digit, e.g. '9'
# u is a unit, e.g. ['A1','B1','C1','D1','E1','F1','G1','H1','I1']
@jedp
jedp / gist:970079
Created May 13, 2011 06:23
Jison grammar to convert numerals into an integer
/* Jison grammar for converting numerals into an integer */
/* The lexical analyzer
How we break things up into tokens */
%lex
%%
[0-9]+ return 'INT'
"-" return '-'
@jedp
jedp / gist:970091
Created May 13, 2011 06:46
steve.jison
/* Part of the grammar of Steve */
%lex
%%
\s+ { /* ignore whitespace */ }
[0-9]+"."[0-9]+\b { return 'FLOAT'; }
[0-9]+\b { return 'INT'; }
\"[^\"]+\" { yytext = yytext.substr(1, yyleng-2); return 'STR'; }
"int" return 'INTTYPE'
@jedp
jedp / gist:1784039
Created February 9, 2012 22:53
ldap auth for express and socket.io
// express + socket.io example (chat server)
// that requires authentication via ldap.
// express shares authentication with socket.io.
var express = require('express');
var io = require('socket.io');
var ldap = require('./lib/node-ldapauth/ldapauth');
var sessionStore = new express.session.MemoryStore(); // whatever
var parseCookie = require('connect').utils.parseCookie;
@jedp
jedp / gist:1792050
Created February 10, 2012 19:38
compiling python support in vim73
# must set this vi_cv_path_python_plibs var
# people say having a trailing slash on the python-config-dir causes problems
$ export vi_cv_path_python_plibs="-L/usr/lib64/python2.7/config -lpython2.7 -ldl"
$ ./configure --enable-cscope \
--enable-multibyte \
--enable-gui \
--with-python-config-dir=/usr/lib64/python2.7/config \
--enable-pythoninterp=yes \
--with-x \
@jedp
jedp / gist:1829212
Created February 14, 2012 19:01
pyvows teardown not invoked unless all tests pass
from pyvows import Vows, expect
@Vows.batch
class IfATestFails(Vows.Context):
def topic(self):
return "oh noes!"
def setup(self):
print "test 1 setup: this will be printed"
@jedp
jedp / gist:1894029
Created February 23, 2012 17:54
example node.js event emitter
var util = require('util');
var events = require('events');
var redis = require('redis');
var RedisQueueConsumer = function (port, host) {
events.EventEmitter.call(this);
this.port = port || 6379;
this.host = host || '127.0.0.1';
};