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: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 / jupyter-envs.md
Created April 13, 2023 22:21 — forked from James-Leslie/jupyter-envs.md
How to add conda environment to jupyter lab

How to add conda environments to JupyterLab

Credit for this goes to the Stack Overflow user Statistic Dean for his post on this question

1. Install nb_conda_kernels into your base environment

(base)$ conda install -c conda-forge nb_conda_kernels

2. Activate desired environment and install ipykernel

@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 / 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 / index.html
Last active July 21, 2020 20:04
no-collision dev fork
<!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 {
-- In pg_stat_statements, there is a problem: sometimes (quite often), it registers the same query twice (or even more).
-- It's easy to check in your DB:
--
-- with heh as (
-- select userid, dbid, query, count(*), array_agg(queryid) queryids
-- from pg_stat_statements group by 1, 2, 3 having count(*) > 1
-- ) select left(query, 85) || '...', userid, dbid, count, queryids from heh;
--
-- This query gives you "full picture", aggregating stats for each query-database-username ternary
@curlup
curlup / haproxy rate limiting
Created January 23, 2018 10:24 — forked from jeremyj/haproxy rate limiting
haproxy rate limiting
HTTP request limiting ===================================================================================================================
frontend ft_web
# Use General Purpose Couter (gpc) 0 in SC1 as a global abuse counter
# Monitors the number of request sent by an IP over a period of 10 seconds
stick-table type ip size 1m expire 10s store gpc0,http_req_rate(10s)
tcp-request connection track-sc1 src
# refuses a new connection from an abuser
tcp-request content reject if { src_get_gpc0 gt 0 }
Region Name Region Latency
EU (Frankfurt) eu-central-1 305ms
Asia Pacific (Tokyo) ap-northeast-1 716ms
EU (Ireland) eu-west-1 770ms
US West (N. California) us-west-1 927ms
US East (N. Virginia) us-east-1 1048ms
Asia Pacific (Seoul) ap-northeast-2 1066ms
US West (Oregon) us-west-2 1098ms
Asia Pacific (Singapore) ap-southeast-1 1242ms
South America (Sao Paulo) sa-east-1 1266ms
@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
@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 []