Skip to content

Instantly share code, notes, and snippets.

View glesica's full-sized avatar

George Lesica glesica

View GitHub Profile
@glesica
glesica / gist:1028630
Created June 16, 2011 03:38
Install virtualenvwrapper - .bashrc
# setup virtualenvwrapper
export WORKON_HOME=~/.envs
mkdir -p $WORKON_HOME
source /usr/local/bin/virtualenvwrapper.sh
* POST - create a new log item with the POSTed data. The response
will include a status_code, status_message and the ID of the
newly created log item (if one was successfully created).
Request must contain a valid bot key along with enough information
to construct a valid log item.
* DELETE - delete the given log item. Must include the item ID number
or enough information to uniquely identify the item (see GET
below).
@glesica
glesica / hn.py
Created June 21, 2011 01:39
hacker news phenny module
'''
Phenny module to make Phenny fetch the highest scoring HN article and post
it for discussion.
'''
import os, urllib, json
from datetime import datetime as dt
LOG_PATH = '.'
# Generated by iptables-save v1.4.4 on Fri Jun 18 01:22:38 2010
*filter
# WHAT THE FUCK DO THE NEXT THREE LINES DO?
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [27:2732]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
// Mutifunctional method to get and set values to a collection
// The value/s can optionally be executed if it's a function
access: function( elems, key, value, exec, fn, pass ) {
var length = elems.length;
// Setting many attributes
if ( typeof key === "object" ) {
for ( var k in key ) {
jQuery.access( elems, k, key[k], exec, fn, value );
}
attr: function( elem, name, value, pass ) {
var nType = elem.nodeType;
// don't get/set attributes on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return undefined;
}
if ( pass && name in jQuery.attrFn ) {
return jQuery( elem )[ name ]( value );
var forward = function($c) {
var t = window.setTimeout(function() {
if ($c.data('running')) {
goForward.call($c);
}
forward($c);
}, settings.delay);
}
forward($container);
@glesica
glesica / software.vbs
Created November 4, 2011 20:01
A VBScript to enumerate applications installed on a machine and output a tab-delimited CSV file, one for each machine. The idea is for this to be slightly less awful than all the similar scripts out there on the webz.
'*******************************************************************************
' software.vbs
' Create a list of software installed on one or more
' machines in TSV format.
'
' Usage: cscript.exe software.vbs [/path:<path>] [machine names]
'
' If <path> is given, the script will attempt to store logs
' in that location. It is treated as a relative path and must
' end in a backslash.
mysql> SELECT c.computer_name, a.application_name, a.application_version, i.audit_date FROM installations i INNER JOIN computers c ON i.computer_id=c.computer_id INNER JOIN applications a ON i.application_id=a.application_id WHERE c.computer_name="computer01" ORDER BY c.computer_name, a.application_name, i.audit_date;
+---------------+-----------------------+---------------------+------------+
| computer_name | application_name | application_version | audit_date |
+---------------+-----------------------+---------------------+------------+
| computer01 | Adobe Acrobat Reader | 8.1.4 | 2011-11-09 |
| computer01 | Adobe Acrobat Reader | 8.1.4 | 2011-11-10 |
| computer01 | Microsoft Office 2007 | 12.0.1 | 2011-11-09 |
| computer01 | Microsoft Office 2007 | 12.0.1 | 2011-11-10 |
| computer01 | Mozilla Firefox | 5.0 | 2011-11-09 |
| computer01 | Mozilla Firefox | 7.0 | 2011-11-10 |
def post(self, computer_name):
computer = self._get_computer(computer_name)
data = json.loads(self.request.body)
for application in data['applications']:
result = self.database.query(
'''
INSERT INTO applications (
application_name,