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 operator import itemgetter | |
from threading import Thread | |
try: | |
from Queue import Queue | |
except ImportError: | |
from queue import Queue | |
def concurrently(fns): |
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 json | |
import requests | |
from lxml import html | |
def num_to_state(n): | |
assert n <= 35 | |
if n < 10: |
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
"""Script to delete spam DMs sent from your account by some malicious | |
apps on twitter | |
Usage: This script needs to be run in two steps | |
1. $ python twdm.py auth (for getting oauth token and secret) | |
This step will prompt you to enter pin and then print the oauth | |
token and secret. |
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
fun xyz 1 = "single" | |
| xyz 2 = "double" | |
| xyz 3 = "triple" | |
| xyz _ = "multiple" | |
(* | |
val xyz = fn : int -> string | |
val it = () : unit |
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 functools import wraps, partial | |
def mul(a, b): | |
return a * b | |
double = partial(mul, 2) | |
## And now try this, | |
print(wraps(double)(lambda a: str(double(a)))(2)) |
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
## Update! Found an alternative approach that's concise and feels much more idiomatic | |
def compose (f, g): | |
return lambda x: f(g(x)) | |
def comp(*args): | |
return reduce(compose, args[1:], args[0]) | |
def comp1(*args): |
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 twython import Twython | |
## Defining access_token as a function so that the token may be cached | |
## using a decorator as follows, | |
## | |
## get_access_token = cache_textfile('.twython-token')(access_token) | |
## | |
def access_token(auth_client): | |
return auth_client.obtain_access_token() |

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
In 1967 I took an introductory course in photography. Most of the students (including me) came | |
into that course hoping to learn how to be creative-to take pictures like the ones I admired | |
by artists such as Edward Weston. On the first day the teacher patiently explained the long | |
list of technical skills that he was going to teach us during the term. A key was Ansel Adams' | |
"Zone System" for previsualizing the print values (blackness in the final print) in a photograph | |
and how they derive from the light intensities in the scene. In support of this skill we had | |
to learn the use of exposure meters to measure light intensities and the use of exposure time | |
and development time to control the black level and the contrast in the image. This is in turn | |
supported by even lower level skills such as loading film , developing and printing, and mixing | |
chemicals. One must learn to ritualize the process of developing sensitive material so that one |
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 sys | |
from urllib import urlencode | |
import requests | |
from urlparse import urlparse, parse_qs | |
from random import choice | |
import re | |
self_id = None # your facebook id here | |
utc_bday = None # utc timestamp of your birthday |