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 / 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

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 / 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
@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 / Node.js CORS
Created August 17, 2018 23:25 — forked from nilcolor/Node.js CORS
Node.js cross-origin POST. You should response for OPTIONS request first. Something like this.
if (req.method === 'OPTIONS') {
console.log('!OPTIONS');
var headers = {};
// IE8 does not allow domains to be specified, just the *
// headers["Access-Control-Allow-Origin"] = req.headers.origin;
headers["Access-Control-Allow-Origin"] = "*";
headers["Access-Control-Allow-Methods"] = "POST, GET, PUT, DELETE, OPTIONS";
headers["Access-Control-Allow-Credentials"] = false;
headers["Access-Control-Max-Age"] = '86400'; // 24 hours
headers["Access-Control-Allow-Headers"] = "X-Requested-With, X-HTTP-Method-Override, Content-Type, Accept";
@lon-io
lon-io / .gitignore
Created September 16, 2018 02:26 — forked from jbergler/.gitignore
Acestream on Mac
.vagrant
@lon-io
lon-io / README-Template.md
Created December 11, 2018 07:26 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@lon-io
lon-io / async-await-error-handling.js
Last active February 1, 2019 10:57
Async Await Error handling
const a = (cb) => {
cb()
.then((res) => console.log(res))
.catch(error => {
console.log('Error caught', error.message)
})
}
const b = async() => {
throw new Error('new error')
@lon-io
lon-io / cloudSettings
Last active April 18, 2019 09:30
Visual Studio Code Settings Sync Gist
{"lastUpload":"2019-03-25T05:11:44.124Z","extensionVersion":"v3.2.7"}
@lon-io
lon-io / image-onload.jsx
Created April 11, 2019 21:46 — forked from shuhei/image-onload.jsx
img.onload and unit test in React
import * as React from 'react';
import { mount } from 'enzyme';
import sinon from 'sinon';
function isImageLoaded(img: HTMLImageElement) {
return img.complete && img.naturalHeight > 0;
}
type Props = {
src: string,