Skip to content

Instantly share code, notes, and snippets.

View lon-io's full-sized avatar

Excellence Ilesanmi lon-io

View GitHub Profile
@lon-io
lon-io / self-signed-ssl-certificate.md
Created August 8, 2018 15:23 — forked from clemlatz/self-signed-ssl-certificate.md
Setup a self-signed SSL certificate with Nginx (server and browser)

1. Configure server: Nginx

Create the certificate:

$ sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx-selfsigned.key -out /etc/ssl/certs/nginx-selfsigned.crt

Create a strong Diffie-Hellman group:

$ sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
@lon-io
lon-io / mysql-docker.sh
Created August 1, 2018 00:04 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
package main
import (
"fmt"
"github.com/julienschmidt/httprouter"
"log"
"net/http"
)
// The type of our middleware consists of the original handler we want to wrap and a message
@lon-io
lon-io / docker-cleanup-resources.md
Created July 8, 2018 10:51 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@lon-io
lon-io / debounce.js
Created July 3, 2018 17:41
A Javascript function to Debounce other functions
// Debounce function
let debounce = (func, delay) => {
let timeout;
return (...args) => {
// If this function is called again, and there's a timeout defined, clear it;
if (timeout) clearTimeout(timeout);
// Set a timeout to call the original function, after the `delay`
timeout = setTimeout(() => {
@lon-io
lon-io / gist:36d814a95e2d5c42716298a365249af8
Created July 1, 2018 01:19 — forked from doginthehat/gist:1890659
compare block helper for handlebars
// {{compare unicorns ponies operator="<"}}
// I knew it, unicorns are just low-quality ponies!
// {{/compare}}
//
// (defaults to == if operator omitted)
//
// {{equal unicorns ponies }}
// That's amazing, unicorns are actually undercover ponies
// {{/equal}}
// (from http://doginthehat.com.au/2012/02/comparison-block-helper-for-handlebars-templates/)
@lon-io
lon-io / 1_kubernetes_on_macOS.md
Created March 6, 2018 08:34 — forked from kevin-smets/1_kubernetes_on_macOS.md
Local Kubernetes setup on macOS with minikube on VirtualBox and local Docker registry

Requirements

Minikube requires that VT-x/AMD-v virtualization is enabled in BIOS. To check that this is enabled on OSX / macOS run:

sysctl -a | grep machdep.cpu.features | grep VMX

If there's output, you're good!

Prerequisites

// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@lon-io
lon-io / destructuring.js
Created August 6, 2017 19:54 — forked from mikaelbr/destructuring.js
Several demos and usages for ES6 destructuring. Runnable demos and slides about the same topic: http://git.mikaelb.net/presentations/bartjs/destructuring
// === Arrays
var [a, b] = [1, 2];
console.log(a, b);
//=> 1 2
// Use from functions, only select from pattern
var foo = () => [1, 2, 3];
@lon-io
lon-io / jsonkeystrip.js
Created June 18, 2017 18:55
Strip the quotes("") off the keys in a JSON Object
let jsonObj = {
"name": "Lon",
"email": "lon@lon.com"
};
console.log(JSON.stringify(jsonObj).replace(/(")(\w*)(")(:)/g, '$2$4'))