Skip to content

Instantly share code, notes, and snippets.

View curlup's full-sized avatar

Pavel T curlup

  • Knowledge Systems @ DFCI
View GitHub Profile
@curlup
curlup / gist:2920364
Created June 12, 2012 21:53
Eratosthenes
def filterer(k, DEBUG = False):
def g():
x = 1; m = yield;
while True:
m = yield (m if x<=k or x%k != 0 else 0)
x += 1
g = g()
g.next()
def _debug_filterer(x):
res = map(g.send, x)
@curlup
curlup / gist:3175629
Created July 25, 2012 11:25
sql pyparsing
"""
Temporal Proxy
(c) Looking Glass Solutions 2007
Licensed under GPL v2
"""
## SQL COMMANDS: http://www.postgresql.org/docs/8.3/interactive/sql-commands.html
## USE PSYCO
# Importing the required modules
@curlup
curlup / simpleSQL.py
Created July 25, 2012 11:26
simpleSQL pyparsing
# simpleSQL.py
#
# simple demo of using the parsing library to do simple-minded SQL parsing
# could be extended to include where clauses etc.
#
# Copyright (c) 2003, Paul McGuire
#
from pyparsing import Literal, CaselessLiteral, Word, Upcase, delimitedList, Optional, \
Combine, Group, alphas, nums, alphanums, ParseException, Forward, oneOf, quotedString, \
ZeroOrMore, restOfLine, Keyword
@curlup
curlup / gist:3229682
Created August 1, 2012 18:40
monik http agent config ex
def status_conf(port):
return {
'name': 'frontikd_{0}'.format(port),
'response_processor': 'regexp',
'url': 'http://127.0.0.1:{0}/status/'.format(port),
'metrics': {
'served': (r'pages served: (\d+)', 'COUNTER'),
'http-calls': (r'http reqs made: (\d+)', 'COUNTER'),
}
}
@curlup
curlup / gist:3370381
Created August 16, 2012 14:12
график релизов по командам
#!/usr/bin/env python
#coding: utf-8
import calendar, datetime, time, itertools
from itertools import cycle, starmap
class ReleaseCal(calendar.HTMLCalendar):
def __init__(self, groups, offset=0, skip_list=None):
super(ReleaseCal, self).__init__()
self.skip_list = skip_list if skip_list is not None else []
@curlup
curlup / index.html
Last active August 17, 2020 20:50
No-collision (small browser game) http://bl.ocks.org/curlup/raw/7279535/
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" src="http://mbostock.github.io/d3/talk/20111018/d3/d3.js"></script>
<script type="text/javascript" src="http://mbostock.github.io/d3/talk/20111018/d3/d3.geom.js"></script>
<script type="text/javascript" src="http://mbostock.github.io/d3/talk/20111018/d3/d3.layout.js"></script>
<style type="text/css">
circle {
@curlup
curlup / README.md
Created November 12, 2013 16:38 — forked from mbostock/.block

The first 15 seconds of the D3 show reel. See full video at http://vimeo.com/29862153. Includes seamless transitions between the following visualization types:

  • lines
  • horizons
  • areas
  • stacked areas
  • streamgraph
  • overlapping areas
  • grouped bars
  • stacked bars
year pov_level income_deficit
1992 33.5 5.9
1993 31.5 5.3
1994 22.4 3.3
1995 24.7 3.8
1996 22 3.1
1997 20.7 2.8
1998 23.3 3.5
1999 28.3 4.8
2000 29 5
@curlup
curlup / README.md
Last active August 29, 2015 14:03 — forked from mbostock/.block

A spanning tree of the canvas is generated using Prim’s algorithm and then flooded with color. Hue encodes Manhattan distance from the root of the tree. (This is not an optimal visual encoding, but it suffices and is pretty.)

Spanning trees can also be used to generate mazes. See a maze generated with Prim’s algorithm flooded with color, and compare color floods of spanning trees generated with Prim’s algorithm to random traversal, randomized depth-first traversal and Wilson’s algorithm.

@curlup
curlup / README.md
Last active August 29, 2015 14:03 — forked from mbostock/.block