Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- created by WenQuanYi FcDesigner v0.5 -->
<match>
<test name="family"><string>sans-serif</string></test>
<edit name="family" mode="prepend" binding="strong">
<string>Droid Sans</string>
<string>WenQuanYi Micro Hei</string>
<string>DejaVu Sans</string>
@wuman
wuman / gist:5562157
Created May 12, 2013 02:20
get local ip address on android
static String getIPAddress(Context context) {
try {
for (NetworkInterface ni : Collections.list(NetworkInterface.getNetworkInterfaces())) {
for (InetAddress inetAddress : Collections.list(ni.getInetAddresses())) {
if (!inetAddress.isLoopbackAddress()) {
String address = inetAddress.getHostAddress().toUpperCase();
if (InetAddressUtils.isIPv4Address(address)) {
return address;
}
}
@wuman
wuman / android_volley_pom
Created May 22, 2013 07:16
sample maven pom for android volley library
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.android</groupId>
<artifactId>volley</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>volley</name>
@wuman
wuman / raced_slice.go
Created November 18, 2013 03:52
An example of a slice that should be protected against possible race conditions.
package main
import (
"math/rand"
)
func main() {
nroutines := 100
count := 100
m := make([]int, nroutines*count)
@wuman
wuman / protobuf.patch
Created November 25, 2013 07:28
Patch to protobuf for goprotobuf issue #32 (https://code.google.com/p/goprotobuf/issues/detail?id=32).
Index: src/google/protobuf/descriptor.proto
===================================================================
--- src/google/protobuf/descriptor.proto (revision 505)
+++ src/google/protobuf/descriptor.proto (working copy)
@@ -281,6 +281,8 @@
// placed. There is no default.
optional string go_package = 11;
+ // Sets the Go import path of structs generated from this .proto file.
+ optional string go_import_path = 12;
diff -r 61664b8425f3 protoc-gen-go/descriptor/descriptor.pb.go
--- a/protoc-gen-go/descriptor/descriptor.pb.go Fri Oct 11 10:08:35 2013 +1100
+++ b/protoc-gen-go/descriptor/descriptor.pb.go Sat Nov 23 23:39:44 2013 +0800
@@ -682,7 +682,8 @@
OptimizeFor *FileOptions_OptimizeMode `protobuf:"varint,9,opt,name=optimize_for,enum=google.protobuf.FileOptions_OptimizeMode,def=1" json:"optimize_for,omitempty"`
// Sets the Go package where structs generated from this .proto will be
// placed. There is no default.
- GoPackage *string `protobuf:"bytes,11,opt,name=go_package" json:"go_package,omitempty"`
+ GoPackage *string `protobuf:"bytes,11,opt,name=go_package" json:"go_package,omitempty"`
+ GoImportPath *string `protobuf:"bytes,12,opt,name=go_import_path" json:"go_import_path,omitempty"`
@wuman
wuman / gist:6f5d651769d742136e2c
Created May 28, 2014 09:54
Proguard error running connectedAndroidTest on deckard-gradle
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.3 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties.
Deprecated dynamic property: "destinationDir" on "task ':testDebugClasses'", value: "/home/david/projects/r...".
:clean
:preBuild
:compileDebugNdk
:preDebugBuild
@wuman
wuman / gist:0648395f7c6866f6ca55
Created June 17, 2014 02:48
robolectric deckard-gradle espresso proguard error
WARNING: Dependency commons-logging:commons-logging:1.1.1 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.3 is ignored for debugTest as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties.
Deprecated dynamic property: "destinationDir" on "task ':testDebugClasses'", value: "/home/david/projects/r...".
:clean
:preBuild
:compileDebugNdk
:preDebugBuild
@wuman
wuman / dagger2.diff
Created January 19, 2015 09:24
Dagger2 example fix
diff --git a/compiler/pom.xml b/compiler/pom.xml
index 8c67461..26b612c 100644
--- a/compiler/pom.xml
+++ b/compiler/pom.xml
@@ -57,7 +57,6 @@
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
- <version>1.0-SNAPSHOT</version>
<optional>true</optional>
@wuman
wuman / nexus_6_android_m_logcat
Created June 6, 2015 03:11
adb logcat output on Nexus 6 and Android M Preview
06-06 11:10:37.490 2830 3273 D WifiHAL : Stopping GScan
06-06 11:10:37.490 2830 3273 D WifiHAL : Stopping scan
06-06 11:10:37.492 2830 3273 D wifi : Initialized common fields 60000, 25, 100, 10
06-06 11:10:37.492 2830 3273 D wifi : bucket[0] = 4:3:60000:0
06-06 11:10:37.492 2830 3273 D WifiHAL : Starting GScan, halHandle = 0xaf11a640
06-06 11:10:37.492 2830 3273 D WifiHAL : GSCAN start
06-06 11:10:37.492 2830 3273 I WifiHAL : bucket 0: period 60000 band 3 report 0
06-06 11:10:37.492 2830 3273 D WifiHAL : ....starting scan