Skip to content

Instantly share code, notes, and snippets.

View metric-space's full-sized avatar

Luke Meyers metric-space

View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@metric-space
metric-space / jaxkarpathy.py
Last active April 1, 2023 18:51
Karpathy's charRNN using primitive jax
import jax.numpy as jnp
from jax import jit, vmap, grad, value_and_grad
from jax import random
import jax
SEED = 42234
key = random.PRNGKey(SEED)
# hyperparameters
hidden_size = 100
#!/bin/bash
set +e
curl ww.somesitethatdoesnotexist.com
@metric-space
metric-space / interleave.hs
Created December 11, 2022 09:41
DP problem to check if a string is the result of interleaving two strings
import Data.Map qualified as M
import Data.List qualified as L
is_interleaved :: String -> String -> String -> Bool
is_interleaved a b inte = let alen = length a
blen = length b
k x y
| (x == alen) = drop y b == drop (x+y) inte
| (y == blen) = drop x a == drop (x+y) inte
| otherwise = ((a L.!! x == dest_elem) && ds M.! (x + 1,y)) || ((b L.!! y == dest_elem) && ds M.! (x ,y + 1))
@metric-space
metric-space / rrt.hs
Created December 6, 2022 08:12
implementation of Rapidly-exploring random tree (algorithm on wikipedia: https://en.wikipedia.org/wiki/Rapidly-exploring_random_tree)
import qualified Data.List as L
import Control.Monad (foldM)
import qualified Data.Map as M
import System.Random (randomRIO, RandomGen, randomR, initStdGen )
import Debug.Trace (trace)
import qualified Data.Set as S
type ConfigMap = (Int, Int)
type Vertex = (Int, Int)
type Graph = M.Map Vertex [(Vertex)]
import Data.Maybe (fromMaybe)
import Debug.Trace (traceShow, trace)
data GameTree a = Leaf a | Nodes (Maybe a) [GameTree a] deriving (Show, Eq)
type IsMaximizingPlayer = Bool
example :: GameTree Int
example =
Nodes Nothing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@metric-space
metric-space / cut.sh
Last active January 8, 2021 05:36
split csv into n files with each file containing content as well as csv header
inputfile=$1
filename="${inputfile%.*}"
line_count=$(wc -l < $1)
row_count=$((${line_count} - 1))
movement=$(($row_count/$2))
@metric-space
metric-space / move.sh
Created April 24, 2020 22:52
personal bash script to move pdfs of a certain page count to a folder
ls | grep -i .pdf | while read -r line ; do
egg=$(pdfinfo "$line" | grep Pages | sed 's/[^0-9]*//')
if [ $egg -gt 20 ]; then
echo "Processing $line with $egg"
mv "$line" BOOKS
fi
done
#!/usr/bin/env python
import os.path
import sys
import datetime
project_clj = "project.clj"
migration_directory = "resources/migrations"