Skip to content

Instantly share code, notes, and snippets.

View kaedea's full-sized avatar
:electron:
Shooting Star

Kaede Akatsuki kaedea

:electron:
Shooting Star
View GitHub Profile
@kaedea
kaedea / NativeCrashUtils.java
Created July 1, 2020 13:03
Utility to trigger native crash in Android
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 / xxx.sh
Last active November 24, 2020 17:52
Mount EFI
#!/bin/bash
# sh xxx.sh <password>
input=$1
if [ ! "$input" ];then
input="default password"
fi
set -e
diskName=$(echo $input | sudo -S diskutil list | grep -e "EFI" | awk '{ print $3 }' | sed -n '1p')
@kaedea
kaedea / MediaCodecInfoTest.java
Created July 27, 2016 08:12
get MediaCodecInfo
@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);
@kaedea
kaedea / retrace.sh
Created October 21, 2019 15:38
Retrace proguard stacktrace by copy-paste
# 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"
# 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 August 13, 2019 13:38 — 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
# 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`
@kaedea
kaedea / Dispatcher.java
Created October 19, 2016 08:59
Task dispatcher.
/**
* 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 September 13, 2016 09:13
Synchronize helper class in TestCase.
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 September 7, 2016 07:03
Java process-safe locker
/**
* 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 August 31, 2016 08:30
JavaScript for monitoring Android WebView performance.
window.addEventListener('DOMContentLoaded',
function() {
prompt('domc:' + window.app.getCurrentTime());
})
window.addEventListener('load',
function() {
prompt('load:' + window.app.getCurrentTime());
})