Skip to content

Instantly share code, notes, and snippets.

View amites's full-sized avatar

Alvin Mites amites

View GitHub Profile
adjust_timeout () {
cat <<EOF
if keystatus --shift; then
set timeout=-1
else
set timeout=0
fi
EOF
}
@amites
amites / add-ip-ec2.py
Created May 25, 2012 07:50
python add current IP address to ec2
#!/usr/bin/python
import urllib2
from boto.ec2.connection import EC2Connection
try:
from django.conf import settings
except ImportError:
class settings:
@amites
amites / findIP.py
Created May 25, 2012 07:44
find public ip using python (executable)
!#/usr/bin/python
# simple python script to return your public IP address using whatismyip.com
# if executed from command line will display IP
def findIP():
'''
Returns your IP address. Includes setting the header to match the request
see http://www.whatismyip.com/faq/automation.asp
'''
@amites
amites / model_util.py
Created January 8, 2012 06:27
Django TemplateTag to Return Filename without Directory Information
from django import template
register = template.Library()
@register.filter
def fileNameClean(file, arg):
'''
Return the file name without any directory information.
'''
obj = getattr(file, arg, False)
@amites
amites / qsolve360
Created December 23, 2011 00:21
Simple method for connecting to Solve360 API
import base64
import httplib
import logging
import string
try:
import simplejson as json
except ImportError:
import json
class settings:
@amites
amites / qsolve360
Created December 23, 2011 00:21
Simple method for connecting to Solve360 API
import base64
import httplib
import logging
import string
try:
import simplejson as json
except ImportError:
import json
class settings:
@amites
amites / clear_django_sessions.py
Created February 16, 2011 01:03
Simple script to clear database sessions in a django project.
import MySQLdb
host = 'localhost'
user = 'USER'
passwd = 'PASSWORD'
database = raw_input('Enter database name:')
conn = MySQLdb.connect (host=host, user=user, passwd=passwd, db=database)