Skip to content

Instantly share code, notes, and snippets.

View alexdong's full-sized avatar

Alex Dong alexdong

  • Dunedin, New Zealand
  • 10:47 (UTC -12:00)
  • X @alexdong
View GitHub Profile
@alexdong
alexdong / ambush.sh
Last active December 19, 2015 23:29
Some short-lifed Android apps will quit before we had a chance to attach strace to it and inspect its internal state. So this script will put itself in an endless loop and wait for the certain process to show up. Once the process appears, it will attach the strace to it and start writing output to a log file.
#!/system/bin/sh
#
# Attach strace to a process as soon as it starts up.
#
# Some short-lifed Android apps will quit before we
# had a chance to attach strace to it and inspect its
# internal state. So this script will put itself in
# an endless loop and wait for the certain process to
# show up. Once the process appears, it will attach
@alexdong
alexdong / git archeology
Last active December 17, 2015 14:39
Git commands to grep through historical patches
git log --no-merges --format="%ad %s" -i --grep=invite
> db.stats()
{
"collections" : 31,
"objects" : 33273261,
"avgObjSize" : 276.750695520947,
"dataSize" : 9208398124,
"storageSize" : 10635470336,
"numExtents" : 242,
"indexes" : 58,
"indexSize" : 10991725824,
@alexdong
alexdong / punch_card_visualizing_chi.html
Created November 16, 2010 13:53
Django template for visualizing Customer Happiness Index
{% load usage %}
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Trunkly · Punch Chart</title>
<style>
body { margin: 30px auto; width: 800px; background-color:#333; }
div { background-color: green; }
a { color: #eee; font-size:11px; text-decoration:none; }
</style>
#!/bin/sh
# the basic boost library
sudo apt-get install libboost-dev
# install the boost.python library
sudo apt-get install libboost-python-dev
# install the extra libraries we need
sudo apt-get install libboost-date-time-dev
#!/usr/bin/env python
import plumrain
s = "2010-10-9 8:12:00"
print plumrain.utc_date_str_to_int(s, 10)
#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;
# 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/ ;
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 ;
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