🏳️🌈
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
function parseUrl(uri) { | |
// @source http://jsperf.com/url-parsing/34 | |
var matches = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/.exec(uri); | |
return { | |
href: uri || '', | |
host: matches[10] || '', | |
hash: matches[17] || '', | |
port: matches[12] || '', | |
origin: (matches[4] || '') + (matches[5] || '') + (matches[10] || ''), | |
search: matches[16] || '', |
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
function stacktrace() { | |
var stack; | |
function trace(fn) { | |
return (typeof fn !== 'function') | |
? [] | |
: trace(fn.caller).concat([fn.toString().split('(')[0].substring(9)]); | |
} | |
try { |
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
/** | |
* @url http://stackoverflow.com/questions/1855884/determine-font-color-based-on-background-color | |
* @url http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color | |
**/ | |
function perceptiveLuminance(color) { | |
return 1 - (0.299 * color.r + 0.587 * color.g + 0.114 * color.b) / 255 | |
} | |
function getFontColor(backgroundColor) { | |
if (perceptiveLuminance(backgroundColor) < 0.5) { |
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
const http = require('http') | |
const path = require('path') | |
const url = require('url') | |
const fs = require('fs') | |
const port = 8080 | |
const mimeTypes = { | |
'.html': 'text/html', | |
'.js': 'application/javascript', | |
'.css': 'text/css', |
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
/* usage example */ | |
console.log( | |
mergeSort( | |
[1, 8, 6, 8, 6, 4, 2, 10, 89, 5456, 55], | |
(a, b) => { | |
if (a > b) { | |
return -1 | |
} else if (a < b) { | |
return 1 | |
} |
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
declare module '@google-cloud/pubsub' { | |
import stream from 'stream' | |
import events from 'events' | |
interface ConfigurationObject extends Object { | |
projectId?: string | |
keyFilename?: string | |
email?: string | |
credentials?: CredentialsObject | |
autoRetry?: boolean |
OlderNewer