Skip to content

Instantly share code, notes, and snippets.

View adamstener's full-sized avatar
🎧

Adam adamstener

🎧
View GitHub Profile
@a7madgamal
a7madgamal / dark.md
Last active November 24, 2024 16:39
Dark mode for Slack on MacOS
@khanlou
khanlou / Array+EachCons.swift
Last active July 7, 2020 17:48
each_cons from Ruby in Swift as a function on Sequence
extension Collection {
func eachConsecutive(_ size: Int) -> Array<SubSequence> {
let droppedIndices = indices.dropFirst(size - 1)
return zip(indices, droppedIndices)
.map { return self[$0...$1] }
}
}
@rnystrom
rnystrom / :(
Created November 3, 2014 16:37
A friendly challenge to anyone w/ functional chops to improve this function. No holds barred: op overloading, enum/struct/class, everything-is-a-singleton... go for it! The only rule is no forced unwrapping (e.g. !).
import Foundation
import ImageIO
func datesFromImagesInDir(dir: String) -> [NSDate] {
let fm = NSFileManager.defaultManager()
var error: NSError?
let df = NSDateFormatter()
df.dateFormat = "yyyy:MM:dd HH:mm:ss"