Skip to content

Instantly share code, notes, and snippets.

View sukima's full-sized avatar

Devin Weaver sukima

View GitHub Profile
@sukima
sukima / latch.js
Last active September 5, 2016 16:48 — forked from nowelium/latch.js
CountdownLatch
var CountdownLatch = function (limit) {
this.limit = limit;
this.count = 0;
this.waitBlock = function () {};
};
CountdownLatch.prototype.async = function (fn, ctx) {
var _this = this;
fn.call(ctx, function () {
_this.count = _this.count + 1;
if(_this.limit <= _this.count){
#!/bin/bash
## Copyright (C) 2009 Przemyslaw Pawelczyk <[email protected]>
## License: GNU General Public License v2, v3
#
# Lockable script boilerplate
### HEADER ###
LOCKFILE="/var/lock/`basename $0`"
@sukima
sukima / .ctags
Last active August 29, 2015 14:13 — forked from kflu/.ctags
--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/(^|=[ \t])*class ([A-Za-z_][A-Za-z0-9_]+\.)*([A-Za-z_][A-Za-z0-9_]+)( extends .+)?$/\3/c,class/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?@?(([A-Za-z][A-Za-z0-9_.]*)+):.*[-=]>.*$/\3/m,method/
--regex-coffee=/^[ \t]*(module\.)?(exports\.)?(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=.*[-=]>.*$/\3/f,function/
--regex-coffee=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/v,variable/
--regex-coffee=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+)[ \t]*=[^->\n]*$/\1/f,field/
--regex-coffee=/^[ \t]*@(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/f,static field/
--regex-coffee=/^[ \t]*(([A-Za-z][A-Za-z0-9_.]*)+):[^->\n]*$/\1/f,field/
--regex-coffee=/((constructor|initialize):[ \t]*\()@(([A-Za-z][A-Za-z0-9_.]*)+)([ \t]*=[ \t]*[^,)]+)?/\3/f,field/
@sukima
sukima / disfocus.js
Last active December 21, 2015 19:29 — forked from charyorde/disfocus
function iAmAllDone() {
// Do something herebecause It's All Done!
}
function onContributionWizardAfterAddEntry(entries) {
for(var i = 0; i < entries.length; i++) {
parent.top.$j("#externalVideoID").val(entries[i].entryId);
}
// Trigger an event however the library event model handles event triggering.
class ReadlineLoop
constructor: ->
@rl = readline.createInterface
input: process.stdin
output: process.stdout
@rl.on("line" , @onLine)
.on("close", @onClose)
onLine: => # ...
onClose: => # ...
@sukima
sukima / README.md
Last active December 12, 2015 00:28 — forked from neoGeneva/gist:1309070

Super Simple Event Dispatcher

Use this to add events to your objects without needing any libaries.

Simple function can be imported or copy pasted. In your object constructor assign your event functions to the return value of the createCustomEvent().

Simple example:

@sukima
sukima / Router.js
Last active December 10, 2015 05:38 — forked from yorickvP/gist:2725801
A simple router class in JavaScript using callbacks (not events)
/**
* # Simple Router
* A JavaScript router class.
*
* #### Examples
* var appRouter, func,
* Router = require("Router");
*
* appRouter = new Router();
* appRouter.get("/", indexMethod);
// * document is the JavaScript document object
// * bind adds an event listener to the document object
// * pageinit is the event that document object should listen for
// * the anonymous function is the callback that getsw executed when the
// document recieves the pageinit event.
$(document).bind("pageinit", function(){
// Now the pageinit event was triggered
// again lets attach an event listener to the document element #listitem2
// This time the event to listen for is the swipeleft event
// The convinience function swipeleft is the same a s bind("swipeleft",...)
@sukima
sukima / gist:3933058
Created October 22, 2012 18:07 — forked from heath/gist:3932795
An attempt to avoid a long list of if statements
//all of this is within a pretty long method for handling key events
var groupChoices = {
65 : 'a', 66 : 'b', 67 : 'c',
68 : 'd', 69 : 'e', 70 : 'f',
71 : 'g', 72 : 'h', 73 : 'i',
74 : 'j', 75 : 'k', 96 : '0',
97 : '1', 98 : '2', 99 : '3',
100 : '4', 101 : '5', 102 : '6',
103 : '7', 104 : '8', 105 : '9'
@sukima
sukima / coffeescript_converter.rb
Created June 13, 2012 17:13 — forked from phaer/coffeescript_converter.rb
A trivial CoffeeScript.org -> Javascript plugin for OLDER OctoPress. Put this file in 'plugins/' and write a YAML header to your .coffee files (i.e. "---\nlayout:nil\n---\n")
module Jekyll
require 'coffee-script'
class CoffeeScriptConverter < Converter
safe true
priority :normal
def matches(ext)
ext =~ /coffee/i
end