Skip to content

Instantly share code, notes, and snippets.

Karan Lyons karanlyons

Block or report user

Report or block karanlyons

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am karanlyons on github.
  • I am karanlyons (https://keybase.io/karanlyons) on keybase.
  • I have a public key whose fingerprint is 58E3 3A33 462A 60BC AB6E 8E86 69B3 9688 5CB5 219B

To claim this, I am signing this object:

@karanlyons
karanlyons / partial_object.py
Last active Aug 29, 2015
PartialObject (as functools.partial is to functions)
View partial_object.py
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
import inspect
from collections import OrderedDict
class PartialManager(type):
@karanlyons
karanlyons / duct.py
Created May 28, 2012
duct(): Almost like dict(), but worse.
View duct.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import copy
class _DuctView(object):
"""
*Almost* like `DictView`, but worse.
"""
@karanlyons
karanlyons / gevent_fib.py
Created Jun 4, 2012
Node vs. Gevent (Sync and Async)
View gevent_fib.py
#!/usr/bin/env python
# encoding: utf-8
# $ brew install libev
# $ pip install http://gevent.googlecode.com/files/gevent-1.0b2.tar.gz
# $ chmod +x ./gevent_fib.py
# $ ./gevent_fib.py
import time
@karanlyons
karanlyons / thesaurus.py
Last active Dec 14, 2015
For when a dictionary is too boring.
View thesaurus.py
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
from decimal import Decimal
from difflib import get_close_matches
class Thesaurus(dict):
'''
For when a dictionary is too boring.
@karanlyons
karanlyons / stupid_django_search.py
Last active Dec 24, 2015
Because setting up haystack would just be silly.
View stupid_django_search.py
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
import operator
from django.contrib.admin.util import lookup_needs_distinct
from django.contrib import admin
from django.db.models import Q
View hide_meta_opts.py
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
from copy import deepcopy
from django.db import models
View locks.py
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
from __future__ import division, absolute_import, print_function, unicode_literals
from contextlib import contextmanager
from os import getpid
from random import getrandbits
@karanlyons
karanlyons / tail_call_decorator.py
Last active May 29, 2016
Tail Call Decorator for Python
View tail_call_decorator.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
try:
from sys import _getframe
except ImportError:
import sys
try:
@karanlyons
karanlyons / tal_music.json
Last active Jun 28, 2017
Music played in This American Life episodes, scraped from their transcripts.
View tal_music.json
[
{
"music": [
{
"artist": "Dinah Washington",
"song": "Destination Moon",
"time": "00:05:40.49"
},
{
"artist": "Frank Sinatra",
You can’t perform that action at this time.