Skip to content

Instantly share code, notes, and snippets.

View liminal's full-sized avatar

Karl Åström liminal

  • Stockholm/Sweden
View GitHub Profile
@liminal
liminal / LeakSlackUploadService.java
Last active September 15, 2015 10:29 — forked from pyricau/LeakSlackUploadService.java
Sending Leak Traces to a Slack Channel (and HipChat, see the comments)
import android.util.Log;
import com.squareup.leakcanary.AnalysisResult;
import com.squareup.leakcanary.DisplayLeakService;
import com.squareup.leakcanary.HeapDump;
import retrofit.RestAdapter;
import retrofit.RetrofitError;
import retrofit.http.Multipart;
import retrofit.http.POST;
import retrofit.http.Part;
import retrofit.mime.TypedFile;
@liminal
liminal / hello.go
Created April 9, 2015 16:04
With/Without syntax highlighting
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
@liminal
liminal / ppa.prg
Created April 9, 2015 15:54
This is the main program for a pick and place application.
%%%
VERSION:1
LANGUAGE:ENGLISH
%%%
MODULE PPAMAIN
!***********************************************************
!
! File: PMppa340.prg
!
@liminal
liminal / OMG-!HALP.md
Last active April 3, 2018 09:11
How the F*@! do I get out of this thing?! #terminal #help

Oh crap, I did something in my terminal and now I don't know how to get out of the state I'm in!

I did something in the terminal and now I'm in an app or state I don't know how to get out of. Here's a cheat sheet to get you out of whatever mess you're in without jumping out a window.

I Seem to be in an editor

Oh shit I'm in Emacs

Save and exit (Technically save-buffers-kill-terminal)

@liminal
liminal / ContactPhotoLoader
Created March 12, 2015 13:58
Load contact photo from asset uri. (Glide does it automatically so this is just for reference)
/**
* Load a contact photo thumbnail and return it as a Bitmap,
* resizing the image to the provided image dimensions as needed.
* @param photoData photo ID Prior to Honeycomb, the contact's _ID value.
* For Honeycomb and later, the value of PHOTO_THUMBNAIL_URI.
* @return A thumbnail Bitmap, sized to the provided width and height.
* Returns null if the thumbnail is not found.
*/
private Bitmap loadContactPhotoThumbnail(String photoData) {
// Creates an asset file descriptor for the thumbnail file.
@liminal
liminal / build.gradle
Last active April 3, 2018 09:12
Quickest way to set retrolambda.oldJdk in your build.gradle on os x #android-deprecated
retrolambda {
// OS X comes with a tool to get the home directory for a given version
// of Java so let's just use that rather than mess about with properties
// or environment variables.
oldJdk "/usr/libexec/java_home -v1.7".execute().text.trim()
}
@liminal
liminal / MyApplication.java
Created February 24, 2015 13:57
Facebook Stetho QuickStart
public class MyApplication extends Application {
public void onCreate() {
super.onCreate();
Stetho.initialize(
Stetho.newInitializerBuilder(this)
.enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
.enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
.build());
}
@liminal
liminal / build.gradle
Created October 29, 2014 09:21
Template for android build.gradle including my most used dependencies, settings and plugins
//buildscript {
// dependencies {
// classpath 'me.tatarka:gradle-retrolambda:+' // Lambda support on android
// }
//}
//apply plugin: 'retrolambda'
android {
//compileOptions {
// sourceCompatibility JavaVersion.VERSION_1_8
@liminal
liminal / WhateverActivity.java
Created October 22, 2014 20:16
Emulating Theme.AppCompat.Light.DarkActionBar for use with android.support.v7.widget.Toolbar
public class WhateverActivity extends ActionBarActivity {
public void onCreate(Bundle savedInstanceState) {
super(savedInstanceState);
setContentView(R.layout.whatever);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
}
@liminal
liminal / gist:acfe5c6f01d57bd7af48
Created October 19, 2014 12:51
Problems building the Android Gradle Plugin on ubuntu
If you get a lot of linking errors like this:
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/4.8/libstdc++.a
you probably need to
sudo apt-get install g++-multilib