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 / 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 / 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 / data_analysis.md
Last active October 7, 2015 10:11
Getting started with Data analysis

Data analysis basic summary

Getting started with Data analysis

การวิเคราะห์ข้อมูลดิบ ทำการจัดเรียงลำดับหรือจัดหมวดหมู่ เพื่ออธิบายสิ่งที่เกิดขึ้นในอดีตและทำนายสิ่งที่จะเกิดขึ้นในอนาคต โดยไม่ได้หมายถึงเฉพาะตัวเลข แต่เป็นการสร้างและตั้งคำถาม การพัฒนาและสร้างคำอธิบาย นิยามของข้อสันนิษฐานหรือเหตุการณ์ที่เกิดขึ้น

ทั้งนี้จำเป็นต้องอาศัยองค์ความรู้หลายแขนงด้วยกันเช่น

computer science
@xemoe
xemoe / php_command_templates.php
Created September 17, 2015 07:08
PHP Command template
<?php
$configuration = ['eth0' => ['ip_address' => '192.168.1.100', 'netmask' => '255.255.255.0', 'gateway_ip_address' => '192.168.1.1', 'interface' => 'eth0']];
$template = [
'template' => 'ip addr add %s dev %s',
'variables' => ['ip_address', 'interface'],
];
function build($configuration, $template)
{
@xemoe
xemoe / remove_old_kernel.md
Created August 11, 2015 05:19
Remove old kernel
sudo apt-get remove --purge $(dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d')
@xemoe
xemoe / influxdb_setup.md
Created August 3, 2015 15:07
Metric setup

For Ubuntu 14.04

Download dpkg file

wget https://s3.amazonaws.com/influxdb/influxdb_0.9.2_amd64.deb 
sudo dpkg -i influxdb_0.9.2_amd64.deb

Generate influxdb configuration

/opt/influxdb/influxd config > /opt/influxdb/influxdb.conf

@xemoe
xemoe / php_array_nested.php
Last active August 29, 2015 14:25
PHP Array nested get/set
<?php
function array_bags($keys, $root, $bags)
{
$key = array_shift($keys);
$root = $root[$key];
$bags[] = ['key' => $key, 'root' => $root];
$length = sizeof($keys);
@xemoe
xemoe / palindrome.php
Last active August 29, 2015 14:25
Palindrome
<?php
//
// Testing on:
// PHP 5.6.10-1+deb.sury.org~vivid+1 (cli)
//
function palindrome($string)
{
ksort($counter = count_chars($string, 1));
$ret = '';
@xemoe
xemoe / real_network_interface_card.md
Created June 29, 2015 15:43
Get physical network interface
find /sys/class/net -type l|xargs readlink -f|grep -v virtual|xargs -n1 -d '\n' basename
@xemoe
xemoe / logstash_develop.md
Last active January 18, 2017 10:34
Logstash development

Preconfigure ** Important ***

  1. Install rvm https://rvm.io/

  2. Install jruby

    rvm install jruby
  3. use jruby