Skip to content

Instantly share code, notes, and snippets.

xiaom / install
Created Jan 29, 2014
install eclipse from tarball
View install
tar -xzvf eclipse*.tar.gz -C /opt
chmod -R +r /opt/eclipse
# use the technique "HERE document"
(cat <<'EOF'
export ECLIPSE_HOME="/opt/eclipse"
$ECLIPSE_HOME/eclipse $*
xiaom / hive
Created Jan 13, 2014
mirror a great example of writing bash in practice
View hive
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
xiaom /
Last active Aug 12, 2021
install mosh locally
# this script does absolutely ZERO error checking. however, it worked
# for me on a RHEL 6.3 machine on 2012-08-08. clearly, the version numbers
# and/or URLs should be made variables. cheers,
mkdir mosh
cd mosh
xiaom /
Last active Dec 19, 2015
incorporating with cmp.sql
import shlex, subprocess
raw_args = "sqlcmd -S -d cmpt354_bank -i %s.sql"%(test)
args = shlex.split(raw_args)
output = subprocess.check_output(args)
print output
xiaom / cmp.sql
Last active Dec 19, 2015
compare two sql statement
View cmp.sql
DECLARE @Query1Checksum bigint
DECLARE @Query2Checksum bigint
Use Northwind354 
-- Get checksum from source query
Select @Query1Checksum = CHECKSUM_AGG(BINARY_CHECKSUM(*))
-- [Start Source Query]
SELECT O.OrderID, O.OrderDate,
View inheritance.cpp
#include <iostream>
using namespace std;
class Base{
virtual ~Base() {
cout << "Base Destruct" << endl;
virtual void print(){
cout << "Base" << endl;
xiaom / difftime
Created Jun 15, 2013
difference in time
View difftime
clock_t start, end;
start = clock();
end = clock();
cerr << "Inverted Index is built in "
xiaom /
Last active Dec 18, 2015
set hostname #OneLineCommand
#change your Mac hostname with the command line and make it permanent:
sudo scutil –-set HostName new_hostname
xiaom /
Created Feb 15, 2013
generate combinations
# generate combinations
# combinations(iterable, r) --> combinations object
# Return successive r-length combinations of elements in the iterable.
combinations(range(4), 3) --> (0,1,2), (0,1,3), (0,2,3), (1,2,3)
xiaom / pq.cpp
Created Jul 16, 2012
use priority queue
View pq.cpp
// top k denest regions: the k-th region is on the top
class RegionCmp {
bool operator()(const Region& lhs, const Region& rhs) const {
return lhs.d > rhs.d;
typedef priority_queue<Region, vector<Region>, RegionCmp> RegionPQ;