Skip to content

Instantly share code, notes, and snippets.

Elliott Hoffman slor

Block or report user

Report or block slor

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
""" An example of a Linux daemon written in Python.
Based on
The changes are:
1 - Uses file open context managers instead of calls to file().
2 - Forces stdin to /dev/null. stdout and stderr go to log files.
3 - Uses print instead of sys.stdout.write prior to pointing stdout to the log file.
4 - Omits try/excepts if they only wrap one error message w/ another.
slor /
Created Jun 12, 2013
Run django test on all the packages listed in a CSV file. Supports additional args too.
#!/usr/bin/env bash
# Run tests on packages listed in a csv file.
# Usage: ./ [arg1 arg2 ...]
# Runs test on all the packages listed in what_to_test.csv. You can
# pass additional args and they will be appended to the manage command.
# Example:
payload = {'html': ' <!doctype html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]--> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>Home | Linkminded</title> <meta name="description" content="Discover like minded individuals with complementing skillset to collaborate on an idea together."> <meta name="keywords" content="link, minded, like, developers, designers, entrepreneurs, startup, collaborate, collaboration, find, discover, ideas, projects"> <meta name="author" content=""> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="shortcut icon" href="">
# -*- coding: utf-8 -*-
import sys
import datetime
import base64
import requests
def main():
slor /
Created Jan 16, 2013
Mock the open() builtin as a context manager.
from mock import MagicMock
open_name = '' % __name__
with patch(open_name, create=True) as mock_open:
mock_file = MagicMock(spec=file) = 'hello'
mock_open.return_value.__enter__.return_value = mock_file
with open('/some/path', 'rU') as f:
slor / xorg.conf
Created Sep 1, 2012
TwinView xorg.conf file for dual 23" LEDs created via NVidia settings
View xorg.conf
# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings: version 295.33 (buildd@allspice) Fri Mar 30 13:37:33 UTC 2012
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
Option "Xinerama" "0"
slor / gist:3561826
Created Sep 1, 2012
OSX-style EOL/BOL bindings for sublime text 2
View gist:3561826
{ "keys": ["ctrl+e"], "command": "move_to", "args": {"to": "eol"} },
{ "keys": ["ctrl+a"], "command": "move_to", "args": {"to": "bol"} }
slor /
Created Jan 15, 2012
Mint 12 installs for Django app on Heroku Cedar
# Installs the prerequisites to set up a Django app on Heroku Cedar [2].
apt-get install python-setuptools
apt-get install python-dev
easy_install pip
pip install virtualenvwrapper
apt-get install curl
apt-get install postgresql
sudo apt-get install postgresql-server-dev-9.1
slor /
Created Dec 21, 2011
An example and explaination of a Python decorator that takes a non-optional parameter.
""" An example of writing a decorator that takes an argument.
Based on e-satis's answer at
from functools import wraps
# The outer-most level is the decorator factory. The middle level is the
# decorator and the inner most level is where we call the decorated function.
def decorator_maker(buzz):
You can’t perform that action at this time.