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 / gist:3939213
Created October 23, 2012 14:51
Lite closure i js
var importantvariable="superimportant!";
asynchronous_api_call(
'http://anrops-URL',
function (closedOverParam) {
return function (response) {
alert(closedOverParam);
};
}(importantvariable);
);
-- IMStatus
-- version 2.0, Lantrix (http://techdebug.com)
-- idea conceived from script by Jason Kenison "theWebGuy" Blog at:
-- http://www.jasonkenison.com/blog.html?id=22
(*
Copyright (c) 2008, TechDebug.com
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@liminal
liminal / MyActivity.java
Created August 19, 2013 09:20
Avoiding null pointer exceptions when passing events back from fragment to activity
package com.example;
import android.app.Activity;
public class MyActivity extends Activity
implements MyFragment.Callbacks {
@Override
public void onItemClick(Object object) {
//Do thing with the passed object
@liminal
liminal / MyItemView.java
Last active December 21, 2015 06:58
Custom android ViewGroup
package com.example;
public class MyItemView extends LinearLayout {
public static final MyItem EMPTY = new MyItem(null);
private TextView mTitleView;
private TextView mDescriptionView;
private MyItem item = EMPTY;
@liminal
liminal / CustomViewActivity.java
Created August 19, 2013 11:17
From http://stackoverflow.com/questions/17477981/using-custom-views-in-xml-without-using-fully-qualified-class-name How to use a custom layoutinflater in order to use layout xml files with custom classes without using fully qualified classname
public class CustomViewActivity extends Activity {
public void onCreate (Bundle savedInstanceState) {
//Get the LayoutInflater for this Activity context
//and set the Factory to be our custom view factory
LayoutInflater.from(this).setFactory(CustomViewFactory.getInstance());
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_with_custom_view);
}
}
@liminal
liminal / teststrings.json
Created October 16, 2013 08:43
Good java test strings
{
"minvals" : [
"DESIGNING WORKHOUSES",
"polygenelubricants"
],
"zerovals": [
"pollinating sandboxes",
"amusement & hemophilias",
"schoolworks = perversive"
]
@liminal
liminal / build.gradle
Last active December 28, 2015 00:49 — forked from khernyo/build.gradle
// Updated to work with newer gradle plugin
apply plugin: 'android'
targetCompatibility = 1.6
sourceCompatibility = 1.6
android {
target = 'android-14'
@liminal
liminal / gist:8801401
Created February 4, 2014 10:40
Using adb over wifi with Android Tether device
# Set up adb to use tcpip port
adb tcpip 5555
# Default device ip when it's used as a portable hotspot
adb connect 192.168.43.1
# List connected devices
adb devices
@liminal
liminal / KeyboardUtil.java
Last active April 3, 2018 09:11
Utility for hiding android keyboard #android
import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
public class KeyboardUtil {
public static void hideKeyboard(final Context ctx, final View view) {
InputMethodManager imm = (InputMethodManager)ctx.getSystemService(Context.INPUT_METHOD_SERVICE);
@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