Skip to content

Instantly share code, notes, and snippets.

View jamesadney's full-sized avatar

James Adney jamesadney

View GitHub Profile
@jamesadney
jamesadney / gist:978852
Created May 18, 2011 15:49
Simple Tk text file reader
from Tkinter import *
import tkFileDialog
main = Tk()
main.title("Notpad")
main.minsize(width=500,height=400)
text = Text(main)
text.pack(expand=YES, fill=BOTH)
@jamesadney
jamesadney / pdftotif
Created July 27, 2011 16:55
Convert PDF to TIF to extract text (use tesseract or cuneiform)
convert -colorspace RGB -density 300 -quality 80 file.pdf file.tif
@jamesadney
jamesadney / convert2crlf.py
Created September 16, 2011 00:42
Simple tkinter script to open file and convert line endings to Windows style (CRLF)
#!/usr/bin/python
import os
#TODO: What happens if script is imported as module?
WORKING_DIRECTORY = os.path.dirname(os.path.abspath(__file__))
from Tkinter import *
import tkFileDialog
@jamesadney
jamesadney / bootstrap.sh
Created January 29, 2012 01:58 — forked from anonymous/bootstrap.sh
Django on Heroku with Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
@jamesadney
jamesadney / inset_text
Created February 2, 2012 16:52
inset text with CSS
-webkit-background-clip: text;
@jamesadney
jamesadney / suspend.sh
Created February 5, 2012 05:24
Suspend using dbus upower interface
dbus-send --system --print-reply --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend
@jamesadney
jamesadney / get_dir.sh
Created February 21, 2012 22:19
Get the directory of a bash script
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
@jamesadney
jamesadney / xidle.py
Created February 21, 2012 23:21
X11 Idle Time
import ctypes
import os
class XScreenSaverInfo( ctypes.Structure):
""" typedef struct { ... } XScreenSaverInfo; """
_fields_ = [('window', ctypes.c_ulong), # screen saver window
('state', ctypes.c_int), # off,on,disabled
('kind', ctypes.c_int), # blanked,internal,external
('since', ctypes.c_ulong), # milliseconds
('idle', ctypes.c_ulong), # milliseconds
@jamesadney
jamesadney / dbus_service.py
Created February 22, 2012 06:38
Dbus Service with Python (for gtk2)
# myservice.py
# simple python-dbus service that exposes 1 method called hello()
import gtk
import dbus
import dbus.service
from dbus.mainloop.glib import DBusGMainLoop
class MyDBUSService(dbus.service.Object):
def __init__(self):
@jamesadney
jamesadney / idle.py
Created February 22, 2012 06:43 — forked from tcurvelo/energysaver.py
idle time on windows
#!/usr/bin/env python
from ctypes import Structure, windll, c_uint, sizeof, byref
import time
class LASTINPUTINFO(Structure):
_fields_ = [
('cbSize', c_uint),
('dwTime', c_uint),
]