Skip to content

Instantly share code, notes, and snippets.

View th0j's full-sized avatar
💭
🚀 🚀

Tho Vo th0j

💭
🚀 🚀
View GitHub Profile
@th0j
th0j / install_BWAPP.md
Last active July 14, 2018 04:25
Install BWAPP

1. Install XAMPP

Use PHP 5.x, not use PHP 7.x, because some function of BWAPP can't run.

chmod +x xampp-linux-x64-5.6.36-0-installer.run
sudo ./xampp-linux-x64-5.6.36-0-installer.run

2. Install BWAPP

After download BWAPP, extract and copy add dir to /opt/lampp/htdocs/ (dir install XAMPP).

Show top 10 comments

history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a; }' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n10

Delete all local branch except master and develop

git branch | grep -v "(master\|develop)" | xargs git branch -D'
@th0j
th0j / connect_ec2.md
Last active June 10, 2018 16:38
How to connect PostgreSQL on EC2

Update pg_hba.conf as described in the previous section:

sudo vim /etc/postgresql/9.1/main/pg_hba.conf

Update the bottom of the file, which will read something like this, by default:

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
@th0j
th0j / *.html
Last active May 16, 2018 10:38
Custom checkbox
<li ng-repeat="group in groups" ng-class="{active: filterGroupIds[group.id]}">
<div class="checkboxgroup whitebg large-custom">
<input type="checkbox" id="groupsSelected{{$index}}" ng-model="group.selected" ng-value="group.id">
<label class="fake-input" for="groupsSelected{{$index}}"></label>
<label for="groupsSelected{{$index}}">{{ group.name }}</label>
</div>
</li>
@th0j
th0j / ci.sh
Last active May 8, 2018 15:01
Setup shell for Jenkins CI
cd /var/lib/jenkins/workspace/rails_ci_1
ruby -v
gem install bundler
bundle install
@th0j
th0j / curl.sh
Created April 9, 2018 08:44
Curl multipart/form-data
curl -X POST -H "Content-Type: multipart/form-data" -F cloud_storages[]["bookmark_data"]=@arch_screenshot.png -F cloud_storages[]["real_filename"]=test_1 -F cloud_storages[]["ext"]=jpg -F cloud_storages[]["bookmark_data"]=@arch_screenshot.png -F cloud_storages[]["real_filename"]=test_2 -F cloud_storages[]["ext"]=png localhost:3000/api/v2/cloud_storages?keyapi=03da0b83c3dab8e2a48d28d1944b08dd
@th0j
th0j / Dockerfile
Last active April 5, 2018 16:35
Docker alpine + Rails + Postgresql
FROM ruby:2.4.1-alpine3.6
RUN apk add --update build-base libffi-dev libxml2-dev libxslt-dev postgresql-dev nodejs tzdata bash
ENV RAILS_ENV=production \
APP_HOME=/app
ENV BUNDLE_PATH /box
RUN mkdir -p $APP_HOME
@th0j
th0j / Dockerfile
Created October 9, 2017 15:59
Speedup docker
FROM ruby:2.4.1-alpine3.6
RUN apk add --update build-base libffi-dev libxml2-dev libxslt-dev postgresql-dev nodejs tzdata bash
ENV RAILS_ENV=production \
APP_HOME=/app \
ENV BUNDLE_PATH /bundle
RUN mkdir -p $APP_HOME
@th0j
th0j / .drink_water_linux.sh
Last active October 28, 2018 10:30
Send notification to remember drink water
eval "export $(egrep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)";
DISPLAY=:0 notify-send "Hey!!!" "Keep your back straight and remember drink water!"
------------------ CREATE SAMPLE DATABASE ------------------
CREATE TABLE depts(
dept_id INT PRIMARY KEY,
dept_name VARCHAR(50) NOT NULL
);
CREATE TABLE Employees(
employee_id INT PRIMARY KEY,
dept_id INT NOT NULL,