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
const _Some = Symbol("some"); | |
const _None = Symbol("none"); | |
type Some<T> = { | |
type: typeof _Some; | |
value: T; | |
}; | |
type None = { | |
type: typeof _None; |
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 { Machine } from "./machine"; | |
import { Context, State } from "./models"; | |
describe("Machine", () => { | |
describe("Machine.create(state)", () => { | |
test("it returns an instance of state machine", () => { | |
const machine = Machine.create({ value: "saying.hello", context: {} }); | |
expect(machine).toBeInstanceOf(Machine); | |
}); | |
}); |
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 { Result } from "./result"; | |
describe("Result", () => { | |
describe("creating", () => { | |
describe("Result.ok()", () => { | |
test("it returns an ok result", () => { | |
const result = Result.ok("I'm good"); | |
expect(result.isOk()).toBeTruthy(); | |
}); |
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
optimalChargeDischarge←{ | |
⍝ ⍵ is a list of numbers | |
⍝ returns an array of 3 values (charge, discharge, revenue) | |
⎕IO←0 ⍝ zero based indexing is required | |
⍝ create table of differences between values | |
diffs←∘.(-⍨)⍨⍵ ⍝ flip subtraction as we are interested in the difference from left to right | |
mask←∘.<⍨⍳≢⍵ ⍝ Create a mask including only the upper right corner (excluding diagonal) | |
⍝ The upper right corner represents the differences that move forward in time |
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
const AUTH_URL = 'https://smartweather.weatherflow.com/authorize.html' | |
export const toAuthUrl = ({ | |
clientId: client_id, | |
codeChallenge: code_challenge, | |
}) => { | |
const params = { | |
response_type: 'code', | |
redirect_uri: '<REDIRECT_URL>', | |
code_challenge_method: 'S256', |
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 re | |
from functools import partial | |
stripPairs = partial(re.sub, "\(\)|\[\]|{}|<>", "") | |
def untilStable(f, x): | |
if ((y := f(x)) == x): return x | |
else: return untilStable(f, y) | |
navs = [ |
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
⌊/+/(|(⍳1+⌈/)∘.-⊢)in | |
⌊/+/((+/(1∘+⍤⍳⊢))⍤0⊢)(|(⍳1+⌈/)∘.-⊢)in |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<style> | |
body, html { | |
height: 100%; | |
margin: 0; | |
width: 100%; |
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
{"count": 20, "fitness_disciplines": [{"id": "walking", "name": "Walking"}, {"id": "strength", "name": "Strength"}, {"id": "cycling", "name": "Cycling"}, {"id": "stretching", "name": "Stretching"}, {"id": "running", "name": "Running"}, {"id": "beyond_the_ride", "name": "Floor"}, {"id": "circuit", "name": "Bootcamp"}, {"id": "yoga", "name": "Yoga"}, {"id": "meditation", "name": "Meditation"}, {"id": "cardio", "name": "Cardio"}], "rides": [{"scheduled_start_time": 1565883000, "rating": 0, "difficulty_rating_avg": 0.0, "equipment_tags": [], "difficulty_rating_count": 0, "captions": [], "title": "30 min Power Zone Ride", "is_explicit": false, "live_stream_id": "e571d20a9efc4e34a75a8bb3924acfd7-live", "origin_locale": "en-US", "difficulty_estimate": null, "content_format": "video", "location": "nyc", "original_air_time": 1565882340, "has_closed_captions": false, "pedaling_duration": 1800, "sample_vod_stream_url": null, "extra_images": [], "series_id": "9fde039566054ea499130bed1c289eb3", "studio_peloton_id": "7812b |
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
function fixup | |
set -lx current_branch (git rev-parse --abbrev-ref HEAD) | |
set -lx commits (git log --oneline $current_branch...origin/master)[-1..1] | |
set -lx len (count $commits) | |
printf "Fixup: Which commit would you like to fixup? \n\n" | |
for i in (seq $len) | |
printf "$i) $commits[$i]\n" | |
end |
NewerOlder