In computing, memoization or memoisation
is an optimization technique used primarily
to speed up computer programs by storing
the results of expensive function calls and
returning the cached result when the same
inputs occur again.
— wikipedia
#include <string.h> | |
#include <cstring> | |
#include <fstream> | |
#include <iostream> | |
std::string dir = "/data/data/uk.lgl.modmenu/cache/imei"; | |
std::string buf = "whatever"; | |
std::ifstream myfile(dir); | |
if (!myfile.is_open()) { | |
std::ofstream os(dir.c_str(), std::ios::trunc); |
-
Install Termux, an Android terminal emulator that provides a Linux execution environment and various tools.
-
Update system packages in Termux:
$ pkg update -y
It's a lot easier to test accessibility on the fly using ADB. This gist attempts to make the days of navigating through the Android device settings UI to change Accessibility settings obsolete.
These ADB commands will hopefully encourage Android developers to test and use their apps with common Accessiblility settings enabled.
Credit to James Nitsch for inspiring this, and for figuring out the put
commands to enable these settings.
/* | |
This method can be used to download an image from the internet using a url in Android. This use Android Download Manager to | |
download the file and added it to the Gallery. Downloaded image will be saved to "Pictures" | |
Folder in your internal storage | |
*/ | |
private void downloadImageNew(String filename, String downloadUrlOfImage){ | |
try{ | |
DownloadManager dm = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); | |
Uri downloadUri = Uri.parse(downloadUrlOfImage); |
# arm | |
export PATH=$PATH:$HOME/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin | |
export CC=armv7a-linux-androideabi19-clang | |
export CXX=armv7a-linux-androideabi19-clang++ | |
~/.cargo/bin/cargo build --target armv7-linux-androideabi | |
# aarch64 | |
export PATH=$PATH:$HOME/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin | |
export CC=aarch64-linux-android21-clang | |
export CXX=aarch64-linux-android21-clang++ |
//How it works: all the script relies on a tiny javascript stub injected to webView's document that uses Proxy api and json serialicing stuff. Calls to our internal objects are proxified to a single method "__mm_handle_method", that using reflection find the target method and populate arguments exchanged in json, plus a custom interface for methods passed as argument. | |
package es.pabloko.webviewbridge; | |
import android.app.Activity; | |
import android.content.Context; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.util.Log; | |
import android.webkit.JavascriptInterface; |
A collection of Markdown code and tricks that were tested to work in Gist.
This and all public gists in https://gist.github.com/ww9 are Public Domain. Do whatever you want with it including , no need to credit me.
- Reformat this whole document and assimilate these:
// Discord all events! | |
// A quick and dirty fleshing out of the discord.js event listeners (not tested at all!) | |
// listed here -> https://discord.js.org/#/docs/main/stable/class/Client | |
// Learn from this, do not just copy it mofo! | |
// | |
// Saved to -> https://gist.github.com/koad/316b265a91d933fd1b62dddfcc3ff584 | |
// Last Updated -> Halloween 2022 | |
/* |
#!/system/bin/sh | |
[ "$(whoami)" != "root" ] && { echo "root required"; exit 1; } | |
configs=( /data/misc/wifi/WifiConfigStore.xml /data/misc/apexdata/com.android.wifi/WifiConfigStore.xml ) | |
for z in ${configs[@]}; do | |
if [ -f $z ]; then | |
config=$z | |
break | |
fi | |
done |