Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Xiao Meng xiaom

:octocat:
  • Activision Blizzard
  • Canada
View GitHub Profile
@xiaom
xiaom / Zenodo-Metadata-Extraction.md
Last active Oct 13, 2017
Research Data Metadata Extraction - GSoc 2017
@xiaom
xiaom / tei_to_fulltext.py
Created Aug 17, 2017
tei_to_fulltext.py
View 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 Apr 30, 2017 — forked from nopper/tmux_fabric.py
Tmux helper for fabric
View tmux_fabric.py
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 Aug 18, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// 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 Aug 14, 2014
C++ Notes: Prefix with Root Namespace
View cpp-namesapce.md

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<double> const& values) {
View gist:0ee335251727eed0cb0b
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 Apr 10, 2014
hive-scripts/stop_hive.sh: stop hive service
View stop_hive.sh
#!/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 Aug 29, 2015
hive-scripts/start_hive.sh: Scripts to start hive
View start_hive.sh
#!/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 Aug 29, 2015
ssh tunnel connection
View ssh tunnel
# 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 Feb 7, 2014
regex and refactor
View sed.sh
ack DataMode.OPTIONAL | awk 'BEGIN {FS =":"} {print $1}' | xargs sed -i "s/DataMode.OPTIONAL/DataMode.DM_OPTIONAL/g"