Skip to content

Instantly share code, notes, and snippets.

View SleeplessByte's full-sized avatar
💎
💎 💎 💎

Derk-Jan Karrenbeld SleeplessByte

💎
💎 💎 💎
View GitHub Profile
@SleeplessByte
SleeplessByte / .gradle
Created January 24, 2015 23:51
Android Studio - How to gitignore your signing.
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile [...]
}
android {
// Add a gradle.properties to your root to make this workd:
@SleeplessByte
SleeplessByte / timezones
Created February 19, 2015 01:24
Android Timezones
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
Africa/Asmera
Africa/Bamako
Africa/Bangui
Africa/Banjul
Africa/Bissau
@SleeplessByte
SleeplessByte / ListUtils.sortedAdd.java
Created April 2, 2015 19:25
Mainly for use with ArrayList to keep it sorted at insertion time. This method runs in `log(n)` time for a "random access" list (which provides near-constant-time positional access). If the specified list does not implement the `RandomAccess` interface and is large, this method will do an iterator-based binary search that performs `O(n)` link tr…
private static final int NOT_UNIQUE = -1;
/**
* Adds an item in a list using it's comparable sort
*
* @param item the item to add
* @param list the list to add to
* @param uniq if true, reject duplicates
* @param <A> if
* @param <I>
@SleeplessByte
SleeplessByte / resolve.java
Created May 7, 2015 14:42
Resolve a resource ID for Android
/**
* Resolve id
*
* @param context the context
* @param id the id
* @return the resolved id
*/
public static String resolveId( Context context, int id ) {
StringBuilder out = new StringBuilder();
out.append(" #");
@SleeplessByte
SleeplessByte / FlagUtils.java
Created May 7, 2015 22:17
Flag utilities for parcelable or packing/unpacking in general
public class FlagUtils {
/**
* Packs booleans into an integer
*
* This does not check if the number of booleans is less then the number of bits in the integer
*
* @param params the booleans
*
* @return the packed integer
@SleeplessByte
SleeplessByte / music.md
Last active August 29, 2015 14:20
Music during Daily Droid feat. Rx and AppCompat
@SleeplessByte
SleeplessByte / build.gradle
Created May 8, 2015 00:05
singning.properties configuration in your build.gradle so your credentials are safe(r)
File propFile = file('signing.properties');
if (propFile.exists()) {
def Properties props = new Properties()
props.load(new FileInputStream(propFile))
if (props.containsKey('STORE_FILE') &&
props.containsKey('STORE_PASSWORD') &&
props.containsKey('KEY_ALIAS') &&
props.containsKey('KEY_PASSWORD')) {
@SleeplessByte
SleeplessByte / xml_entity.rb
Created July 27, 2015 13:20
Camelize Grape Entity output
class XmlEntity < Grape::Entity
protected
def self.key_for( attribute )
( exposures[ attribute.to_sym ][ :as ] || name_for( attribute ) ).to_s.camelize
end
end