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 / htpass.md
Last active November 23, 2016 11:54
Create htpasswd basic authentication

Install package

sudo apt-get install apache2-utils

Generate htpasswd file

sudo htpasswd -c /var/www/yourweb/.htpasswd yourname
@xemoe
xemoe / lighttpd_laravel5_rewrite.md
Created November 30, 2015 16:50
Lighttpd laravel 5 rewrite
alias.url = ("/netcleaner" => "/home/nontawatt/workspaces/net_cleaner/src/www/public/")
url.rewrite-once = (
        "^/netcleaner/compiled/(.*)" => "/netcleaner/compiled/$1",
        "^/netcleaner/(favicon\.ico|robots\.txt|sitemap\.xml)$" => "/netcleaner/$1",
        "^/netcleaner/[^\?]*(\?.*)?$" => "/netcleaner/index.php/$1"
)

$HTTP["url"] =~ "^/netcleaner" {
 url.redirect = ()
@xemoe
xemoe / ubuntu_create_lvm.md
Last active December 23, 2017 17:16
Ubunutu server create lvm
@xemoe
xemoe / mariadb_all.list
Created November 13, 2015 22:18
Mariadb mirror list
#
# Mariadb mirror list
# Generate since: 2015-11-14 05:17:40
deb [arch=amd64,i386] http://mirrors.bestthaihost.com/mariadb/repo/10.1/ubuntu trusty main
deb-src http://mirrors.bestthaihost.com/mariadb/repo/10.1/ubuntu trusty main
deb [arch=amd64,i386] http://mirrors.opencas.cn/mariadb/repo/10.1/ubuntu trusty main
deb-src http://mirrors.opencas.cn/mariadb/repo/10.1/ubuntu trusty main
@xemoe
xemoe / gist.md
Created November 12, 2015 19:25
Calculate system memory by half
MYMEM=$(printf "%.2f" $(( $(vmstat -s | head -n1 | awk '{print $1}') * 0.5 )) | numfmt --to=si --from-unit=K)
@xemoe
xemoe / gist:2a3dc139db2bd62d2991
Created November 9, 2015 05:21
SSH Web tunneling
ssh -L 8080:localhost:80 user@remote-host
@xemoe
xemoe / traits_switchers.php
Created November 4, 2015 18:03
Traits switcher
<?php
trait Bar1
{
function getBody($type, &$body) {
switch($type) {
case 1:
$body = 'A';
break;
case 2:
@xemoe
xemoe / ansible_with_ubuntu.md
Last active October 26, 2015 11:35
Ansible with Ubuntu (Draft)

Ansible with Ubuntu

  1. setup ansible playbook from ppa for latest available update
  2. create sample local playbook <E.g. whoami>
  3. execute playbook to remote server

The first task - setup ansible package from ppa

just a simple command

How to generate PDF reports file from html views

  1. generate filename with .html extension
  2. geneate pdf output filename with .pdf extension
  3. set pdf tmp path variables
    E.g. /tmp/my_reports.pdf
  1. set command template
 /usr/bin/xvfb-run --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf %s %s
@xemoe
xemoe / gist:effd7dd50c5eb7193fc5
Created October 15, 2015 05:12
Ubuntu remove kernel
echo $(dpkg --list | grep linux-image | awk '{ print $2 }' | sort -V | sed -n '/'`uname -r`'/q;p') $(dpkg --list | grep linux-headers | awk '{ print $2 }' | sort -V | sed -n '/'"$(uname -r | sed "s/\([0-9.-]*\)-\([^0-9]\+\)/\1/")"'/q;p') | xargs sudo apt-get -y purge