Skip to content

Instantly share code, notes, and snippets.

@Ider
Ider / android_screen_capture.sh
Last active September 11, 2018 20:05
Capture or record android screen, pull file to Mac when it's completed
# Demo: https://www.youtube.com/watch?v=4GsUf5OQAlI
# capture screen of android device
andrdroidScreenCapture() {
curTime=`date +%Y-%m-%d-%H-%M-%S`
tmpeName="$curTime.png"
[[ -n $1 ]] && fileName=$1 || fileName=$tmpeName
devicePath="/sdcard/$tmpeName"
adb shell screencap -p $devicePath
adb pull $devicePath $fileName
@Ider
Ider / notify.sh
Created September 10, 2015 20:46
Send out notification in Mac
#!/bin/bash
notification="display notification \"$1\" sound name \"\""
if [[ $2 ]]; then
notification="$notification with title \"$2\""
fi
osascript -e "$notification"
@Ider
Ider / title.sh
Created December 12, 2014 22:40
Change the terminal title in Mac OS
title() {
echo -n -e "\033]0;$@\007"
}
# usage:
# title hello world
@Ider
Ider / adb-dump-activities.sh
Created December 4, 2014 05:01
dump android activities stack
adb shell dumpsys activity activities | sed -En -e '/Running activities/,/Run #0/p'
@Ider
Ider / andrdroidScreenCapture.sh
Created August 1, 2014 23:40
Capture screen of android device with command
# capture screen of android device
andrdroidScreenCapture() {
curTime=`date +%Y-%m-%d-%H-%M-%S`
name="/sdcard/$curTime.png"
adb shell screencap -p $name
adb pull $name $1
adb shell rm $name
}
alias asc=andrdroidScreenCapture
@Ider
Ider / __func__.java
Created July 16, 2014 19:28
Log the called function name in Android
Log.d("IDER", Thread.currentThread().getStackTrace()[2] + "()");
@Ider
Ider / git-append
Created June 20, 2014 19:01
Quick append all changes to previous commit without change message
git commit -a --amend --no-edit
@Ider
Ider / idx.php
Created March 3, 2014 19:36
Safe way to get index from array with default return value even if key dose not exist
/**
* Get value from $array with index or indics given by $keyOrKeys.
* @param array $array The array to get value from.
* @param mixed $keyOrKeys A single key, or a numeric array that contains multiple keys
* to fetch from multidimensional array.
* Key cound be either numeric or string.
* If emtpy array given, the original $array will be returned.
* @param mixed $default The default value to be returned if the array dose not contain
* given key or midway value is not array type.
* @return mixed The value that associated in $array.
@Ider
Ider / NodeList.forEach.js
Created November 22, 2013 01:21
Extend NodeList.prototype with Array.prototype.forEach, hence we could call forEach on return value of document.querySelectorAll().
NodeList.prototype.forEach = Array.prototype.forEach;
@Ider
Ider / Observer.java
Created November 5, 2013 21:27
This class represents an generic observer/listener pattern.
package com.iderzheng.util;
import java.util.HashSet;
import java.util.Set;
/**
* This class represents an generic observer object.
*
* @author Ider Zheng
* @since 10/31/13.