Skip to content

Instantly share code, notes, and snippets.

View manadream's full-sized avatar

manadream

View GitHub Profile
@manadream
manadream / ClearInputBuff.cpp
Created March 21, 2015 15:50
Clearing input buffer in C++ completely
#include <iostream>
#include <limits>
using namespace std;
int main(){
char var[10];
bool valid = false;
while(!valid){
cout << "Enter a string 9 characters long: ";
@manadream
manadream / getDevices.sh
Created March 21, 2015 16:30
Bash Script for connecting to and parsing android devices over adb
getDevices () {
DEVICES=($(adb devices | grep "device$" | sed -e "s|device||g"))
for i in {1..9}
do
FOUND=0
for j in ${DEVICES[@]}
do
if [ "$j" == "192.168.56.10${i}:5555" ]
then
FOUND=1
@manadream
manadream / mvnLauncher.sh
Created March 21, 2015 16:32
Executing maven with java options in shell script
eval $(echo mvn clean test $(echo -D$(printf cucumber.options=\"--tags\ "$TAGS"\"\ "$ARGS")))
@manadream
manadream / cucumberJvmRerun.sh
Last active August 29, 2015 14:17
Parsing Cucumber JVM rerun.txt to be used in subsequent run
RERUN_OPTIONS=$(sed -e "s|com/|classpath:com/|g" rerun.txt)
eval $(echo mvn clean test $(echo -D$(printf cucumber.options=\""$RERUN_OPTIONS"\"\ "$ARGS")))
@manadream
manadream / setAndTimezone.sh
Created March 21, 2015 16:39
Set Android Device timezone using adb
adb shell setprop persist.sys.timezone ${TIMEZONE}
@manadream
manadream / andOrientation.sh
Created March 21, 2015 16:45
Commands for setting android device orientation from shell
# first turn off accelerometer controlling the orientation
adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0
# then set orientation
shopt -s nocasematch
if [ "$ORIENTATION" == "portrait" ]
then
adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:0
elif [ "$ORIENTATION" == "landscape" ]
then
@manadream
manadream / IsDeviceTable.java
Created March 21, 2015 16:53
Java method for determining if android device is a tablet
public static boolean isDeviceTablet(String deviceId, int screenHeight, int screenWidth) {
try {
Process getDensity;
if (deviceId != null) {
getDensity = new ProcessBuilder("adb", "-s", deviceId, "shell", "getprop", "ro.sf.lcd_density").start();
} else {
getDensity = new ProcessBuilder("adb", "shell", "getprop", "ro.sf.lcd_density").start();
}
getDensity.waitFor();
int deviceDpi = Integer.parseInt(convertStreamToString(getDensity.getInputStream()).replaceAll("[^0-9]", ""));