Skip to content

Instantly share code, notes, and snippets.

View wildthink's full-sized avatar

Jason Jobe wildthink

  • 00:13 (UTC -04:00)
View GitHub Profile
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller
{
self.shouldReloadCollectionView = NO;
self.blockOperation = [[NSBlockOperation alloc] init];
}
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo
atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
{
__weak UICollectionView *collectionView = self.collectionView;
// please... don't do this
import Foundation
class F: NSObject
{
@objc func foo() {
print("hi")
}
}
module type CELL = sig
type 'a cell
type 'a exp
val return : 'a -> 'a exp
val (>>=) : 'a exp -> ('a -> 'b exp) -> 'b exp
val cell : 'a exp -> 'a cell exp
val get : 'a cell -> 'a exp
@kristopherjohnson
kristopherjohnson / sumAndMean.swift
Last active September 21, 2019 13:29
Generic sum() and mean() extensions for Swift numeric collections
/// To use reduce() to sum a sequence, we need
///
/// - a zero (identity) element
/// - an addition operator
protocol Summable {
/// Identity element for this type and the + operation.
static var Zero: Self { get }
@clementgenzmer
clementgenzmer / FBAnimationPerformanceTracker.h
Last active August 20, 2025 04:49
FBAnimationPerformanceTracker
/*
* This is an example provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
{% block head %}
{{ parent() }}
<meta name="description" content="{{ entry.body | trimit(400) }}" />
<link rel="canonical" href="{{ entry.url }}">
<meta name="author" content="{{ siteName }}">
<!-- Schema.org markup for Google+ -->
<meta itemprop="name" content="{{ entry.title }}">
<meta itemprop="description" content="{{ entry.body | trimit(400) }}">
<meta itemprop="image" content="{% if image %}{{ image.getUrl('large') }}{% endif %}">
@erica
erica / AppDelegate.m
Last active August 29, 2015 14:22
Playground Toybox - Mac Helper
NSString *const ToyboxNotification = @"com.sadun.ToyboxNotification";
NSString *const kIdentity = @"kIdentity";
NSString *const kTrigger = @"kTrigger";
NSString *const kString = @"kString";
NSString *const kValue = @"kValue";
NSString *const kRadio = @"kRadio";
NSString *const kRadioRow = @"kRadioRow";
NSString *const kRadioColumn = @"kRadioColumn";
@implementation AppDelegate
@VuMai
VuMai / SizeOfImageAspectFix.m
Last active August 29, 2015 14:22
How to get the size of a scaled UIImage in UIImageView?
-(CGRect)frameForImage:(UIImage*)image inImageViewAspectFit:(UIImageView*)imageView
{
float imageRatio = image.size.width / image.size.height;
float viewRatio = imageView.frame.size.width / imageView.frame.size.height;
if(imageRatio < viewRatio)
{
float scale = imageView.frame.size.height / image.size.height;
@fcanas
fcanas / Distance.swift
Created May 21, 2015 15:11
Creating a Numeric Type : Distance
public struct Distance :NumericType {
public var value :Double
public init(_ value: Double) {
self.value = value
}
}
extension Distance :IntegerLiteralConvertible {
public init(integerLiteral: IntegerLiteralType) {
self.init(Double(integerLiteral))
@davbeck
davbeck / GQL.swift
Created May 2, 2015 15:52
GraphQL data structure implemented in Swift
import Foundation
protocol GQLNodeArgument {}
extension String: GQLNodeArgument {}
extension NSNumber: GQLNodeArgument {}
class GQLNode: StringLiteralConvertible, ArrayLiteralConvertible, Printable, DebugPrintable {
let name: String?