Skip to content

Instantly share code, notes, and snippets.

from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
import time
def scroll(n):
device = MonkeyRunner.waitForConnection()
for i in range(n):
print i
device.drag((216, 500), (216, 200), 0.1, 100)
time.sleep(0.5)
scroll(10000)
var $ = require('jquery');
var http = require('http');
var Sync = require('sync');
var URIjs = require('./URI.js'); // http://medialize.github.com/URI.js/
var fs = require('fs');
var DEBUG = false;
var INFO = true;
var Log = { };
@billynyh
billynyh / bootstrap.html
Created December 24, 2012 07:01
Bootstrap 2.2.2 + font-awesome + jquery cdn quick start template
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 2.2.2 Template</title>
<!-- Bootstrap -->
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap.no-icons.min.css" rel="stylesheet">
<link href="http://netdna.bootstrapcdn.com/font-awesome/2.0/css/font-awesome.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/js/bootstrap.min.js"></script>
@billynyh
billynyh / gist:4276985
Created December 13, 2012 15:06
android pattern repeat drawable
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/leather_1"
android:tileMode="repeat" />
@billynyh
billynyh / RoundedCornerImageView.java
Created November 28, 2012 04:07
#android rounded corner ImageView
//http://stackoverflow.com/questions/1705239/how-should-i-give-images-rounded-corners-in-android
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.ImageView;
@billynyh
billynyh / gist:4043695
Created November 9, 2012 04:27
android monkeyrunner screencap
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
import datetime
def capture_and_save(fname):
device = MonkeyRunner.waitForConnection()
snapshot = device.takeSnapshot()
snapshot.writeToFile(fname)
def capture(prefix=""):
d = datetime.datetime.now()
@billynyh
billynyh / gist:4037680
Created November 8, 2012 09:10
iosched 2012 - handle fragment in onSaveInstanceState
// iosched/android/src/com/google/android/apps/iosched/ui/HomeActivity.java
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
// Since the pager fragments don't have known tags or IDs, the only way to persist the
// reference is to use putFragment/getFragment. Remember, we're not persisting the exact
// Fragment instance. This mechanism simply gives us a way to persist access to the
// 'current' fragment instance for the given fragment (which changes across orientation
@billynyh
billynyh / gist:3869877
Last active October 11, 2015 13:58
common command
# recursive cat
find . -name '*.php' | xargs wc -l
# format json
echo '{"json":"obj"}' | python -mjson.tool
# git diff
git difftool --tool=tkdiff --no-prompt
# grep
@billynyh
billynyh / gist:3779607
Created September 25, 2012 02:25
adb command list
// home intent
adb shell am start -c android.intent.category.HOME -a android.intent.action.MAIN
@billynyh
billynyh / gist:3719885
Created September 14, 2012 04:57
my android text helper : strike text, underline, decimal format
public class TextHelper {
public static SpannableString strikeText(String text){
if (text==null)text = "";
SpannableString str = new SpannableString(text);
str.setSpan(new StrikethroughSpan(), 0, str.length(), Spanned.SPAN_PARAGRAPH);
return str;
}
public static SpannableString underlineText(String text){
if (text==null)text = "";
SpannableString str = new SpannableString(text);