Skip to content

Instantly share code, notes, and snippets.

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

Derk-Jan Karrenbeld SleeplessByte

💎
💎 💎 💎
View GitHub Profile
@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 / 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 / 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 / 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 / .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 / order_extended.html
Created January 20, 2015 20:08
Order / Receipt Gmail
<div itemscope itemtype="http://schema.org/Order">
<div itemprop="merchant" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Amazon.com"/>
</div>
<meta itemprop="orderNumber" content="123-4567890-1234567"/>
<meta itemprop="priceCurrency" content="USD"/>
<meta itemprop="price" content="539.00"/>
<div itemprop="acceptedOffer" itemscope itemtype="http://schema.org/Offer">
<div itemprop="itemOffered" itemscope itemtype="http://schema.org/Product">
<meta itemprop="name" content="Samsung Chromebook"/>
@SleeplessByte
SleeplessByte / save_action.html
Created January 20, 2015 20:07
Save (on-click) Action Gmail
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/SaveAction">
<meta itemprop="name" content="Save Offer"/>
<div itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
<link itemprop="url" href="https://offers-everywhere.com/save?offerId=xyz789"/>
</div>
</div>
<meta itemprop="description" content="$5 meal at Joe's Diner"/>
</div>
@SleeplessByte
SleeplessByte / confirm_action.html
Last active August 29, 2015 14:13
Confirm (one-click) Action Gmail
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ConfirmAction">
<meta itemprop="name" content="Approve XXX"/>
<div itemprop="handler" itemscope itemtype="http://schema.org/HttpActionHandler">
<link itemprop="url" href="https://SOMEURLTOAPPROVE"/>
</div>
</div>
<meta itemprop="description" content="Approval request for John's $10.13 expense for office supplies OR SOMETHING ELSE"/>
</div>
@SleeplessByte
SleeplessByte / view_action.html
Last active August 29, 2015 14:13
View Action Gmail
<div itemscope itemtype="http://schema.org/EmailMessage">
<meta itemprop="description" content="DESCRIPTION"/>
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://evergive.com/redirect_to/posts/organization/xxx/group/yyy"/>
<meta itemprop="name" content="Show community"/>
</div>
<div itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Evergive"/>
<link itemprop="url" href="https://evergive.com"/>
</div>
Verifying that +sleeplessbyte is my openname (Bitcoin username). https://onename.io/sleeplessbyte