This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
result_str = str(result) | |
for ch in result_str: | |
device.touch(getx(ch), gety(ch), 'DOWN_AND_UP') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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 ' ' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice | |
filename = '1.png' | |
device = MonkeyRunner.waitForConnection() | |
device.takeSnapshot().getSubImage((10, 10, 220, 40)).writeToFile(filename, 'png') |