Skip to content

Instantly share code, notes, and snippets.

View flavioespinoza's full-sized avatar
😎

Flavio Espinoza flavioespinoza

😎
View GitHub Profile
@flavioespinoza
flavioespinoza / .gitconfig
Created July 28, 2018 12:21 — forked from johnpolacek/.gitconfig
My current .gitconfig aliases
[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
@flavioespinoza
flavioespinoza / index.html
Created July 1, 2018 22:16 — forked from RiseupDev/index.html
D3.js draw a polygon with mouse
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>D3 Drawing</title>
<script src="https://cdn.jsdelivr.net/d3js/3.5.9/d3.min.js"></script>
</head>
<body>
<h3>Draw a polygon :D</h3>
<script>
@flavioespinoza
flavioespinoza / nginx-socketio-ssl-reverse-proxy.conf
Last active June 30, 2018 00:47 — forked from gmanau/nginx-socketio-ssl-reverse-proxy.conf
How to setup nginx as nodejs/socket.io reverse proxy over SSL
upstream upstream-ubuntu {
server 127.0.0.1:8080;
}
upstream upstream-nodejs {
ip_hash;
server 127.0.0.1:6001;
server 127.0.0.1:6002;
server 127.0.0.1:6003;
server 127.0.0.1:6004;
@flavioespinoza
flavioespinoza / secure-websockets
Created June 26, 2018 17:52 — forked from casecode/secure-websockets
Basic Config for SSL with Secure Websockets using Nginx 1.6.0 + Puma + Thin
=========================
# /etc/nginx/nginx.conf
=========================
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;

Client/Server POST request example in pure Node.js

File server.js:

var http = require('http');
var querystring = require('querystring');

var server = http.createServer().listen(3000);

server.on('request', function (req, res) {
@flavioespinoza
flavioespinoza / es2015-reduce-find-includes.js
Created June 20, 2018 23:08
ES2015 Reduce, Find, Includes
"use strict";
var myArray = [{ "shop": "shop1", "item1": "my apple 1", "item2": "my carrot 1" }, { "shop": "shop1", "item1": "my apple 1", "item2": "my carrot 1" }, { "shop": "shop2", "item1": "my apple 0", "item2": "my carrot 0" }, { "shop": "shop2", "item1": "my apple 0", "item2": "my carrot 1" }];
var MyArrayDefinition = [{ "item": "my apple 0", "color": "red", "group": "fruit", "score": 0 }, { "item": "my carrot 1", "color": "orange", "group": "vegetable", "score": null }, { "item": "my apple 1", "color": "red", "group": "fruit", "score": 1 }, { "item": "my carrot 0", "color": "orange", "group": "vegetable", "score": 0 }];
var k = Object.keys;
var items = MyArrayDefinition.reduce(function (o, v) {
return o[v.item] = v, o;
}, {});
const express = require('express')
const app = express()
const port = process.env.PORT || 9001
const http = require('http')
const index = require('./routes/index')
const server = http.createServer(app)
const socketIo = require('socket.io')
const io = socketIo(server)
const BitGoJS = require('bitgo')
const log = require('ololog').configure({locate: false})
@flavioespinoza
flavioespinoza / PascalsTriangles.js
Created June 7, 2018 14:16 — forked from kgates-github/PascalsTriangles.js
Two ways to create a Pascal's Triangle in JavaScript.
var numTiers = 100,
triangle,
start,
stop;
/**
*
* First version uses recursion
*
*/
@flavioespinoza
flavioespinoza / WebsocketSample.js
Last active September 13, 2021 19:31
Bittres Websocket Node.js Authentication Example
/**
* Node.js example
* https://github.com/Bittrex/beta
*
* By Flavio Espinoza
*
* Expanding on example from Adrian Soluch
*
* prerequisites:
* npm i signalr-client crypto lodash ololog
@flavioespinoza
flavioespinoza / depth_chart.html
Last active April 21, 2023 14:00
D3 Market Depth Chart built from Order Book
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>d3 depth chart</title>
<script type="text/javascript" src="https://d3js.org/d3.v4.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/lodash@4.17.4/lodash.min.js"></script>
<style>