Skip to content

Instantly share code, notes, and snippets.

@alexcohn
alexcohn / hide_behind.xml
Last active August 17, 2019 16:40
To help with https://stackoverflow.com/q/57523822/192373 how texture view can hide behind the activity layout
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.example.android.camera2basic.AutoFitTextureView
android:id="@+id/texture"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
#include <iostream>
enum SumOfWeights {
N
};
template<class T>
class is_time_point {
template<typename U> static auto test(U const* u) -> decltype(u->time_since_epoch(), std::true_type());
template<typename> static std::false_type test(...);
#ifndef almost_private
#define almost_private private
#endif
class A {
private:
void Private();
almost_private:
void AlmostPrivate();
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Audio Recorder</title>
<style>
audio {
display: block;
}
@alexcohn
alexcohn / audio.html
Last active May 9, 2018 18:36
experiment around audio duration
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Audio Recorder</title>
<style>
audio {
display: block;
}
package com.example.thunks
public class SomeClass {
private long m_nativeCallback;
public native void callback(int arg1, long arg2);
}
#include <jni.h>
JNIEXPORT void JNICALL
Java_com_example_thunks_SomeClass_callback(JNIEnv *env, jobject obj, jint arg1, jlong arg2)
{
jclass SomeClass = (*env)->GetObjectClass(env, obj);
jfieldID nativeCallback_ID = (*env)->GetFieldID(env, SomeClass, "m_nativeCallback", "J"); // it would be wise to cache this ID
void (*callbackPtr)(int, long) = (void (*)(int, long)) (*env)->GetLongField(env, object, nativeCallback_ID);
callbackPtr(arg1, arg2);
}