This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Inits a project made with the django-cms-boilerplate | |
# Requires virtualenvwrapper and pip | |
# Create virtualenv if no active | |
if [ "$VIRTUAL_ENV" == "" ]; then | |
echo "Creating virtualenv... Name?" | |
read venvname | |
source virtualenvwrapper.sh | |
mkvirtualenv --no-site-packages $venvname | |
workon $venvname |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
# | |
# registrable.py | |
# | |
"""Demonstrates how to use meta-classes to build a registry of sub-classes.""" | |
__all__ = [ | |
'Registrable', | |
'RegistrableMeta', | |
'BlueColor', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import contextmanager | |
from time import time | |
from sys import stdout | |
@contextmanager | |
def duration(outfile=stdout): | |
start = time() | |
yield | |
end = time() | |
outfile.write(str(end - start) + '\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from contextlib import contextmanager | |
from operator import itemgetter | |
from sys import argv, stdout | |
from time import time | |
@contextmanager | |
def duration(outfile=stdout): | |
start = time() | |
yield | |
end = time() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pyxrun() { | |
PYTHON="${PYTHON:-python}" | |
if [ "x$1" = "x-t" ]; then | |
local timeit="time" | |
shift | |
fi | |
if [ -z "$1" ]; then | |
echo "usage: pyxrun [-t] <file>.pyx" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cpdef int fib(int n): | |
if n == 2: | |
return 2 | |
elif n < 0: | |
raise NotImplementedError | |
elif n <= 1: | |
return 1 | |
else: | |
return fib(n-1) + fib(n-2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Select block corresponding to current folding level | |
--]] | |
line, col = geany.rowcol() | |
-- Scintilla uses 0-based line numbering internally | |
line = line - 1 | |
--~print("L: " .. line .. " C: " .. col) | |
fstart = geany.scintilla("SCI_GETFOLDPARENT", line) | |
--~print("S: " .. fstart+1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# aurinfohelper.sh | |
# | |
process() { | |
if [ ! -f PKGBUILD ]; then | |
echo "PKGBUILD not found!" | |
else | |
source PKGBUILD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: http://pydanny.com/jinja2-quick-load-function.html | |
from jinja2 import FileSystemLoader, Environment | |
def render_from_template(directory, template_name, **kwargs): | |
"""Render named Jinja2 template in given direcctory. | |
Sample usage:: | |
>>> from mymodule import render_from_template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#-*- coding:utf-8 -*- | |
"""Download Zip bundle of Python package requirements for MarkdownPDF.py | |
and extract them to 'site-packages' sub-directory. | |
This is meant for Pythonista (an iOS app) users as an easy way to install | |
these packages. | |
Packages included in the Zip bundle: |
OlderNewer