This file contains 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
['Knowledge', 'Hardwork', 'Attitude'].map(function (word) { | |
return { | |
word: word, | |
count: word.toUpperCase().split('').reduce(function (p, c) { | |
return p + (c.charCodeAt(0)-'A'.charCodeAt(0) + 1); | |
}, 0) | |
}; | |
}); |
This file contains 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
Number.prototype.mod = function(n) { | |
return ((this % n) + n) % n; | |
}; | |
function encode(string, generator, cycle=10, reverse=false) { | |
let sequence = generator(); | |
let start = ' '.charCodeAt(); | |
let end = '~'.charCodeAt(); | |
return Array.from(string).map((c, i) => { |
This file contains 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 request = require('request'); | |
const fs = require('fs'); | |
const intercomDrinks = require('intercom-drinks').default; | |
const radius = 100000; //in meters | |
const latitude = 53.3381985; | |
const longitude = -6.2592576; | |
const onlineSource = 'https://gist.githubusercontent.com/brianw/19896c50afa89ad4dec3/raw/6c11047887a03483c50017c1d451667fd62a53ca/gistfile1.txt'; | |
const offlineSource = 'input.jsonl'; |
This file contains 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 util = require('util'); | |
const Transform = require('stream').Transform; | |
const intercomDrinks = require('intercom-drinks').default; | |
function Stream() { | |
if (!(this instanceof Stream)) { | |
return new Stream(); | |
} | |
Transform.call(this, { | |
writableObjectMode: true |
This file contains 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
module.exports = function (fileInfo, api) { | |
const j = api.jscodeshift; | |
const isPromiseDelay = (nodePath) => { | |
const { object, property } = nodePath.node.callee; | |
return object && object.name === 'Promise' && property && property.name === 'delay'; | |
}; | |
const isRequire = (nodePath, name) => { |
This file contains 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
type A = {a: 'a'} | {b: 'b'}; | |
const c: A = { | |
a: 'a', | |
b: 'b' | |
}; | |
type C = typeof c; // === A | |
// Confused TS: I cannot access c.a nor c.b |
This file contains 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
-- Lua uses at least 8 bytes to represent a number | |
-- Base64 minimum processable unit is represented by four 6-bit chunks which is 24-bits => 3 bytes | |
-- Hence we can safely use bit operations on number type for multiplexing and extraction | |
-- Define function to extract 8-bit ASCII char from 24-bit base64 unit | |
local function extractChar(unit, idx) | |
-- Skip mask for first ASCII char since shifting will destroy other two parts | |
if idx == 2 then | |
local charCode = (unit) >> (8 * idx) |