Skip to content

Instantly share code, notes, and snippets.

View soplakanets's full-sized avatar

Serhiy Oplakanets soplakanets

View GitHub Profile
@soplakanets
soplakanets / ISSUE.md
Last active August 29, 2015 13:57
Mailgun Response Content-type inconsistency

A call to create a mailing list responds with text/html content type.

~ → curl -i -s --user 'api:key-...' --data 'name=TestCampaign' -X POST 'https://api.mailgun.net/v2/sandbox67449.mailgun.org/campaigns'
HTTP/1.1 200 OK
Server: nginx/1.4.1
Date: Fri, 28 Mar 2014 14:27:26 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 302
Connection: keep-alive
/**
* Create a web friendly URL slug from a string.
*
* Requires XRegExp (http://xregexp.com) with unicode add-ons for UTF-8 support.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <sean@iamseanmurphy.com>
@soplakanets
soplakanets / cmd.sh
Created May 9, 2013 12:15
Get coderwall team members
curl https://coderwall.com/team/rebbix.json | python -m json.tool | egrep -oE '\"username\"\: \"([^\"])+\"' | sed -n 's/\"username\"\: \"\(.*\)\"/\1/p'
@soplakanets
soplakanets / creative
Created August 5, 2011 07:50
Bash utility that aids creative thinking (:
#!/usr/bin/env bash
# utility that aids creative thinking by generating a random word.
# See 'Random Input' technique (http://members.optusnet.com.au/charles57/Creative/Techniques/random.htm)
FILE='/usr/share/dict/words'
head -$((${RANDOM} % `wc -l < ${FILE}` + 1)) ${FILE} | tail -1
@soplakanets
soplakanets / password.js
Created May 19, 2011 13:20
Password hashing for node.js
var crypto = require('crypto');
var SaltLength = 9;
function createHash(password) {
var salt = generateSalt(SaltLength);
var hash = md5(password + salt);
return salt + hash;
}
@soplakanets
soplakanets / restart-on-modification.sh
Created April 15, 2011 07:54
Sample script to restart node.js server when current directory is modified(recursively).
#!/usr/bin/env bash
PID=0
APP_FILE="./app.js"
function start_server {
node $APP_FILE &
PID=$!
}
@soplakanets
soplakanets / decorators.py
Created March 4, 2011 10:07
Basic implementation of decorators to generate default str, repr and eq for class.
#!/usr/bin/env python
# coding: utf-8
def _str(o):
return "%s(%s)" % (o.__class__.__name__, ", ".join([("%s=%s" % (k, v)) for k, v in o.__dict__.items()]))
def default_str(cls):
setattr(cls, "__str__", _str)
return cls
#!/usr/bin/env python3
# coding: utf-8
import unittest
class MetaTestCase(type):
def __new__(cls, name, supers, dictionary):
processBefore(dictionary)
processTestMethods(dictionary)
def append(value, list = None):
list = list or []
list.append(value)
return list
print append(1)
print append(2)
@soplakanets
soplakanets / gist:66363
Created February 18, 2009 14:43 — forked from svetlyak40wt/gist:15067
Automagically install/update the "vimrope" vim plugin
#!/bin/bash
# Plant rope vim's plugin
# This is a script to install or update 'ropevim'
# Copyright Alexander Artemenko, 2008
# Contact me at svetlyak.40wt at gmail com
function create_dirs
{
mkdir -p src