Skip to content

Instantly share code, notes, and snippets.

Vignesh Venkat vickyg3

Block or report user

Report or block vickyg3

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@vickyg3
vickyg3 / temple_runner.py
Created Jun 23, 2012
Temple runner controller
View temple_runner.py
#! /home/vignesh/android-sdk-linux/tools/monkeyrunner
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
import sys
def jump():
global device
device.drag((400,900), (400, 800), 0.25)
def duck():
@vickyg3
vickyg3 / sample_controller.py
Created Jun 23, 2012
Sample monkeyrunner code
View sample_controller.py
#! /path_to_sdk/tools/monkeyrunner
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
print 'waiting for device'
device = MonkeyRunner.waitForConnection()
print 'device attached'
# the body will probably go like this
while True:
View kid_vs_programmer.py
#! /usr/bin/python
import numpy.linalg as lin
def get_values(s):
lhs, rhs = s.split("=")
sparts = map(int, lhs)
freq = dict((i, sparts.count(i)) for i in set(sparts))
return ([freq.get(i,0) for i in range(10)], int(rhs))
@vickyg3
vickyg3 / auto_math_workout.py
Created Aug 8, 2011
Hacking Math Workout with OCR
View auto_math_workout.py
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
import os
import time
import math
import re
def getx(n):
if n in ('1', '4', '7'):
return 50
elif n in ('2', '5', '8', '0'):
@vickyg3
vickyg3 / gist:1132371
Created Aug 8, 2011
Touch simulation
View gist:1132371
result_str = str(result)
for ch in result_str:
device.touch(getx(ch), gety(ch), 'DOWN_AND_UP')
View result_eval.py
percent = re.compile(r'([0-9]+)\%of([0-9]+)')
question = os.popen("./ocr.sh %s" % filename).read()
if '+' not in question and '-' not in question and '/' not in question and '*' not in question and '%' not in question and 'i' not in question:
result = int(question[0:-1]) * int(question[0:-1])
elif '%' in question:
result = int(percent.search(question).group(1)) * int(percent.search(question).group(2)) / 100;
else:
result = eval(question)
@vickyg3
vickyg3 / ocr.sh
Created Aug 8, 2011
PNG Conversion and OCR
View ocr.sh
#! /bin/bash
pngtopnm $1 |
ocrad --format=utf8 --filter=numbers |
sed -r -e 's/x/\*/' -e 's/÷/\//' -e 's/\_([0-9]+)/int\(math\.sqrt\(\1\)\)/' |
tr -d '\n' |
tr -d ' '
View snapshot.py
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
filename = '1.png'
device = MonkeyRunner.waitForConnection()
device.takeSnapshot().getSubImage((10, 10, 220, 40)).writeToFile(filename, 'png')
You can’t perform that action at this time.