Skip to content

Instantly share code, notes, and snippets.

View kiliankoe's full-sized avatar
👩‍💻

Kilian Koeltzsch kiliankoe

👩‍💻
View GitHub Profile
#!/usr/bin/env xcrun swift
import Foundation
struct Pod {
let source: String
let name: String
let version: String
let platforms: String
@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 }
@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 / 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 + 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> {
#!/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 / 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/"
@kiliankoe
kiliankoe / clfdns.rb
Last active February 22, 2019 20:37
Cloudflare DynDNS
#! /usr/bin/env ruby
require 'net/http'
require 'cloudflare'
# Email used for login
CLOUDFLARE_EMAIL = ENV["CLOUDFLARE_EMAIL"]
# API Key, can be found here => https://www.cloudflare.com/a/account/my-account
CLOUDFLARE_API_KEY = ENV["CLOUDFLARE_API_KEY"]

Keybase proof

I hereby claim:

  • I am kiliankoe on github.
  • I am kilian (https://keybase.io/kilian) on keybase.
  • I have a public key ASCz4sJieKckxHJqOiR30vsRPg47ypoeanEFpDPUAuPuigo

To claim this, I am signing this object:

#! /usr/bin/env ruby
require 'mechanize'
mechanize = Mechanize.new
poll_name = ARGV[0]
options = ARGV.slice(1,ARGV.count)