Skip to content

Instantly share code, notes, and snippets.

Amal Antony amalantony

Block or report user

Report or block amalantony

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:30345112dad8a96b8ecd90cd8a61b292
{
"components":{
"gps":{
"rule21":{
"filters":{
"message_type":"gll"
},
"outputs":{
"latitude":"data.split(\",\")[1]",
"longitude":"data.split(\",\")[2]"
View gist:2318816df78053694c130ebd9256dee5
{
"components":{
"gps":{
"rule2":{
"filters":{
"message_type":"gll"
},
"latitude":"data.split(\",\")[1]",
"longitude":"data.split(\",\")[2]"
View selectors.js
import { createSelector } from "reselect";
const getItems = state => state.products.get("items");
export const getRenderableItems = createSelector([getItems], items => {
return items;
});
View video-stream.js
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);
View json.clj
(ns anthology.json
(:require [clojure.string :as str]))
(def escape-characters
{\return "\\r"
\newline "\\n"
\tab "\\t"
\\ "\\\\"
\" "\\\""})
View html-xml.clj
(ns anthology.xhtml
"XML/HTML emitter"
(:require [clojure.string :as str]))
(defn- yoke [& xs] (apply str (flatten xs)))
(def escape-characters
{\" """
\' "'"
\& "&"
View eventemitter.js
/*
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
@amalantony
amalantony / bind.js
Created Feb 12, 2017
Function.prototype.bind implementation.
View bind.js
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)))
}
}
View exponentialBackoff.js
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 {
View latency.txt
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
You can’t perform that action at this time.