Skip to content

Instantly share code, notes, and snippets.

import time
import sys
ms = int(sys.argv[1]) if len(sys.argv) > 1 else 250
words, start = 0, time.time()
print "\n"*2
try:
for line in sys.stdin:
------------------------------------------------------------------------------------------
-- A formalization of the Cheryl's birtday problem; using Haskell/SBV
--
-- See: http://www.nytimes.com/2015/04/15/science/a-math-problem-from-singapore-goes-viral-when-is-cheryls-birthday.html
--
-- By Levent Erkok, This file is in the public domain. Use it as you wish!
--
-- NB. Thanks to Amit Goel for suggesting the formalization strategy used in here.
------------------------------------------------------------------------------------------
## Yacc is dead - Ruby edition (recognizer only)
# Pretty much a direct port of the recognizer from:
# http://matt.might.net/articles/parsing-with-derivatives/code/dparse.rkt
#
# Requires 1.9
# gem install lazy
require 'lazy'
include Lazy::Methods
@starenka
starenka / wg.py
Created January 1, 2011 14:36
wordlist generator
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# simple wl generator
#
# @author: starenka
# @email: 'moc]tod[liamg].T.E[0aknerats'[::-1]
# @version: 1.0
# @since 1/1/11
# @requires python 2.6
@starenka
starenka / maralik.py
Created February 14, 2011 14:51
Maralik (DJC) v Py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# @author: starenka
# @email: 'moc]tod[liamg].T.E[0aknerats'[::-1]
# @version: 1.0
# @since 2/14/11
# @depends DJC
import random, time, sys, datetime
@pachacamac
pachacamac / whereami.sh
Created June 30, 2011 17:34
Wanna know where you are?
#!/bin/bash
echo -n "{\"version\": \"1.1.0\",\"host\": \"maps.google.com\",\"request_address\": true,\"address_language\": \"en_GB\", \"wifi_towers\": [`iwlist scan 2> /dev/null | tr -d '\n' | sed -e 's/Cell [0-9]* - Address: \([0-9A-Z:]*\)[^C]*Channel:\([0-9]*\)[^S]*Signal level=\([0-9-]*\) dBm[^E]*E[^E]*ESSID:"\([^"]*\)"/\{"mac_address": "\1","signal_strength": \3,"age": 0,"channel": \2,"ssid": "\4"}/g' -e 's/[^{]*{/{/' -e 's/}[^{]*{/},{/g' -e 's/\}[^}]*$/\}/' `]}" | curl -s -X POST -d @/dev/fd/0 http://www.google.com/loc/json
# TIP: run with sudo for improved accuracy since iwlist can then provide more than the active hotspot
@starenka
starenka / papu.py
Created August 5, 2011 23:45
greps menus of my fav restaurants close to my office
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime
from pyquery import PyQuery as pq
doc = pq(url='http://www.jinakrajina.cz/cz/poledni-menu')
noms = doc.find('td > p')
print '\n%s'%noms[0].text_content()[2:]
for i,nom in enumerate(noms[1:-1:2],1):
print '[%d] %s'%(i,nom.text_content().strip())
@gallais
gallais / Cellular.hs
Created September 7, 2015 22:28
Formalisation of Cellular Automaton & running rule 90
module Data.Cellular where
import Data.Monoid
import Data.Function.Memoize
newtype Cellular g a = Cellular { delta :: (g -> a) -> a }
step :: Monoid g => Cellular g a -> (g -> a) -> (g -> a)
step (Cellular d) init g = d (init . (g <>))
@jozefg
jozefg / mltt.agda
Created November 2, 2015 06:15
Defining a realizability model for MLTT using induction-recursion.
module realize where
open import Relation.Nullary
import Data.Empty as E
open import Data.Product
open import Data.Sum
open import Data.Nat
data Term : Set where
var : ℕ → Term
lam : Term → Term
@starenka
starenka / volby2.py
Last active December 11, 2015 18:29
#!/usr/bin/env python
import time
from pyquery import PyQuery as pq
while True:
def to_float(text):
return float(text.text.replace(',', '.'))
doc = pq(url='http://www.volby.cz/pls/prez2013/pe2?xjazyk=CZ')