Skip to content

Instantly share code, notes, and snippets.

View mkhairi's full-sized avatar
🤜
Hello, Nice to meet you

Khairi Adnan mkhairi

🤜
Hello, Nice to meet you
View GitHub Profile
class RoutesReloader
def initialize(app)
@app = app
end
def call(env)
reload_routes_if_changed
return *@app.call(env)
end
@mkhairi
mkhairi / gitcheats.txt
Created June 13, 2017 05:10 — forked from chrismccoy/gitcheats.txt
git cheats
# shortform git commands
alias g='git'
# push changes to an empty git repository for the first time
git push --set-upstream origin master
# Remove + and - from start of diff lines
git diff --color | sed "s/^\([^-+ ]*\)[-+ ]/\\1/" | less -r
# clear out git hooks
@mkhairi
mkhairi / gist:4e2f276c7071e91aa8f7cc82d0b1254c
Created November 20, 2017 14:59 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.0 using Homebrew (macOS)
After automatically updating Postgres to 10.0 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.0."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# need to have both 9.6.x and latest 10.0 installed, and keep 10.0 as default
brew unlink postgresql
brew install [email protected]
brew unlink [email protected]
brew link postgresql
@mkhairi
mkhairi / Mampu.pem
Last active November 14, 2022 19:34
MAMPU 1GovNet SSL Ubuntu Server
wget https://cots.gitn.net.my/1govnet/upload/SSL_Extended.cer
openssl x509 -in SSL_Extended.cer -inform PEM -out Mampu.crt
mv SSL_Extended.cer Mampu.pem
sudo cp Mampu.crt /etc/ssl/certs
sudo cp Mampu.pem /usr/local/share/ca-certificates/
sudo update-ca-certificates
export NODE_EXTRA_CA_CERTS=/usr/local/share/ca-certificates/Mampu.pem
@mkhairi
mkhairi / apache_cors_example
Created August 29, 2019 11:49 — forked from brianlmoon/apache_cors_example
CORS example for Apache with multiple domains
# Sets CORS headers for request from example1.com and example2.com pages
# for both SSL and non-SSL
SetEnvIf Origin "^https?://[^/]*(example1|example2)\.com$" ORIGIN=$0
Header set Access-Control-Allow-Origin %{ORIGIN}e env=ORIGIN
Header set Access-Control-Allow-Credentials "true" env=ORIGIN
# Always set Vary: Origin when it's possible you may send CORS headers
Header merge Vary Origin