Skip to content

Instantly share code, notes, and snippets.

View amites's full-sized avatar

Alvin Mites amites

View GitHub Profile
def Integer(obj):
if obj["min"] < obj["value"] < obj["max"]:
return True
else:
raise ValueError("value out of range")
min_tile_size = {"type": Integer,
"min": 10,
"max": 20,
"value": 15,
function control_zone() {
this.var_a = 'a';
this.var_b = 'b';
this.var_c = 'c';
this.do_stuff = function() {
// do stuff with variables
console.log('var_a: '+this.var_a);
console.log('var_b: '+this.var_b);
console.log('var_c: '+this.var_c);
@amites
amites / setup_TP-WN722NC.sh
Last active September 5, 2015 05:49
Bash script to setup a TL-WN722NC as an available wifi dongle onto a bbb.
#!/bin/bash
# install linux headers
wget https://raw.github.com/gkaindl/beaglebone-ubuntu-scripts/master/bb-get-rcn-kernel-source.sh
chmod +x bb-get-rcn-kernel-source.sh
sudo ./bb-get-rcn-kernel-source.sh
# download backports drivers
wget https://www.kernel.org/pub/linux/kernel/projects/backports/stable/v3.16/backports-3.16-1.tar.gz
tar xvfz backports-3.16-1.tar.gz
@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)
@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 / 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 / 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 / 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 / gimp-to-css.py
Created September 12, 2012 08:39
Convert Gimp Palette to SCSS vars
# coding: utf-8
import re
## quick hack to convert gimp color palettes into scss vars
## ended up getting rather complex when I started making it more dynamic
## may clean up in the future as proper functions with command line option
## title will be written as title_basetitle_sub[loop#]
## allows customization of title that could be extended into a config