Skip to content

Instantly share code, notes, and snippets.

View flavioespinoza's full-sized avatar
😎

Flavio Espinoza flavioespinoza

😎
View GitHub Profile

Keybase proof

I hereby claim:

  • I am flavioespinoza on github.
  • I am flavioespinoza (https://keybase.io/flavioespinoza) on keybase.
  • I have a public key ASBKDaHpFFevPWKGy02d_aXuckg7e5X90k8q4fC9wCQ5uAo

To claim this, I am signing this object:

@flavioespinoza
flavioespinoza / cloudSettings
Last active February 23, 2020 22:50
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-02-10T18:33:23.976Z","extensionVersion":"v3.4.3"}
@flavioespinoza
flavioespinoza / cloudSettings
Created October 29, 2019 05:50
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-10-29T05:50:52.835Z","extensionVersion":"v3.4.3"}

Show JSON with Comments

Render JSON with comments in Github by changing code block language definition from json to jsonc


change this:

@flavioespinoza
flavioespinoza / Types_Integer.ts
Created February 21, 2019 15:56
TypeScript Integer Types
export type Int = number & { __int__: void }
export const roundToInt = (num: number): Int => Math.round(num) as Int
export const toInt = (value: string): Int => {
return Number.parseInt(value) as Int
}
export const checkIsInt = (num: number): num is Int => num % 1 === 0
@flavioespinoza
flavioespinoza / socket_orderbook.js
Created November 10, 2018 06:56 — forked from hitbtc-com/socket_orderbook.js
Socket API example with orderbook
if (typeof WebSocket !== 'function') {
// for node.js install ws package
WebSocket = require('ws');
}
const logger = {
debug: (...arg) => {
// console.log((new Date).toISOString(), 'DEBUG', ...arg)
},
info: (...arg) => {
@flavioespinoza
flavioespinoza / async-await.js
Created October 26, 2018 18:40 — forked from wesbos/async-await.js
Simple Async/Await Example
// 🔥 Node 7.6 has async/await! Here is a quick run down on how async/await works
const axios = require('axios'); // promised based requests - like fetch()
function getCoffee() {
return new Promise(resolve => {
setTimeout(() => resolve('☕'), 2000); // it takes 2 seconds to make coffee
});
}
@flavioespinoza
flavioespinoza / async-foreach.js
Last active October 24, 2018 05:48 — forked from Atinux/async-foreach.js
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
@flavioespinoza
flavioespinoza / load-balancer.js
Created September 15, 2018 06:29 — forked from Zaggen/load-balancer.js
Node.js load balancer with
/*
* Author: Zaggen - 2017
* version: 0.1
* github: https://github.com/Zaggen
* Free to use and modify
* */
const httpProxy = require('http-proxy')
const http = require('http')
const proxy = httpProxy.createProxyServer({})