Skip to content

Instantly share code, notes, and snippets.

View halfvector's full-sized avatar
😄

Alex Barkan halfvector

😄
View GitHub Profile
@halfvector
halfvector / ogg-vorbis-encoder.cpp
Created February 20, 2014 01:34
Ogg+Vorbis encoder, designed to be compiled by Emscripten and used in browsers.
#include <stdio.h> // printf
#include <math.h> // sin
#include <time.h> // time
#include <stdlib.h> // srand
#include <string.h> // memcpy
#include <vorbis/vorbisenc.h>
struct tEncoderState
{
@halfvector
halfvector / gist:9732963
Last active August 29, 2015 13:57
playing various form-gathering syntaxes
$data = $this->getRequirements([
'description' => ['type' => 'markdown', 'minLength' => 3, 'persistent' => true],
'title' => ['type' => 'string', 'minLength' => 3, 'persistent' => true],
'action' => ['type' => 'string', 'minLength' => 3],
'suggestionId' => ['type' => 'int'],
'reason' => ['type' => 'string', 'minLength' => 3, 'optional' => true, 'default' => ""],
'tags' => ['type' => 'array', 'optional' => true],
'attachments' => ['type' => 'file', 'optional' => true],
'keepAttachments' => ['type' => 'array', 'optional' => true]
]);
@halfvector
halfvector / update-android-id.sh
Created July 16, 2014 17:09
update device's android_id
# prerequisites: rooted device, adb, sqlite installed locally
# works beautifully on glass
# android-ids are hexadecimal [0-9a-f]
# install sqlite3 locally to modify the db
sudo apt-get install -y sqlite3
# make sure we have a device connected
adb devices
@halfvector
halfvector / keybase.md
Created August 14, 2014 00:17
keybase.md

Keybase proof

I hereby claim:

  • I am halfvector on github.
  • I am unbuffered (https://keybase.io/unbuffered) on keybase.
  • I have a public key whose fingerprint is 06A0 B06E C8DA 531E D77F 7C6A 0671 385C D805 BB2D

To claim this, I am signing this object:

@halfvector
halfvector / intellij-beautify.md
Last active January 16, 2018 20:41
Android Studio & IntelliJ Beautification
@halfvector
halfvector / docker-purge-images.sh
Created March 25, 2015 13:49
Cleanup untagged Docker images. Manual garbage collection to keep your drive from running out of space.
#!/bin/sh
echo "Removing untagged docker images.."
docker images -q -f dangling=true | xargs docker rmi
@halfvector
halfvector / docker-purge-containers.sh
Created March 25, 2015 13:50
Cleanup exited Docker containers to free up disk space
#!/bin/sh
echo "Removing exited docker containers.."
docker ps -f status=exited -q | xargs docker rm
# a few git commands
alias gs='git status'
alias gp='git push'
alias gl='git log --graph --pretty=tformat:"%C(auto)%h%Creset - %s %Cgreen(%cr) %C(bold blue)<%an>%Creset %C(auto)%d%Creset" --abbrev-commit'
alias cdiff='cdiff -s -c always | less -rFX'
# recent log entries without a pager
alias glr='git --no-pager log -25 --graph --pretty=tformat:"%C(auto)%h%Creset - %s %Cgreen(%cr) %C(bold blue)<%an>%Creset %C(auto)%d%Creset" --abbrev-commit'
alias gs='git status -s'
@halfvector
halfvector / android-flat-wifi-model.java
Created March 16, 2016 16:48
Flattened Android Wifi model with Enterprise configuration extensions (EAP)
/**
* All fields are allowed to be null.
*/
class WifiConfig {
/**
* The network's SSID. Can either be an ASCII string, which must be enclosed in double quotation marks
* (e.g., "MyNetwork"), or a string of hex digits,which are not enclosed in quotes (e.g., 01a243f405).
*/
String SSID;
@halfvector
halfvector / jacocoTestReport-build.gradle
Created September 29, 2016 16:49
jacocoTestReport for unit + instrumentation test code coverage for Android
/**
* This JacocoTestReport task merges local Unit Tests and emulator/device Instrumentation Tests into a single coverage report.
* Also ignores Dagger 2 generated code.
* Add this task to your Android app/build.gradle and run your test suites then execute this task.
* Coverage report will appear in app/build/reports/jacoco/jacocoTestReport/
* as standard xml compatible with codecov.io and human readable html
* dependsOn: ['testDebugUnitTest', 'connectedDebugAndroidTest']
*/
task jacocoTestReport(type: JacocoReport) {
group = "Reporting"