This file contains 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 rg | |
import random | |
class Robot: | |
def act(self, game): | |
self.game = game | |
max_angry = 10 | |
angry = 8 |
This file contains 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
[12] pry(main)> Digest::MD5.hexdigest('one two three four five six seven eight nine ten').to_i(16) % (2**100) | |
=> 1097922911283534226527226500115 |
This file contains 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 functools | |
import timeit | |
def fib(x): | |
if x <= 1: | |
return 1 | |
return fib(x-1) + fib(x-2) | |
@functools.lru_cache() | |
def cached_fib(x): | |
if x in (0,1): |
This file contains 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 abc import ABCMeta | |
from enum import Enum | |
import typing as t | |
class AbstractDFA: | |
... | |
T = t.TypeVar('T', bound=t.Type[AbstractDFA]) | |
This file contains 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 logger ---- | |
EXTENDS Integers, TLC, Sequences | |
Files == { "a" } | |
FileStruct == [ requested : BOOLEAN, uploaded : {FALSE}, logged : {FALSE}, downloaded : {FALSE}] | |
Range(F) == { F[x]: x \in DOMAIN F } | |
(* --algorithm logger | |
variables files \in [Files -> FileStruct]; | |
define | |
FileProc(proc) == [ f : Files, p : {proc} ] |
This file contains 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
EXTENDS Integers, TLC, Sequences | |
CONSTANTS Devices | |
(* --algorithm BatchInstall | |
variables | |
AppScope \in [Devices -> {0, 1}]; | |
Installs \in [Devices -> BOOLEAN]; | |
batch_pool = {}; | |
lock = FALSE; |
This file contains 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
EXTENDS Integers, TLC, Sequences | |
CONSTANTS Devices | |
(* --algorithm BatchInstall | |
variables | |
AppScope \in [Devices -> {0, 1}]; | |
Installs \in [Devices -> BOOLEAN]; | |
batch_pool = {}; | |
define |
This file contains 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
EXTENDS Integers, Sequences, TLC, FiniteSets | |
(* --algorithm deadlock | |
variable mq = <<>>; | |
macro add_message(msg) begin | |
await Len(mq) < 5; | |
mq := Append(mq, <<msg>>); | |
end macro |
This file contains 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
aws_pipeline = client.create_pipeline(name: pipeline_name, | |
unique_id: pipeline_uid, | |
description: 'Automatic') | |
begin | |
# AWS uses different JSON formats for CLI and ruby sdk. | |
tempjson = Tempfile.new('tempjson') | |
tempjson.write(JSON.dump(pipeline_schema)) | |
tempjson.rewind | |
`aws datapipeline put-pipeline-definition --pipeline-id #{aws_pipeline.pipeline_id} --pipeline-definition file://#{tempjson.path}` | |
ensure |
This file contains 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
{{ with index $.Site.Data.person (.Get 0) }} | |
{{ if .site }} | |
{{ printf "[%s](%s)" .name .site | markdownify }} | |
{{ else }} | |
{{ .name }} | |
{{ end }} | |
{{ end }} |
OlderNewer