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
""" An example of a Linux daemon written in Python. | |
Based on http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/ | |
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. |
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 bash | |
# | |
# Run tests on packages listed in a csv file. | |
# | |
# Usage: ./test_everything.sh [arg1 arg2 ...] | |
# | |
# Runs manage.py 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: |
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
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="link-minded.com"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="shortcut icon" href="https://d1ttgy8gd6pa2l.cloudfront.net/img/favicon.fbe95e4d6cf2.ico"> |
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 -*- | |
import sys | |
import datetime | |
import base64 | |
import requests | |
def main(): |
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
# http://www.voidspace.org.uk/python/mock/ | |
from mock import MagicMock | |
open_name = '%s.open' % __name__ | |
with patch(open_name, create=True) as mock_open: | |
mock_file = MagicMock(spec=file) | |
mock_file.read.return_value = 'hello' | |
mock_open.return_value.__enter__.return_value = mock_file | |
with open('/some/path', 'rU') as f: |
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
# 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" | |
EndSection |
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
[ | |
{ "keys": ["ctrl+e"], "command": "move_to", "args": {"to": "eol"} }, | |
{ "keys": ["ctrl+a"], "command": "move_to", "args": {"to": "bol"} } | |
] |
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
# 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 |
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
""" An example of writing a decorator that takes an argument. | |
Based on e-satis's answer at http://stackoverflow.com/questions/739654/understanding-python-decorators#1594484. | |
""" | |
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): |
NewerOlder