Skip to content

Instantly share code, notes, and snippets.

View lispandfound's full-sized avatar
🪤
Caught in Mouse Trap

Jake Faulkner lispandfound

🪤
Caught in Mouse Trap
  • QuakeCoRE
  • Christchurch, New Zealand
  • 17:25 (UTC +12:00)
View GitHub Profile
@lispandfound
lispandfound / model.py
Created May 5, 2021 08:51
Bengio et al model.
from collections import Counter
import tensorflow as tf
import tensorflow.keras as keras
import tensorflow.keras.layers as layers
from nltk import word_tokenize
class BengioModel(keras.Model):
''' Model that replicates the architecture of Bengio et al. '''
@lispandfound
lispandfound / ulam.hs
Created December 17, 2019 08:53
Ulam Spiral Code
module Lib
where
import Graphics.Gloss
density :: Float
density = 0.1
spiral :: [Float] -> [(Float, Float)]
spiral pts = map f pts
from enum import Enum, auto
class HeadMove(Enum):
LEFT = -1
RIGHT = 1
NOTHING = 0
class TuringMachine:
program := 0;
i := 0;
read program;
read i;
j := i;
l := 0;
data := 0;
while j >= 0 do
pow := 1;
k := 0;
@lispandfound
lispandfound / sort_of.py
Created March 29, 2019 23:53
sort_of in linear time
#!/usr/bin/env python
def sort_of(numbers):
""" Old bad code.
Computes the minimum element of each sublist from i..n where n is the length of the list. """
result = []
for i in range(len(numbers)):
sub = sorted(numbers[i:])
import Data.Foldable
import qualified Data.List as L
data Tree a = Node Integer (Tree a) (Tree a) a | Leaf deriving (Show, Eq)
data Direction a = L Integer a (Tree a) | R Integer a (Tree a)
newtype Zipper a = (Tree a, [Direction])
left :: Zipper a -> Zipper a
left z@(Zipper Leaf directions) = z
left (Zipper (Node lvl left right val) directions) = Zipper left $ (Left lvl val right):directions
import Data.Foldable
import qualified Data.List as L
data Tree a = Node Integer (Tree a) (Tree a) a | Leaf deriving (Show, Eq)
data Path = LeftP | RightP
instance Foldable Tree where
foldMap f Leaf = mempty
foldMap f (Node _ l r v) = foldMap f l `mappend` f v `mappend` foldMap f r
#!/usr/bin/env fish
set -l maths (cat)
echo 'stem:[' (string trim -- "$maths" ) ']'
asciiTeX "$maths"
color cursor black white
color status white default bold
color header black white
color title-blur white black
color title-focus white black bold
-- load standard vis module, providing parts of the Lua API
require('vis')
require('surround')
require('vis-commentary')
vis.events.subscribe(vis.events.INIT, function()
-- Your global configuration options
vis:command('set theme default-16')
vis:command('set ai on')
vis:command('set expandtab true')