Skip to content

Instantly share code, notes, and snippets.

View mingyuan-xia's full-sized avatar

Mingyuan Xia mingyuan-xia

View GitHub Profile
@mingyuan-xia
mingyuan-xia / test-appetizer-toolkit-replays.sh
Created March 24, 2017 08:25
Test the visual difference caused by replay with appetizer-toolkit
#!/bin/bash
PKG=com.paijwar.drawithme # the package name of the app to be launched
WAITTIME=3 # seconds to wait after starting the app
REPEAT=2 # number of replays
DEVICE=xxxxxx # device serialno
echo 'Make sure you have ImageMagick'
./appetizer devices control $DEVICE launch_pkg $PKG
sleep $WAITTIME
echo '1. When recording starts, perform some complicated gestures, type exit to finish'
@mingyuan-xia
mingyuan-xia / py-json-proc
Created March 11, 2017 18:13
Control a process that produces JSON output in Python
# -*- coding: utf-8 -*-
import subprocess
import time
import os
import fcntl
import json
from datastruct import truncate_string
from colorprint import print_warning, print_emph
@mingyuan-xia
mingyuan-xia / py-term-colorful
Created March 11, 2017 18:12
Make Python terminal output colorful
# -*- coding: utf-8 -*-
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
@mingyuan-xia
mingyuan-xia / py-cmd-file-autocomp.py
Created March 11, 2017 18:11
Autocompletion support for file paths for Python cmd library
# -*- coding: utf-8 -*-
import os
import glob
def _append_slash_if_dir(p):
if p and os.path.isdir(p) and p[-1] != os.sep:
return p + os.sep
else: