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 just(x){ return {just: x}; } | |
var nothing = {nothing: null}; | |
function maybe(d, f, m){ | |
if('nothing' in m){ | |
return d; | |
} | |
else if('just' in m){ | |
return f(m.just); | |
} | |
else{ |
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
(ns atomic-playground.sheets | |
(:import [com.google.api.client.http GenericUrl] | |
[com.google.api.services.drive.model File] | |
[com.google.api.client.googleapis.auth.oauth2 GoogleCredential GoogleCredential$Builder] | |
[com.google.api.client.http HttpTransport] | |
[com.google.api.services.drive Drive Drive$Builder] | |
[com.google.api.services.drive DriveScopes] |
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
{-# LANGUAGE ScopedTypeVariables #-} | |
{-# LANGUAGE AllowAmbiguousTypes #-} | |
import Test.QuickCheck | |
import Control.Monad | |
{- | |
This defines a "continuous space" I and a continuous function from I to itself. | |
You can interpret this space as a really low resolution continuous line segment | |
It consists of 5 "open subspaces": |
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
// code is for 16MHz adafruit trinket (atmel ATtiny85) | |
int red = 0; | |
int green = 1; | |
int blue = 2; | |
void setup() { | |
// put your setup code here, to run once: | |
pinMode(red, OUTPUT); | |
pinMode(green, OUTPUT); | |
pinMode(blue, OUTPUT); |
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 Foo where | |
import Data.Attoparsec.ByteString | |
import Data.Attoparsec.ByteString.Char8 | |
import Data.Attoparsec.Combinator | |
import Control.Applicative | |
import Data.Time | |
import Data.ByteString | |
import qualified Data.ByteString as BS | |
import Control.Monad |
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
withShader :: ShType -> Src -> (GLuint -> IO (Either String a)) -> IO (Either String a) | |
withShader ty src action = mask $ \restore -> do | |
eithv <- loadShader ty src | |
case eithv of | |
Left err -> return (Left err) | |
Right v -> restore (action v) `finally` deleteShader v |
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
d/dt enemies = keep <> new <> gone where | |
keep = mapWithKey (Ok . enemyAI) enemies | |
new = on buttonA newK (Create newEnemy) | |
gone = on buttonB target (Delete (enemies ! target)) | |
on but k act = unDelta (\d -> if d < 0 then singleton k act else mempty) (d/dt but) | |
ks = keys enemies | |
newK = maximum ks + 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
d/dt x = v | |
d/dt v = a | |
a = -x |
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
Let's say you have these equations: | |
a = -x | |
d/dt v = a | |
d/dt x = v | |
x and v are state variables and their initial values are a free choice. | |
Let's say x = 1 and v = 0 are the chosen starting state. | |
According to Wolfram Alpha, the solution to these equations and these initial values is: | |
x(t) = cos(t) |
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
/* The cord switch is attached to CORD_IN, and we're using internal pullups. | |
so normally the value reads HIGH. when cord is pulled and connects to ground, reads LOW. */ | |
/* In so many words, we're using the debounce protocol | |
described at university of utah "debouncing.pdf" section "software debouncers" */ | |
/* return 1 if cord pull is detected, else 0 */ | |
/* If 1 is returned, it will only be returned once (until cord is released and cycled). */ | |
#define DEBOUNCE_TIME 100 | |
int debounceState = HIGH; | |
int debounceTimer = DEBOUNCE_TIME; | |
int checkCordIn() { |
OlderNewer