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
Xion / error.py
Created Aug 23, 2015
ErrorExtension for Jinja
View error.py
"""
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
Xion / setup.py
Last active Mar 21, 2016
setup.py skeleton
View setup.py
#!/usr/bin/env python
"""
{project}
======================================
{description}
"""
import ast
import os
from setuptools import find_packages, setup
@Xion
Xion / Cell.java
Created Dec 28, 2014
Cell enum from Taphoo
View Cell.java
package pl.org.xion.taphoo.logic;
/**
* An utility class to hold ranges of cells' values.
* @author Xion
*/
final class CellRanges {
/**
* Private constructor to prevent instantiation.
@Xion
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
Xion / git-today
Last active Aug 29, 2015
Git command displaying work summary for today
View git-today
#!/bin/sh
# 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
Xion / list_tags.sh
Last active Jun 4, 2016
List "tags" (TODO etc.) found in inline comments
View list_tags.sh
#!/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 / gist:8624077
Created Jan 25, 2014
requirements.txt parser for setup.py
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
Xion / debug_smtpd
Last active Jan 1, 2016
Debug SMTP server
View debug_smtpd
#!/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 / listshellaliases.py
Created Dec 24, 2013
Mocking "the filesystem" by stubbing built-in open() in Python
View listshellaliases.py
"""
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
Xion / setup_gae_virtualenv.sh
Created Oct 18, 2013
Setup virtualenv for a Google App Engine project
View setup_gae_virtualenv.sh
#!/bin/sh
# Script for setting up virtualenv to work correctly with Google App Engine projects
# @author Karol Kuczmarski "Xion"
DEFAULT_APPENGINE_SDK_PATH="/opt/google_appengine"
DEFAULT_PROJECT_LIB_PATH="./lib"
You can’t perform that action at this time.