Skip to content

Instantly share code, notes, and snippets.

@gene9
gene9 / a.py
Created October 22, 2010 14:53
modified = '*' if self.buffer.get_modified() else ''
modified = '*' if self.buffer.get_modified() else ''
@gene9
gene9 / erlang-interview-question.erl
Created April 21, 2011 12:00 — forked from vlm/erlang-interview-question.erl
Erlang inteview question
%% Given the parsed HTML tree in the following format:
%%
%% Types HTML = [Element]
%% Element = {Tag, [Attribute], [Element | Text]}
%% Tag = atom() % e.g. 'a', 'pre', 'p'
%% Attribute = {Name, Value}
%% Name = atom()
%% Value = string()
%% Text = iolist()
%%
@gene9
gene9 / gist:969303
Created May 12, 2011 19:51 — forked from rblaze/problemK.hs
Problem K
import Data.Char
import Data.Map (Map, keys, fromList, toList, adjust)
import qualified Data.Map
import Data.Maybe
data Cell = StrConst String |
Empty |
Number Int |
Expr String |
Error String
@gene9
gene9 / pubsub.md
Created January 11, 2012 18:46 — forked from addyosmani/pubsub.md
Four ways to do Pub/Sub with jQuery 1.7 and jQuery UI (in the future)

#Four Ways To Do Pub/Sub With jQuery 1.7 and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

@gene9
gene9 / pubsub.md
Created February 27, 2012 09:59 — forked from addyosmani/pubsub.md
Four ways to do Pub/Sub with jQuery 1.7 and jQuery UI (in the future)

#Four Ways To Do Pub/Sub With jQuery 1.7 and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

@gene9
gene9 / example.js
Created February 27, 2012 10:01 — forked from addyosmani/example.js
Mediator pattern
// Example 1
mediator.name = 'Doug';
mediator.subscribe('nameChange', function(arg){
console.log(this.name);
this.name = arg;
console.log(this.name);
});
madiator.publish('nameChange', 'Jorn');
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
D:\as\projects\test>lein plugin install lein-noir 1.2.1
[INFO] Unable to find resource 'lein-noir:lein-noir:jar:1.2.1' in repository cen
tral (http://repo1.maven.org/maven2)
Copying 1 file to c:\tmp\lein-57e6bf6f-bbab-4035-9060-b310b0ae1cb4\lib
Including lein-noir-1.2.1.jar
Including clojure-1.2.1.jar
Exception in thread "main" java.io.IOException: Couldn't delete c:\tmp\lein-57e6
@gene9
gene9 / model_localized_classmethod.py
Created May 14, 2012 13:32 — forked from acdha/model_localized_classmethod.py
Using @simonw's django-queryset-transform to avoid massive performance penalties with translated model content
@classmethod
def localized(cls, lang=u'en'):
"""
Returns a QuerySet which will be pre-populated with localized values
Usage:
Item.localized("en").filter(…)
"""
if not isinstance(lang, Language):
lang = Language.objects.get(iso639_3=lang)
@gene9
gene9 / gist:2714357
Created May 16, 2012 22:06 — forked from mikeyk/gist:1329319
Testing storage of millions of keys in Redis
#! /usr/bin/env python
import redis
import random
import pylibmc
import sys
r = redis.Redis(host = 'localhost', port = 6389)
mc = pylibmc.Client(['localhost:11222'])
@gene9
gene9 / gist:2931885
Created June 14, 2012 18:09 — forked from SamSaffron/gist:893878
mini orm
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Reflection.Emit;
using System.Collections.Concurrent;
using System.Data;
using System.Reflection;