WWDC 2007 2008 2009 2010 2011 2012 2013 2014 2015
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# taken from https://blog.wotw.pro/sort-git-config/ | |
# the options for each property need to be indented using a single tab beforehand... | |
cat ~/.config/git/config | sed 's/ +/\t/g' | awk -F '\t' '$1 { current = $1; print current } $2 { print current "\t" $2}' | sort | awk -F '\t' '!$2 {print $1} $1 && $2 { print "\t" $2 }' | pbcopy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// reconnect when slack websocket disconnects, taken from multi readme | |
setInterval(() => { | |
if (document.body.innerText.includes('Load new messages.')) | |
window.location.reload(); | |
}, 90000); | |
// find in page, taken from multi readme | |
(() => { | |
const highlightResults = (text, color) => { | |
document.designMode = "on"; // https://stackoverflow.com/a/5887719 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
final class Day1520: Day { | |
override func perform() { | |
let numbers = String.input(forDay: 15, year: 2020) | |
.split(separator: ",") | |
.map(String.init) | |
.map(Int.init) | |
.compactMap { $0 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension String { | |
var asUInt64: UInt64 { UInt64(self, radix: 2)! } | |
func masking(with mask: String, mapper: (Character, Character) -> Character) -> [Element] { | |
zip(padded(with: "0", toLength: 36), mask).map(mapper) | |
} | |
func padded(with character: String, toLength length: Int) -> String { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
final class Day1320: Day { | |
override func perform() { | |
let components = String.input(forDay: 13, year: 2020).split(separator: "\n") | |
let estimate = Int(String(components[0]))! | |
let buses = components[1] | |
.split(separator: ",") | |
.map(String.init) | |
.map(Int.init) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
final class Day1020: Day { | |
override func perform() { | |
let input = String.input(forDay: 10, year: 2020) | |
var joltages = input | |
.split(separator: "\n") | |
.map(String.init) | |
.map(Int.init) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
enum Operation: String { | |
case noOperation = "nop" | |
case accumulator = "acc" | |
case jump = "jmp" | |
} | |
struct Instruction { | |
let operation: Operation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var numbers = [1, 2, 3, 4, 5] | |
numbers.forEach { num in | |
print("num: \(num)") | |
print("numbers: \(numbers)") | |
if num == 2 { | |
numbers = numbers.reversed() | |
} | |
print("numbers: \(numbers)") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let input = """ | |
Step X must be finished before step C can begin. | |
Step C must be finished before step G can begin. | |
Step F must be finished before step G can begin. | |
Step U must be finished before step Y can begin. | |
Step O must be finished before step S can begin. | |
Step D must be finished before step N can begin. | |
Step M must be finished before step H can begin. |
NewerOlder