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 / c5_execute_a_search.md
Created October 9, 2015 10:11
Elasticsearch documents

Executing a search

ElasticSearch was born as a search engine. Its main work is to process queries and give results. As we'll see in this recipe, search in ElasticSearch is not only limited to match some documents, but also to calculate additional information required to improve user experience.

The HTTP method used to execute a search is GET (but POST also works), the REST URLS are as follows:

http://<server>/_search
http://<server>/<index_name(s)>/_search
http://<server>/<index_name(s)>/<type_name(s)>/_search

@xemoe
xemoe / d3_settings.js
Last active October 13, 2015 16:06
D3JS Histogram settings
function histogram_settings(jQuery, d3, id, colors, data) {
var t = this;
var stack = d3.layout.stack();
stack(data);
t.getId = function() {
return id;
}
t.getDataset = function() {
@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

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 / 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

@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 / gist:2a3dc139db2bd62d2991
Created November 9, 2015 05:21
SSH Web tunneling
ssh -L 8080:localhost:80 user@remote-host
@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 / 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 / ubuntu_create_lvm.md
Last active December 23, 2017 17:16
Ubunutu server create lvm