Skip to content

Instantly share code, notes, and snippets.

View zsiegel's full-sized avatar

Zac Siegel zsiegel

View GitHub Profile
@zsiegel
zsiegel / gist:ef6573dbbf09ad1ced87
Created November 11, 2014 18:13
SparseArrayTypeAdapter for testing a square-flow bug
package com.square.flow;
import android.util.SparseArray;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonToken;
@zsiegel
zsiegel / Presenter
Last active August 29, 2015 14:15
Android MVP Presenter example
public class MyPresenter {
public MyPresenter(IView viewInterface){
}
public void start() {
//this should be called from a onResume() lifecycle method or similar
//subscribe here
}
@zsiegel
zsiegel / gist:9de976807e4000995059
Created March 6, 2015 20:41
Android content transition problem
//Setup how the content elements should animate
TransitionSet transitionSet = new TransitionSet();
transitionSet.addTransition(
new Slide(Gravity.TOP).addTarget(R.id.header_container)
//Why do i have to exclude this?
.excludeTarget(R.id.content_container, true));
transitionSet.addTransition(
new Slide(Gravity.BOTTOM).addTarget(R.id.content_container)
@zsiegel
zsiegel / AnimatingDrawerToggle.java
Last active August 29, 2015 14:18
Animating Drawer Toggle
public class AnimatingDrawerToggle extends ActionBarDrawerToggle {
public enum State {
UP,
HOME
}
private static final float MENU_POSITION = 0f;
private static final float ARROW_POSITION = 1.0f;
function githarvest() {
local week_ago=$(eval date -v -7d +'%d/%m/%Y')
git log --since $week_ago --author="YOUR GIT NAME HERE" --pretty=format:'%C(yellow)%h|%Cred%ad|%Cblue%an|%Cgreen%d %Creset%s' --date=short
}
@zsiegel
zsiegel / gist:3939839
Last active October 11, 2015 23:58
Core Text - Line height property inspection
/* Setup our fonts - One system font from Apple and a custom font */
CTFontRef bodyCopyFont = CTFontCreateWithName((__bridge CFStringRef) [Theme fontForBodyOfSize:11].fontName, [Theme fontForBodyOfSize:11].lineHeight, NULL);
CTFontRef systemFont = CTFontCreateWithName((__bridge CFStringRef) [UIFont systemFontOfSize:11].fontName, [UIFont systemFontOfSize:11].lineHeight, NULL);
/* Lets inspect the properties */
NSLog(@"*****************************************************************");
NSLog(@"SYSTEM-FONT LINE HEIGHT PROPERTY %f", [UIFont systemFontOfSize:11].lineHeight);
NSLog(@"SYSTEM-FONT CALCULATED LINE HEIGHT %f", [self getLineHeightForFont:systemFont]); //Custom function
NSLog(@"*****************************************************************");
NSLog(@"CUSTOM-FONT LINE HEIGHT PROPERTY %f", [Theme fontForBodyOfSize:11].lineHeight);
@zsiegel
zsiegel / gist:3954411
Created October 25, 2012 18:12
UIView Rounded Corner Mask
CAShapeLayer *layer = [CAShapeLayer layer];
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerBottomLeft) cornerRadii:CGSizeMake(5.0, 5.0)];
layer.path = path.CGPath;
self.layer.mask = layer;
@zsiegel
zsiegel / gist:3954413
Created October 25, 2012 18:12
UIView Rounded Corner Mask
CAShapeLayer *layer = [CAShapeLayer layer];
NSUInteger cornersToRound = UIRectCornerTopLeft | UIRectCornerBottomLeft;
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds
byRoundingCorners:cornersToRound
cornerRadii:CGSizeMake(5.0, 5.0)];
layer.path = path.CGPath;
self.layer.mask = layer;
@zsiegel
zsiegel / gist:3969946
Created October 28, 2012 21:15
CouchDB replication filter template
function (doc, req) {
if(doc._deleted){ return true; }
//YOUR CUSTOM LOGIC HERE
return false;
}
@zsiegel
zsiegel / gist:7588299
Last active December 29, 2015 00:49
WTF
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
teamSelector.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
teamSelector.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}