Skip to content

Instantly share code, notes, and snippets.

View theeasiestway's full-sized avatar
👉
👈

theeasiestway

👉
👈
View GitHub Profile
@theeasiestway
theeasiestway / .gitignore
Last active February 11, 2020 08:08
The gitignore file for Android Studio
*.iml
.gradle
/local.properties
/.idea
.DS_Store
/build
/captures
*.cxx
app/.cxx/*
.externalNativeBuild
@theeasiestway
theeasiestway / gist:20e0b961f11d56e6a3e0dbbf32f5678b
Last active October 24, 2019 07:23
The most important commands for Git
# Set a new remote
$ git remote add origin https://github.com/user/repo.git
# Update a remote url
$ git remote set-url origin https://github.com/user/repo.git
# Verify new remote
$ git remote -v
> origin https://github.com/user/repo.git (fetch)
> origin https://github.com/user/repo.git (push)
@theeasiestway
theeasiestway / DecodeActivity.java
Created March 13, 2020 07:27 — forked from waveacme/DecodeActivity.java
MediaCodec decode h264 example
//from https://github.com/vecio/MediaCodecDemo
package io.vec.demo.mediacodec;
import java.nio.ByteBuffer;
import android.app.Activity;
import android.media.MediaCodec;
import android.media.MediaCodec.BufferInfo;
@theeasiestway
theeasiestway / Android_camera_image_planes_to_byte_array.kt
Created March 26, 2020 01:42
Convert android camera image planes to a byte array for encoding or sending
var yData = ByteArray(1)
var uData = ByteArray(1)
var vData = ByteArray(1)
for (i in 0 until 3) {
val plane = image.planes[i]
val bytes = ByteArray(plane.buffer.remaining())
plane.buffer.get(bytes)
when(i) {
0 -> yData = bytes
// ==================== pull from Facebook/rockdb@github ====================
class ListJni {
public:
// Get the java class id of java.util.List.
static jclass getListClass(JNIEnv* env) {
jclass jclazz = env->FindClass("java/util/List");
assert(jclazz != nullptr);
return jclazz;
}
@theeasiestway
theeasiestway / convert_map_jni.cpp
Last active June 26, 2024 05:39
Java HashMap to C++ std::map conversion and vice versa
jobject StlStringStringMapToJavaHashMap(JNIEnv *env, const std::map<std::string, std::string>& map) {
jclass mapClass = env->FindClass("java/util/HashMap");
if(mapClass == NULL)
return NULL;
jmethodID init = env->GetMethodID(mapClass, "<init>", "()V");
jobject hashMap = env->NewObject(mapClass, init);
jmethodID put = env->GetMethodID(mapClass, "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");
std::map<std::string, std::string>::const_iterator citr = map.begin();
#include <random>
std::random_device rd; // only used once to initialise (seed) engine
std::mt19937 rng(rd()); // random-number engine used (Mersenne-Twister in this case)
std::uniform_int_distribution<int> uni(minValue, maxValue); // guaranteed unbiased
int randomInt = uni(rng);