Skip to content

Instantly share code, notes, and snippets.

View tkissing's full-sized avatar

Timo Kissing tkissing

  • Orange County, CA
  • 07:33 (UTC -07:00)
View GitHub Profile
@tkissing
tkissing / LICENSE.txt
Created November 7, 2011 04:26 — forked from 140bytes/LICENSE.txt
JavaScript Luhn Checksum 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Timo Kissing http://kissing.name
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@tkissing
tkissing / LICENSE.txt
Created November 8, 2011 05:40 — forked from 140bytes/LICENSE.txt
getOffTheCamel - 140byt.es splitCamelCaseString in JavaScript
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Timo Kissing http://kissing.name
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@tkissing
tkissing / LICENSE.txt
Created November 8, 2011 07:45 — forked from 140bytes/LICENSE.txt
mstc - mustache style templating compressed to (less than) 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Timo Kissing http://kissing.name
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@tkissing
tkissing / LICENSE.txt
Created November 12, 2011 08:18 — forked from 140bytes/LICENSE.txt
MiniGame in 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@tkissing
tkissing / gist:8029250
Created December 18, 2013 20:19
Console script to count and list out globals on your page
/*jslint browser:true, eqeq:true, forin:true, sloppy: true*/
(function (window, document) {
var differences = {},
exceptions = ['addEventListener', 'document', 'location', 'navigator', 'window'],
globals = [],
ignoreList = (window.prompt('Ignore filter (comma sep)?', '$,jQuery,ko') || '').split(','),
iframe = document.createElement('iframe'),
i;
for (i in window) {
nslookup rtcgw.citrixonline.com
tracert rtcgw.citrixonline.com
@tkissing
tkissing / gist:5ff2aff41ff3c5740545
Created September 25, 2014 18:24
Promise.resolve issue(?)
function ithrow() {
throw Error("Can't do that");
}
p1 = new Promise(function(resolve) {
resolve(ithrow())
});
p1.then(console.log.bind(console, 'p1'), console.warn.bind(console, 'p1'));
@tkissing
tkissing / gist:da645abfa7e9fa3bc9ea
Created September 30, 2014 03:10
Chain mandatory and optional async operations
// Problem:
// - We have 2 operations that can and should run in parallel
// - Both operations may finish in arbitrary order
// - one operation is mandatory, the other is optional
// - the result promise is to be resolved with a merge of the intermediate ones, with optional overriding mandatory
// Question:
// Can this be done
// - in a more readable manner than the "result = new Promise..." code block
// - with less code than the "result = new Promise..." code block
@tkissing
tkissing / gist:dacc9e3e9dbbede84296
Last active August 29, 2015 14:07
serve-it - an easy-to-use local http(s) server

A global npm command serve-it that takes a "virtual url path" with an optional port and an optional path (defaulting to cwd). The command starts up an http server (optionally: https) and adds the required configuration to serve the files in that folder (recursively). If the server is already running, it just reconfigures the server at runtime.

Examples:

  • serve-it foo:8081 // serves current working directory at http://localhost:8081/foo
  • serve-it --save bar ./bar/src // serves ./bar/src at http://localhost:$PORT/bar with $PORT being default port from ~/.serve-it/config.json or 8080 if not configured; persists to ~/.serve-it/config.json

An optional --save adds the configuration to ~/.serve-it/config.json Anytime the runtime configuration changes, it is also written to ~/.serve-it/.runtime.json - allowing to restore the last configuration after a crash using a command like serve-it --restore

@tkissing
tkissing / gist:0a642811a783ad0e09be
Created January 7, 2015 18:14
$.Deferred vs new Promise vs Callbacks - be careful you are not rebuilding the hell
// consider the following code
function getInfoDef() {
var result = {something: 'static'};
var def = $.Deferred();
$.ajax('/some-url').then(function(data) {
result.also = data.dynamic;
def.resolve(result);
}).fail(def.reject.bind(def));