Skip to content

Instantly share code, notes, and snippets.

View xaviervia's full-sized avatar

Fernando Via Canel xaviervia

View GitHub Profile
@xaviervia
xaviervia / index.html
Created September 24, 2020 11:24
lights
<script src="./script.js"></script>
<!-- <script src="./test.js" type="module"></script> -->
<style> body { margin: 0 } </style>
<canvas />
// --- WASM COMMANDS
const WASM_BINARY_MAGIC = [0x00, 0x61, 0x73, 0x6d]
const WASM_BINARY_VERSION = [0x01, 0x00, 0x00, 0x00]
const HEADER = WASM_BINARY_MAGIC.concat(WASM_BINARY_VERSION)
const I32 = 0x7F
const I32_ADD = 0x6a
const SECTION_CODE_TYPE = 0x01
const SECTION_CODE_FUNCTION = 0x03
const SECTION_CODE_EXPORT = 0x07
const R = require('ramda')
const args = [2, [1, 2, 3]]
const output = [[1, 2], [3]]
const whichRamdaFunctionShouldIUse = (args, output) => {
return Object.keys(R).filter((key) => {
if (typeof R[key] !== 'function') {
return false
}
data Alignment
= LeftAligned
| CenterAligned
| RightAligned
data FontLevel
= DisplayTitle
| BodyText
data Variant
@xaviervia
xaviervia / RiemannZeta.idr
Created November 4, 2017 16:54
Riemann 𝜻 function in Idris, quick and dirty implementation for the rationals that prints information on each iteration
riemannZeta : (s : Double) -> IO Double
riemannZeta s = riemannZetaStep s 1.0 0.0
where riemannZetaStep : (s : Double) -> (n : Double) -> (p : Double) -> IO Double
riemannZetaStep s n p =
do let currentPower = pow n s
let currentFraction = 1.0 / currentPower
let currentValue = currentFraction + p
putStrLn ("s " ++ show s)
putStrLn ("n " ++ show n)
putStrLn ("power " ++ show currentPower)
const buttonLayout = createLayoutStyles({
spacing: {
top: 0,
bottom: 0,
left: 0,
right,
},
size: {
height: 500,
@xaviervia
xaviervia / Cell.idr
Last active June 4, 2017 00:57
Simple Cell recomputation
data Recomputation a = Same a
| Different a
data Cell : Type where
MkCell : Eq b => (computation : (a -> b)) -> (value : Recomputation (a, b)) -> Cell
recompute : Cell -> Cell
recompute (MkCell computation (Same x)) = MkCell computation (Same x)
recompute (MkCell computation (Different (a, b))) =
let
interface Parseable a where
parse : String -> a
data Name : Type where
MkName : String -> Name
Parseable Name where
parse = MkName
data A : Type -> Type where
import Data.Vect
Matrix : Nat -> Nat -> Type -> Type
Matrix x y t = Vect x (Vect y t)
createEmpties : Vect n (Vect 0 elem)
createEmpties = replicate _ []
transposeMatrix : Matrix rows columns elem ->
Matrix columns rows elem
  • Responsive chrome
  • Zoom of contents
  • Path animation with React Motion on mouse event
  • Inlining HTML

Notes:

  • Because all position is absolute and done with transforms, is super fast to animate