Skip to content

Instantly share code, notes, and snippets.

import random
import string
import cherrypy
class StringGenerator(object):
@cherrypy.expose
def index(self):
return """<html>
import StringIO
import cPickle
small = [{i: i} for i in xrange(9)]
medium = [{i: i} for i in xrange(999)]
large = [{i: i} for i in xrange(999999)]
def dumps(obj):
return cPickle.dumps(obj)
(flycheck-define-checker javascript-flow
"A JavaScript syntax and style checker using Flow.
See URL `http://flowtype.org/'."
:command ("flow" source-original)
:error-patterns
((error line-start
(file-name)
":"
line
(flycheck-define-checker erlang-dialyzer
"Erlang syntax checker based on dialyzer."
:command ("dialyzer" source-original)
:error-patterns
((error line-start
(file-name)
":"
line
":"
(message)
@lbolla
lbolla / pylint.vim
Created August 25, 2011 10:43
pylint
" Vim compiler file for Python
" Compiler: Style checking tool for Python
" Maintainer: Oleksandr Tymoshenko <gonzo@univ.kiev.ua>
" Last Change: 2011 Aug 25
" Version: 0.5
" Contributors:
" Artur Wroblewski
" Menno
" Lorenzo Bolla
"
@lbolla
lbolla / taba.hs
Created January 15, 2012 17:46
There and Back Again
-- There and Back Again
-- http://www.brics.dk/RS/02/12/BRICS-RS-02-12.pdf
-- Fold a function over a sequence and the reverse of another sequence, in
-- just one passage.
taba :: ((t1, t2) -> t -> t) -> t -> [t1] -> [t2] -> t
taba f b xs ys =
let (r, _) = foldr (\x (r, y:ys) -> (f (x,y) r, ys))
(b, ys)
xs
@lbolla
lbolla / Sudoku.hs
Created February 27, 2012 17:23
Brute force Sudoku solver
module Main where
import Data.List (nubBy, concat, findIndices)
import Control.Monad (liftM2, forM, join, guard)
import Data.Maybe (catMaybes, fromMaybe)
import Debug.Trace
type Board = String
-- Some boards
@lbolla
lbolla / Makefile
Created September 1, 2012 08:12
Warp vs. Yesod benchmark
GHC=ghc --make -O2 #-threaded
GHC_PROF=${GHC} -prof -auto-all
warp: warp.hs
${GHC} warp.hs
warp-prof: warp.hs
${GHC_PROF} warp.hs
yesod: yesod.hs
all: go.so
go.o: go.c
gcc -std=c99 -c -fPIC go.c -o go.o
go.so: go.o
gcc -shared -Wl,-soname,libgo.so -o libgo.so go.o
@lbolla
lbolla / par.py
Last active January 1, 2016 05:19
Python GIL and Cython
from threading import Thread
def busy_sleep(n):
while n > 0:
n -= 1
N = 99999999
t1 = Thread(target=busy_sleep, args=(N, ))