Skip to content

Instantly share code, notes, and snippets.

View oanhnn's full-sized avatar

Oanh Nguyen oanhnn

View GitHub Profile
themsaid / AppServiceProvider.php
Created January 26, 2020 16:24
Re-encryption after APP_KEY rotation
namespace App\Providers;
use App\Encrypter;
use Illuminate\Support\Str;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
oanhnn /
Last active March 27, 2019 09:05
LEMP provider scripts
#!/bin/bash -ex
addgroup dev
adduser --disabled-password --ingroup dev $SSHUSER
usermod -aG sudo $SSHUSER
mkdir -p /home/$SSHUSER/.ssh
rsperl / Makefile #snippet
Last active April 17, 2024 23:02
self-documenting makefile with colors
# to see all colors, run
# bash -c 'for c in {0..255}; do tput setaf $c; tput setaf $c | cat -v; echo =$c; done'
# the first 15 entries are the 8-bit colors
# define standard colors
ifneq (,$(findstring xterm,${TERM}))
BLACK := $(shell tput -Txterm setaf 0)
RED := $(shell tput -Txterm setaf 1)
calebporzio / PreviewOfUpcomingPackage.php
Last active April 16, 2024 06:26
A model trait that allows child models to use parent table names and relationship keys.
namespace App\Abilities;
use Illuminate\Support\Str;
use ReflectionClass;
* Note: This is a preview of an upcoming package from Tighten.
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<title>Subscriptions -</title>
<outline text="PHP" title="PHP">
<outline htmlUrl="" title="" xmlUrl="" type="rss" text=""/>
<outline htmlUrl="" title="" xmlUrl="" type="rss" text=""/>
<outline title="" xmlUrl="" type="rss" text=""/>
dylanscott /
Last active March 12, 2024 08:36
Travis Update to Docker 1.13
#!/usr/bin/env bash
set -euo pipefail
sudo sh -c 'echo "deb ubuntu-$(lsb_release -cs) main" > /etc/apt/sources.list.d/docker.list'
curl -fsSL | sudo apt-key add -
sudo apt-key fingerprint 58118E89F3A912897C070ADBF76221572C52609D
sudo apt-get update
sudo apt-get -y install "docker-engine=1.13.1-0~ubuntu-$(lsb_release -cs)"
santoshachari / Laravel PHP7 LEMP
Last active February 20, 2024 10:00
Laravel 5.x on Ubuntu 16.x, PHP 7.x, Nginx 1.9.x

#Steps to install latest Laravel, LEMP on AWS Ubuntu 16.4 version. This tutorial is the improvised verision of this tutorial on Digitalocean based on my experience.

Install PHP 7 on Ubuntu

Run the following commands in sequence.

sudo apt-get install -y language-pack-en-base
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install zip unzip
mathewdgardner /
Created March 1, 2016 02:55
Save / load compressed docker images
# Save docker images
ds() {
docker images | \
cut -d ' ' -f 1 | \
tail -n +2 | \
xargs -t -n 1 -I {} -P 4 \
sh -c 'docker save {} | bzip2 > $(echo "{}" | sed "s/^.*\///").tar.bz2'
oanhnn /
Last active July 22, 2024 13:33
Using multiple github accounts with ssh keys


I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).


Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
leroy / Gulpfile.js
Created November 21, 2015 13:41
My Phaser gulp workplace
var gulp = require('gulp');
var gutil = require('gulp-util');
var source = require('vinyl-source-stream');
var buffer = require('gulp-buffer');
var babelify = require('babelify');
var browserify = require('browserify');
var browserSync = require('browser-sync');
var ROOT_PATH = "."
var PHASER_PATH = ROOT_PATH + '/node_modules/phaser/build/';