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 sys | |
import os | |
import warnings | |
import zlib | |
import struct | |
import random | |
import shutil | |
import zipfile | |
from zipfile import ZipFile | |
import 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
MAX_TRANSLATE = 6; | |
const elements = [ | |
"background", "clouds", "back-mountain", "front-mountain", | |
"hills-4", "hills-3", "hills-2", "hills-1", "birds" | |
].map(klass => document.querySelector(`.${klass}`)); | |
function updatePositions(height, width) { | |
const maxVHTranslation = -height * MAX_TRANSLATE; |
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
toss = {"Fair": ["Heads", "Tails"], "Biased": ["Heads", "Heads"]} | |
@do | |
def coins(): | |
coin = yield ["Fair", "Biased"] | |
result = yield toss[coin] | |
_ = yield guard(result == "Heads") | |
return coin | |
# Probability of a biased coin, given you observed Heads, is 2/3. |
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
data CoinType = Fair | Biased deriving (Show) | |
data Coin = Head | Tail deriving (Eq,Show) | |
toss Fair = [Head, Tail] | |
toss Biased = [Head, Head] | |
pick = [Fair, Biased] | |
experiment = do | |
coin <- pick -- Pick a coin at random |
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 functools import wraps | |
def do(f): | |
def partial_run(f, args, kwargs, values_so_far=()): | |
# First, create a NEW instance of the coroutine. | |
coroutine = f(*args, **kwargs) | |
# Advance the coroutine to the first yield point. | |
yielded_monad = next(coroutine) |
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 React, { useState } from "react"; | |
import posed from "react-pose"; | |
import "./App.css"; | |
const Box = posed.div({ | |
regular: { width: '10vw', height: '10vh', flip: true }, | |
fullscreen: { width: "100vw", height: '100vh', flip: true } | |
}); |
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 React, { useState } from "react"; | |
import posed from "react-pose"; | |
import "./App.css"; | |
export default function App() { | |
const [fullscreen, setFullscreen] = useState(false); | |
const toggle = () => setFullscreen(!fullscreen); | |
const pose = fullscreen ? 'fullscreen' : 'regular'; |
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
document.addEventListener("mousemove", event => { | |
const height = event.clientY / window.innerHeight; | |
const width = event.clientX / window.innerWidth; | |
updatePositions(height, width); | |
}); | |
window.addEventListener("deviceorientation", event => { | |
const height = -event.beta / 90; | |
const width = event.gamma / 180; |
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
<svg width="120" height="120" class="ring two"> | |
<circle class="path" cx="60" cy="60" | |
r="58" stroke="rgb(176, 168, 142)" | |
stroke-width="2" fill="none" /> | |
</svg> |
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
.ring.two { | |
stroke-dasharray: calc(2 * 3.1415 * 58); | |
stroke-dashoffset: calc(2 * 3.1415 * 58); | |
stroke-dashoffset: -calc(2 * 3.1415 * 58); | |
transform: rotate(-90deg); | |
transition: stroke-dashoffset linear 0.5s; | |
} | |
.button:hover .ring.two { | |
stroke-dashoffset: 0; |