Skip to content

Instantly share code, notes, and snippets.

View Xion's full-sized avatar

Karol Kuczmarski Xion

View GitHub Profile
from collections import Mapping
import unittest
import warnings
from flask import get_template_attribute
from myapplication import app
class JinjaTestCase(unittest.TestCase):
@Xion
Xion / setup_gae_virtualenv.sh
Created October 18, 2013 20:20
Setup virtualenv for a Google App Engine project
#!/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"
@Xion
Xion / listshellaliases.py
Created December 24, 2013 16:53
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
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 / 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 / git-today
Last active February 14, 2023 21:39
Git command displaying work summary for 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 --no-pager diff ${LAST_BEFORE_TODAY}..HEAD --stat
@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 / Cell.java
Created December 28, 2014 14:28
Cell enum from Taphoo
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 / 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