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
def bounce(func, *args): | |
return ('bounce', func, args) | |
def land(value): | |
return ('land', value) | |
def pogo(bouncer): | |
''' Keep bouncing until landing. ''' |
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 Text.Parsec | |
-- import Text.Parsec.String (Parser) | |
import Data.List (findIndex) | |
import Prelude hiding (exp) | |
import Data.IORef | |
import System.IO.Unsafe | |
{-# NOINLINE varCnt #-} | |
varCnt :: IORef Int | |
varCnt = unsafePerformIO (newIORef 0) |
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
{-# LANGUAGE OverloadedStrings #-} | |
import qualified Data.Map as M (findWithDefault, fromList) | |
import qualified Data.ByteString as BS | |
horspool :: BS.ByteString -> BS.ByteString -> Maybe Int | |
horspool s p = f (lenp - 1) (lenp - 1) (lenp - 1) | |
where lenp = BS.length p | |
lens = BS.length s | |
jmptbl = M.fromList $ zip (BS.unpack p) [lenp - 1, lenp - 2 .. 1] | |
jmp c = M.findWithDefault lenp c jmptbl |
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 | |
from PIL import Image | |
import glob | |
# icons downloaded from http://bindingofisaacrebirth.gamepedia.com/ | |
IMGS_PATH = "./img/*" | |
# clipboard to image file | |
if os.system('pngpaste isaac_clip.png'): | |
exit() |
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 | |
import requests | |
from pprint import pprint | |
from base64 import encodestring | |
from rauth import OAuth1Session | |
assert len(sys.argv) == 3, "Useage: python twlogin.py USERNAME PASSWORD" | |
headers = { 'authorization': 'x-td-basic ' + encodestring(sys.argv[1] + ':' + sys.argv[2]), | |
'X-TD-Authtype': 'twitter' } |
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
# coding: utf-8 | |
import os,sys,zipfile | |
def walkdir(d): | |
l=os.listdir(d) | |
nodir=True | |
for t in l: | |
p=os.path.join(d,t) | |
if os.path.isdir(p): | |
nodir=False |
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
# coding: utf-8 | |
import cookielib,urllib2 | |
from cStringIO import StringIO | |
from pysqlite2 import dbapi2 as sqlite | |
from BeautifulSoup import BeautifulSoup | |
# a useful function from others | |
def sqlite2cookie(filename,host): | |
con = sqlite.connect(filename) |
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
# coding: utf-8 | |
a=[ i.decode('utf8').encode('gbk') for i in | |
['澳', '怖', '错', '堕', '贰', '咐', '过', | |
'祸', '祸', '骏', '阔', '络', '穆', '诺', | |
'沤', '瀑', '群', '弱', '所', '唾', | |
'唾', '唾', '误', '褕', '孕', '座',] ] | |
def firstpy(s,code='utf8'): | |
s=s.decode(code).encode('gbk') |
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
# -*- coding: utf-8 -*- | |
import re, time, sys | |
import socket | |
import threading | |
from time import time | |
from random import random | |
PORT = 8080 | |
mbps=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
" vim: set ft=vim: | |
" Vimperator 3.5 | |
source! /Users/scturtle/.vimperatorrc.local | |
source ~/.vimperator/plugin/pinyin-hints.js | |
let mapleader="," | |
" quick jump | |
noremap <leader>1 :b 1<cr> |