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 / 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 / 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 / query_profile.py
Created October 5, 2015 10:44 — forked from amorton/query_profile.py
Tool for profiling Cassandra query performance.
"""Tool for profiling Cassandra query performance.
Tests are run by profile() multiple times and the 'Read Latency' is
extracted using node tool.
Usage:
#Create the schema using the cassandra-cli.
create keyspace query
// Support routines for automatically reporting user timing for common analytics platforms
// Currently supports Google Analytics, Boomerang and SOASTA mPulse
// In the case of boomerang, you will need to map the event names you want reported
// to timer names (for mPulse these need to be custom0, custom1, etc) using a global variable:
// rumMapping = {'aft': 'custom0'};
(function() {
var wtt = function(n, t, b) {
t = Math.round(t);
if (t >= 0 && t < 3600000) {
// Google Analytics
""""
The orignal author: Alexer / #python.fi
"""
import opcode
import dis
import sys
import multiprocessing
@curlup
curlup / README.md
Last active August 29, 2015 14:03 — forked from mbostock/.block
@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.