Skip to content

Instantly share code, notes, and snippets.

View xiaom's full-sized avatar
:octocat:

Xiao Meng xiaom

:octocat:
  • Goldsky
  • Canada
  • 23:24 (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 / hive
Created January 13, 2014 01:51
mirror https://github.com/apache/hive/blob/trunk/bin/hive a great example of writing bash in practice
#!/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
#
# http://www.apache.org/licenses/LICENSE-2.0
@xiaom
xiaom / install_mosh_locally.sh
Last active April 2, 2024 16:48
install mosh locally
#!/bin/sh
# 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, zmil...@cs.wisc.edu
mkdir mosh
cd mosh
@xiaom
xiaom / cmp.py
Last active December 19, 2015 11:09
incorporating with cmp.sql
import shlex, subprocess
raw_args = "sqlcmd -S cypress.csil.sfu.ca -d cmpt354_bank -i %s.sql"%(test)
args = shlex.split(raw_args)
output = subprocess.check_output(args)
print output
@xiaom
xiaom / cmp.sql
Last active December 19, 2015 11:09
compare two sql statement
DECLARE @Query1Checksum bigint
DECLARE @Query2Checksum bigint
Use Northwind354 
-- Get checksum from source query
Select @Query1Checksum = CHECKSUM_AGG(BINARY_CHECKSUM(*))
FROM
(
-- [Start Source Query]
SELECT O.OrderID, O.OrderDate,
@xiaom
xiaom / inheritance.cpp
Last active December 18, 2015 22:09
inheritance
#include <iostream>
using namespace std;
class Base{
public:
virtual ~Base() {
cout << "Base Destruct" << endl;
}
virtual void print(){
cout << "Base" << endl;
@xiaom
xiaom / difftime
Created June 15, 2013 07:11
difference in time
clock_t start, end;
start = clock();
//
// YOUR CODE
//
end = clock();
cerr << "Inverted Index is built in "
@xiaom
xiaom / hostname.sh
Last active December 18, 2015 10:39
set hostname #OneLineCommand
#change your Mac hostname with the command line and make it permanent:
sudo scutil –-set HostName new_hostname
@xiaom
xiaom / gencomb.py
Created February 15, 2013 20:01
generate combinations
# generate combinations
#
# http://docs.python.org/2/library/itertools.html#itertools.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
xiaom / pq.cpp
Created July 16, 2012 22:56
use priority queue
// top k denest regions: the k-th region is on the top
class RegionCmp {
public:
bool operator()(const Region& lhs, const Region& rhs) const {
return lhs.d > rhs.d;
}
};
typedef priority_queue<Region, vector<Region>, RegionCmp> RegionPQ;