Skip to content

Instantly share code, notes, and snippets.

@border
border / urlencode.sh
Created November 1, 2013 09:05
Shell for urlencode
#!/bin/bash
if [ -z "$1" ]
then
echo "usage: ./urlencode.sh 'hello'"
exit 0
fi
echo -n $( php -r "echo rawurlencode(\"$1\");"; )
@border
border / proguard-android.txt
Created October 29, 2013 08:55
proguard for android
-optimizationpasses 5 # 指定代码的压缩级别
-dontusemixedcaseclassnames # 是否使用大小写混合
-dontskipnonpubliclibraryclasses # 是否混淆第三方jar
-dontpreverify # 混淆时是否做预校验
-keepattributes SourceFile,LineNumberTable # 混淆号错误信息里带上代码行
-verbose # 混淆时是否记录日志
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* # 混淆时所采用的算法
-libraryjars libs/android_api.jar
-libraryjars libs/baidumapapi_v2_2_0.jar
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
@border
border / keystone.conf
Created November 14, 2012 04:07
Openstack keystone install
[DEFAULT]
# A "shared secret" between keystone and other openstack services
admin_token = ADMIN
# The IP address of the network interface to listen on
bind_host = 0.0.0.0
# The port number which the public service listens on
public_port = 5000
@border
border / cpu.sh
Created November 13, 2012 02:05
取得CPU利用率
#!/bin/sh
##echo user nice system idle iowait irq softirq
CPULOG_1=$(cat /proc/stat | grep 'cpu ' | awk '{print $2" "$3" "$4" "$5" "$6" "$7" "$8}')
SYS_IDLE_1=$(echo $CPULOG_1 | awk '{print $4}')
Total_1=$(echo $CPULOG_1 | awk '{print $1+$2+$3+$4+$5+$6+$7}')
sleep 5
CPULOG_2=$(cat /proc/stat | grep 'cpu ' | awk '{print $2" "$3" "$4" "$5" "$6" "$7" "$8}')
@border
border / diff.diff
Created October 25, 2012 03:28
Golang mutex and RWMutex 测试比较
~ ✗ diff -ruN mutex.go mutexv2.go
--- mutex.go 2012-10-25 11:30:04.170656858 +0800
+++ mutexv2.go 2012-10-25 11:30:04.174656858 +0800
@@ -9,8 +9,9 @@
)
type Msg struct {
- mutex sync.Mutex
- count map[int64]string
+ rmutex sync.RWMutex
@border
border / hijackclient.go
Created September 26, 2012 06:03
Http Hijack longpolling
package main
import (
"flag"
"fmt"
"net"
"net/http"
"net/http/httputil"
"net/url"
"time"
@border
border / long_polling.go
Created September 25, 2012 09:58
long polling for golang
package main
import (
"container/list"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
@border
border / monitormem.go
Created September 18, 2012 10:03
monitormem.go
package main
import (
"fmt"
"syscall"
"time"
)
const (
Megabyte = 1024 * 1024
@border
border / fetchv1.go
Created September 6, 2012 01:25
启动100个goroutines去抓取URL,这100个抓取完后再继续下一组, v2版本更简洁明了,
package main
import (
"fmt"
"runtime"
"sync"
"time"
)
const MAX = 100