Skip to content

Instantly share code, notes, and snippets.

@airtonix
airtonix / postactivate
Created June 16, 2013 06:53
virtualenv postactivate hook to create a per project gemset based on your virtualenv name. ~/.virtualenv/${virtualenvname}/bin/postactivate
#!/bin/bash
# This hook is run after this virtualenv is activated.
source ~/.rvm/scripts/rvm
rvm use 1.9.3
gemsets=`rvm gemset list`
proj_name=$(echo $VIRTUAL_ENV|awk -F'/' '{print $NF}')
if [[ ! $gemsets == *"$proj_name" ]]; then
rvm gemset create $proj_name
from functools import wraps
import traceback
import sys
registry = {}
def autodiscover(submodule_name=None, variables=None, callback=None):
"""
Auto-discover INSTALLED_APPS {submodule_name}.py modules and fail silently when
not present.
/*global angular:true, browser:true */
/**
* @license HTTP Auth Interceptor Module for AngularJS
* (c) 2012 Witold Szczerba
* License: MIT
*/
(function () {
'use strict';
class ListAsMember(list):
def __getattr__(self, index):
if index.startswith("_"):
index = index.replace("_", "")
if not isinstance(index, int):
index = int(index)
value = self[index]
@airtonix
airtonix / dict and class to object
Created August 3, 2013 01:45
create class objects with attributes instead of dictionary key/values
HERE_DIR = os.path.abspath(os.path.dirname(__file__))
CONFIGPATH = os.path.abspath("../fabric.yaml")
import yaml
class ListAsMember(list):
def __getattr__(self, index):
if index.startswith("_"):
index = index.replace("_", "")
@airtonix
airtonix / wineprefix
Last active December 20, 2015 14:28
Simple wineprefix tool (something winetricks should really support)
#!/usr/bin/env python
"""
Chuck this in : ~/bin/wineprefix
$ chmod +x ~/bin/wineprefix
$ wineprefix list
# makes a list of directories at ~/.local/share/wineprefixes
borderlands2
masseffect3
fonv
@airtonix
airtonix / addon.xml
Last active December 20, 2015 14:49
hello world xbmc web interface
<?xml version="1.0" encoding="UTF-8"?>
<addon id="MyWebinterface"
version="0.0.1"
name="Hello World Webinterface"
provider-name="MyName">
<requires>
<import addon="xbmc.gui" version="4.0.0"/>
<import addon="xbmc.json" version="6.0.0"/>
</requires>
<extension point="xbmc.gui.webinterface"/>
@airtonix
airtonix / runserver.py
Created August 11, 2013 07:13
Management command that overrides the default runserver to provide `compass watch`
"""
License
=======
Do whatever you like.
Usage
=====
1. put it in your project
@airtonix
airtonix / generate_key.py
Last active June 28, 2018 02:54
Django Settings. Dynamic secret key. Keep your secret key out of version control.
from hashlib import md5, sha1
from base64 import urlsafe_b64encode as b64encode
import random, string
random.seed()
pattern = "%%0%dX"
junk_len = 1024
def generate_key(max_length, seed_length, encoder=b64encode, digester=sha1):
@airtonix
airtonix / call-periscope
Last active May 4, 2016 13:06
Call Periscope from Sickbeard
#!/usr/bin/env python
# chmod +x /opt/sickbeard/postprocess.d/call-periscope
# /opt/sickbeard/postprocess.d/call-periscope
import os, sys
import contextlib
import logging
import logging.handlers