Skip to content

Instantly share code, notes, and snippets.

View OnlyInAmerica's full-sized avatar

David Brodsky OnlyInAmerica

  • Oakland, CA
View GitHub Profile
@OnlyInAmerica
OnlyInAmerica / Olm.i
Created May 3, 2016 20:17
A SWIG interface file to map Matrix's olm C interface to Java
/*
* 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
OnlyInAmerica / Account.java
Last active April 19, 2016 23:56
Java Wrapping Matrix's Olm using SWIG
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* 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
OnlyInAmerica / Mirror Vector Shader
Created April 8, 2016 02:07
A Vertex shader that mirrors its source horizontally
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
OnlyInAmerica / build_output.sh
Last active August 29, 2015 14:22
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 libprocessortest.la ../../../lib/cpp/libthrift.la ../../../lib/cpp/libthriftnb.la -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
make[3]
@OnlyInAmerica
OnlyInAmerica / make-mega-adblock-hostsfile.sh
Last active September 30, 2023 23:29
Create Mega Adblock Hostsfile for use with Dnsmasq (Modified from Pi-hole)
#!/bin/bash
# Modified Pi-hole script to generate a generic hosts file
# for use with dnsmasq's addn-hosts configuration
# original : https://github.com/jacobsalmela/pi-hole/blob/master/gravity-adv.sh
# The Pi-hole now blocks over 120,000 ad domains
# Address to send ads to (the RPi)
piholeIP="192.168.1.1"
outlist='./final_blocklist.txt'
@OnlyInAmerica
OnlyInAmerica / gist:e0e73ae971791c652c61
Created May 23, 2015 05:59
Pull and decompile Android APK (Jank Edition)
import sys
import subprocess
DEX2JAR_PATH =/PATH/TO/dex2jar-2.0/d2j-dex2jar.sh' # https://github.com/pxb1988/dex2jar
APKTOOL_JAR_PATH = ‘PATH/TO/apktool.jar' # http://ibotpeaches.github.io/Apktool/install/
JDCLI_JAR_PATH = '/PATH/TO/jd-cli.jar' # https://github.com/kwart/jd-cmd
# TODO SANITIZE INPUT
query = sys.argv[1]
@OnlyInAmerica
OnlyInAmerica / delete_iam_users.py
Created May 12, 2015 21:31
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
OnlyInAmerica / crop_frames.py
Created December 9, 2014 22:28
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
OnlyInAmerica / gist:3dadd26fddb29c0f777d
Last active January 24, 2022 18:18
Get Thumbnail from Android Storage Access Framework file using MediaStore
if (/* your media path came from Android Storage Access Framework on 4.4+ */) {
//mediaFile.getPath() = "content://com.android.providers.media.documents/document/video:183"
long videoId = Long.parseLong(Uri.parse(mediaFile.getPath()).getLastPathSegment().split(":")[1]);
Bitmap thumbnail = MediaStore.Video.Thumbnails.getThumbnail(mContext.getContentResolver(),
videoId,
MediaStore.Images.Thumbnails.MINI_KIND, // 512 x 384
//MediaStore.Images.Thumbnails.MICRO_KIND, // 96 x 96
null)); // BitmapFactory.Options
@OnlyInAmerica
OnlyInAmerica / gist:389b8e8d9e3867b51476
Created September 5, 2014 08:43
RajaWali Interior Shape Rendering
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));
sphere.setMaterial(material);