Skip to content

Instantly share code, notes, and snippets.

View benjiao's full-sized avatar

Benjie Jiao benjiao

View GitHub Profile
@benjiao
benjiao / deploy.sh
Created August 23, 2015 15:50
Shell script to deploy an app from a git repository using a deploy key
#!/bin/bash
eval `ssh-agent -s`
ssh-add ~/.ssh/deploy-key
cd /sample/path/to/app
git pull origin master
@benjiao
benjiao / squid.conf
Last active September 7, 2015 15:20
Squid3.3 Config
http_port 8080
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex -i cgi-bin \? \.php$ \.asp$ \.shtml$ \.cfm$ \.cfml$ \.phtml$ \.php
acl localnet src 192.168.0.0/16
acl localhost src 127.0.0.1/32
acl SSL_ports port 443
@benjiao
benjiao / flask-logging-example.py
Created September 21, 2015 11:20
Flask Logging to File Example
# Setup Logging
formatter = logging.Formatter('%(asctime)s %(levelname)-8s %(message)s')
fh = logging.FileHandler(filename='flask-tutorial.log')
fh.setFormatter(formatter)
fh.setLevel(logging.DEBUG)
app.logger.addHandler(fh)
apt-get -y update
# Download Zulip
cd /root
wget https://www.zulip.com/dist/releases/zulip-server-1.3.6.tar.gz
echo "665a1e6ef840b3a86cc18946429ad1c0033d27a2 zulip-server-1.3.6.tar.gz" | sha1sum -c
tar -xf zulip-server-1.3.6.tar.gz
mv zulip-server-1.3.6 zulip
# Install SSL Certs
sudo apt-get -y update
sudo apt-get -y install git
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo apt-get -y update && sudo apt-get install -y nodejs
sudo apt-get -y install mongodb
curl https://install.meteor.com/ | sh
git clone https://github.com/RocketChat/Rocket.Chat.git
cd Rocket.Chat
@benjiao
benjiao / angular-nginx-sub-uri.conf
Created November 6, 2015 04:42
Nginx config for Angular app under sub-URI
location /testapp/ {
rewrite ^/testapp/(.*) /$1 break;
proxy_redirect off;
proxy_pass http://127.0.0.1:9090;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
}
# Install GDAL python libraries on Virtualenv. Tested in Ubuntu 14.04
sudo apt-get install gdal-bin
sudo apt-get install libgdal-dev libgdal1h
pip install GDAL==$(gdal-config --version) --global-option=build_ext --global-option="-I/usr/include/gdal"
sudo fallocate -l 4G /swapfile && \
sudo chmod 600 /swapfile && \
sudo mkswap /swapfile && \
sudo swapon /swapfile && \
sudo sh -c 'echo "/swapfile none swap sw 0 0" >> /etc/fstab'
set nocompatible
" Syntax Highlighting
filetype indent plugin on
set syntax=on
" Use case insesitive search
set ignorecase
set smartcase
sudo timedatectl set-timezone Asia/Manila
sudo yum install ntp && \
sudo systemctl start ntpd && \
sudo systemctl enable ntpd && \
sudo service ntpd restart
# Setup Swapfile
sudo dd if=/dev/zero of=/swapfile count=4096 bs=1MiB && \\
sudo chmod 600 /swapfile && sudo mkswap /swapfile && \\