Skip to content

Instantly share code, notes, and snippets.

Sam Duke samskiter

  • Cambridge, UK
Block or report user

Report or block samskiter

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@samskiter
samskiter / Playground.swift
Created Jan 11, 2018
A playground demonstrating an issue with UILabel's intrinsic content size
View Playground.swift
//: Playground - noun: a place where people can play
import UIKit
import PlaygroundSupport
class LabelView: UIView {
let label = UILabel()
override init(frame: CGRect) {
@samskiter
samskiter / iOS11CompatibleLabel.swift
Last active Jan 12, 2018
A UILabel subclass that detects and attempts to fix intrinsicContentSize bugs in UILabel on iOS 11
View iOS11CompatibleLabel.swift
import UIKit
/// A UILabel subclass that detects and attempts to fix intrinsicContentSize bugs in UILabel
class iOS11CompatibleLabel: UILabel {
override var intrinsicContentSize: CGSize {
// First attempt at a fix...
// All UILabels that misbehave have numberOfLines==0 and preferredMaxLayoutWidth=0
// but all UILabels that have these two properties as 0 do not necessarily misbehave
@samskiter
samskiter / a
Created Feb 20, 2017
Broken preservesSuperviewLayoutMargins
View FloatLabelLayout.java
/*
* Copyright 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
View gist:568cdb071ea8c4688a51
private void waitForResponse()
{
signal = new CountDownLatch(1);
try
{
assertTrue(signal.await(30, TimeUnit.SECONDS));
}
catch (InterruptedException e)
{
fail();
View gist:43d8396d6262a73ffbd7
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="blah" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".HomeScreen"
android:label="@string/app_name" >
@samskiter
samskiter / gist:822c78795f46df2571f9
Last active Aug 29, 2015
Url encode requests from GSON objects :)
View gist:822c78795f46df2571f9
package uk.co.airsource.android.authtest;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import java.util.Set;
import retrofit.converter.GsonConverter;
@samskiter
samskiter / gist:ef9ce09fdd64f3c389fa
Created Jan 29, 2015
First cut of Google-http-client retrofitting
View gist:ef9ce09fdd64f3c389fa
package uk.co.airsource.android.authtest;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import retrofit.client.Client;
import retrofit.client.Header;
View NSManagedObjectArchiving.h
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
@interface NSManagedObjectArchiver : NSObject
/*
* Takes a NSManagedObject and converts it to a NSData archive - it traverses all relationships ( including circular ) and archives it
*/
+ (NSData *)archivedDataWithRootObject:(NSManagedObject *)pObject;
You can’t perform that action at this time.