Skip to content

Instantly share code, notes, and snippets.

View khacanh's full-sized avatar
😀

khacanh khacanh

😀
  • Ho Chi Minh city
View GitHub Profile
@khacanh
khacanh / appium
Last active August 29, 2015 14:06
appium
1. ENVS
ln -s /Applications/Android\ Studio.app /Applications/AndroidStudioApp
export ANDROID_HOME=/Applications/AndroidStudioApp/sdk
export ANDROID_SDK=$ANDROID_HOME
PATH=$PATH:/Applications/apache-ant-1.8.4/bin
PATH=$PATH:/usr/local/share/npm/bin/
PATH=$PATH:$ANDROID_HOME/build-tools
PATH=$PATH:$ANDROID_HOME/platform-tools
PATH=$PATH:$ANDROID_HOME/tools
export JAVA_HOME="`/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home`"
@khacanh
khacanh / iptables
Created September 3, 2014 17:02
Useful iptables cmd
iptables -L --line-numbers # list
iptables -D INPUT [line] # delete
iptables -I INPUT [line] # insert
iptables -P # change policy ACCEPT/DROP
# open port 81 for anyone
iptables -A INPUT -p tcp --dport 81 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 81 -j ACCEPT
# open port 81 for a specific private network
@khacanh
khacanh / FB-fanpage
Created August 4, 2014 23:45
FB-fanpage
{""=>
[{"description"=>
"Lifetime: Aggregated Facebook location data, sorted by country, about the people who like your Page. (Unique Users)",
"title"=>"Lifetime Likes by Country",
"period"=>"lifetime",
"values"=>
[{"end_time"=>"2014-07-31T07:00:00+0000",
"value"=>
{"BD"=>123,
"FR"=>29,
@khacanh
khacanh / unattended-upgrades.log
Created July 19, 2014 06:28
unattended-upgrades log
2014-07-17 06:45:31,261 INFO Initial blacklisted packages:
2014-07-17 06:45:31,262 INFO Starting unattended upgrades script
2014-07-17 06:45:31,263 INFO Allowed origins are: ['o=Ubuntu,a=trusty-security']
2014-07-17 06:46:11,356 INFO Packages that will be upgraded: apt apt-transport-https apt-utils dbus dpkg file gnupg gpgv libapt-inst1.5 libapt-pkg4.12 libdbus-1-3 libelf1 libjson-c2 libjson0 libmagic1 libssl1.0.0 libxml2 linux-firmware linux-generic linux-headers-3.13.0-24 linux-headers-3.13.0-24-generic linux-headers-generic linux-image-3.13.0-24-generic linux-image-extra-3.13.0-24-generic linux-image-generic openssl rsync tzdata
2014-07-17 06:46:11,357 INFO Writing dpkg log to '/var/log/unattended-upgrades/unattended-upgrades-dpkg_2014-07-17_06:46:11.357019.log'
2014-07-17 06:48:13,287 INFO All upgrades installed
2014-07-17 06:48:13,295 ERROR No '/usr/bin/mail' or '/usr/sbin/sendmail',can not send mail. You probably want to install the 'mailx' package.
2014-07-18 06:46:19,904 INFO Initial blacklisted packa
@khacanh
khacanh / _etc_init.d_supervisord
Last active August 29, 2015 14:03
supervisor init script
#! /bin/sh
#
# skeleton example file to build /etc/init.d/ scripts.
# This file should be used to construct scripts for /etc/init.d.
#
# Written by Miquel van Smoorenburg <[email protected]>.
# Modified for Debian
# by Ian Murdock <[email protected]>.
# Further changes by Javier Fernandez-Sanguino <[email protected]>
#
@khacanh
khacanh / configs
Created June 18, 2014 08:35
Configs
Cannot connect to monit daemon: http://www.idimmu.net/2013/03/28/monit-error-connecting-to-the-monit-daemon/
def uni_z1(input)
output = input;
output = output.gsub(/\u104E\u1004\u103A\u1038/, '\u104E');
output = output.gsub(/\u102B\u103A/, '\u105A');
output = output.gsub(/\u102D\u1036/, '\u108E');
output = output.gsub(/\u103F/, '\u1086');
output = output.gsub(/(\u102F[\u1036]?)\u1037/, $1 ? $1 + '\u1094' : "#{$0}#{$1}")
output = output.gsub(/(\u1030[\u1036]?)\u1037/, $1 ? $1 + '\u1094' : "#{$0}#{$1}")
output = output.gsub(/(\u1014[\u103A\u1032]?)\u1037/, $1 ? $1 + '\u1094' : "#{$0}#{$1}")
output = output.gsub(/(\u103B[\u1032\u1036]?)\u1037/, $1 ? $1 + '\u1095' : "#{$0}#{$1}")
module Z1Uni
def self.convert(input)
output = input.clone.force_encoding("UTF-8")
tallAA = "\u102B"
nAA = "\u102C"
vi = "\u102D"
ii = "\u102E"
u = "\u102F"
uu = "\u1030"
ve = "\u1031"
function Z1_Uni(input)
{
var output=input;
var tallAA = "\u102B";
var AA = "\u102C";
var vi = "\u102D";
var ii = "\u102E";
var u = "\u102F";
var uu = "\u1030";
var ve = "\u1031";
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_relation_size(C.oid)) AS "size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_relation_size(C.oid) DESC
LIMIT 20;
Example output (from a database created with pgbench, scale=25):