Skip to content

Instantly share code, notes, and snippets.

View kiliankoe's full-sized avatar
👩‍💻

Kilian Koeltzsch kiliankoe

👩‍💻
View GitHub Profile
@kiliankoe
kiliankoe / highlightTODOFIXME.sh
Created March 11, 2016 20:17
Highlight TODOs and FIXMEs in Xcode - Add this as a Run Script Phase
TAGS="TODO:|FIXME:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" -or -name "*.swift" \) -not -path "*/Carthage/*" -print0 | xargs -0 egrep --with-filename --line-number --only-matching "($TAGS).*\$" | perl -p -e "s/($TAGS)/ warning: \$1/"
#!/bin/bash
if [ ! -z $QUERY_STRING ]
then
error="";
case $QUERY_STRING in
kaffee|"kaffee=")
cat <<-"EOK"
Status: 418 I'm a teapot
Content-type: text/html
@kiliankoe
kiliankoe / Dictionary + mapD.swift
Last active July 4, 2016 09:58
Dictionary Map
extension Dictionary {
func mapD<T: Hashable, U>(_ elementClosure: ((key: T, value: U) -> (T, U))) -> Dictionary<T, U> {
return self.map { (tuple) in
return elementClosure(key: tuple.0 as! T, value: tuple.1 as! U) // The compiler demands these casts exist 😕
}.toDictionary()
}
}
extension Sequence {
func toDictionary<T: Hashable, U>() -> Dictionary<T, U> {
@kiliankoe
kiliankoe / Dictionary+mapValues.swift
Created July 4, 2016 10:49
Dictionary mapValues
extension Dictionary {
func mapValues<TransformedValue: Sequence where Value: Sequence>(transform: (Value) -> TransformedValue) -> Dictionary<Key, TransformedValue> {
var newDict: [Key: TransformedValue] = [:]
for (k, v) in self {
newDict[k] = transform(v)
}
return newDict
}
}
@kiliankoe
kiliankoe / Dictionary+mapValues.swift
Created July 4, 2016 11:15
Dictionary mapValues
extension Dictionary {
func mapValues<T>(transform: (Value) -> T) -> Dictionary<Key, T> {
return Dictionary<Key, T>(zip(self.keys, self.values.map(transform)))
}
init<S: Sequence where S.Iterator.Element == (Int, [String])>(_ seq: S) {
self.init()
for (key, val) in seq {
self[key] = val // (!) Ambiguous reference to member 'subscript'
}
@kiliankoe
kiliankoe / coords.swift
Last active July 21, 2016 09:44
Coord pairs
let coords = [
13.723288596942021,
51.02547875103679,
13.723312997594022,
51.02553463039252,
13.723399424330877,
51.02551749405676
]
let lats = coords.enumerated().filter({ $0.offset % 2 == 0 }).map { $1 }
#!/usr/bin/env xcrun swift
import Foundation
struct Pod {
let source: String
let name: String
let version: String
let platforms: String
#import <Foundation/Foundation.h>
@interface Person : NSObject
{
@private char *name;
}
@property (readwrite, assign) char *name;
- (void)sayHello;
@end
package main
import (
"bytes"
"encoding/json"
"fmt"
"html"
"io/ioutil"
"net/http"
"os"
POST http://webapi.vvo-online.de/dm?format=json
Accept: application/json, text/plain, */*
{
"stopid": "33000037",
"time": "2016-11-13T16:01:12Z",
"isarrival": false,
"limit": 30,
"shorttermchanges": true,