Skip to content

Instantly share code, notes, and snippets.

Avatar

Vamshi jvvk

View GitHub Profile
View create_imdb_db.py
from subprocess import Popen
from datetime import date, datetime
import os
import math
import codecs
from itertools import islice
from sqlalchemy import create_engine, Column, Index
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.dialects.sqlite import FLOAT, INTEGER, TEXT
@jvvk
jvvk / fogcreek_hash.hs
Created Aug 19, 2014
Fogcreek hash problem
View fogcreek_hash.hs
hash s h0 str = last $ scanl1 (\x y -> x*37 + y) (h0:[fromJust $ elemIndex c str | c <- s])
unhash h h0 str = reverse $ unfoldr (\x -> if x == h0 then Nothing else Just (str !! (x `mod` 37), x `quot` 37)) h
hash "leepadg" 7 "acdegilmnoprstuw"
unhash 680131659347 7 "acdegilmnoprstuw"