Skip to content

Instantly share code, notes, and snippets.

View alexdong's full-sized avatar

Alex Dong alexdong

View GitHub Profile
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@alexdong
alexdong / pre-commit
Last active August 29, 2015 14:01
jshint pre-commit hook
#!/bin/sh
files=$(git diff --cached --name-only --diff-filter=ACM | grep ".js$")
if [ "$files" = "" ]; then
exit 0
fi
pass=true
for file in ${files}; do
@alexdong
alexdong / color_picker.js
Created May 25, 2014 23:28
This implements a stateful function in javascript using closure. The same construct requires either a singleton class or a static variable in other languages.
var pick_color = (function(str) {
// We use a circular buffer here to allocate the colors. `label_color_map`
// is a hash with key as `str` and value is the index into the `colors`
// list. The following 'static' variables keep the state within the function.
var label_color_map = {},
current_color_idx = 0,
colors = ['#a6cee3', '#1f78b4', '#b2df8a', '#33a02c', '#fb9a99',
'#e31a1c', '#fdbf6f', '#ff7f00', '#cab2d6', '#6a3d9a', '#ffff99', '#b15928'];
return function(str) {
@alexdong
alexdong / FLG360 to choir.io.js
Last active August 29, 2015 14:03
Takes a new lead webhook from FLG 360 and create a new event in choir.io
/*
To use this script, replace the {{YOUR_TORPIO_KEY}} with your torpio.io API key
and replace {{{{YOUR_CHOIR_IO_KEY}} with your choir.io key when you create an API source.
*/
var settings = {};
Verifying that +alexdong is my Bitcoin username. You can send me #bitcoin here: https://onename.io/alexdong
$ ht shell
hypertable> create table bookmarks (url);
Elapsed time: 0.03 s
hypertable> INSERT INTO bookmarks VALUES
-> ("homepage", "url", "http://alexdong.com");
Elapsed time: 0.00 s
Avg value size: 19.00 bytes
Total cells: 1
alexdong@clifton % date /opt/hypertable/current/log
Tue Jul 27 09:53:56 UTC 2010
alexdong@clifton % tail -n 5 Hypertable.RangeServer.log /opt/hypertable/current/log
STAT hits[550,2009-02-17 02:06:56,14739441..633,2009-10-27 22:20:04,7783332](default) cumulative_size 201426188 <= prune_threshold 867668958
STAT hits[633,2009-10-27 22:20:04,7783332..7428,2009-01-26 22:59:26,4197051](default) cumulative_size 201426188 <= prune_threshold 867668958
STAT hits[7428,2009-01-26 22:59:26,4197051..86059,2010-02-02 09:25:06,56699891](default) cumulative_size 353111255 <= prune_threshold 867668958
STAT hits[86059,2010-02-02 09:25:06,56699891..��](default) cumulative_size 353111255 <= prune_threshold 867668958
1280224430 INFO Hypertable.RangeServer : (/root/src/hypertable/src/cc/Hypertable/RangeServer/RangeServer.cc:2619) Memory Usage: 1170841532 bytes
alexdong@clifton % date
using python ;
# Specify that the boost-python library exists under the name
# boost_python. That is, because the library was installed at the
# standard search path as /usr/lib/libboost_python.so, bjam will find
# it automatically. No need to specify the absolute path.
# lib libboost_python : : <name>boost_python-mt ;
lib libboost_python : : <name>boost_python ;
lib libboost_date_time : : <name>boost_date_time ;
# Edit this path to point at the tools/build/v2 subdirectory of your
# Boost installation. Absolute paths work, too.
boost-build /usr/share/doc/libboost1.40-doc/examples/tools/build/v2/ ;
#include "boost/date_time/gregorian/gregorian.hpp"
#include "boost/date_time/posix_time/posix_time.hpp"
#include <boost/python.hpp>
#include <iostream>
#include <string>
int utc_date_str_to_int(const char* s, int offset) {
using namespace boost::gregorian;
using namespace boost::posix_time;