Skip to content

Instantly share code, notes, and snippets.

David Brodsky OnlyInAmerica

View GitHub Profile
OnlyInAmerica / Olm.i
Created May 3, 2016
A SWIG interface file to map Matrix's olm C interface to Java
View Olm.i
* Call swig: "swig -java -c++ -package org.chatsecure.olmwrapper -outdir ~/Code/olmJava olm.i"
%module olmwrapper
/* Put headers and other declarations to include in the wrapper code here */
#include "olm.hh"
OnlyInAmerica /
Last active Apr 19, 2016
Java Wrapping Matrix's Olm using SWIG
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (
* Version 3.0.8
* Do not make changes to this file unless you know what you are doing--modify
* the SWIG interface file instead.
* ----------------------------------------------------------------------------- */
public class Account {
OnlyInAmerica / Mirror Vector Shader
Created Apr 8, 2016
A Vertex shader that mirrors its source horizontally
View Mirror Vector Shader
private static final String FRAGMENT_SHADER_MIRROR =
"#extension GL_OES_EGL_image_external : require\n" +
"precision mediump float;\n" +
"varying vec2 vTextureCoord;\n" + // Coordinate within texture
"uniform samplerExternalOES sTexture;\n" + // Texture
"uniform vec2 uPosition;\n" + // Position within OpenGL scene
"void main() {\n" +
" vec2 texCoord = vTextureCoord.xy;\n" +
" vec2 normCoord = 2.0 * texCoord - 1.0;\n"+
" normCoord.x = normCoord.x * sign(normCoord.x + uPosition.x);\n"+
OnlyInAmerica /
Last active Aug 29, 2015
Debugging a libtool error while building Apache Thrift 0.9.2 for Mac OS X
$ ./configure --prefix=/usr/local/ --with-boost=/usr/local --with-libevent=/usr/local
$ make
/bin/sh ../../../libtool --tag=CXX --mode=link g++ -Wall -Wextra -pedantic -g -O2 -std=c++11 -L/usr/local/lib -o processor_test processor/ProcessorTest.o processor/EventLog.o processor/ServerThread.o ../../../lib/cpp/ ../../../lib/cpp/ -L/usr/local/lib -levent -l:libboost_unit_test_framework.a -lssl -lcrypto -lpthread
libtool: link: g++ -Wall -Wextra -pedantic -g -O2 -std=c++11 -o .libs/processor_test processor/ProcessorTest.o processor/EventLog.o processor/ServerThread.o -Wl,-bind_at_load -L/usr/local/lib ./.libs/libprocessortest.a ../../../lib/cpp/.libs/libthrift.dylib ../../../lib/cpp/.libs/libthriftnb.dylib -levent -l:libboost_unit_test_framework.a -lssl -lcrypto -lpthread
ld: library not found for -l:libboost_unit_test_framework.a
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[4]: *** [processor_test] Error 1
OnlyInAmerica /
Last active May 11, 2020
Create Mega Adblock Hostsfile for use with Dnsmasq (Modified from Pi-hole)
# Modified Pi-hole script to generate a generic hosts file
# for use with dnsmasq's addn-hosts configuration
# original :
# The Pi-hole now blocks over 120,000 ad domains
# Address to send ads to (the RPi)
OnlyInAmerica / gist:e0e73ae971791c652c61
Created May 23, 2015
Pull and decompile Android APK (Jank Edition)
View gist:e0e73ae971791c652c61
import sys
import subprocess
DEX2JAR_PATH =/PATH/TO/dex2jar-2.0/' #
APKTOOL_JAR_PATH = ‘PATH/TO/apktool.jar' #
JDCLI_JAR_PATH = '/PATH/TO/jd-cli.jar' #
query = sys.argv[1]
OnlyInAmerica /
Created May 12, 2015
Delete old IAM AWS users
import boto.iam
Delete the NUM_USERS_TO_DELETE oldest IAM users in your account*
*IMPORTANT: The boto iam api appears to only allow querying 1000 users
at a time so if you have over 1000 IAM users there is no guarantee these
will be the oldest. The deleted users are only guaranteed to be the oldest
among the 1000 aws returns us.
OnlyInAmerica /
Created Dec 9, 2014
Assemble an image hidden among multiple video frames.
Construct a single image by stacking the bottom READ_HORIZ_PX
of each source frame of form image-XXXX.jpeg.
To create source frames of form image-XXXX.jpeg from a video file:
$ ffmpeg -i inputfile.avi image-%4d.jpeg
This was helpful in extracting a QR code partially displayed
across many frames.
OnlyInAmerica / gist:3dadd26fddb29c0f777d
Last active May 22, 2019
Get Thumbnail from Android Storage Access Framework file using MediaStore
View gist:3dadd26fddb29c0f777d
if (/* your media path came from Android Storage Access Framework on 4.4+ */) {
//mediaFile.getPath() = "content://"
long videoId = Long.parseLong(Uri.parse(mediaFile.getPath()).getLastPathSegment().split(":")[1]);
Bitmap thumbnail = MediaStore.Video.Thumbnails.getThumbnail(mContext.getContentResolver(),
MediaStore.Images.Thumbnails.MINI_KIND, // 512 x 384
//MediaStore.Images.Thumbnails.MICRO_KIND, // 96 x 96
null)); // BitmapFactory.Options
OnlyInAmerica / gist:389b8e8d9e3867b51476
Created Sep 5, 2014
RajaWali Interior Shape Rendering
View gist:389b8e8d9e3867b51476
getCurrentCamera().setPosition(0, 0, 0);
Sphere sphere = new Sphere(10, 24, 24);
/** Below renders a portion of the exterior of the sphere with texture applied */
sphere.setPosition(0, 0, -13);
/** Below renders nothing when I'd expect to "see" the interior of the sphere */
//sphere.setPosition(0, 0, 0);
Material material = new Material();
material.addTexture(new Texture("brc", R.drawable.brc_sm));
You can’t perform that action at this time.