Skip to content

Instantly share code, notes, and snippets.

@bjhomer
bjhomer / instructions.md
Last active January 17, 2023 23:03
How to make the Day One command line tool automatically write to Day One 2

Using the Day One CLI with Day One 2

The dayone command line tool was originally written to work with Day One Classic, and by default writes its entries to the default Day One Classic journal directory1. If you want to use the dayone tool to write entries in to Day One 2 instead, there are a couple options.




Option 1. Use this option if you don't use Day One Classic at all.

@bjhomer
bjhomer / wwdc_stats.txt
Last active June 6, 2016 19:30
WWDC redacted schedule statistics
# The following WWDC information is based on the initial redacted WWDC
# schedule posted each year. Session counts generally change a bit
# each year as the conference draws closer, but these numbers are
# close enough for a rough estimate.
#
# While session names and descriptions are redacted, the underlying
# data still includes information about which platforms they target.
# This allows us to do a bit of comparative analysis. These numbers
# are for "sessions" only -- Keynote, "Get Togethers", Labs, etc. have
# been excluded.
@bjhomer
bjhomer / swift3.swift
Created October 4, 2016 23:06
What's wrong here?
func doThing(x: Int, y: Int, z: Int) -> Int {
return x + y + z
}
class Foo {
func doThing(x: Int) {
doThing(x: x, y: 2, z: 4) // extra argument 'y' in call
}
}
@bjhomer
bjhomer / searchingAString.swift
Last active February 2, 2017 16:45
Incrementally searching through a string in Swift
import Foundation
let str = "abXcdXefXg"
let start = str.startIndex
var searchStart = start
while let xRange = str.range(of: "X", range: searchStart..<str.endIndex) {
searchStart = xRange.upperBound
@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.
[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
import Foundation
enum Foo: Error {
case dogAteHomework
}
func makesAnError(_ error: NSErrorPointer) {
autoreleasepool {
error?.pointee = Foo.dogAteHomework as NSError
}
@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": [
@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 / 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 '$'