Skip to content

Instantly share code, notes, and snippets.

@erkie
erkie / UIFont+DahDit
Last active November 27, 2021 22:45
UILabel get CGRect for substring of text
//
// UIFont+DahDit.m
// DahDit
//
// Created by Erik Andersson on 2011-07-28.
// Copyright 2011 Åva gymnasium. All rights reserved.
//
#import "UIFont+DahDit.h"
@vigorouscoding
vigorouscoding / DateFlowLayout.h
Created March 13, 2013 20:10
UICollectionView with sticky headers which works for horizontal as well as vertical scrolling
#import <UIKit/UIKit.h>
@interface DateFlowLayout : UICollectionViewFlowLayout
@end
@cvogt
cvogt / gist:9239494
Last active September 9, 2019 01:30
Slick app architecture cheat sheet
// Please comment in case of typos or bugs
import scala.slick.driver.H2Driver._
val db = Database.for...(...)
case class Record( ... )
class Records(tag: Tag) extends Table[Record](tag,"RECORDS"){
...
def * = ... <> (Record.tupled,Record.unapply)
// place additional methods here which return values of type Column
@dbachelder
dbachelder / PeekableDrawerLayout.java
Last active May 19, 2017 11:16
A version of support DrawerLayout that can open the drawer X pixels... uses reflection to access the private members of DrawerLayout
package android.support.v4.widget;
import android.content.Context;
import android.graphics.Point;
import android.os.Build;
import android.support.v4.view.GravityCompat;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.Display;
import android.view.Gravity;
@lshoo
lshoo / gist:9785645
Created March 26, 2014 15:13
Slick2 generic dao
package slicks.docs.dao
import scala.slick.driver.PostgresDriver.simple._
import scala.slick.driver._
trait Profile {
val profile: JdbcProfile
}
@staltz
staltz / introrx.md
Last active July 4, 2024 10:11
The introduction to Reactive Programming you've been missing
@kristopherjohnson
kristopherjohnson / isNilOrEmpty.swift
Last active December 7, 2021 07:03
Swift: determine whether optional String, NSString, or collection is nil or empty
import Foundation
/**
Determine whether Optional collection is nil or an empty collection
:param: collection Optional collection
:returns: true if collection is nil or if it is an empty collection, false otherwise
*/
public func isNilOrEmpty<C: CollectionType>(collection: C?) -> Bool {
switch collection {
#! /bin/bash
# DHC - Hacked to always return a 0 code when successful.
SIM_DEVICES_FOLDER=~/Library/Developer/CoreSimulator/Devices
SIM_RUNTIME_PRFIX=com.apple.CoreSimulator.SimRuntime
function usage () {
echo "simulatorAppFolders (-s <name> | -d <device-type>) [-?] [-i <iOS version>] [-a <app-name>]"
echo "-? show help, and prints simulators currently installed"
@algal
algal / groupBy.swift
Last active February 3, 2016 13:47
groupBy
func groupBy<T>(equivalent:(a:T,b:T)->Bool, items:[T]) -> [[T]] {
var lastItem:T? = nil
var groups:[[T]] = []
var currentGroup:[T] = []
for item in items {
if lastItem == nil {
// first item
currentGroup.append(item)
}
else {
@natecook1000
natecook1000 / NSScanner+Swift.swift
Created March 3, 2015 20:13
Swift-friendly NSScanner methods
// NSScanner+Swift.swift
// A set of Swift-idiomatic methods for NSScanner
//
// (c) 2015 Nate Cook, licensed under the MIT license
import Foundation
extension NSScanner {
// MARK: Strings