Skip to content

Instantly share code, notes, and snippets.

@cakl
cakl / blackfriday.list
Created November 17, 2018 15:56
Stuff to buy on Black Friday
Software
========
- Deckset Version 2.0 - https://www.deckset.com/
- Dash App Version 4.0 - https://kapeli.com/dash
- GitTower - https://www.git-tower.com/mac
- 1Password - https://1password.com
@cakl
cakl / curriedLogin.swift
Created March 30, 2016 13:43
Curry Example
//: stolen from https://www.objc.io/blog/2014/11/17/functional-snippet-7-applicative-functors/
func login(email: String, pw: String, success: Bool -> ()) {
if email == "email" && pw == "pw" {
success(true)
} else {
success(false)
}
}
@cakl
cakl / patternMatching.swift
Created March 2, 2016 01:04
Swift Pattern Matching
//example from https://developer.apple.com/library/mac/documentation/Swift/Conceptual/Swift_Programming_Language/TypeCasting.html
//data
var things = [Any]()
things.append(0)
things.append(0.0)
things.append(42)
things.append(3.14159)
things.append("hello")
things.append((3.0, 5.0))
@cakl
cakl / capturing.swift
Last active February 24, 2016 13:36
Some Capturing in swift
/*
based on https://twitter.com/chriseidhof/status/695150433967456256
*/
var funs : [() -> Int] = []
for(var i = 0; i < 10; i++) {
funs.append({[i] () -> Int in //capture list -> capture by copy
return i
})
funs.append({() -> Int in // capture by reference
@cakl
cakl / Imports.h
Last active February 21, 2016 22:23
portfoliopage includes
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <SDWebImage/UIImageView+WebCache.h>
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioServices.h>
#import <CoreMotion/CoreMotion.h>
#import <CoreLocation/CoreLocation.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import <Parse/Parse.h>
#import <AFNetworking.h>
@cakl
cakl / CallByName.scala
Last active December 30, 2015 00:47
Call by Name Chaos
def unless(condition:Boolean, value:Int, then: => Unit ) = {
if(!condition) {
then
}
}
unless(1+2==3, 42, throw new RuntimeException) //no runtime exception
def unless(condition:Boolean, value:Int, then:Int => Unit ) = {
if(!condition) {
then(value)
@cakl
cakl / TraitLin.scala
Created December 29, 2015 21:28
Trait Linearization
class Animal() {
def msg()=println("Animal")
}
trait Furry extends Animal {
override def msg()={
super.msg()
println("Furry")
}
}
trait HasLegs extends Animal {
@cakl
cakl / pattern.scala
Created December 27, 2015 23:34
Pattern matching with types
//pattern matching with types
abstract class Point {
def x : Int
def y : Int
}
case class Point3D(x:Int, y:Int, z:Int) extends Point
val p : Point = Point3D(1,2,3)
def matchAPoint(p : Point) = {
@cakl
cakl / gisexample.sql
Last active August 29, 2015 14:27
gisexample
--guess my hometown
gisdb> select name from gemeinden where st_touches(geom, (select geom from gemeinden where gid=221));
/*
+----------------+
| name |
|----------------|
| St. Gallen |
| Hundwil |
| Teufen (AR) |
| Herisau |
@cakl
cakl / linqexercises.cs
Created January 18, 2015 05:00
Some LINQ Exercises
namespace LinqTests
{
class Student {
public int Id { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
class Course {