Skip to content

Instantly share code, notes, and snippets.

View simpleton's full-sized avatar
👷‍♂️
Hello World

Sim Sun simpleton

👷‍♂️
Hello World
View GitHub Profile
@simpleton
simpleton / webview.java
Created September 5, 2012 03:33
html5 custom view
private class MyWebChromeClient extends WebChromeClient {
private Bitmap mDefaultVideoPoster;
private View mVideoProgressView;
@Override
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback)
{
//Log.i(LOGTAG, "here in on ShowCustomView");
HTML5WebView.this.setVisibility(View.GONE);
@simpleton
simpleton / Singleton.py
Created September 15, 2012 16:42
Singleton implement by metaclass
class Singleton(type):
def __init__(cls, name, bases, dict):
super(Singleton, cls).__init__(name, bases, dict)
cls.instance = None
def __call__(cls, *args, **kw):
if cls.instance is None:
cls.instance = super(Singleton, cls).__call__(*args, **kw)
return cls.instance
@simpleton
simpleton / OrgProvider.java
Created May 21, 2013 10:20
OrgProvider.java
private enum UriType {
DEPARTMENT( "#/" + DB_Department.TABLE_NAME , DB_Department.TABLE_NAME, DB_Department.TYPE_ELEM_TYPE),
COLLEGUE("#/" + DB_Collegue.TABLE_NAME, DB_Collegue.TABLE_NAME, DB_Collegue.TYPE_ELEM_TYPE),
COLLEGUE_RELATION("#/" + DB_Collegue_relation.TABLE_NAME, DB_Collegue_relation.TABLE_NAME, DB_Collegue_relation.TYPE_ELEM_TYPE),
DEPARTMENT_RELATION("#/" + DB_Department_relation.TABLE_NAME, DB_Department_relation.TABLE_NAME, DB_Department_relation.TYPE_ELEM_TYPE),
DEPARTMENT_UIN( "#/" + DB_Department.TABLE_NAME + "/UIN/#", DB_Department.TABLE_NAME, DB_Department.TYPE_ELEM_TYPE),
COLLEGUE_CorpUIN("#/" + DB_Collegue.TABLE_NAME + "/UIN/#", DB_Collegue.TABLE_NAME, DB_Collegue.TYPE_ELEM_TYPE),
COLLEGUE_RELATION_UIN("#/" + DB_Collegue_relation.TABLE_NAME + "/UIN/#", DB_Collegue_relation.TABLE_NAME, DB_Collegue_relation.TYPE_ELEM_TYPE),
DEPARTMENT_RELATION_CorpUIN("#/" + DB_Department_relation.TABLE_NAME + "/UIN/#", DB_Department_relation.TABLE_NAME, DB_De
@simpleton
simpleton / RequestMaker.java
Last active December 18, 2015 09:19
build facebook signed request in hmac-sha256 method
//http://en.wikipedia.org/wiki/Base64#URL_applications
//http://stackoverflow.com/questions/11106393/url-safe-base64-in-objective-c
//http://stackoverflow.com/questions/10812140/facebook-signed-request-for-ios-hmac-sha256
public class RequestMaker {
private static final String KEY = "testkey";
private static final int BASE64_FLAG = Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING | Base64.NO_CLOSE;
public RequestMaker() {
}
public String getRequestPayload(String token, String user_id, String expires) {
//java code
public class MainActivity extends Activity {
private WebView webView;
private static final String TAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
this.webView = (WebView) findViewById(R.id.webview);
#btn_download {
background: url("../images/download-normal.png") no-repeat scroll center top transparent;
display: block;
height: 54px;
width: 190px;
margin-top: 50px;
}
#btn_download:active {
background: url("../images/download-down.png") no-repeat bottom;
public class RSAEncrypt {
private static final String DEFAULT_PUBLIC_KEY=
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQChDzcjw/rWgFwnxunbKp7/4e8w" + "\r" +
"/UmXx2jk6qEEn69t6N2R1i/LmcyDT1xr/T2AHGOiXNQ5V8W4iCaaeNawi7aJaRht" + "\r" +
"Vx1uOH/2U378fscEESEG8XDqll0GCfB1/TjKI2aitVSzXOtRs8kYgGU78f7VmDNg" + "\r" +
"XIlk3gdhnzh+uoEQywIDAQAB" + "\r";
private static final String DEFAULT_PRIVATE_KEY=
"MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAKEPNyPD+taAXCfG" + "\r" +

从 svn 迁移到 gitlab

找出所有提交者

$ svn log --xml | grep author | sort -u | perl -pe 's/.>(.?)<./$1 = /'

手动设置对应关系 users.txt

@simpleton
simpleton / dex.sh
Created February 24, 2014 09:55 — forked from JakeWharton/dex.sh
function dex-method-count() {
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
}
function dex-method-count-by-package() {
dir=$(mktemp -d -t dex)
baksmali $1 -o $dir
for pkg in `find $dir/* -type d`; do
smali $pkg -o $pkg/classes.dex
count=$(dex-method-count $pkg/classes.dex)
name=$(echo ${pkg:(${#dir} + 1)} | tr '/' '.')
@simpleton
simpleton / ManifestMerger.py
Last active August 29, 2015 13:56
ManifestMerger
from xml.etree import ElementTree as ET
import glob
import sys
import os
class ManifestMerger(object):
def __init__(self, app_manifest, filenames):
assert len(filenames) > 0, 'No filenames!'
ET.register_namespace("android", "http://schemas.android.com/apk/res/android")
print app_manifest