Skip to content

Instantly share code, notes, and snippets.

View pmkhoa's full-sized avatar

Khoa Pham pmkhoa

View GitHub Profile
@pmkhoa
pmkhoa / AsyncComponent.jsx
Last active December 5, 2017 07:11 — forked from lencioni/AsyncComponent.jsx
<AsyncComponent> at Airbnb used for Webpack code splitting
// Usage:
//
// function loader() {
// return new Promise((resolve) => {
// if (process.env.LAZY_LOAD) {
// require.ensure([], (require) => {
// resolve(require('./SomeComponent').default);
// });
// }
// });
@pmkhoa
pmkhoa / jquery.deparam.js
Created July 28, 2017 22:21 — forked from samny/jquery.deparam.js
jQuery.deparam - The oposite of jQuery param. Creates an object of query string parameters
/**
* jQuery.deparam - The oposite of jQuery param. Creates an object of query string parameters.
*
* Credits for the idea and Regex:
* http://stevenbenner.com/2010/03/javascript-regex-trick-parse-a-query-string-into-an-object/
*/
(function($){
$.deparam = $.deparam || function(uri){
if(uri === undefined){
uri = window.location.search;
@pmkhoa
pmkhoa / docker-destroy-all.sh
Created June 6, 2017 22:40 — forked from JeffBelback/docker-destroy-all.sh
Destroy all Docker Containers and Images
#!/bin/bash
# Stop all containers
docker stop $(docker ps -a -q)
# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)
@pmkhoa
pmkhoa / MySQL_macOS_Sierra.md
Last active April 3, 2017 05:08 — forked from nrollr/MySQL_macOS_Sierra.md
Install MySQL on Sierra using Homebrew

Install MySQL on macOS Sierra

This procedure explains how to install MySQL using Homebrew on macOS Sierra 10.12

Install Homebrew

  • Installing Homebrew is effortless, open Terminal and enter :
    $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Note: Homebrew will download and install Command Line Tools for Xcode 8.0 as part of the installation process.

Install MySQL

At this time of writing, Homebrew has MySQL version 5.7.15 as default formulae in its main repository :

@pmkhoa
pmkhoa / .vimrc
Created March 15, 2017 06:32 — forked from Deraen/.vimrc
Vimrc clojure parts
" Parts of my .vimrc which might be relevant to Clojure users.
" Src: https://raw.githubusercontent.com/Deraen/dotfiles/master/.vimrc
" NeoBundle is a Vim package manager
" Check https://github.com/Shougo/neobundle.vim for installation
" Autocomplete - https://github.com/Valloric/YouCompleteMe
NeoBundle 'Shougo/vimproc', {'build': {'unix': 'make'}}
NeoBundle 'Valloric/YouCompleteMe'
" Clojure syntax highlight
@pmkhoa
pmkhoa / letsencrypt-renew.sh
Created October 11, 2016 16:29 — forked from jcjones/letsencrypt-renew.sh
Cron script to renew Let's Encrypt certs using the official client
#!/bin/bash
# This is free and unencumbered software released into the public domain.
#
# This script is designed to be run daily by cron. Please run it with randomness in its timing to
# avoid load spikes at Let's Encrypt. One example, running between midnight at 2 AM, would be:
#
# 0 0 * * * sleep $[(RANDOM % 115)+5]m ; /usr/sbin/letsencrypt-renew.sh
#
# If you aren't using Nginx, adjust the startServer and stopServer methods to suit. Also, you could
# use the webroot method.
@pmkhoa
pmkhoa / gist:580fce3cb8d2265fee0665097f316e40
Created September 30, 2016 21:29 — forked from henrik/gist:3181718
Fix "unsupported new OS, trying as if it were 10.6-10.7" from reattach-to-user-namespace on Mountain Lion (probably in tmux).
# Start by checking if they fixed it upstream:
brew update
brew upgrade reattach-to-user-namespace
# If it says it's already installed, they haven't fixed it upstream. So do this:
# Edit the recipe:
brew edit reattach-to-user-namespace
@pmkhoa
pmkhoa / google.css
Created September 6, 2016 18:02 — forked from brandonrosage/google.css
Stylesheet intended to override Google's custom search styles on the OIC website.
#cse-search-form {
position: relative;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
background: #f2f2f2;
padding: 3px;
}
#dialog-container #cse-search-form {
@pmkhoa
pmkhoa / webhook-mailer.php
Created August 18, 2016 22:58 — forked from jcanfield/webhook-mailer.php
Stripe Webhook PHP Example
<?php
// SETUP:
// 1. Customize all the settings (stripe api key, email settings, email text)
// 2. Put this code somewhere where it's accessible by a URL on your server.
// 3. Add the URL of that location to the settings at https://manage.stripe.com/#account/webhooks
// 4. Have fun!
// set your secret key: remember to change this to your live secret key in production
// see your keys here https://manage.stripe.com/account
@pmkhoa
pmkhoa / migrate_postgresql_database.md
Created June 23, 2016 05:20 — forked from olivierlacan/migrate_postgresql_database.md
How to migrate a Homebrew-installed PostgreSQL database to a new major version (9.3 to 9.4) on OS X

This guide assumes that you recently run brew upgrade postgresql and discovered to your dismay that you accidentally bumped from one major version to another: say 9.3.x to 9.4.x. Yes, that is a major version bump in PG land.

First let's check something.

brew info postgresql

The top of what gets printed as a result is the most important: