Skip to content

Instantly share code, notes, and snippets.

Karol Kuczmarski Xion

Block or report user

Report or block Xion

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Xion /
Created Aug 23, 2015
ErrorExtension for Jinja
Jinja extension adding support for {% error %} tag
that allows to raise exceptions directly from templates.
from jinja2 import TemplateAssertionError
from jinja2.ext import Extension
from jinja2.nodes import CallBlock, Const
class ErrorExtension(Extension):
Xion /
Last active Mar 21, 2016 skeleton
#!/usr/bin/env python
import ast
import os
from setuptools import find_packages, setup
Xion /
Created Dec 28, 2014
Cell enum from Taphoo
* An utility class to hold ranges of cells' values.
* @author Xion
final class CellRanges {
* Private constructor to prevent instantiation.
Xion / preview.hs
Last active Jun 14, 2017
Preview structured text files (like Markdown) in the browser
View preview.hs
#!/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 / git-today
Last active Aug 29, 2015
Git command displaying work summary for today
View git-today
# git-today
# Usage:
# * Name it `git-today` and put somewhere inside a `$PATH` directory
# * Invoke as $ git today
LAST_BEFORE_TODAY=$(git log --oneline --until='yesterday 23:59:59' | head -1 | cut -d' ' -f 1)
git diff ${LAST_BEFORE_TODAY}..HEAD --stat
Xion /
Last active Jun 4, 2016
List "tags" (TODO etc.) found in inline comments
# List code "tags" (TODO et al.) present in source files within given directory
# :author: Karol Kuczmarski "Xion"
# :license: Public Domain
Xion / gist:8624077
Created Jan 25, 2014
requirements.txt parser for
View gist:8624077
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 / debug_smtpd
Last active Jan 1, 2016
Debug SMTP server
View debug_smtpd
# Start a debug SMTP server using Python's smtpd module
show() {
echo 1>&2 "$@"
smtpd_args="-c DebuggingServer localhost:$port"
Xion /
Created Dec 24, 2013
Mocking "the filesystem" by stubbing built-in open() in Python
Example function that reads a file and does something with it.
import re
import sys
def list_shell_aliases(script):
"""Find all command aliases defined in a shell script.
Aliases are created though the ``alias`` command::
Xion /
Created Oct 18, 2013
Setup virtualenv for a Google App Engine project
# Script for setting up virtualenv to work correctly with Google App Engine projects
# @author Karol Kuczmarski "Xion"
You can’t perform that action at this time.