Skip to content

Instantly share code, notes, and snippets.

View pflammertsma's full-sized avatar

Paul Lammertsma pflammertsma

View GitHub Profile
@pflammertsma
pflammertsma / logcat.lang
Last active October 15, 2017 13:18
Gedit highlighter file for gedit
<?xml version="1.0" encoding="UTF-8"?>
<language id="logcat" _name="logcat" version="2.0" _section="Others">
<metadata>
<property name="mimetypes">text/x-logcat</property>
<property name="globs">*.logcat</property>
</metadata>
<styles>
<style id="comment" _name="Comment" map-to="def:comment"/>
<style id="verbose" _name="Verbose" map-to="def:identifier"/>
public class MultiViewPager extends ViewPager {
/**
* Maximum size.
*/
private int mMaxWidth = -1;
/**
* Maximum size.
*/
private int mMaxHeight = -1;
@pflammertsma
pflammertsma / dbdump.sh
Last active August 29, 2015 14:14
Database dump script
#!/bin/bash
#####
# Note about extracting databases using cat:
# On some devices (e.g. Moto X 2014) the database file contains some misplaced 0x0D characters. At first look these
# occur preceding a "CREATE TABLE" instruction.
#####
function notice {
echo -e "\033[1m$1\033[0m"
@pflammertsma
pflammertsma / gist:de7b8c0fef60c8abc910
Last active November 11, 2015 16:29
Example of using a custom annotation for prefixing Index names
// Define the @IndexPrefixedByTableName annotation:
@Retention(value = RetentionPolicy.RUNTIME)
@Target(value = ElementType.FIELD)
public @interface IndexPrefixedByTableName {}
// In your model, for instance in a superclass of multiple models:
@pflammertsma
pflammertsma / PrimitiveConverterFactory.java
Created January 18, 2016 17:15
Retrofit converter that outputs "text/plain" for primary types
package com.pixplicity.retrofit;
import com.squareup.okhttp.MediaType;
import com.squareup.okhttp.RequestBody;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import retrofit.Converter;
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.software.leanback"
android:required="true" />
<application
...
android:banner="@drawable/my_banner">
<activity ... >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
</manifest>
mediaSession = new MediaSessionCompat(this, "sample");
mediaSessionConnector = new MediaSessionConnector(mediaSession);
mediaSessionConnector.setPlayer(player);