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
@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
@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 / 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 postgresql@9.6
brew unlink postgresql@9.6
brew link postgresql
@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
class RoutesReloader
def initialize(app)
@app = app
end
def call(env)
reload_routes_if_changed
return *@app.call(env)
end
#respond remote true redirect
def create
@post = Post.new(post_params)
respond_to do |format|
if @post.save
format.js { redirect_to post_comments_path(@post), turbolinks: false}
#or
#redirect_to post_comments_path(@post), status: 303, turbolinks: false
else
format.html { render :new }
@mkhairi
mkhairi / dnsmasq OS X.md
Created July 18, 2016 07:10 — forked from ogrrd/dnsmasq OS X.md
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.dev domains, e.g. project.dev, awesome.dev and so on, without having to add to your hosts file each time.

Requirements

Install

@mkhairi
mkhairi / postgresql_cmd.md
Last active January 3, 2024 23:33
common postgresql command

#install

sudo apt-get install postgresql
sudo apt-get install libpq-dev
# for hstore
sudo apt-get install postgresql-contrib

##Modify /etc/postgresql/9.3/main/pg_hba.conf access control, local TCP access set to full trust

@mkhairi
mkhairi / activerecord_without_rails.rb
Created November 21, 2015 22:07 — forked from jimmynguyc/activerecord_without_rails.rb
ActiveRecord without Rails
require 'active_record'
require 'sqlite3'
ActiveRecord::Base.establish_connection(
:adapter => "sqlite3",
:database => "teachers.db"
)
# Migration
ActiveRecord::Schema.define do
@mkhairi
mkhairi / server.md
Last active August 29, 2015 14:17 — forked from jtadeulopes/server.md

Update and upgrade the system

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get autoremove
sudo reboot