Skip to content

Instantly share code, notes, and snippets.

View sshirokov's full-sized avatar
💭
I am a 🐈

Slava Shirokov sshirokov

💭
I am a 🐈
View GitHub Profile
@sshirokov
sshirokov / chains.py
Created May 22, 2009 03:37
Functions to create class methods chain-friendly (as in A.b().c().d()) and a function to create function chains (as in: make_consuming_chain(a, b, c)() #=> c(b(a())) )
def make_consuming_chain(*functions, **kwargs):
'''
Return a function that will call functions in sequence, passing the return down the chain of functions
'''
return reduce(lambda acc, f: lambda *args, **kwargs: f(acc(*args, **kwargs)), functions)
def make_chainable(method):
'''
Make a method returning none return self
'''
/* A facade for the Web Worker API that fakes it in case it's missing.
Good when web workers aren't supported in the browser, but it's still fast enough, so execution doesn't hang too badly (e.g. Opera 10.5).
By Stefan Wehrmeyer, licensed under MIT
*/
var WorkerFacade;
if(!!window.Worker && !iCanHasFastBrowser()){
WorkerFacade = (function(){
return function(path){
return new window.Worker(path);
@sshirokov
sshirokov / gist:1116473
Created July 31, 2011 06:07
Tunnel Package For Emacs Nerds v0.0.1
;; Tunnel boot scaffold [elisp]
(defun toggle-tunnel-out (&optional again)
(interactive "P")
(let* ((bname " *tun*")
(tun (get-buffer bname)))
(if tun
(let ((kill-buffer-query-functions nil))
(kill-buffer tun))
(async-shell-command "~/bin/loop-tunnel.sh" " *tun*")))
(when again (toggle-tunnel-out)))
@erikh
erikh / hack.sh
Created March 31, 2012 07:02 — forked from DAddYE/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@sshirokov
sshirokov / fsm.lisp
Created May 14, 2012 23:51
CLOS FSM with MOP Sauce (requires :closer-mop)
(defpackage :fsm
(:use :cl)
(:export :standard-state-machine
:standard-state-machine-event
:state
:defstate
:deffsm))
(in-package :fsm)
;; Basic copy-pasta protection
@maxrice
maxrice / us-state-names-abbrevs.php
Created May 23, 2012 18:32
US State Names & Abbreviations as PHP Arrays
<?php
/* From https://www.usps.com/send/official-abbreviations.htm */
$us_state_abbrevs_names = array(
'AL'=>'ALABAMA',
'AK'=>'ALASKA',
'AS'=>'AMERICAN SAMOA',
'AZ'=>'ARIZONA',
'AR'=>'ARKANSAS',
@johntyree
johntyree / getBlockLists.sh
Last active June 4, 2024 12:30
Make one large blocklist from the bluetack lists on iblocklist.com
#!/usr/bin/env sh
# Download lists, unpack and filter, write to stdout
curl -s https://www.iblocklist.com/lists.php \
| sed -n "s/.*value='\(http:.*=bt_.*\)'.*/\1/p" \
| xargs wget -O - \
| gunzip \
| egrep -v '^#'
@RobinThrift
RobinThrift / feed.hbt
Created April 11, 2014 21:24
Metalsmith RSS feed Handlebars template
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ sitename }}</title>
<description>{{ description }}</description>
<link>{{ baseUrl }}</link>
<atom:link href="{{ baseUrl }}/feed.xml" rel="self" type="application/rss+xml" />
{{#each collections.entries}}

Early Life

Slava was born in 1986 in Moscow, Russia—a red commie bastard if there ever was one. Like all Russians, he was born to an alcoholic soldier father, and a mother who would have been a famous prima ballerina, had the Cossacks not sacked the family's potato farm, requiring her to abandon her dreams and return home to help support them. Violin music in a minor key played at all times during this period, which may or may not have actually been only visible to the human eye in shades of grey.

As the family grew destitute, it became necessary for Slava to be taken in by the state. Unfortunately, Slava came into being at the same time as a program intended to breed the perfect Communist: no passion, no desires, only cold, cruel logic. The infant was placed in an experiment that substituted a nurturing parent for a mechanized need-meeting device. The young Slava's physical needs never went unmet, but unfortunately the experiment was deemed a failure when it was determined that while the ensuing