Skip to content

Instantly share code, notes, and snippets.

View glesica's full-sized avatar

George Lesica glesica

View GitHub Profile
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
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
@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');
}
};
@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() {
/*
celebrity.c
Author: George Lesica
Description: An implementation of the celebrity
graph algorithm.
*/
#include <stdlib.h>
#include <stdio.h>
@glesica
glesica / install.sh
Created April 4, 2012 21:10
A script for linking dot files into a home directory.
#!/bin/bash
# install.sh
# Author: George Lesica <glesica@gmail.com>
# Description: Deploy script for my dotfiles repo.
# License: Public Domain (where it exists), any OSI-approved
# license elsewhere.
#
# Configuration
/*
shotgun.c
Author: George Lesica <glesica@gmail.com>
Description: An ANSI C implementation of the shotgun sorting algorithm.
*/
#include <stdlib.h>
/* Private utility functions. */
@glesica
glesica / subsequence.py
Created April 28, 2012 01:54
Function to find a subsequence with the largest sum from a list.
"""
Function to find the contiguous subsequence in a
list that has the greatest sum.
"""
def max_subsequence(L):
"""
Implements a linear time algorithm.
>>> max_subsequence([1,2,3,4,5])
>>> a = re.compile(r'^[0-9_]+|\W|[_]+$')
>>> a.findall('__hello world')
['__', ' ']
>>> a.sub('', '__username@gmail.com_table name hello')
'usernamegmailcom_tablenamehello'
>>> a.sub('', 'a')
'a'
>>> a.sub('', '_')
''
>>> a.sub('', '0')
# In views.py
import flask
from flask import request, session, g
from datably import app, crypt, db
from datably import operations as ops
@app.route('/login', methods=('GET', 'POST'))
def login():
context = {}