Ron DuPlain - PyOhio 2013
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 | |
# /etc/init.d/supervisord | |
### BEGIN INIT INFO | |
# Provides: supervisord | |
# Required-Start: $remote_fs $syslog | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: process supervisor | |
### END INIT INFO |
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 | |
# /usr/sbin/policy-rc.d | |
# Do not stop/restart postgresql. --rduplain 2013-02-13 | |
# http://askubuntu.com/a/254307/113086 | |
if [ "$1" = "postgresql" ]; then | |
# Forbid stop/restart, or any init action for that matter. | |
# 101 - action forbidden by policy | |
exit 101 | |
fi |
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
"Build a road-trip curated mp3 directory of a podcast." | |
# Developed against feedparser v5.1.2 and BeautifulSoup v3.2.1. | |
# pip install feedparser BeautifulSoup | |
import datetime | |
import re | |
import time | |
import urllib |
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 | |
# Watch xscreensaver and react to status changes. | |
# | |
# Replaced my previous perl-based recipe with this: | |
# http://semicomplete.googlecode.com/svn/tools/xscreensaver-watch.sh | |
# | |
# Include somewhere in X session startup with: | |
# | |
# xscreensaver-watch & |
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 | |
# Hook for git commits to print top-line character count of commit message. | |
# Useful for calls to `git commit -m '...'` keeping to 50 char convention. | |
# | |
# Place into a file called .git/hooks/commit-msg on a repository. | |
# Be sure to set executable mode: chmod a+x .git/hooks/commit-msg | |
count_plus_newline=`head -1 $1 | wc -m | awk '{ print $1 }'` | |
let count=$count_plus_newline-1 | |
echo "Top line character count: $count" |
This demonstrates that you can configure a Flask application through Flask-Script, without having to create a Flask instance or deal with circular dependencies. Note that Flask-Script's Manager accepts a factory function in place of a Flask app object.
Running:
python manage.py runserver
gives "Hello, world!" on http://localhost:5000/, while running:
python manage.py runserver -c development.cfg
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
"Wrapper to provide ed-style line editing." | |
# Ron DuPlain <ron.duplain@gmail.com> | |
from subprocess import Popen, PIPE | |
def edit(text, command): | |
r"""Edit given text using ed-style line editing, using system's sed command. | |
Examples: |
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
"A dumb script builder to clone scraped GitHub repo listings." | |
# 1. Scrape <ul id="repo_listing" class="repo_list"> into listing.html | |
# 2. python build_clone_script.py | sort -u > clone.sh | |
# 3. time sh clone.sh | |
from __future__ import print_function | |
import lxml.html |