Skip to content

Instantly share code, notes, and snippets.

View quangtt-rks's full-sized avatar
🎸
Rocking

Quang Tran quangtt-rks

🎸
Rocking
View GitHub Profile
@quangtt-rks
quangtt-rks / pre-commit
Last active May 22, 2023 10:21
just a pre-commit hook
#!/bin/sh
rejected_message()
{
echo "COMMIT REJECTED! Please fix your diff.\n\
If you must, run 'git commit --no-verify' to skip this check." && \
exit 1
}
#== 1. Check forbidden keywords within modified files, except commented out sections
/*
################################################################
# Nhân quả không nợ chúng ta thứ gì, cho nên xin đừng oán giận #
# _ #
# _ooOoo_ #
# o8888888o #
# 88" . "88 #
# (| -_- |) #
# O\ = /O #
@quangtt-rks
quangtt-rks / downgrade.sh
Created January 31, 2018 03:58 — forked from 1v/downgrade.sh
Apache 2.2.22 + PHP 5.3.10 on Ubuntu 14.04
cat <<EOF >> /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu precise main restricted universe
deb http://archive.ubuntu.com/ubuntu precise-updates main restricted universe
deb http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse
EOF
apt-get update
apt-get remove \
apache2 \
@quangtt-rks
quangtt-rks / gist:edd92249b41fd1e0b957b20d7771c2a8
Created October 11, 2017 09:16 — forked from ericchen/gist:3081968
ruby openssl AES encrypt and decrypt
require 'base64'
require 'digest'
require 'openssl'
module AESCrypt
def AESCrypt.encrypt(password, iv, cleardata)
cipher = OpenSSL::Cipher.new('AES-256-CBC')
cipher.encrypt # set cipher to be encryption mode
cipher.key = password
@quangtt-rks
quangtt-rks / gist:2f6d96f2e8512d75b1794c406028fa9b
Last active October 11, 2017 09:16 — forked from bentonporter/gist:2891463
Ruby - HMAC-SHA256 example
require 'openssl'
require 'Base64'
key = "secret-key"
data = "some data to be signed"
Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha256'), key, data)).strip()
@quangtt-rks
quangtt-rks / gist:5505f46c5bd6343df3d7862acd1a6e41
Created October 11, 2017 01:31
Ruby AES Encryption using OpenSSL
#!/usr/bin/env ruby
require "openssl"
require 'digest/sha2'
require 'base64'
# We use the AES 256 bit cipher-block chaining symetric encryption
alg = "AES-256-CBC"
# We want a 256 bit key symetric key based on some passphrase
digest = Digest::SHA256.new
@quangtt-rks
quangtt-rks / build_mysql.sh
Last active July 4, 2017 01:23 — forked from shichao-an/build_mysql.sh
Build and install MySQL 5.1 from source on Ubuntu 14.04, 12.04
#!/bin/bash
# Run as root
set -e
apt-get update
apt-get install -y build-essential
apt-get install -y libncurses5-dev
useradd mysql
@quangtt-rks
quangtt-rks / upgrade_ghost_blog.sh
Last active April 21, 2017 08:55
Auto upgrade Ghost blog (version 0.x.x). Tired of typing so many commands when upgrading? Write your own script!
#!/bin/sh
# This script works only on my system, edit it before apply to your system!
echo "\n Ghost Upgrader"
waiting_sign=" ⌛"
okay_sign=" ✓"
ng_sign=" ✗"
ghost_dir="/var/www/ghost"
@quangtt-rks
quangtt-rks / sample_apache2_loadbalancer.conf
Created April 5, 2017 08:34
Sample config for load balancer on localhost
Listen 8080
<VirtualHost *:8080>
ServerAdmin webmaster@localhost
ServerName 192.168.xxx.xxx
ProxyRequests Off
<Proxy balancer://mycluster>
BalancerMember http://192.168.xxx.yyy:8080 route=lb1
BalancerMember http://192.168.xxx.zzz:8080 route=lb2
ProxySet lbmethod=byrequests
@quangtt-rks
quangtt-rks / devise.rb
Created June 30, 2016 09:32 — forked from nicalpi/devise.rb
Omniauth multiple facebook login strategy
# initializers/devise.rb
config.omniauth :facebook, [APP_ID], [APP_SECRET]
config.omniauth :facebook_app1, [APP_ID], [APP_SECRET], :iframe => true, :scope => 'publish_stream,offline_access,email'
config.omniauth :facebook_app2, [APP_ID], [APP_SECRET], :iframe => true, :scope => 'publish_stream,offline_access,email'