Skip to content

Instantly share code, notes, and snippets.

David Giese johndgiese

Block or report user

Report or block johndgiese

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@johndgiese
johndgiese / apploi-test-script.js
Last active Dec 14, 2015
A silly test script for testing Apploi's angular script loader.
@johndgiese
johndgiese / weird.py
Created Apr 4, 2015
Weird stuff about python
View weird.py
a = 10
b = 10
print(a is b)
a = 10000000
b = 10000000
print(a is b)
def func(a):
@johndgiese
johndgiese / cards.py
Created Mar 31, 2015
Analysis of Card Game My Younger Brother Plays
View cards.py
"""
The card game we are analyzing plays as follows:
1. Shuffle a deck of 52 playing cards
2. Player is dealt N cards into the "face down pile"
3. Turn over a card and place it in the "face up pile":
- if it is an ace, deal 4 cards from the deck to the "face down pile"
- if it is a king deal 3
- if it is a queen deal 2
- if it is a jack deal 1
@johndgiese
johndgiese / circular_buffer.lua
Last active Jul 25, 2018
Circular Buffer in Lua
View circular_buffer.lua
-- circular buffer factory for lua
local function rotate_indice(i, n)
return ((i - 1) % n) + 1
end
local circular_buffer = {}
local function circular_buffer:filled()
@johndgiese
johndgiese / transaction.js
Last active Aug 29, 2015
Group-level transactional support in javascript using promises.
View transaction.js
Q = require('Q');
/**
* Store a promise for each `group` of function calls; the existence of a
* promise for a given key indicates a lock on that group, and subsequent
* calls in that group are delayed until that promise is resolved. After the
* last call is complete, the lock (i.e. key) is cleared.
*/
var groupQueues = exports._groupQueus = {};
@johndgiese
johndgiese / winstonConfig.js
Last active May 6, 2019
Make node's winston logger print stack traces
View winstonConfig.js
// Extend a winston by making it expand errors when passed in as the
// second argument (the first argument is the log level).
function expandErrors(logger) {
var oldLogFunc = logger.log;
logger.log = function() {
var args = Array.prototype.slice.call(arguments, 0);
if (args.length >= 2 && args[1] instanceof Error) {
args[1] = args[1].stack;
}
return oldLogFunc.apply(this, args);
You can’t perform that action at this time.