Skip to content

Instantly share code, notes, and snippets.

Samuel Beek samuelbeek

Block or report user

Report or block samuelbeek

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
samuelbeek / ImageTitleButton.swift
Created May 1, 2017
Button that contains image and title. Their relative position can be modified.
View ImageTitleButton.swift
// ImageTitleButton.swift
// Coyote
// Created by Samuel Beek on 01/05/2017.
// Copyright © 2017 Samuel Beek. All rights reserved.
import UIKit
samuelbeek / ForceTouchGestureRecognizer.swift
Created Jan 4, 2017
Swift 3 implementation of Kraken Devs' force touch recognizer
View ForceTouchGestureRecognizer.swift
// Source:
// Without this import line, you'll get compiler errors when implementing your touch methods since they aren't part of the UIGestureRecognizer superclass
import UIKit.UIGestureRecognizerSubclass
//Since 3D Touch isn't available before iOS 9, we can use the availability APIs to ensure no one uses this class for earlier versions of the OS.
@available(iOS 9.0, *)
public class ForceTouchGestureRecognizer: UIGestureRecognizer {
//Since it also doesn't make sense to have our force variable as a settable property, I'm using a private instance variable to make our public force property read-only
private var _force: CGFloat = 0.0
samuelbeek / playground.swift
Created Nov 16, 2016
Enums with Associated Values that conform to NSCoding
View playground.swift
// Inspiration:
//: Playground - noun: a place where people can play
import UIKit
enum SavableEnum {
case simpleCase
case associatedValue(String)
case anotherAssociated(Int)
extension SavableEnum {
samuelbeek / RandomColor.swift
Created Jun 15, 2016
Return random color (nice for debugging)
View RandomColor.swift
extension UIColor {
static func randomColor(alpha: CGFloat?) -> UIColor {
let red:CGFloat = CGFloat(drand48())
let green:CGFloat = CGFloat(drand48())
let blue:CGFloat = CGFloat(drand48())
return UIColor(red: red, green: green, blue: blue, alpha: alpha ?? 1.0)
samuelbeek / CartographyExtensions.swift
Created Jun 14, 2016
Making Cartography compile faster.
View CartographyExtensions.swift
// CartographyExtensions.swift
// portkey
// Created by Samuel Beek on 14/06/16.
// Note: still WIP. I only dealt with the equality operator (==), haven't worked on <= and ~ yet.
// But adding this won't be bad for you project, it saves me 70% compile time per block on avarage.
import Foundation
samuelbeek / UIDeviceHelpers.swift
Created Apr 21, 2016
All devices in one big enum
View UIDeviceHelpers.swift
import Foundation
public extension UIDevice {
public enum Model {
case iPodTouch5, iPodTouch6, iPhone4, iPhone4s, iPhone5, iPhone5c, iPhone5s, iPhone6, iPhone6Plus, iPhone6s, iPhone6sPlus, iPhoneSE, iPad2, iPad3, iPad4, iPadAir, iPadAir2, iPadMini, iPadMini2, iPadMini3, iPadMini4, iPadPro, AppleTV, Simulator, None
static var model: Model {
var systemInfo = utsname()
samuelbeek / TypingLabel.swift
Created Dec 9, 2015
Typewriting effect in swift
View TypingLabel.swift
// TypingLabel.swift
// Created by Samuel Beek on 09/12/15.
// Copyright © 2015 Samuel Beek. All rights reserved.
import UIKit
import SwiftyTimer
View SearchbarViewController.swift
self.resultSearchController = ({
let controller = UISearchController(searchResultsController: nil)
controller.searchResultsUpdater = self
controller.dimsBackgroundDuringPresentation = false
controller.hidesNavigationBarDuringPresentation = false
controller.searchBar.barStyle = .Black
self.tableView.tableHeaderView = controller.searchBar
View HiddenBackgroundNavigationBar.swift
// remove navigation bar
navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)
navigationController?.navigationBar.shadowImage = UIImage()
navigationController?.navigationBar.translucent = true
samuelbeek / AppDelegate.swift
Created Nov 25, 2015
Set application wide navigation bar appereance
View AppDelegate.swift
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
UINavigationBar.appearance().barStyle = UIBarStyle.Black
// rest of the didFinishLaunch stuff
You can’t perform that action at this time.