Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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;
}
}
<?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>