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 / db_backup.sh
Created July 15, 2019 07:41 — forked from NARKOZ/db_backup.sh
MySQL backup shell script
#!/bin/bash
# Shell script to backup MySQL database
# Set these variables
MyUSER="" # DB_USERNAME
MyPASS="" # DB_PASSWORD
MyHOST="" # DB_HOSTNAME
# Backup Dest directory
DEST="" # /home/username/backups/DB
@lon-io
lon-io / resource.test.ts
Created May 25, 2021 11:31
GraphQL E2E Testing with Supertest
import request from "supertest";
import { GET_RESOURCE } from "./queries/resource";
import startTestServer from "./setup";
import { Await } from "src/types/global";
describe("Queries", () => {
let config: Await<ReturnType<typeof startTestServer>>;
beforeAll(async () => {
config = await startTestServer();
@lon-io
lon-io / lazy-image.js
Created June 17, 2019 14:58 — forked from ianmcnally/lazy-image.js
Lazy image loading
//@flow
import React, { Component } from 'react'
import type { ElementRef } from 'react'
type Props = { src: string, alt: string }
type State = { source?: string }
export default class LazyImage extends Component<Props, State> {
state = {}
@lon-io
lon-io / mongodb-s3-backup.sh
Created May 17, 2019 22:05 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@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,
@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 / 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 / .gitignore
Created September 16, 2018 02:26 — forked from jbergler/.gitignore
Acestream on Mac
.vagrant