Skip to content

Instantly share code, notes, and snippets.

View pedrominicz's full-sized avatar

Pedro Minicz pedrominicz

View GitHub Profile
@pedrominicz
pedrominicz / snake.html
Last active August 10, 2019 20:28
Snake game in pure Javascript.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>snake</title>
<style type="text/css">
* { margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: #002f38; }
canvas {
@pedrominicz
pedrominicz / bf.c
Last active July 31, 2019 16:47
Brainfuck to C compiler.
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
void die(const char* msg) {
puts(msg);
exit(1);
}
void cp(FILE* a, FILE* b) {
@pedrominicz
pedrominicz / furigana.py
Last active November 14, 2020 02:42
Furigana!
#!/usr/bin/env python3
from fugashi import Tagger
import re
import sys
# Japanese card creation process
# - Word list on Google Keep
# - Find phrase and add to a temporary file
# - Create cards and add it to `Stage 0` deck
@pedrominicz
pedrominicz / noise.c
Last active August 18, 2019 02:39
Noise!
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#define WIDTH 150
#define HEIGHT 150
#define POINTS 60
struct point {
@pedrominicz
pedrominicz / 99-problems.hs
Last active August 29, 2019 18:49
Learning Haskell with Ninety-Nine Problems
-- Ninety-Nine Haskell Problems
-- Problem 1
myLast :: [a] -> Maybe a
myLast [] = Nothing
myLast [x] = Just x
myLast (_:xs) = myLast xs
-- Problem 2
myButLast :: [a] -> Maybe a
@pedrominicz
pedrominicz / 99-problems.rkt
Created August 26, 2019 20:35
Ninety-Nine Racket Problems
#lang plai-typed
; Problem 1
(define (my-last list)
(if (<= (length list) 1)
list
(my-last (rest list))))
;(test (my-last empty) empty)
;(test (my-last (list 1)) (list 1))
@pedrominicz
pedrominicz / Twelf.hs
Last active September 21, 2019 19:01
Haskell doodle made while reading about Twelf.
-- Haskell doodle made while reading about Twelf.
-- http://twelf.org/wiki/Proving_metatheorems_with_Twelf
module Twelf where
data Nat
= Zero
| Succ Nat
deriving (Eq, Show)
@pedrominicz
pedrominicz / FAlgebra.hs
Last active October 5, 2019 23:47
Haskell doodle (F-Algebras, very short)
module FAlgebra where
-- https://www.schoolofhaskell.com/user/bartosz/understanding-algebras
{-
class Functor f where
fmap :: (a -> b) -> f a -> f b
(<$) :: a -> f b -> f a
(<$) = fmap . const
{-# MINIMAL fmap #-}
@pedrominicz
pedrominicz / Cata.hs
Last active September 21, 2019 19:02
Catamorphic Lambda Calculus Interpreter (doodle made while following a tutorial).
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
-- https://www.schoolofhaskell.com/user/bartosz/understanding-algebras
-- https://www.michaelpj.com/blog/2018/04/08/catamorphic-lc-interpreter.html
@pedrominicz
pedrominicz / Typed.hs
Last active July 18, 2022 16:36
Simply Typed Lambda Calculus with Type Checker (doodle made while reading a SO answer).
module Typed where
-- https://stackoverflow.com/questions/27831223/simply-typed-lambda-calculus-with-failure-in-haskell
import Safe (atMay)
data Type
= LamT Type Type
| NumT
deriving (Eq, Show)