Skip to content

Instantly share code, notes, and snippets.

View joseluisq's full-sized avatar

Jose Quintana joseluisq

View GitHub Profile
@joseluisq
joseluisq / docker-swarm-ports.md
Created March 6, 2019 21:47 — forked from BretFisher/docker-swarm-ports.md
Docker Swarm Port Requirements, both Swarm Mode 1.12+ and Swarm Classic, plus AWS Security Group Style Tables

Docker Swarm Mode Ports

Starting with 1.12 in July 2016, Docker Swarm Mode is a built-in solution with built-in key/value store. Easier to get started, and fewer ports to configure.

Inbound Traffic for Swarm Management

  • TCP port 2377 for cluster management & raft sync communications
  • TCP and UDP port 7946 for "control plane" gossip discovery communication between all nodes
  • UDP port 4789 for "data plane" VXLAN overlay network traffic
  • IP Protocol 50 (ESP) if you plan on using overlay network with the encryption option

AWS Security Group Example

#!/bin/bash
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v
# remove unused images:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' | xargs -r docker rmi
# remove unused volumes:
find '/var/lib/docker/volumes/' -mindepth 1 -maxdepth 1 -type d | grep -vFf <(
@joseluisq
joseluisq / linux_production_server_setup.md
Created January 29, 2019 06:50 — forked from leommoore/linux_production_server_setup.md
Linux - Production Server Setup

#Linux - Production Server Setup The principle of running a server in production is to run only what is needed. This keeps the server load to a minimum and reduces the security footprint.

See also http://plusbryan.com/my-first-5-minutes-on-a-server-or-essential-security-for-linux-servers

##Setup the Domain Name (DNS) Point the dns address at the ip address of your server. If the server is rented you should already have a static ip address. If the machine is on your local network you may have to sudo nano /etc/network/interfaces to edit the ip address file. Your setup should be like:

iface eth0 inet static
BLACK => "\033[30m",
RED => "\033[31m",
GREEN => "\033[32m",
YELLOW => "\033[33m",
BLUE => "\033[34m",
PURPLE => "\033[35m",
CYAN => "\033[36m",
WHITE => "\033[37m",
# background color
@joseluisq
joseluisq / iTerm2.md
Created November 9, 2018 14:18 — forked from soifou/iTerm2.md
iTerm2 Shortcuts

iTerm2 Shortcuts

Tab navigation

  • open new tab: Cmd + t
  • next tab: Cmd + Shift + ]
  • previous tab: Cmd + Shift + [

Pane navigation

@joseluisq
joseluisq / js-micro.js
Created September 17, 2018 21:40 — forked from yuval-a/js-micro.js
Javascript micro-optimizations
// Array literal (= []) is faster than Array constructor (new Array())
// http://jsperf.com/new-array-vs-literal/15
var array = [];
// Object literal (={}) is faster than Object constructor (new Object())
// http://jsperf.com/new-array-vs-literal/26
var obj = {};
// property === undefined is faster than hasOwnProperty(property)
// Note: don't use this in cases where 'undefined' is a possible value for your properties
var Benchmark = require('benchmark');
var expect = require('expect');
var suite = new Benchmark.Suite;
var testArray = [1,2,3,4,5,6,7,8,9,10,11,12,13];
var resultat = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26];
suite
.add('forHoley', () => forHoley(testArray))
.add('forPush', () => forPush(testArray))
@joseluisq
joseluisq / generators-vs-asyncawait-vs-native-promises.js
Last active April 26, 2021 11:52 — forked from netroy/generators-vs-asyncawait-vs-native-promises.js
Native Promises vs Generators vs Async/Await Performance vs Bluebird Promises
const Benchmark = require('benchmark')
const co = require('co')
const bluebird = require('bluebird')
const suite = new Benchmark.Suite
suite
.add('co generators', {
defer: true,
fn: deferred => {
@joseluisq
joseluisq / footgun.md
Created July 4, 2018 08:52 — forked from Rich-Harris/footgun.md
Top-level `await` is a footgun
@joseluisq
joseluisq / nano-shorts.md
Last active June 18, 2018 14:33 — forked from franz-josef-kaiser/nano-shorts.md
nano useful keyboard shortcuts

^ = Ctrl key M = Alt key

^G      (F1)            Display this help text
^X      (F2)            Close the current file buffer / Exit from nano
^O      (F3)            Write the current file to disk
^J      (F4)            Justify the current paragraph

^R      (F5)            Insert another file into the current one