Skip to content

Instantly share code, notes, and snippets.

@piranha
piranha / mixin-vs-dec.py
Created May 28, 2011 09:30
Mixin vs class decorator
import logging, timeit
class LoggedSetItemMixin(object):
def __setitem__(self, index, value):
logging.info('Setting %r to %r' % (index, value))
super(LoggedSetItemMixin, self).__setitem__(index,value)
class LoggingDict(LoggedSetItemMixin, dict):
pass
@piranha
piranha / git-req
Last active November 9, 2019 14:43
Script to create pull requests right from the shell
#!/bin/sh
# git-req -- make a pull request
#
# Assumes branch is pushed to same repo as pull request is made to (origin)
#
# How to obtain GITREQ_TOKEN:
#
# curl -u "$USER:$PASSWORD" -d '{"scopes": ["repo"], "note": "git-req"}' https://api.github.com/authorizations
#
# Usage:
@piranha
piranha / github-upload.py
Created July 9, 2012 11:08
Github upload script. Pretty much useless now.
#!/usr/bin/env python
#
# (c) 2012 Alexander Solovyov under terms of ISC License
# to use, install dependencies:
# pip install opster requests
import os, sys, json
from subprocess import check_output
import requests
@piranha
piranha / md5ize-index.js
Last active December 10, 2015 22:38
Custom RequireJS packer/optimizer & md5 map generator.
#!/usr/bin/env node
// (c) 2012-2013 Instant Communication Bhd, under terms of ISC License.
//
// Process index.html to add md5ized path mapping for RequireJS.
//
// Needs empty CacheBust variable to be defined (see replacement logic), which
// afterwards should be used in `require.config({paths: CacheBust});` call.
@piranha
piranha / git-cleanup
Created February 20, 2013 09:54
Script to cleanup git branches
#!/bin/sh
current_branch=$(git symbolic-ref HEAD | awk -F / '{print $3}')
if [ "$current_branch" != "master" ]; then
echo "WARNING: You are on branch $current_branch, NOT master."
fi
echo "Fetching merged branches..."
git remote prune origin
remote_branches=$(git branch -r --merged | grep -v '/master$' | grep -v "/$current_branch$")
@piranha
piranha / uuid.js
Created April 16, 2013 16:28
UUID4 (almost) in Javascript, for when you need some more or less unique id.
function S4() {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
}
function UUID(short) {
if (short) {
return S4() + S4();
}
return S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4();
}
@piranha
piranha / anchorify.js
Last active February 12, 2020 09:27
Anchorify.js
/*
* Anchorify without jQuery
* Rewritten from https://github.com/willdurand/anchorify.js/
*/
var anchorify = (function() {
var specialCharsRe = /[ ;,.'?!_]/g;
function generateId(text) {
return text
@piranha
piranha / пше
Last active March 25, 2023 07:41
пше гит, прошу пана
#!/usr/bin/env python
# -*- mode: python, coding: utf-8 -*-
#
# This incredible piece of code makes git a bit Polish, a bit Western Ukrainian,
# пше прошу пана
# Joke is based on fact that 'git' is 'пше' in qwerty/йцукен layouts
#
# (c) 2013 Alexander Solovyov under terms of WTFPL
import sys
@piranha
piranha / keybase.md
Last active August 29, 2015 13:58
keybase.md

Keybase proof

I hereby claim:

  • I am piranha on github.
  • I am asolovyov (https://keybase.io/asolovyov) on keybase.
  • I have a public key whose fingerprint is 1F63 22C2 2BAE B0D4 18C1 4477 AB09 CA13 33A4 4CB6

To claim this, I am signing this object:

(ns mailers.main
(:gen-class)
(:require [com.stuartsierra.component :as c]
[aleph.http :as aleph]
[manifold.stream :as mani]
[ring.util.response :as response]
[ring.middleware.file-info :only [wrap-file-info]]
[ring.middleware.resource :refer [wrap-resource]]))