Skip to content

Instantly share code, notes, and snippets.

View arianvp's full-sized avatar
🎱
Focusing

Arian van Putten arianvp

🎱
Focusing
View GitHub Profile
@arianvp
arianvp / gist:9116037
Last active August 29, 2015 13:56
Sql divisie
SELECT id,name
FROM Driver AS D
WHERE NOT EXISTS (
SELECT *
FROM Route AS R
WHERE R.numberOfStops > 10
AND NOT EXISTS (
SELECT *
FROM Schedule AS S
WHERE S.driverID = D.id
<?php
class User
{
public function __construct($db)
{
$this->db = $db;
}
// calculates a user's mbt
<link rel="import" href="../core-animated-pages/core-animated-pages.html">
<link rel="import" href="../core-animated-pages/transitions/hero-transition.html">
<link rel="import" href="../core-animated-pages/transitions/cross-fade.html">
<link rel="import" href="../core-animated-pages/transitions/slide-down.html">
<link rel="import" href="../core-animated-pages/transitions/slide-up.html">
<link rel="import" href="../core-animated-pages/transitions/tile-cascade.html">
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
<link rel="import" href="../core-animated-pages/core-animated-pages.html">
<link rel="import" href="../core-animated-pages/transitions/hero-transition.html">
<link rel="import" href="../core-animated-pages/transitions/cross-fade.html">
<link rel="import" href="../core-animated-pages/transitions/slide-down.html">
<link rel="import" href="../core-animated-pages/transitions/slide-up.html">
<link rel="import" href="../core-animated-pages/transitions/tile-cascade.html">
<link rel="import" href="../paper-button/paper-button.html">
<polymer-element name="my-element">
@arianvp
arianvp / gist:c167ceda0c5684da28c5
Last active August 29, 2015 14:04
99 problems and thunking probably is one

Basically we want something like: https://github.com/evancz/elm-html/blob/master/Html/Optimize/RefEq.elm

we want a function thunked :: (a -> VTree) -> a -> VTree

What it does is: say a -> VTree produces a quite complex VTree (which is expensive to build) we could just referentially compare a to it's previous version at previous render. IF they're equal, we just return the previous VTree. so we dont need to rebuild it.

    newtype VTree = VTree (JSRef VTree) -- 

foreign import javascript unsafe "new Thunk($1, $2)"

import GHCJS.Types
import GHCJS.Foreign
import Data.Text
newtype Elem = Elem (JSRef Elem)
foreign import javascript unsafe "document.createElement($1)"
js_newElem :: JSString -> IO Elem
@arianvp
arianvp / gist:956ddccc1e0614b5c23b
Last active August 29, 2015 14:05
Simple router
module Network.Wai.Middleware.VerySimpleRouter
( router
, dir
)
where
import qualified Data.Text as T
import Network.Wai (Request(..), Application, Middleware)
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCy0ANd0DzAS5Hk/mtbjXYjPTZR0o+nG8ULh3pGr6406y1r4+kVEMJ0984SP1kG1y6TKiK4mIqY/ZPdn9QbSzMiZlJKm25ttNalA/Sdo7zCAAi+PiNbfiG2EPfSN+yFf6TutL5nk98DWeXXqSDMKU+Y61dQvnpbbvjVU/Zhi0GwR/Ln7h3In5vrOf5RQX3fmjrG0tndp6ESbLWjQ+kTxrErj/+uO6F/ozgHYuPnjeNBJPaQlHZN5VjiYihWRm9bGq0q+lO2dWsJwSTtK5kuTwgGzZ74kq20qpVfSqBCgn3k79tT0yLiloFQhSX5/Qwdx+9xhKALpLWTpgsGgLZg+2eL arian@arian-Aspire-V5-573G
module TodoItem where
import Hom
data TodoItem = TodoItem { _checked :: Bool, _description :: String }
instance Renderable TodoItem where
render (TodoItem checked description) = div [] [checkbox [checked:=checked] [render description]]
import java.io.Console;
interface Context {
State state();
void state(State state);
Console console();
}