Skip to content

Instantly share code, notes, and snippets.

@a-kr
a-kr / proxy.go
Created August 9, 2019 13:58
HTTP proxy with delay
package main
import (
"log"
"time"
"flag"
"net/http"
"net/http/httputil"
)
@a-kr
a-kr / proxy.go
Last active October 24, 2017 08:48 — forked from montanaflynn/proxy.go
Golang reverse proxy
package main
import (
"log"
"net/http"
"net/http/httputil"
"encoding/base64"
)
func main() {
package main
import (
"github.com/go-pg/pg"
"log"
)
type Thing struct {
Id int
Title string
@a-kr
a-kr / gist:589ec5217618fef40438
Created June 1, 2014 12:06
Naive part of speech classifer for English words based on suffixes
POS_SUFFIX_CLASSIFIER = [('scious', 'adj'), ('ation', 'noun'), ('cious', 'adj'), ('ience', 'noun'), ('ance', 'noun'), ('able', 'adj'),
('ible', 'adj'), ('ancy', 'noun'), ('cial', 'adj'), ('ence', 'noun'), ('eous', 'adj'), ('hood', 'noun'),
('ical', 'adj'), ('ious', 'adj'), ('less', 'noun'), ('ling', 'noun'), ('most', 'adv'), ('ness', 'noun'), ('ship', 'noun'),
('sion', 'noun'), ('tail', 'verb'), ('tain', 'verb'), ('tude', 'noun'), ('ture', 'noun'), ('acy', 'noun'),
('ary', 'adj'), ('ain', 'verb'), ('age', 'noun'), ('ate', 'verb'), ('ent', 'adj'), ('ant', 'adj'),
('ane', 'adj'), ('dom', 'noun'), ('eer', 'adj'), ('ent', 'adj'), ('est', 'adj'), ('ery', 'adj'),
('ful', 'adj'), ('ice', 'verb'), ('ien', 'noun'), ('ile', 'adj'), ('ine', 'adj'), ('ion', 'noun'), ('ing', 'adj'),
('ish', 'adj'), ('ism', 'noun'), ('ist', 'noun'), ('ity', 'noun'), ('ize', 'verb'), ('ose', 'adj'),
('ory', 'adj'), ('ous', 'adj'), ('sor', 'adj'), ('tor', 'noun'), ('an', 'noun'), ('al', 'adj'), ('cy', 'noun'),
('er', 'adj'), ('en', 'adj'), (
package main
import (
"log"
"fmt"
"encoding/gob"
"bytes"
"runtime/pprof"
"bufio"
"strconv"
import random
import statsd
import time
random.seed(123)
client = statsd.StatsClient()
order_metrics = []
N_VIDEOS = 5000
@a-kr
a-kr / .vimrc
Created December 12, 2012 16:40
Minimal .vimrc
imap jk <Esc>
cnoreabbrev nt tabnew
nmap gr gT
set laststatus=2
set showtabline=2
set autoindent
syntax on
set number
set incsearch
set ignorecase
@a-kr
a-kr / decimal_tracking.py
Created November 6, 2012 18:01
Отслеживание арифметических вычислений в Python
#coding: utf-8
from decimal import Decimal as TrueDecimal
import traceback
def main1():
def compute(x):
k1 = Decimal('3.5')
k2 = Decimal('1.5')
k3 = Decimal('6')
@a-kr
a-kr / blame-remote-branches.pl
Created October 24, 2012 11:29
Git: перечень веток на origin c авторами
#!/usr/bin/perl
sub get_all_branches {
my @branches = ();
open(BRANCHES, 'git ls-remote origin|') or die $!;
while (<BRANCHES>) {
chomp;
$line = $_;
if ($line =~ /\s*refs\/heads\/(.*)$/) {
@a-kr
a-kr / gist:3887628
Created October 14, 2012 06:43
Short snippet to unindent a string containing Python code
def unindent(code):
lines = code.split('\n')
indent_len = 0
for line in lines:
stripped = line.strip()
if stripped:
indent_len = line.index(stripped[0])
break
if indent_len == 0:
return code