Skip to content

Instantly share code, notes, and snippets.

View ErikHellman's full-sized avatar
🏠
Working from home

Erik Hellman ErikHellman

🏠
Working from home
View GitHub Profile
[
{id: 1, name: "Erik", hometown: "Stockholm"},
{id: 2, name: "Anna", hometown: "Malmö"},
{id: 3, name: "Per", hometown: "Göteborg"},
{id: 4, name: "Lisa", hometown: "Umeå"},
{id: 5, name: "Johan", hometown: "Falun"},
]
@ErikHellman
ErikHellman / VisualizationRenderer
Last active August 29, 2015 14:05
Simple renderer for a pixel shader on Android
public class VisualizationRenderer implements GLSurfaceView.Renderer {
private static final int FLOAT_SIZE_BYTES = Float.SIZE / Byte.SIZE;
private final FloatBuffer mRectData;
private final Context mContext;
private String mVertexShader;
private String mFragmentShader;
public VisualizationRenderer(Context context) {
mContext = context;
@ErikHellman
ErikHellman / keybase.md
Created April 3, 2015 17:50
keybase.md

Keybase proof

I hereby claim:

  • I am ErikHellman on github.
  • I am erikhellman (https://keybase.io/erikhellman) on keybase.
  • I have a public key whose fingerprint is D0CC 217D A17A 94D5 FDD4 BC03 6765 F7D5 70C3 E561

To claim this, I am signing this object:

@ErikHellman
ErikHellman / gradle_tips_for_android.md
Last active August 29, 2015 14:20
Boosting the performance for Gradle in your Android projects

Boosting the performance for Gradle in your Android projects

Ever feel like all you do is waiting for the builds to complete in Android Studio all day? Me too. Fortunately, there are a number of improvements you can do to speed things up. Some of these are still experimental and could be unsafe, but it is probably worth a try in case you’re suffering from long build times. I’ve seen project go down to 2.5 seconds when building after small code changes using the stuff I describe below. Hope it works for you as well.

Android uses Gradle for building. The default version of Gradle at the time of writing is 2.2. The latest version is 2.4 and has a huge performance boost over previous versions. In order to make your Android project use this version, add the following at the end of your root build.grade script.

task wrapper(type: Wrapper) {
    gradleVersion = '2.4'
}
@ErikHellman
ErikHellman / RxGattWrapper.java
Created September 24, 2015 08:22
A base for a wrapper for the Bluetooth LE API on Android
public final class RxGattWrapper {
private SerializedSubject<BluetoothGattEvent, BluetoothGattEvent> eventSubject = new SerializedSubject<>(PublishSubject.<BluetoothGattEvent>create());
private BluetoothDevice bluetoothDevice;
private BluetoothGatt bluetoothGatt;
public RxGattWrapper(BluetoothDevice bluetoothDevice) {
this.bluetoothDevice = bluetoothDevice;
}
public void connect(Context context) {
@ErikHellman
ErikHellman / gist:6055718
Created July 22, 2013 17:17
GLES Shader for edge detection
#extension GL_OES_EGL_image_external : require
precision mediump float;
varying vec2 vTextureCoord;
uniform samplerExternalOES sTexture;
uniform float uResS;
uniform float uResT;
void main() {
vec3 irgb = texture2D(sTexture, vTextureCoord).rgb;
float ResS = uResS;
@ErikHellman
ErikHellman / MainActivity.java
Created March 23, 2016 13:46
Demo of using Handlers for async operations in Android
public class MainActivity extends AppCompatActivity {
private static final int MSG_LONG_RUNNING_OPERATION = 101;
private static final int MSG_UPDATE_UI = 102;
private static final long THRITY_SECONDS = 30000;
private Handler bgHandler;
private Handler uiHandler;
private Handler.Callback callback;
private boolean doAgain = false;
Verifying that "erikhellman.id" is my Blockstack ID. https://onename.com/erikhellman
@ErikHellman
ErikHellman / twig.kt
Last active November 21, 2017 09:31
Twig - A logcat wrapper using Kotlin reified generics
package se.hellsoft.twig
import android.util.Log
import se.hellsoft.kotlinhacks.BuildConfig
/**
* Verbose logging. Will be stripped from release builds.
*/
inline fun <reified T> T.logv(error: Throwable? = null, m: () -> String) {
if (BuildConfig.DEBUG) {
@ErikHellman
ErikHellman / BackgroundThreadFunction.kt
Last active January 16, 2018 07:09
Background Thread Function
fun launchBackgroundJob(job: () -> Unit) {
thread { job() }
}