Skip to content

Instantly share code, notes, and snippets.

@kittolau
kittolau / Package Install
Last active September 23, 2016 07:53
Sublime Text 3 Settings
Theme:
Theme - Soda
Colour Scheme:
RailsCasts Colour Scheme
Package Installed:
Package Control
SublimeLinter
SideBarEnhancements
Alignment
All Autocomplete
@kittolau
kittolau / kmean
Created November 27, 2014 07:02
K Mean
var inputElm = [1,7,10,16,17,32];
var numberOfCluster = 3;
function findMean(inputArray){
var sum = 0;
for( var i = 0; i < inputArray.length; i++ ){
sum += inputArray[i]
}
var avg = sum/inputArray.length;
@kittolau
kittolau / add_deploy_user.sh
Last active October 26, 2018 09:41
Ubuntu 14.04 mangement Script
#!/bin/sh
sudo su
#============================
#Create deploy user
DEPLOY_USER=deploy
DEPLOY_USER_PASSWORD=deploy
#============================
#create deploy user
adduser --disabled-password --gecos "" ${DEPLOY_USER}
sudo adduser ${DEPLOY_USER} sudo
@kittolau
kittolau / Post Put exmaple
Last active August 29, 2015 14:20
Fiddler related stuff
#request header
Content-type: application/x-www-form-urlencoded
User-Agent: Fiddler
Host: localhost:13000
Content-Length: 84
#Request Body
title="aaabbb"&post_images_attributes[0][_destroy]=1&post_images_attributes[0][id]=4
@kittolau
kittolau / nginx_html.conf
Last active August 29, 2015 14:22
nginx config example
server {
server_name subdomain.example.com example.com www.example.com;
listen 80;
root /home/deploy/www/my_site/public;
index index.html index.htm;
#try file when server_name is visited
#@fallback default to 500
#=404 will be 404
@kittolau
kittolau / vagrant cheat sheet
Last active February 26, 2016 06:39
vagrant related
#list all vm id
vagrant global-status
#delete vm
vagrant destroy {id}
#create vm
vagrant init {box_name}
#start vm
vagrant up
#reload config
@kittolau
kittolau / beanstalkd.sh
Last active April 19, 2017 20:40
Ubuntu 14.04 software install script, curl -L <url> | bash
#!/bin/sh
#==============================
#Install beanstalkd - from apt-get
#https://www.digitalocean.com/community/tutorials/how-to-install-and-use-beanstalkd-work-queue-on-a-vps
#==============================
sudo apt-get install beanstalkd -y < "/dev/null"
@kittolau
kittolau / lmnr.sh
Last active November 9, 2015 14:08
Ubuntu 14.04 install bundle
#!/bin/sh
#============================
#Ubuntu 14.04 LMNR Webserver Stack Provision Script(Linux Mysql Nginx Rails)
#install via "sudo curl -L <url/to/lmnrr.sh> | bash"
#============================
#============================
#result hint set up
#===========================
red='\033[0;31m'
@kittolau
kittolau / InsecurePlatformWarning
Last active October 2, 2015 17:30
virtualenv cheat sheet
#To solve the InsecurePlatformWarning
#==========================================
#for ubuntu
sudo apt-get install libffi-dev libssl-dev
pip install pyopenssl ndg-httpsclient pyasn1
@kittolau
kittolau / gem
Created October 4, 2015 09:58
Rails Resource
#Paging
gem "kaminari"
#mobile Push notification
gem 'rpush'
#Image upload
gem "rmagick"
gem "carrierwave"