Skip to content

Instantly share code, notes, and snippets.

View jzerbe's full-sized avatar

Jason Zerbe jzerbe

View GitHub Profile
@jzerbe
jzerbe / login.html
Created November 16, 2012 04:16
Spring Security login form with HTML5 boilerplate
<!doctype html>
<!--
/*
* Jason Zerbe
* Copyright 2012
* Build-Id: EMPTY
*
* any comments before doctype will set IE9 to quirks mode
*/
-->
@jzerbe
jzerbe / createCorsRequest.js
Created January 17, 2013 02:54
create a Cross Origin Resource Sharing enabled request
function createCorsRequest(method, url) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined") {
xhr = new XDomainRequest();
xhr.open(method, url);
} else {
xhr = null;
}
@jzerbe
jzerbe / postCorsRequest.js
Created January 17, 2013 02:59
use a previously initialized CORS XHR object to POST a JSON payload
function postCorsRequest(theUrl, theJsonObj, theOnLoadCallback, theErrorCallback) {
var aJsonStr = JSON.stringify(theJsonObj);
var aRequest = createCorsRequest("post", theUrl);
if (aRequest) {
aRequest.onload = theOnLoadCallback;
aRequest.onerror = theErrorCallback;
aRequest.send(aJsonStr);
}
@jzerbe
jzerbe / selection.py
Last active August 29, 2015 14:05
PolyModel for ever-more-specific selection information instead of a sparse data model
from google.appengine.ext import ndb
from google.appengine.ext.ndb import polymodel
class SelectionBinder(polymodel.PolyModel):
"""
Base class for selecting content.
https://developers.google.com/appengine/docs/python/ndb/polymodelclass
All selections are at the binder level or more specific.
"""
@jzerbe
jzerbe / migration.py
Last active August 29, 2015 14:14
alter PolyModel inheritance tree
from logging import debug as log_debug
from google.appengine.ext import deferred
from google.appengine.ext import ndb
from model2 import Child # this works for query purposes!
# deserialize bigtable data into object will yield
# just GrandParent fields prior to migration running
BATCH_SIZE = 20
@jzerbe
jzerbe / karma.conf.js
Created March 22, 2015 17:03
karma and mocked backend server configurations
module.exports = function(config) {
config.set({
browsers: ["PhantomJS"],
coverageReporter: {
dir: 'report/coverage/',
reporters: [
{type: 'html', subdir: 'html'},
{type: 'text'}
]
},
@jzerbe
jzerbe / gulpfile.js
Created March 22, 2015 17:18
gulpfile.js used in conjunction with wGulp
// Initialize and use dependencies from "npm install"
var customizedOptions = {
languages: ['javascript', 'typescript'],
path: {
docs: './report/docs/'
},
taskTree: {
'karma': {
include: ['express_start']
},
@jzerbe
jzerbe / CoolThing.spec.ts
Created March 22, 2015 17:30
async Jasmine spec file example in typescript
/// <reference path="../../api/jasmine/jasmine.d.ts" />
/// <reference path="../../src/Task/CoolThing.ts" />
describe("CoolThingTest", function() {
var RESOURCE_ID:string = 'agdiaWctc2t5ch4LEhFTZWxlY3Rpb25SZXNvdXJjZRiAgICAgICgCgw';
beforeEach(function(done) {
this.testTask = new Task.CoolThing(RESOURCE_ID);
expect(this.testTask.run()).toBe(true);
@jzerbe
jzerbe / usbmount.conf
Created April 22, 2015 00:52
steambox usbmount config
# Configuration file for the usbmount package, which mounts removable
# storage devices when they are plugged in and unmounts them when they
# are removed.
# Change to zero to disable usbmount
ENABLED=1
# Mountpoints: These directories are eligible as mointpoints for
# removable storage devices. A newly plugged in device is mounted on
# the first directory in this list that exists and on which nothing is