Skip to content

Instantly share code, notes, and snippets.

@jlerche
jlerche / README.md
Created June 17, 2020 22:05 — forked from dishbreak/README.md
Google Foobar Ion Relabeling Solution

Ion Relabeling Solution

Acknowledgements

This post on StackExchange Code Review is the basis for this algorithm.

Problem Summary

Oh no! Commander Lambda's latest experiment to improve the efficiency of her LAMBCHOP doomsday device has backfired spectacularly. She had been improving the structure of the ion flux converter tree, but something went terribly wrong and the flux chains exploded. Some of the ion flux converters survived the explosion intact, but others had their position labels blasted off. She's having her henchmen rebuild the ion flux converter tree by hand, but you think you can do it much more quickly - quickly enough, perhaps, to earn a promotion! >

@jlerche
jlerche / notes_little_book_of_semaphores.md
Last active January 22, 2023 18:31
Notes on implementing synchronization techniques using semaphores, in rust, from The Little Book of Semaphores

Link to the book

Semaphore implementation in rust taken from the previously deprecated std-semaphore

Chapter 3

3.3 Rendezvous

If you have two threads, executing the following:

| Thread A | Thread B |

@jlerche
jlerche / naive_constant_module.ex
Created November 22, 2017 20:25
dumb naive module store
defmodule Store do
def get do
[:foo]
end
end
@jlerche
jlerche / naive_constant_ets_genserver.ex
Created November 22, 2017 03:19
A naive ets store
defmodule Store do
use GenServer
def start_link(state \\ [:foo]) do
GenServer.start_link(__MODULE__, state, name: __MODULE__)
end
def init(state) do
:ets.new(:store, [:named_table])
:ets.insert(:store, {:key, state})
@jlerche
jlerche / naive_constant_genserver.ex
Created November 22, 2017 02:56
A naive genserver constant store
defmodule Store do
use GenServer
def start_link(state \\ [:foo]) do
GenServer.start_link(__MODULE__, state, name: __MODULE__)
end
def init(state), do: {:ok, state}
def get, do: GenServer.call(__MODULE__, :get)
@jlerche
jlerche / 0_reuse_code.js
Created July 21, 2016 15:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console