Skip to content

Instantly share code, notes, and snippets.

// in a UITableViewController (or any other view controller with a UITableView)
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
UIView *header = [[UIView alloc] initWithFrame:CGRectMake(0, 0, size.width, 0)];
header.translatesAutoresizingMaskIntoConstraints = NO;
// [add subviews and their constraints to header]
NSLayoutConstraint *headerWidthConstraint = [NSLayoutConstraint
// how to programatically create NSLayoutConstraints inside a playground
import UIKit
let viewFrame = CGRect(x: 0, y: 0, width: 640, height: 750)
let view = UIView(frame: viewFrame)
view.backgroundColor = UIColor.greenColor()
// initially the subView will obscure the entire view
let subView = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.Dark))
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- RED -->
<color name="red_50">#FFEBEE</color>
<color name="red_100">#FFCDD2</color>
<color name="red_200">#EF9A9A</color>
<color name="red_300">#E57373</color>
<color name="red_400">#EF5350</color>
<color name="red_500">#F44336</color>
package retrofit.converter;
import com.bluelinelabs.logansquare.LoganSquare;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
import retrofit.converter.ConversionException;
import retrofit.converter.Converter;
@fdln
fdln / README.md
Last active August 29, 2015 14:16 — forked from polbins/README.md

Android REST Controller with Cache-Control

Android REST Controller with Simple Cache Control Headers using Retrofit 1.9.0 + OkHttp 2.2.0

public static Picasso getImageLoader(Context ctx) {
if(sPicassoInstance == null) {
Picasso.Builder builder = new Picasso.Builder(ctx);
sTransformRequest = new Picasso.RequestTransformer() {
@Override
public Request transformRequest(Request request) {
Uri uri = request.uri;
if(uri.getScheme().startsWith("http")) {
String urlString = uri.toString();
@TargetApi(Build.VERSION_CODES.KITKAT)
static class DocumentExifTransformation implements Transformation {
private static final String[] CONTENT_ORIENTATION = new String[] {
MediaStore.Images.ImageColumns.ORIENTATION
};
final Context context;
final Uri uri;
DocumentExifTransformation(Context context, Uri uri) {
@fdln
fdln / dex.sh
Last active August 29, 2015 14:23 — forked from JakeWharton/dex.sh
function dex-method-count() {
cat $1 | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d\n"'
}
function dex-method-count-by-package() {
dir=$(mktemp -d -t dex)
baksmali $1 -o $dir
for pkg in `find $dir/* -type d`; do
smali $pkg -o $pkg/classes.dex
count=$(dex-method-count $pkg/classes.dex)
name=$(echo ${pkg:(${#dir} + 1)} | tr '/' '.')
@fdln
fdln / NBNet.m
Created November 14, 2015 21:08 — forked from akhenakh/NBNet.m
Download image and update using NSURLSession
@interface NBNet()
@property(nonatomic, strong) NSURLSession *imageSession;
@property(nonatomic, strong) NSOperationQueue *netOperationQueue;
@end
@implementation NBNet
+ (id)sharedNBNet {
static NBNet *sharedNBNet = nil;
static dispatch_once_t onceToken;
@fdln
fdln / UITableView.swift
Created December 20, 2015 18:44 — forked from watert/UITableView.swift
UITableView example in iOS Playground with XCode 6 beta
// Playground - noun: a place where people can play
import UIKit
class ViewController: UIViewController ,UITableViewDelegate, UITableViewDataSource
{
var tableView: UITableView!
var items: NSMutableArray!
override func viewDidLoad() {
super.viewDidLoad()