Skip to content

Instantly share code, notes, and snippets.

View BlackVegetable's full-sized avatar

Devin Ekins BlackVegetable

View GitHub Profile
@BlackVegetable
BlackVegetable / collapsing_die.py
Last active February 9, 2017 20:05
A collapsing die simulator
import random
def collapse_die(dice_count, dice_size):
'''
Collapse on a 1, rerolling remaining dice.
All 1s => 0.
'''
# Error checking.
if dice_count < 1:
@BlackVegetable
BlackVegetable / odd_cleanup_bug.js
Created June 26, 2015 17:21
1) Keen IO "after each" hook: TypeError: '[object Object]' is not a function (evaluating 'this.traits({})')
it('should always refresh global properties with user traits if present', function() {
var id = 'Devon Higgins';
var traits = { trait: 'Pretty Neat', id: id };
analytics.user().userId = id;
analytics.user().traits = traits;
// Notice no identify() call is made here.
// This is to emulate a page reload which loses the global
// properties that identify() saves.
# This is module A
colton_salary = 900000
def print_hello():
print "hello"
class Employee:
def __init__(self):
self.salary = colton_salary - 5000
@BlackVegetable
BlackVegetable / nonsense.c
Created September 20, 2014 21:24
Optional description
;ghao;yhgd
@BlackVegetable
BlackVegetable / indent.py
Created September 20, 2014 21:06
An example of proper and improper indentation of if statements.
def returnOneOrTwo (self, value):
if value is 1:
return 1
if value is 2:
return 2
print "Oh no! I didn't handle this case!"
return 12 # Haha!
def badSyntax (self):
if self.hungry:
@BlackVegetable
BlackVegetable / noop.py
Created September 20, 2014 20:57
A trivial noop (no operation) function in Python
def noop (self):
if True:
pass
@BlackVegetable
BlackVegetable / gjs-driver.js
Created October 25, 2013 21:43
Incomplete test runner port of Jasmine from nodejs to gjs. Line 224 to 228 requires particular investigation as I am unsure of how to port that section at all. When run with the various referenced files in their proper locations, this attempts to run the tests found in ConsoleReporterSpec but all 14 tests fail. The stack trace grows longer with …
#!/usr/bin/gjs
imports.searchPath.unshift('lib/jasmine-core');
imports.searchPath.unshift('src');
imports.searchPath.unshift('src/core');
imports.searchPath.unshift('src/core/matchers')
imports.searchPath.unshift('src/consoleJ');
imports.searchPath.unshift('.');
/*