Skip to content

Instantly share code, notes, and snippets.

View stefanhoth's full-sized avatar
:shipit:
Shipping it

Stefan Hoth stefanhoth

:shipit:
Shipping it
View GitHub Profile
@stefanhoth
stefanhoth / gcm_send.php
Created April 2, 2014 14:29
Example on how to send a message through Google Cloud Messaging (GCM, see http://developer.android.com/google/gcm/server.html ) using a simple PHP script
<?php
// Replace with real BROWSER API key from Google APIs
$apiKey = "<ENTER API KEY HERE>";
// Replace with real client registration IDs
$registrationIDs = array(
"APA91bGOrAyHktj3DU0H0z4tsu-...",
"APA91bHr0vERPIe-DHbQGZLBjuj..."
);
@stefanhoth
stefanhoth / keybase.md
Created May 31, 2014 21:45
Pretty nerdy way to prove to keybase.io my github account belongs to me. I love it!

Keybase proof

I hereby claim:

  • I am stefanhoth on github.
  • I am stefanhoth (https://keybase.io/stefanhoth) on keybase.
  • I have a public key whose fingerprint is 5FD2 323B 54C3 241D 8E3F 3F98 823F FCCB 59AE 700F

To claim this, I am signing this object:

@stefanhoth
stefanhoth / jack.bat
Last active August 29, 2015 14:11
Jack & Jill command line helpers. Put them in a directory in your PATH, e.g. <android-sdk>/. Use .bat files for Windows, .sh for Mac/Linux. More info in the documentation: http://tools.android.com/tech-docs/jackandjill
@ECHO OFF
@REM Jack is only available from build tools version 21.1.0 and up. Install/Update via SDK Manager
SET BUILD_TOOLS_VERSION=21.1.2
java -jar %ANDROID_HOME%/build-tools/%BUILD_TOOLS_VERSION%/jack.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
@stefanhoth
stefanhoth / tools_override.xml
Last active August 29, 2015 14:13
Override a views visibility at design time using the tools namespace. See line 13 how and don't forget to add line 2. See http://tools.android.com/tips/layout-designtime-attributes for details.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/group_image"
@stefanhoth
stefanhoth / gist:5d6fa521aad322d15d44
Last active August 29, 2015 14:14 — forked from anonymous/gist:1571520dd1aa934fce28
Simple Factory pattern
// The Factory
public final class VehicleFactory {
// private constructor => can't be instanciated, final can't be extended since the constructor is not reachable for a subclass
private VehicleFactory (){
// no-op
}
public static Vehicel Vehicle produceVehicle(String name, String manufacturer, int horsepowerInPS){
return new Vehicle(name, manufacturer, horsepowerInPS);
@stefanhoth
stefanhoth / RootStatus.java
Last active August 29, 2015 14:16
How to detect if an app is launched on a potentially rooted phone in an non-invasive way. It could be improved by checking existence of known super user apk in the package manager and certain build tags of the ROM.
package com.yourapp;
import java.io.File;
public final class RootStatus {
private static RootStatus instance;
private final boolean rooted;
@stefanhoth
stefanhoth / device_provider.gradle
Last active August 29, 2015 14:21
Allow gradle to only use devices that meet your criteria
android {
...
deviceProvider new AwesomeDeviceProvider(getAdbExe())
}
class AwesomeDeviceProvider extends com.android.builder.testing.ConnectedDeviceProvider {
AwesomeDeviceProvider(File adbLocation) {
super(adbLocation)
}
@stefanhoth
stefanhoth / GradleWorkersPleaseStopTakingFocus.gradle
Last active August 29, 2015 14:25 — forked from artem-zinnatullin/GradleWorkersPleaseStopTakingFocus.gradle
Prevent Gradle Workers from taking focus! #DevelopersLikeComfort
// You can place it in the root build.gradle
allprojects {
tasks.withType(JavaForkOptions) {
// Forked processes like GradleWorkerMain for tests won't steal focus!
jvmArgs '-Djava.awt.headless=true'
}
}
@stefanhoth
stefanhoth / server.js
Created December 22, 2011 15:51 — forked from jeffrafter/server.js
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var sys = require('sys');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = "YOURTWITTERCONSUMERKEY";
var _twitterConsumerSecret = "YOURTWITTERCONSUMERSECRET";
function consumer() {
@stefanhoth
stefanhoth / gist:2029345
Created March 13, 2012 15:11
Dos & Don'ts for the perfect developer event

Dos & Don'ts for the perfect developer event

A crowdsourced list compiled by Stefan Hoth and the fine folks at the Droidcon Berlin Barcamp.

How would you describe yourself? (just tags)

  • (Android) developer
  • entrepreneur
  • event-dude/-girly
  • networker