- dining philosophers problem - many threads accessing the same memory lead to problems like deadlock / livelock
- locks? hard to think about, don’t compose, priority inversion
- thread-safe hash table doesn’t mean you can atomically move an entry from one hash table to another
- transactions in memory! ACI from ACID (memory isn’t durable)
- transactional memory does compose!
- but wait, rolling back a transaction can get really expensive, how is this a benefit?
- only allowed to perform operations that can be rolled back / undone
- Haskell already does this in the type system, non-issue there
- optimistic concurrency
- no work completed while waiting for a lock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # for long running commands | |
| function try () { | |
| tally $* && fin || die; # cargo install tally, replacement for time | |
| } | |
| function play_sound () { | |
| aplay -N -q $HOME/.bin/$1.au | |
| } | |
| function fin () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE OverloadedStrings #-} | |
| module Main where | |
| import Control.Applicative | |
| import Data.Attoparsec.Text hiding (take) | |
| import Data.Maybe | |
| import Data.Monoid | |
| import qualified Data.Sequence as S | |
| import qualified Data.Text.IO as TIO | |
| main :: IO () |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [root@nixos:~]# nixos-rebuild switch | |
| building Nix... | |
| building the system configuration... | |
| Warning: do not know how to make this configuration bootable; please enable a boot loader. | |
| activating the configuration... | |
| setting up /etc... | |
| setting up tmpfiles |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Edit this configuration file to define what should be installed on | |
| # your system. Help is available in the configuration.nix(5) man page | |
| # and in the NixOS manual (accessible by running ‘nixos-help’). | |
| { config, pkgs, ... }: | |
| { | |
| imports = | |
| [ # Include the results of the hardware scan. | |
| ./hardware-configuration.nix |
I hereby claim:
- I am shapr on github.
- I am shapr (https://keybase.io/shapr) on keybase.
- I have a public key ASA7FgvzEF2Ut3QWjCrZRiM4hGTsde3eotGWwha3zs2T_wo
To claim this, I am signing this object:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| def showbits(n): | |
| return "{0:b}".format(n) | |
| def findnum(n): | |
| rn = random.randrange(0,n) | |
| return (rn, showbits(rn)) | |
| def oddbits(s): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| viewer { | |
| login | |
| name | |
| bio | |
| isHireable | |
| createdAt | |
| } | |
| repository(owner: "owner", name: "reponame") { | |
| pullRequests(last: 20) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from hypothesis import given | |
| import hypothesis.strategies as st | |
| import json | |
| @given(st.one_of( st.integers(), st.text(), st.lists(st.text()))) | |
| def test_decode_inverts_encode(s): | |
| assert json.loads(json.dumps(s)) == s | |
| @given(x=st.floats(), y=st.floats(), z=st.floats()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Main where | |
| import System.Process (readProcess, callCommand) | |
| import Data.List (isInfixOf, words) | |
| import Data.List.Split (splitOn) | |
| main = do res <- readProcess "xinput" ["list"] "" | |
| let devices = (filter (isInfixOf "TouchPad") (lines res)) | |
| let ids = concatMap (filter (isInfixOf "id=") . words) devices | |
| mapM_ (callCommand . buildDisable) (map delId ids) |