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
{ | |
"components":{ | |
"gps":{ | |
"rule21":{ | |
"filters":{ | |
"message_type":"gll" | |
}, | |
"outputs":{ | |
"latitude":"data.split(\",\")[1]", | |
"longitude":"data.split(\",\")[2]" |
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
{ | |
"components":{ | |
"gps":{ | |
"rule2":{ | |
"filters":{ | |
"message_type":"gll" | |
}, | |
"latitude":"data.split(\",\")[1]", | |
"longitude":"data.split(\",\")[2]" |
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
import { createSelector } from "reselect"; | |
const getItems = state => state.products.get("items"); | |
export const getRenderableItems = createSelector([getItems], items => { | |
return items; | |
}); |
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
app.get('/stream', (req, res) => { | |
const pathToVideo = "/path/to/video"; | |
fs.stat(pathToVideo, function(err, stats) { | |
if (err) { | |
if (err.code === 'ENOENT') { | |
// 404 Error if file not found | |
console.log('File not found!'); | |
return res.sendStatus(404); | |
} | |
res.end(err); |
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
(ns anthology.json | |
(:require [clojure.string :as str])) | |
(def escape-characters | |
{\return "\\r" | |
\newline "\\n" | |
\tab "\\t" | |
\\ "\\\\" | |
\" "\\\""}) |
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
(ns anthology.xhtml | |
"XML/HTML emitter" | |
(:require [clojure.string :as str])) | |
(defn- yoke [& xs] (apply str (flatten xs))) | |
(def escape-characters | |
{\" """ | |
\' "'" | |
\& "&" |
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
/* | |
Create an eventEmitter, which has methods "on" and "emit" with the following function signatures. | |
*/ | |
var EventEmitter = { | |
handlers: {}, /* store a list of handler functions against each event */ | |
/** | |
* @param {String} eventName | |
* @param {Function} callback |
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.prototype.bind = function() { | |
var args = Array.prototype.slice.call(arguments); | |
var context = args.shift(); | |
var fn = this; | |
return function() { | |
fn.apply(context, args.concat(Array.prototype.slice.call(arguments))) | |
} | |
} |
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 exponentialBackoff(url, retries, delay, callback) { | |
const success = ping(url); | |
if (success) { | |
callback(result); // successfull ping | |
} else { | |
if (retries > 0) { | |
setTimeOut(function() { | |
exponentialBackoff(url, --retries, delay * 2, callback); | |
}, delay); | |
} else { |
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
Latency Comparison Numbers | |
-------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns | |
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms | |
Read 4K randomly from SSD* 150,000 ns 0.15 ms |