Skip to content

Instantly share code, notes, and snippets.

Avatar
😎

Flavio Espinoza flavioespinoza

😎
View GitHub Profile
@flavioespinoza
flavioespinoza / cloudSettings
Last active Feb 23, 2020
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2020-02-10T18:33:23.976Z","extensionVersion":"v3.4.3"}
@flavioespinoza
flavioespinoza / cloudSettings
Created Oct 29, 2019
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2019-10-29T05:50:52.835Z","extensionVersion":"v3.4.3"}
View jsonc.md

Show JSON with Comments

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


change this:

View html5-contact-form.markdown
@flavioespinoza
flavioespinoza / Types_Integer.ts
Created Feb 21, 2019
TypeScript Integer Types
View Types_Integer.ts
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 Nov 10, 2018 — forked from hitbtc-com/socket_orderbook.js
Socket API example with orderbook
View socket_orderbook.js
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 Oct 26, 2018 — forked from wesbos/async-await.js
Simple Async/Await Example
View async-await.js
// 🔥 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 Oct 24, 2018 — forked from Atinux/async-foreach.js
JavaScript: async/await with forEach()
View async-foreach.js
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 Sep 15, 2018 — forked from Zaggen/load-balancer.js
Node.js load balancer with
View load-balancer.js
/*
* 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({})
@flavioespinoza
flavioespinoza / .gitconfig
Created Jul 28, 2018 — forked from johnpolacek/.gitconfig
My current .gitconfig aliases
View .gitconfig
[alias]
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
brD = branch -D
merged = branch --merged
dmerged = "git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
st = status