- filter on parent/child relationship
class SomeResource(Resource):
# always use a string with the full path of the resource
parent = fields.ForeignKey('path.to.module.SomeResource',
attribute='parent')
class Meta:
# Python ascii codec can't decode and unicode mess | |
# | |
# check this out https://pythonhosted.org/kitchen/unicode-frustrations.html | |
# and this http://www.joelonsoftware.com/articles/Unicode.html | |
# | |
# The short of it is this | |
# 1. If you can, always set PYTHONIOENCODING=utf8 before you start your python programs. | |
# 2. If you can't or you can't ensure this, always use the following lambda _u to get unicode text | |
# whereever you convert to strings (str.format, str % etc.) | |
# |
class ClientRequestTracer(object): | |
""" | |
Trace api calls to a test client | |
Usage: | |
self.client = ClientRequestTracer(self.client) | |
self.api_client = ClientRequestTracer(self.api_client) | |
Limit the traces by giving parameter traces=[...] list of | |
strings 'get', 'post', 'put' |
""" | |
(c) 2015 github.com/miraculixx | |
MIT License | |
Cacheable URL getter for Django | |
Uses Django's cache framework to cache responses with the same URL. | |
Usage: | |
url = 'http://www.domain.com/static/content' |
#!/bin/bash | |
# Collaborator list, add, remove from a repository | |
# (c) 2015 miraculixx | |
# Author: github.com/miraculixx | |
# MIT License, see below | |
function help { | |
echo "Add collaborators to one or more repositories on github" | |
echo "" | |
echo "Syntax: $0 -u user -p password [-l] [-D] -r repo1,repo2 <collaborator id>" |
#!/bin/bash | |
# source: https://wiki.tox.im/Binaries#Linux | |
sudo sh -c 'echo "deb https://repo.tox.im/ nightly main" > /etc/apt/sources.list.d/toxrepo.list' | |
wget -qO - https://repo.tox.im/pubkey.gpg | sudo apt-key add - | |
sudo apt-get install apt-transport-https #for https repos | |
sudo apt-get update | |
echo "Tox Repository Installed." | |
echo "You can now install utox, qtox, toxic, ratox and tox-bootstrapd" | |
echo "just type: sudo apt-get install utox qtox toxic ratox tox-bootstrapd" |
colors | |
* get the eclipse color theme plugin at http://marketplace.eclipse.org/content/eclipse-color-theme | |
* set NightLion Aptana Theme | |
font | |
* in preferences Colors and Fonts, Text Font | |
* linux: Monospace size 13 | |
* osx: Menlo size 16-18 |
class SomeResource(Resource):
# always use a string with the full path of the resource
parent = fields.ForeignKey('path.to.module.SomeResource',
attribute='parent')
class Meta:
# create ./stampit to stamp all PDF files with a given text | |
# adopted from http://www.commandlinefu.com/commands/view/9984/stamp-a-text-line-on-top-of-the-pdf-pages. | |
ls *pdf | xargs -L1 -I{} echo 'echo {} && echo "CONFIDENTIAL - ATTN XYZ" | enscript -B -f Courier-Bold12 -o- | ps2pdf - | pdftk {} stamp - output tozip/{}' > stampit | |
chmod +x stampit |
see https://wiki.archlinux.org/index.php/GNOME_Keyring#SSH_keys
# list
$ ssh-add -L
# remove
$ ssh-add -D
kwparams = lambda kwargs, keys: (kwargs.get(k) for k in keys.split(','))
```
```
def foo(*args, **kwargs):
foo, bar = kwparams(kwargs, ('foo,bar'))