Skip to content

Instantly share code, notes, and snippets.

View alexdong's full-sized avatar

Alex Dong alexdong

  • Dunedin, New Zealand
  • 12:49 (UTC -12:00)
  • X @alexdong
View GitHub Profile
#!/bin/sh
echo "Decompile into smali format ..."
apktool b ${1} /tmp/${1}-pack.apk
echo "\n\nSign the package. Password is mykey ..."
jarsigner -sigalg SHA1withRSA -digestalg SHA1 -keystore mykey.keystore /tmp/${1}-pack.apk mykey
echo "\n\nZip align the apk ..."
zipalign -f -v 4 /tmp/${1}-pack.apk /tmp/${1}.apk
@alexdong
alexdong / threadpool.py
Created July 20, 2013 00:58
Guess a random number using a home-made ThreadPool.
import random
import threading
class ThreadPool(object):
def __init__(self, pool_size):
self.pool_size = pool_size
self.threads = []
def wait_for_thread(self):
@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/ ;