Skip to content

Instantly share code, notes, and snippets.

@runarorama
runarorama / gist:e0b9107f707ef61db93eb67e4823798e
Created July 21, 2020 09:29
Jon Pretty seeks Rúnar's advice on writing better software
Jon Pretty sat down with Rúnar Bjarnason to get help with becoming a better programmer.
Jon: Rúnar, how can I write better software?
--- Prompt ends
Rúnar: Stop making so many bugs.
Jon: What should I do before releasing my code?
Everything after the first "Ayn Rand:" is generated by GPT-3.
----
The New York Times sat down with Ayn Rand to discuss her philosophy of Objectivism.
New York Times: Miss Rand, could you give us a brief summary of your philosophy?
Ayn Rand: The name of my philosophy is Objectivism. As I see it, the purpose of philosophy is to provide man with a comprehensive world view by answering three basic questions:
@runarorama
runarorama / gist:8c096fc1ff6472a5d1141903c4a45187
Created July 21, 2020 09:18
GPT-3 NYT interview with Ayn Rand
Everything after the first "Ayn Rand:" is generated by GPT-3.
----
The New York Times sat down with Ayn Rand to discuss her philosophy of Objectivism.
New York Times: Miss Rand, could you give us a brief summary of your philosophy?
Ayn Rand: The name of my philosophy is Objectivism. As I see it, the purpose of philosophy is to provide man with a comprehensive world view by answering three basic questions:
--- Prompt begins
Rúnar Bjarnason sat down with Ernest Hemingway to get help with becoming a writer.
Rúnar: Mr. Hemingway... can I call you Ernest?
--- Prompt ends
Ernest Hemingway: No.
☝️ The namespace ._prs.ceedubs.pr34 is empty.
._prs.ceedubs.pr34> pull-request.load git@github.com:unisonweb/base:.trunk git@github.com:ceedubs/unison-base:.prs._genEither
I checked out git@github.com:unisonweb/base:.trunk to base.
I checked out git@github.com:ceedubs/unison-base:.prs._genEither to head.
The merged result is in merged.
Use `diff.namespace base merged` to see what's been updated.
Use `todo merged.patch merged` to see what work is remaining for the merge.
@runarorama
runarorama / day2.u
Last active December 20, 2019 22:55
Advent of code 2019, day 2
Pos.doc = [: Represents a position in memory :]
unique type Pos = Pos Nat
-- Lets us refer to the Pos pattern unqualified
use Pos Pos
Error.doc = [: This ability lets us fail with an error anywhere. :]
ability Error where
@runarorama
runarorama / day2.u
Created December 4, 2019 21:20
Advent of Code, Day 2
unique type Pos = Pos Nat
use Pos Pos
ability IntCode where
add : Pos -> Pos -> Pos -> ()
mul : Pos -> Pos -> Pos -> ()
halt : ()
ability Error where
@runarorama
runarorama / day1.markdown
Last active December 8, 2019 12:42
Advent of Code (Unison Edition), day 1

Advent of Code 2019, in Unison

Spoilers for Advent of Code 2019 follow.

Day 1: The Tyranny of the Rocket Equation

Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2.

This describes a simple function. There seems to be an oversight in the problem statement that modules with very low mass have a negative fuel requirement. I'm going to assume that's not right, and that instead of integer subtraction, we want natural number subtraction (sometimes called "monus"). In Unison, we can use the Nat type instead of integers, so we don't have to consider negatives. The subtraction operation is called drop:

# Unison Metaprogramming ## Motivation The type io.Mode is _ _type io.Mode = Read | Write | Append | ReadWrite_ _

It really should be unique. We need to make this update. Now, a lot of programs use the io.Mode type, and we'd like them to use the new type. In order to do this, we have to:

1. Replace the hash of the old type with the new one wherever it appears in types or type annotations.

" Vim plugin for showing matching parens
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2018 Jul 3
" Exit quickly when:
" - this plugin was already loaded (or disabled)
" - when 'compatible' is set
" - the "CursorMoved" autocmd event is not available.
if exists("g:loaded_matchparen") || &cp || !exists("##CursorMoved")
finish