Skip to content

Instantly share code, notes, and snippets.

View Trevoke's full-sized avatar
🎹
insert meme here.

Trevoke Trevoke

🎹
insert meme here.
View GitHub Profile

The logical relations between Go scoring systems

What is the simplest Go scoring system? It's this:

  • Stone Scoring: just count the stones on the board

At the end of the game, both players will want to fill in as much of their own territory as they can, while allowing two eyes per group (so they aren't captured). Then the winner is just the player with more stones on the board. Note that prisoners are not counted.

But nobody wants to play all these extra stones at the end. So we can instead use:

# In case anyone is wondering how to easily use the :crypto hash or hmac API's from elixir-land, here you go.
File.stream!(filename, [:read, {:read_ahead, 65535}], 65535)
|> Enum.reduce(:crypto.hash_init(:sha), &:crypto.hash_update(&2, &1))
|> :crypto.hash_final
|> Base.encode16
# Line 3 opens up a stream, and we're reading in 64KB chunks from the FS which is roughly pretty efficient
# In line 4, we initialize our hash (which returns a context) and put that as the default value in the reducer
# The hash_update in the reducer returns the modified context. Remember arg1 is the item, and arg2 is the accumulator
@Avaq
Avaq / combinators.js
Last active May 1, 2024 09:38
Common combinators in JavaScript
const I = x => x
const K = x => y => x
const A = f => x => f (x)
const T = x => f => f (x)
const W = f => x => f (x) (x)
const C = f => y => x => f (x) (y)
const B = f => g => x => f (g (x))
const S = f => g => x => f (x) (g (x))
const S_ = f => g => x => f (g (x)) (x)
const S2 = f => g => h => x => f (g (x)) (h (x))
;; I would like a function that inserts a phrase or paragraph into a
;; buffer, but that it is looks like it is being typed. This means to
;; have a slight, but random time delay between each letter. Calling
;; `sit-for' is sufficient for short sentences (around 140
;; characters), but anything longer makes the display look like it
;; hangs until some event, and then the entire results are displayed.
;;
;; Ideas or thoughts on what to look for?
(defun insert-typewriter (str)
@jordanpoulton
jordanpoulton / pair_programming_roles
Last active September 11, 2023 23:18
Pair Programming Role Definitions - Driver:Navigator
Driver:
-Write the code according to the navigator's specification
-Listen intently to the navigators instructions
-Ask questions wherever there is a lack of clarity
-Offer alternative solutions if you disagree with the navigator
-Where there is disagreement, defer to the navigator. If their idea fails, get to failure quickly and move on
-Make sure code is clean
-Own the computer / keyboard
-Ignore larger issues and focus on the task at hand
-Trust the navigator - ultimately the navigator has the final say in what is written

A small sampling of external projects initially built for Ember use but designed to be used standalone:

···································································································
·PORT IVY SURFACE MAP··············································································
···································································································
···································································································
······································································A·allyway····················
······································································B·beach······················
··············B-B-T-B-B-B·············································C·lighthouse·················
·············/···/·······\············································D·docks······················
············B·Z-E-Q-R·····B-B·········································E·Main St····················
·············\··|············\········································F·bank·······················
A = ->(s){ s << "a" }
B = ->(s){ s << "b" }
C = ->(s){ s << "c" }
str = ""
class Object
PIPED = ->(*args, arg){ arg.is_a?(Proc) ? arg[PIPED[*args]] : arg }
@pcreux
pcreux / pipable.rb
Last active June 12, 2018 17:08
*nix has pipes, Elixir has pipes, Ruby deserves pipes.
# Elixir has pipes `|>`. Let's try to implement those in Ruby.
#
# I want to write this:
#
# email.body | RemoveSignature | HighlightMentions | :html_safe
#
# instead of:
#
# HighlightMentions.call(RemoveSignature.call(email.body)).html_safe
#
@kachayev
kachayev / concurrency-in-go.md
Last active March 11, 2024 11:27
Channels Are Not Enough or Why Pipelining Is Not That Easy