Skip to content

Instantly share code, notes, and snippets.

View Xion's full-sized avatar

Karol Kuczmarski Xion

View GitHub Profile
@Xion
Xion / english_plurals.py
Created March 31, 2013 19:29
English plurals experiment
#!/usr/bin/env python
"""
Experiment with automatic generation of English plurals.
"""
import os
import random
def main():
total_count = 0
@Xion
Xion / debug_smtpd
Last active January 1, 2016 11:19
Debug SMTP server
#!/bin/sh
# Start a debug SMTP server using Python's smtpd module
show() {
echo 1>&2 "$@"
}
port=${1-25}
smtpd_args="-c DebuggingServer localhost:$port"
@Xion
Xion / gist:8624077
Created January 25, 2014 21:41
requirements.txt parser for setup.py
def read_requirements(filename='requirements.txt'):
"""Reads the list of requirements from given file.
:param filename: Filename to read the requirements from.
Uses ``'requirements.txt'`` by default.
:return: Requirments as list of strings.
"""
# allow for some leeway with the argument
if not filename.startswith('requirements'):
@Xion
Xion / setup.py
Last active March 21, 2016 01:51
setup.py skeleton
#!/usr/bin/env python
"""
{project}
======================================
{description}
"""
import ast
import os
from setuptools import find_packages, setup
@Xion
Xion / mock.py
Created May 8, 2016 00:12
Fix for Mock.configure_mock
"""
Extensions to the standard Python mock library.
Use it instead of the library itself.
"""
from __future__ import absolute_import
try:
from unittest.mock import *
except ImportErorr:
from mock import *
@Xion
Xion / list_tags.sh
Last active June 4, 2016 02:39
List "tags" (TODO etc.) found in inline comments
#!/bin/sh
# List code "tags" (TODO et al.) present in source files within given directory
#
# :author: Karol Kuczmarski "Xion"
# :license: Public Domain
TAGS="TODO FIXME XXX"
@Xion
Xion / purge_memcache.exp
Created September 20, 2015 03:14
Flush all keys from memcached server
#!/usr/bin/expect --
# Purge local memcache, flushing all the keys & values
set escapechar !; # easier to send than default ^]
set host [lindex $argv 1];
if { ![string length $host] } {
set host "localhost";
}
@Xion
Xion / interruptibleFadeOut.js
Created August 31, 2015 03:20
Interruptible fade-out DOM animation
function interruptibleFadeOut(element, options) {
if (typeof options === 'number') {
options = {fadeOut: options};
}
element = $(element);
return new Promise(function(resolve) {
// Event handlers used by the effect.
var events = {
mouseenter: function() { interruptAnimation(); },
@Xion
Xion / preview.hs
Last active June 14, 2017 20:54
Preview structured text files (like Markdown) in the browser
#!/usr/bin/env runhaskell
-- Preview structured text files in the browser
-- Usage: $ preview FILE [BROWSER]
-- by Karol Kuczmarski "Xion" -- 25 August 2013
import Control.Exception (bracket)
import System.Environment (getArgs)
import System.Directory (getTemporaryDirectory)
@Xion
Xion / Coded4.hs
Created December 27, 2011 21:30
Haskell implementation of coded4 analyzer (simplified)
-- Coded4.hs
-- Simplified version of coded4 analyzer (http://github.com/Xion/coded4)
-- Supports only Git repositories and produces less neatly formatted output
-- usage:
-- $ runghc Coded4.hs <path-to-git-repo>
module Coded4 where