Skip to content

Instantly share code, notes, and snippets.

View glesica's full-sized avatar

George Lesica glesica

View GitHub Profile
/*
celebrity.c
Author: George Lesica
Description: An implementation of the celebrity
graph algorithm.
*/
#include <stdlib.h>
#include <stdio.h>
@glesica
glesica / inherit.js
Created January 8, 2012 18:11
javascript inheritance question
// base class
function Animal() {
// constructor
}
Animal.prototype.makeNoise = function() {
// make noise
}
// first sub-class
function Dog() {
@glesica
glesica / gist:1449693
Created December 9, 2011 01:35
jquery plugin magic
$.fn.orderly = function(method, options) {
// Decide which method we're supposed to call and call it
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || ! method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist on jQuery.orderly');
}
};
SELECT
a.application_id,
a.application_name,
a.application_vendor,
a.application_version,
(SELECT COUNT(*) FROM installations i WHERE i.application_id=a.application_id) count
FROM
applications a
WHERE
1=1
ERROR:root:Uncaught exception POST /audit/computer01 (127.0.0.1)
HTTPRequest(protocol='http', host='localhost:8888', method='POST', uri='/audit/computer01', version='HTTP/1.1', remote_ip='127.0.0.1', body='{"date": "2011-11-11","applications":[{"name":"Adobe CS4", "vendor":"Adobe, Inc.", "version":"9.2.0"}]}', headers={'Host': 'localhost:8888', 'Content-Type': 'applications/json', 'Content-Length': '103', 'Accept': '*/*', 'User-Agent': 'curl/7.21.0 (x86_64-pc-linux-gnu) libcurl/7.21.0 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.15 libssh2/1.2.6'})
Traceback (most recent call last):
File "/home/george/Repos/auditr/envs/auditr/lib/python2.6/site-packages/tornado/web.py", line 954, in _execute
getattr(self, self.request.method.lower())(*args, **kwargs)
File "server.py", line 83, in post
application['version']
File "/home/george/Repos/auditr/envs/auditr/lib/python2.6/site-packages/tornado/database.py", line 111, in query
column_names = [d[0] for d in cursor.description]
TypeError: 'NoneType' object is
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,
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 |
@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.
var forward = function($c) {
var t = window.setTimeout(function() {
if ($c.data('running')) {
goForward.call($c);
}
forward($c);
}, settings.delay);
}
forward($container);
// 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 );
}