Skip to content

Instantly share code, notes, and snippets.

View xiaom's full-sized avatar
:octocat:

Xiao Meng xiaom

:octocat:
  • Goldsky
  • Canada
  • 21:58 (UTC -07:00)
View GitHub Profile
@xiaom
xiaom / install eclipse.sh
Created January 29, 2014 19:07
install eclipse from tarball
#!/bin/sh
tar -xzvf eclipse*.tar.gz -C /opt
chmod -R +r /opt/eclipse
# use the technique "HERE document"
# http://tldp.org/LDP/abs/html/here-docs.html
(cat <<'EOF'
#!/bin/sh
export ECLIPSE_HOME="/opt/eclipse"
$ECLIPSE_HOME/eclipse $*
@xiaom
xiaom / sed.sh
Created February 7, 2014 18:49
regex and refactor
ack DataMode.OPTIONAL | awk 'BEGIN {FS =":"} {print $1}' | xargs sed -i "s/DataMode.OPTIONAL/DataMode.DM_OPTIONAL/g"
@xiaom
xiaom / ssh tunnel
Last active August 29, 2015 13:56
ssh tunnel connection
# Let us assume
#
# - you have a laptop A
# - you work at company C
#
# how can you access C from A?
#
# Solution: a middle man B
#
# http://www.revsys.com/writings/quicktips/ssh-tunnel.html
@xiaom
xiaom / start_hive.sh
Last active August 29, 2015 13:58
hive-scripts/start_hive.sh: Scripts to start hive
#!/bin/sh
# http://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.0.0.2/bk_reference/content/reference_chap3_1.html
export HIVE_HOME=/opt/hive/hive-0.12.0-bin/
export HIVE_CONF=$HIVE_HOME/conf.drill/
su -l hive -c "env HADOOP_HOME=/usr nohup $HIVE_HOME/bin/hive --service metastore > /tmp/hive.out 2> /tmp/hive.log &"
su -l hive -c "nohup $HIVE_HOME/bin/hiveserver2 -hiveconf hive.metastore.uris=\" \" > /tmp/hiveServer2.out 2>/tmp/hiveServer2.log &"
@xiaom
xiaom / stop_hive.sh
Created April 10, 2014 19:26
hive-scripts/stop_hive.sh: stop hive service
#!/bin/sh
# Stop Hive (kill all process owened by user 'hive')
ps aux | awk '{print $1,$2}' | grep hive | awk '{print $2}' | xargs kill >/dev/null 2>&1
select
cast('2008-2-23' as date) as DATE_TYPE,
cast('12:20:30' as time) as TIME_TYPE,
cast('2008-2-23 12:00:00' as timestamp) as TIMESTAMP_TYPE
FROM
INFORMATION_SCHEMA.`SCHEMATA`;
@xiaom
xiaom / cpp-namesapce.md
Created August 14, 2014 18:52
C++ Notes: Prefix with Root Namespace

should we always use ::std::cout?

Use it only when you have to do. For example,

namespace X {
    double std(::std::vector<double> const& values) { … }

 void foo(::std::vector const&amp; values) {
@xiaom
xiaom / 0_reuse_code.js
Created August 18, 2014 22:14
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@xiaom
xiaom / gist:1321544
Created October 28, 2011 03:17
how to eliminate duplicate in a list
# http://docs.python.org/faq/programming.html#how-do-you-remove-duplicates-from-a-list
mylist = list(set(mylist))
@xiaom
xiaom / cw.py
Created October 28, 2011 04:43
counting frequency of word
# http://stackoverflow.com/questions/893417/item-frequency-count-in-python
# defaultdict will automatically initialize values to zero.
from collections import defaultdict
words = "apple banana apple strawberry banana lemon"
d = defaultdict(int)
for word in words.split():
d[word] += 1