Skip to content

Instantly share code, notes, and snippets.

View trevorpao's full-sized avatar
🏠
Working from home

Trevor Pao trevorpao

🏠
Working from home
  • sense-info
  • Taipei
View GitHub Profile
@trevorpao
trevorpao / script-template.sh
Created February 9, 2023 07:53 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@trevorpao
trevorpao / my.cnf
Created September 5, 2022 09:41 — forked from fevangelou/my.cnf
Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers)
# === Optimized my.cnf configuration for MySQL/MariaDB (on Ubuntu, CentOS, Almalinux etc. servers) ===
#
# by Fotis Evangelou, developer of Engintron (engintron.com)
#
# ~ Updated December 2021 ~
#
#
# The settings provided below are a starting point for a 8-16 GB RAM server with 4-8 CPU cores.
# If you have different resources available you should adjust accordingly to save CPU, RAM & disk I/O usage.
#
@trevorpao
trevorpao / Vue3.md
Created October 2, 2021 05:45 — forked from harshadsatra/Vue3.md
Vue3 related lists
@trevorpao
trevorpao / sql-splitter.md
Created January 9, 2020 15:02 — forked from asika32764/sql-splitter.md
PHP - BIG SQL File Splitter as Iterator

SQL Splitter as Iterator

This is a class that can split BIG SQL file or string as iterator so that can help us save memory when importing SQL to database.

Composer version see here: https://github.com/asika32764/sql-splitter

Usage

$it = SqlSplitter::splitFromFile(__DIR__ . '/path/to/db.sql');
@trevorpao
trevorpao / webstoemp-gulpfile.js
Created October 18, 2019 12:21 — forked from jeromecoupe/webstoemp-gulpfile.js
Gulp 4 sample gulpfile.js. For a full explanation, have a look at https://www.webstoemp.com/blog/switching-to-gulp4/
"use strict";
// Load plugins
const autoprefixer = require("autoprefixer");
const browsersync = require("browser-sync").create();
const cp = require("child_process");
const cssnano = require("cssnano");
const del = require("del");
const eslint = require("gulp-eslint");
const gulp = require("gulp");
@trevorpao
trevorpao / jquery.ajax-queue.js
Created December 28, 2018 02:24 — forked from fatihacet/jquery.ajax-queue.js
Simple and easy jQuery AJAX queue implementation trying - this is draft version -
$.ajaxQueue = [];
var que = $.ajaxQueue;
$.ajaxSetup({
beforeSend: function(){
if (this.queue) {
que.push(this);
}
else {
return true;
#!/bin/sh
# Tested on Amazon Linux 2017 (and by extension RHEL and Fedora machines).
# First install neovim
wget https://gist.github.com/Khalian/ebd345b418b6f42a0359b4c89961af4c/raw/a69a496caf247d40535bc194fa2f08923c63d072/install_neovim_to_amazonlinux.sh
sh install_neovim_to_amazonlinux.sh
# Then symlink vim configs to neovim.
mkdir ~/.config
@trevorpao
trevorpao / configure-vim.sh
Created August 1, 2018 23:55 — forked from evokateur/configure-vim.sh
script with the things I do to make vim the way I like it
#!/bin/bash
mkdir -p ~/.vim/autoload ~/.vim/bundle && curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
if [ ! -d ~/.vim/bundle/nerdtree ]; then
git clone https://github.com/scrooloose/nerdtree.git ~/.vim/bundle/nerdtree
fi
touch proper.vimrc
@trevorpao
trevorpao / php_upgrade_to_71.sh
Created September 16, 2017 11:41 — forked from pixeline/php_upgrade_to_71.sh
Update Mac Os X's php version to php 7.1 using homebrew. Includes curl and mcrypt
# 1. Install brew --> http://brew.sh/
# 2. run the following commands in your Terminal
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install --with-openssl curl
brew install --with-homebrew-curl --with-apache php71
brew install php71-mcrypt php71-imagick
# 3. Follow these instructions to make Apache and php-cli use the newer php executable and make the change persist after reboot.
brew info php71
@trevorpao
trevorpao / app.js
Created November 17, 2016 01:44 — forked from xeoncross/app.js
Simple, auto data-binding in pure Javascript
//https://gist.github.com/mudge/5830382
//(function(window) {
/* Polyfill EventEmitter. */
var EventEmitter = function () {
this.events = {};
};
EventEmitter.prototype.on = function (event, listener) {
if (typeof this.events[event] !== 'object') {