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

从 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
private List<WeakReference<IFileDownloader.IFileDownloadCallBack> > callbackList
= Collections.synchronizedList(new ArrayList<WeakReference<IFileDownloader.IFileDownloadCallBack>>());
public void addCallback(IFileDownloader.IFileDownloadCallBack cb) {
if (cb != null) {
for (int i=0; i < callbackList.size(); ++i) {
IFileDownloader.IFileDownloadCallBack callback = callbackList.get(i).get();
if (callback == cb) {
return;
}
public class Main {
public static void main(String[] args) {
try {
System.out.println(encrypt("12345678", "abc", "12345678"));
System.out.println(encrypt("12345678", "ABC", "12345678"));
System.out.println(decrypt("12345678", "9YR6ZPdZufM=", "12345678"));
System.out.println(decrypt("12345678", "6rtTnrF34mPkJ5SO3RiaaQ==", "12345678"));
@simpleton
simpleton / introrx.md
Last active August 29, 2015 14:19 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called Reactive Programming, particularly its variant comprising of Rx, Bacon.js, RAC, and others.

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

@simpleton
simpleton / Android插件相关
Last active August 29, 2015 14:20
Android plugin
Android插件化
===================
[TOC]
Proguard
-------------------
proguard是原生支持keepmapping的,可以直接导入一个mapping文件,保证混淆的一致性,但是我当时做犯了一个错误,就是试图保证所有的mapping文件都一致,但是proguard混淆函数的算法是顺序的,后续导致会有不可避免的冲突发生。现在我想到有2种方法可以避免这个发生:
1. 更改proguard函数生成算法,用更长的签名来做作用域,给每个命名空间留出足够的空间来填充增加的函数;
2. 抽象出sdk类函数,保证这一部分函数的对下一致。不保证插件函数可以keep。
@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 / gist:c2c1c15bd0bba78bff49
Created October 22, 2015 14:22 — forked from amichaelgrant/gist:90d99d7d5d48bf8fd209
failed (104: Connection reset by peer) while reading response header from upstream, client:
failed (104: Connection reset by peer) while reading response header from upstream, client:
If you are getting the above error in nginx logs running in from of upstream servers you may consider doing this as it worked for me:
check the ulimit on the machines and ensure it is high enough to handle the load coming in. 'ulimit' on linux, I am told determines the maximum number of open files the kernel can handle.
The way I did that?
modifying limits: for open files:
--------------------------------
add or change this line in /etc/systcl.conf
fs.file-max = <limit-number>