Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Shooting Star

Kaede Akatsuki kaedea

🎯
Shooting Star
View GitHub Profile
@kaedea
kaedea / NativeCrashUtils.java
Created Jul 1, 2020
Utility to trigger native crash in Android
View NativeCrashUtils.java
public class NativeCrashUtils {
public static void crashNatively() {
try {
Class<?> clazz = Class.forName("dalvik.system.VMDebug");
Method method = reflectMethod(clazz, "crash");
method.setAccessible(true);
method.invoke(null);
} catch (Exception e) {
e.printStackTrace();
@kaedea
kaedea / retrace.sh
Created Oct 21, 2019
Retrace proguard stacktrace by copy-paste
View retrace.sh
# ENV
retraceJar=~/retrace/retrace-*.jar
# get input
mapping=$1
if [ ! "$mapping" ];then
read -p "Input mapping file path: " mapping
fi
if [ ! -f "$mapping" ];then
echo "mapping is not file"
View python-http-client.py
# HTTP REQUEST
def http_request(url, method=None, post_data=None, headers=None):
'''
Args:
url: HTTP URL
method: GET/POST/..
post_data: <dict>
headers: <dict>
Returns: <dict> or None
@kaedea
kaedea / start-stop-server-in-background.sh
Created Aug 13, 2019 — forked from pwittchen/start-stop-server-in-background.sh
Starting and stopping simple HTTP server in background on Linux. After starting server and closing terminal, server should keep running
View start-stop-server-in-background.sh
# starting simple HTTP server with Python in background
screen -d -m python -m SimpleHTTPServer 7777
# killing process running with screen in background
kill -9 `top -n 1 | pgrep screen`
View Dispatcher.java
/**
* Task dispatcher interface.
* Using {@linkplain Maker} to build instance in a simple way.
*
* @author kaede
* @version date 16/10/19
*/
public interface Dispatcher {
String TAG = "task.dispatcher";
@kaedea
kaedea / Latch.java
Created Sep 13, 2016
Synchronize helper class in TestCase.
View Latch.java
public class Latch {
volatile boolean isNotified;
public synchronized void tryNotify() {
isNotified = true;
notify();
}
public synchronized void tryWait(long millis) {
try {
@kaedea
kaedea / Locker.java
Created Sep 7, 2016
Java process-safe locker
View Locker.java
/**
* Multi-process lock
*
* @author kaede
* @version date 16/9/6
*/
class Locker {
public static final int EXPIRED_TIME = 30 * 60 * 1000; // 30 minutes
@kaedea
kaedea / android_h5_monitor.js
Last active Aug 31, 2016
JavaScript for monitoring Android WebView performance.
View android_h5_monitor.js
window.addEventListener('DOMContentLoaded',
function() {
prompt('domc:' + window.app.getCurrentTime());
})
window.addEventListener('load',
function() {
prompt('load:' + window.app.getCurrentTime());
})
View MediaCodecInfoTest.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void testMediaCodecInfo() {
// list media codec
int numCodec = MediaCodecList.getCodecCount();
for (int i = 0; i < numCodec; i++) {
MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
Log.i(TAG, "[kaede][testMediaCodecInfo]" +
"=================================== " + codecInfo.getName() + " ===================================");
boolean isEncoder = codecInfo.isEncoder();
Log.d(TAG, "isEncoder = " + isEncoder);
You can’t perform that action at this time.