This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ Deferred } = require 'promise.coffee' | |
class PromiseKeeper | |
constructor: (value=null) -> | |
def = new Deferred | |
def.resolve(value) | |
@promise = def.promise | |
@_data = {} | |
set: (name, setValue) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Promises | |
{ Deferred } = require 'promise.coffee' | |
fs = require 'fs' | |
emptyPromise = -> | |
def = new Deferred | |
def.resolve(undefined) | |
return def.promise |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; AutoHotkey Version: 1.x | |
; Author: Cole Lawrence | |
; Script Function: | |
; Use capslock as control key | |
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. | |
SetCapslockState AlwaysOff | |
Capslock::Ctrl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Helper function: compares objects | |
isEq = (a, b) -> | |
if a isnt b | |
if typeof a is 'object' and typeof b is 'object' and a? and b? | |
if Object.keys(a).length isnt Object.keys(b).length | |
return false | |
for ak, av of a | |
bv = b[ak] | |
if not isEq bv, av |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
randomString = (len)-> | |
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`~!@#$%^&*()_-+={[}]:;\"'|\\<,>.?/" | |
res = "" | |
res += chars[Math.random()*chars.length|0] for num in [0..len] | |
res |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript: var em, el, emI, ems = document.getElementsByTagName("em"); | |
document.head.appendChild(el = document.createElement("STYLE"), el.innerText="h3:target{background:yellowgreen}", el); | |
for (emI = 0; em=ems[emI], emI<ems.length; emI++){ | |
if (em!=null) { | |
var temp = em.innerHTML; var re=/([A-Z]{3})\s*(\d{3})/g; | |
em.innerHTML = temp.replace(re, function(match,dep,num){ | |
var temp = dep+num; | |
if (document.getElementById(temp)) { return temp.replace(re,"<a href='#$1$2'>$1 $2</a>")} | |
else { return dep+" "+num } | |
})}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tokenStore = { | |
store: {}, | |
lastExpirationRemoval: Date.now(), | |
EXPIRATION_REMOVAL_INTERVAL: 30 * 60 * 1000, // 30 minutes | |
EXPIRATION: 2 * 60 * 1000, // 2 minutes | |
getToken: function(token) { | |
var stored = this.store[token] | |
if (stored != null) | |
if (stored.expires < Date.now()) | |
throw Error("Token expired.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
formatString = (string, locals) -> | |
string.replace /{{([a-zA-Z\.]+)}}/g, (match, value) -> | |
values = value.split(".") | |
value = locals | |
while key = values.shift() | |
value = value[key] | |
String value | |
Say formatString "Hello {{user.name}}", {user:name:"Cole"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Name: Cole Lawrence | |
Date: April 13th, 2015 | |
Assignment: Asn6 | |
Platform/IDE: Windows 8/MVSCPP2010Express | |
Description: | |
Here we have written a LinkedDeque class that inherits a majority of its code from | |
a created Singly Linked List called SLinkedList. In addition, we have exceptions in | |
place that are written in an effort to conform to good programming practice. In | |
addition to this we also have NodeList which supports iterators using its nested |