Skip to content

Instantly share code, notes, and snippets.

import Foundation
extension ImplicitlyUnwrappedOptional: BooleanType {
/// Gets the boolean value of an implicitly unwrapped optional type
/// For all .None or nil values return false. Otherwise return true
public var boolValue: Bool {
return self != nil
}
//
// main.swift
// QuickSort
//
// Created by ChristianEnevoldsen on 17/08/15.
// Copyright © 2015 Reversebox. All rights reserved.
//
import Foundation
func initialize() {
self.layer.actions = [
"onOrderOut": NSNull(),
"sublayers": NSNull(),
"contents": NSNull(),
"bounds": NSNull()
]
}
func changed() {
//
// UINavigationController+CompletionHandler.h
// Entire
//
// Created by ChristianEnevoldsen on 10/08/14.
// Copyright (c) 2014 Reversebox. All rights reserved.
//
#import <UIKit/UIKit.h>
def minMax(lower, upper, n):
return max(lower, min(upper, n))
print minMax(0, 100, 100) == 100
print minMax(0, 100, 101) == 100
print minMax(0, 100, -1) == 0
print minMax(0, 100, 101) / 100;
@chrene
chrene / ListShuffler.sml
Last active December 28, 2015 22:29
List Shuffler
;load "Random";
(* Laver en liste fra 0 til og med n *)
fun listTo n = List.tabulate(n+1, fn n => n);
(* Skifter rækkefølgen af elementerne i en liste tilfældigt.
(Blander listen) *)
fun shuffle(xs) =
let
val rg = Random.newgen()
@chrene
chrene / NSString+sizeWithFont.h
Created August 5, 2013 18:01
NSString extension that allows calculating the size of a string more like sizeWithFont:
//
// NSString+sizeWithFont.h
// UTNoteLabelView
//
// Created by Christian Enevoldsen on 05/08/13.
// Copyright (c) 2013 Utunity. All rights reserved.
//
#import <Foundation/Foundation.h>