Skip to content

Instantly share code, notes, and snippets.

@bjhomer
bjhomer / cross-view-lines.swift
Last active November 5, 2022 05:31
Creating cross-view lines in SwiftUI
//
// ContentView.swift
// SwiftUIPlayground
//
// Created by BJ Homer on 4/26/21.
//
import SwiftUI
@bjhomer
bjhomer / enumFilter.swift
Created January 15, 2019 16:42
Is there a better way to do this?
enum Thing {
case empty
case int(Int)
}
let things: [Thing] = [.empty, .int(3), .int(7)]
// Surely there's a more concise way to write this `filter` closure?
let intThings = things.filter({
if case Thing.int = $0 { return true }
@bjhomer
bjhomer / .gitconfig
Created April 27, 2018 20:19
git delete-merged
[alias]
delete-merged = !bash -c '\
REMOTE=$1 && \
REMOTE=${REMOTE:="origin"} && \
echo "Fetching $REMOTE" && \
git fetch $REMOTE --prune && \
git branch -vv | grep "gone]" | awk \"{ print \\$1 }\" | xargs git branch -d' -
# usage: `git delete-merged`
public extension NSLayoutConstraint.Priority {
public static func -(lhs: NSLayoutConstraint.Priority, rhs: Float) -> NSLayoutConstraint.Priority {
return NSLayoutConstraint.Priority(lhs.rawValue - rhs)
}
public static func +(lhs: NSLayoutConstraint.Priority, rhs: Float) -> NSLayoutConstraint.Priority {
return NSLayoutConstraint.Priority(lhs.rawValue + rhs)
}
}
@bjhomer
bjhomer / fish_prompt.fish
Created June 27, 2017 20:31
My fish prompt
# ~/.config/fish/functions/fish_prompt.fish
function fish_prompt --description 'Write out the prompt'
# Just calculate these once, to save a few cycles when displaying the prompt
if not set -q __fish_prompt_normal
set -g __fish_prompt_normal (set_color normal)
end
set -l delim '$'
@bjhomer
bjhomer / operationCompletionBlock.swift
Last active June 2, 2017 19:38
Proof that NSOperation.completionBlock is not being cleared.
// Run this in an iOS playground. It works correctly on Mac.
import Foundation
import PlaygroundSupport
let page = PlaygroundPage.current
page.needsIndefiniteExecution = true
@bjhomer
bjhomer / feed.json
Created May 19, 2017 16:29
Check the md5 for the thumbnail of moment ID 2230DA8A73AE42958884030BEA8EC958
{
"cursor": 302,
"revision": {
"entryId": "796C229F25F64223ABF87CEB05AA273B",
"saveDate": 1475160495641,
"featureFlags": "1",
"editDate": 1475160494747,
"journalId": "398870",
"revisionId": 2538,
"moments": [
import Foundation
enum Foo: Error {
case dogAteHomework
}
func makesAnError(_ error: NSErrorPointer) {
autoreleasepool {
error?.pointee = Foo.dogAteHomework as NSError
}
[519/1021] Building HTML documentation
FAILED: docs/CMakeFiles/docs_html
cd /Users/bjhomer/Projects/swift-source/swift/docs && /usr/local/bin/sphinx-build -W -D latex_paper_size=letter -d /Users/bjhomer/Projects/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/doctrees -b html . /Users/bjhomer/Projects/swift-source/build/Ninja-DebugAssert/swift-macosx-x86_64/docs/html
Running Sphinx v1.6b3
/usr/local/Cellar/python/2.7.7_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Sphinx-1.6b3-py2.7.egg/sphinx/util/requests.py:64: UserWarning: Some links may return broken results due to being unable to check the Server Name Indication (SNI) in the returned SSL cert against the hostname in the url requested. Recommended to install "requests[security]" as a dependency or upgrade to a python version with SNI support (Python 3 and Python 2.7.9+).
'Some links may return broken results due to being unable to '
Warning, treated as error:
unknown config value 'latex_paper_size' in override, ignor
@bjhomer
bjhomer / crowder_climate.md
Last active May 31, 2017 01:45
Response to Ben Crowder's "Top 5 climate myths" video

I was sent a link to a video by Ben Crowder, titled DEBUNKED: Top 5 "Climate Change" Myths. (Link) The person who sent me the video said that it encapsulates a lot of their own skepticism about climate change, and wanted to know if I had any response. This is my response.


Crowder makes a bunch of argments, but groups them broadly under 5 main claims. We'll address them individually.

1: There's no Scientific Consensus

Claim:

  • The initial paper showing a 97% consensus among scientists has some flaws. They didn't sample enough people, etc. So we don't really know how much consensus there is.