This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import random | |
import sys | |
import time | |
from contextlib import contextmanager | |
from multiprocessing import Manager, Pool | |
class Timer(object): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Regular Expressions | |
;; import re; re.search(r'ab.*', 'cabbage').group(0) # -> 'abbage' | |
(re-find #"ab.*" "cabbage") ; "abbage" | |
;; re.match(r'ab.*', 'cabbage') # -> None | |
(re-matches #"ab.*" "cabbage") ; nil | |
;; re.match(r'ab.*', 'abracatabra').group(0) # -> 'abracatabra' | |
(re-matches #"ab.*" "abracatabra") ; "abracatabra" | |
;; Sequences & Map/Filter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sqlite3 | |
from hashlib import md5 | |
from time import time | |
import simplejson as json | |
from flask import Flask | |
from flask.ext import restful | |
from flask import g | |
from flask import request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import unicode_literals | |
import re | |
import argparse | |
from functools import partial | |
class Options(argparse.ArgumentParser): | |
def __init__(self, **kwargs): | |
self._parsed = False | |
self._options = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import json | |
import argparse | |
import time | |
import requests | |
from functools import partial | |
class GithubBackup(object): | |
def __init__(self, parameters): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Generator implements Iterator { | |
private $index = 0; | |
private $array = array(); | |
private $keys = array(); | |
private $filter = NULL; | |
private $mapper = NULL; | |
private $size = 0; | |
private $seek = 0; | |
private $last = NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import MutableSequence | |
import marshal | |
from operator import add, div, mul, neg, mod, sub | |
from operator import ge, gt, le, lt, eq | |
from itertools import imap | |
''' | |
Extended list class | |
- fast lookups by maintaining a dictionary with the values | |
- numeric operations between 2 instances are possible (like Octave matrices) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
- setup.py | |
from distutils.core import setup, Extension | |
module = Extension('ht', sources = ['zmalloc.c', 'sds.c', 'dict.c', 'python-c-module-example.c']) | |
setup(name = 'Hash Table', version = '1.0', ext_modules = [module]) | |
- install.sh | |
# Fetch dependencies from https://github.com/antirez/redis | |
wget https://raw.github.com/antirez/redis/2.6/src/fmacros.h | |
wget https://raw.github.com/antirez/redis/2.6/src/config.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import argparse | |
import os | |
import re | |
''' | |
**** Crontab file syntax checking *** | |
Useful for scripts stored under /etc/cron.d | |
and for automating crontab task distribution | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
import argparse | |
import readline | |
import rlcompleter | |
import shlex | |
import os | |
import re | |
try: |
NewerOlder