Skip to content

Instantly share code, notes, and snippets.

View wrunk's full-sized avatar

Warren Runk wrunk

View GitHub Profile
@wrunk
wrunk / django_eventlet.py
Created May 27, 2011 02:54
Simple Python script to run a django app using eventlet
#!/usr/bin/env python
#
# A simple eventlet script that will run a django app
#
import eventlet
eventlet.monkey_patch()
from eventlet import wsgi
import django.core.handlers.wsgi
from optparse import OptionParser
@wrunk
wrunk / simple_nudge.py
Created May 31, 2011 18:29
Simple Nudge app using Eventlet. Good starting point for a webapp.
#!/usr/bin/env python
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@wrunk
wrunk / mysql5_to_sqlite3.py
Created June 12, 2011 08:03
A base for coverting a mysql5 dump to sqlite
#!/usr/bin/env python
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
@wrunk
wrunk / simple.py
Created June 24, 2011 18:32
Simple python script for bustin
#!/usr/bin/env python
# The above line will cause this script to be run using the program 'python'
# Lines that start with a hash are comments for fun
# The interpreter wont read these.
def print_function():
print '''
******* * *
* * *
@wrunk
wrunk / logging.conf
Created September 26, 2011 02:34
Getting setup with proper python logging
# ---------------------------------------------------------------------------- #
# Standard setup stuff. In general you will want to alter the formatters
#
[formatters]
keys: detailed,simple
[handlers]
keys: console
[formatter_simple]
@wrunk
wrunk / jinja2_file_less.py
Last active September 19, 2023 15:05
python jinja2 examples
#!/usr/bin/env/python
#
# More of a reference of using jinaj2 without actual template files.
# This is great for a simple output transformation to standard out.
#
# Of course you will need to "sudo pip install jinja2" first!
#
# I like to refer to the following to remember how to use jinja2 :)
# http://jinja.pocoo.org/docs/templates/
#
@wrunk
wrunk / path.py
Created October 28, 2011 00:18
Get current python file path
#!/usr/bin/env python
# Stupid gist by warren runk
import os
if __name__ == "__main__":
full_file_path = os.path.realpath(__file__)
print 'Full path to this current file is', full_file_path
@wrunk
wrunk / haproxy_stats_cmds.c
Created December 20, 2011 01:46
Haproxy stats commands
const char stats_sock_usage_msg[] =
"Unknown command. Please enter one of the following commands only :\n"
" clear counters : clear max statistics counters (add 'all' for all counters)\n"
" help : this message\n"
" prompt : toggle interactive mode with prompt\n"
" quit : disconnect\n"
" show info : report information about the running process\n"
" show stat : report counters for each proxy and server\n"
" show errors : report last request and response errors for each proxy\n"
" show sess [id] : report the list of current sessions or dump this session\n"
@wrunk
wrunk / opt_parse.py
Created December 22, 2011 00:29
Python option parse example (optparse OptionParser)
from optparse import OptionParser
import sys
def example_function():
print "Hello world!"
if __name__ == "__main__":
parser = OptionParser()
parser.add_option(
@wrunk
wrunk / del_files_older_than.py
Created December 22, 2011 02:14
Python clean files from a directory
'''
Pass a time in seconds, and a base directory.
I will nuke anything older than now - seconds in that directory. Optionally
recursively
'''
from datetime import datetime
import os
from optparse import OptionParser