Skip to content

Instantly share code, notes, and snippets.

View xemoe's full-sized avatar
🏠
Working from home

Teerapong Ladlee xemoe

🏠
Working from home
  • Bangkok, Thailand
View GitHub Profile
@xemoe
xemoe / explain.md
Last active August 29, 2015 14:22
Redirect stdout/stderr
spinner()
{
    local pid=$1
    local delay=0.75
    local spinstr='|/-\'
    while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
        local temp=${spinstr#?}
        printf " [%c]  " "$spinstr"
 local spinstr=$temp${spinstr%"$temp"}
@xemoe
xemoe / split_line_bytes.md
Created June 7, 2015 07:58
Split by line + bytes

Split with option -C, --line-bytes=SIZE put at most SIZE bytes of lines per output file

seq -w 1 200 > k; split -C100 k; head xa? -n200|less
@xemoe
xemoe / start_cig_note.md
Last active November 14, 2017 17:45
Setup Collectd + InfluxDB + Grafana

OS: Ubuntu 14.04 amd64

InfluxDB

  1. download deb file http://s3.amazonaws.com/influxdb/influxdb_latest_amd64.deb

  2. install via dpkg -i influxdb_latest_amd64.deb

  3. configure /opt/influxdb/shared/config.toml add input_plugins.collectd below the input_plugins section

    [input_plugins]
    

[input_plugins.collectd]

@xemoe
xemoe / sublime_user_configure.json
Created June 9, 2015 18:07
My sublime text 3 user config
{
"bold_folder_labels": true,
"theme": "Seti.sublime-theme",
"color_scheme": "Packages/Seti_UI/Scheme/Seti_monokai.tmTheme",
"draw_minimap_border": true,
"font_face": "Ubuntu Mono",
"font_options": "subpixel_antialias",
"font_size": 13,

Installing SSHPASS

SSHPass is a tiny utility, which allows you to provide the ssh password without using the prompt. This will very helpful for scripting. SSHPass is not good to use in multi-user environment. If you use SSHPass on your development machine, it don't do anything evil.

Installing on Ubuntu

apt-get install sshpass

Installing on OS X

@xemoe
xemoe / config
Created June 18, 2015 11:29
SSH Config ignore known_hosts
Host 192.168.0.*
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
@xemoe
xemoe / alway_start_provision.md
Last active August 29, 2015 14:23
Always start provision

Provisioning scripts run after mounts. If you set the provisioning script to run "always", then you can do something like this:

config.vm.provision :shell, :inline => "sudo service mysql start", run: "always"

...which is an easier solution than having to use upstart.

- Aron Budinszky

@xemoe
xemoe / test.php
Created June 20, 2015 10:44
test.php
<?php
class Car {
public static function test() {
echo 'test';
}
}
class TestService {
private function model() {
return 'Car';
@xemoe
xemoe / random.js
Created June 23, 2015 07:10
Random js
[ 'new', 'psr2.6' ]
[ 'golf', 'psr2.1' ]
[ 'nut', 'psr2.7' ]
[ 'nueng', 'psr2.5' ]
[ 'bow', 'psr2.4-2' ]
[ 'aof', 'psr2.3' ]
[ 'pf', 'psr2.2' ]
[ 'pkid', 'psr1' ]
[ 'me', 'psr2.4-1' ]