Skip to content

Instantly share code, notes, and snippets.

@WanghongLin
WanghongLin / WebViewDataSourceReflect.java
Created December 26, 2014 02:13
Get webview html5 video data source from Java reflections
import android.net.Uri;
import android.util.Log;
import android.webkit.WebView;
/**
* using java reflect method to get html5 video data source
*/
public class WebViewDataSourceReflect {
private static final String TAG = WebViewDataSourceReflect.class.getSimpleName();
@WanghongLin
WanghongLin / WebViewHttpProxy.java
Created December 26, 2014 02:31
Android WebView http proxy setting
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.apache.http.HttpHost;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.net.Proxy;
@WanghongLin
WanghongLin / prebuilt.diff
Created December 26, 2014 02:40
dex optimization for prebuilt apk in aosp build system
Index: core/prebuilt.mk
===================================================================
--- core/prebuilt.mk (revision 2966)
+++ core/prebuilt.mk (working copy)
@@ -16,6 +16,16 @@
$(error dont use LOCAL_PREBUILT_JAVA_LIBRARIES anymore LOCAL_PATH=$(LOCAL_PATH))
endif
+#ifneq ($(filter APPS,$(LOCAL_MODULE_CLASS)),)
+# ifeq (true,$(WITH_DEXPREOPT))
@WanghongLin
WanghongLin / cscope_kernel.sh
Created December 26, 2014 05:33
bash script file to generate ctags and cscope data file for linux kernel project
#!/bin/bash
function usage()
{
echo "Usage: $0 kerneldir arch"
exit 1
}
if [ "$1" == "" -o "$2" == "" ]
then
@WanghongLin
WanghongLin / color.sh
Created December 26, 2014 05:39
echo a bunch of colors to terminal
#!/bin/bash
#
# This file echoes a bunch of color codes to the
# terminal to demonstrate what's available. Each
# line is the color code of one forground color,
# out of 17 (default + 16 escapes), followed by a
# test use of that color on all nine background
# colors (default + 8 escapes).
#
# Author: Giles Orr
@WanghongLin
WanghongLin / color.sh
Created December 26, 2014 06:28
A simple shell script to output an ANSI terminal color chart
#!/bin/sh
#
# colors v1.03
#
# A simple shell script to output an ANSI terminal color chart.
# It may be useful when trying to customize your ANSI terminal
# color scheme!
#
# Written and placed in the public domain by Ian Abbott <ian@abbott.org>
#
@WanghongLin
WanghongLin / settings.xml
Created January 8, 2015 13:09
m2eclipse proxy setting template
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<proxies>
<proxy>
<id>proxy</id>
<active>true</active>
<protocol>http</protocol>
<host>192.168.1.254</host>
@WanghongLin
WanghongLin / Proxy.md
Last active August 29, 2015 14:13
Proxy configuration collections

A collection usage of proxy with different commandline tools in Linux

  • gradle

The command gradlew is wrapper of jar file, the proxy setting is the same with the standard Java proxy setting.

./gradlew -DsocksProxyHost=127.0.0.1 -DsocksProxyPort=5000 tasks
  • hg
@WanghongLin
WanghongLin / build.gradle
Last active August 29, 2015 14:13
add android framework library in android studio
buildscript {
repositories {
flatDir { dirs '../FrameworkJars' }
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
}
}
apply plugin: 'android'
@WanghongLin
WanghongLin / DESDemo.java
Created February 3, 2015 11:44
DES example
public class PrivateExample {
public static void main(String[] args) throws Exception {
KeyGenerator keyGenerator = KeyGenerator.getInstance("DES");
SecretKey secretKey = keyGenerator.generateKey();
String desString = Base64.encodeBase64String(secretKey.getEncoded());
System.out.println("DES Base64 String: " + desString);