Skip to content

Instantly share code, notes, and snippets.

View xiaom's full-sized avatar
:octocat:

Xiao Meng xiaom

:octocat:
  • Goldsky
  • Canada
  • 07:56 (UTC -07:00)
View GitHub Profile
@xiaom
xiaom / Zenodo-Metadata-Extraction.md
Last active October 13, 2017 12:58
Research Data Metadata Extraction - GSoc 2017
@xiaom
xiaom / tei_to_fulltext.py
Created August 17, 2017 06:52
tei_to_fulltext.py
NS = {'tei': 'http://www.tei-c.org/ns/1.0'}
def tei_to_fulltext(tei):
from lxml import etree
from six import text_type
parser = etree.XMLParser(encoding='UTF-8', recover=True)
tei = tei if not isinstance(tei, text_type) else tei.encode('utf-8')
root = etree.fromstring(tei, parser)
return get_fulltext(root)
@xiaom
xiaom / tmux_fabric.py
Created April 30, 2017 23:00 — forked from nopper/tmux_fabric.py
Tmux helper for fabric
from fabric.api import *
class Tmux(object):
"""Tmux helper for fabric"""
def __init__(self, session_name, run_cmd=run):
self.session_name = session_name
self.run_cmd = run_cmd
self.create_session()
@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 / 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) {
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 / 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
@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 / 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 / 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"