Skip to content

Instantly share code, notes, and snippets.

@Goheeca
Goheeca / Main.hs
Last active November 30, 2021 22:19
reflection + template haskell issue
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Reificator
main :: IO ()
main = pure $$(guardTH (operationTest 11 7 4) [|| () ||])
@Goheeca
Goheeca / RefinedTest.hs
Last active November 29, 2021 19:04
refined library issue
#!/usr/bin/env stack
-- stack --resolver lts-18.5 script --package template-haskell --package refined
{-# LANGUAGE TemplateHaskell, TypeApplications #-}
import Refined
import Data.Either
import RefinedTestDefinitions
refinedTypeAppliedTest :: RefinedTest Int
@Goheeca
Goheeca / examples.lisp
Last active April 9, 2022 03:09
NILP (NIL Processing Language)
(load "nilp.lisp")
(eval
(read-from-string
(write-to-string
(nility
'(loop for i below 10
do (format t "~@(~:r hello world!~)~%" i))))))
@Goheeca
Goheeca / pausable-thread.lisp
Last active February 21, 2021 10:06
Pausable Threads
#!/usr/bin/sbcl --script
(load "~/.sbclrc")
(ql:quickload '("bordeaux-threads") :silent t)
(defun color-formatter (color)
(format nil "~a[~am~~?~a[m" #\Esc color #\Esc))
(defvar *output-lock* (bt:make-lock "OUTPUT LOCK"))
(defmacro safe-format (stream fmt &rest args)
@Goheeca
Goheeca / init.slime
Last active August 29, 2022 11:01
Clean SLIME REPL
(ql:quickload "agnostic-lizard")
@Goheeca
Goheeca / shared.lisp
Last active November 17, 2019 18:45
Multiprocess multithreaded computation with SBCL
#!/usr/bin/sbcl --script
(require :sb-posix)
(require :sb-bsd-sockets)
;;; Globals
;; IPC
(defvar *pid* nil)
(defvar *socket-path* "/tmp/socket")
(defvar *socket* nil)
;; MT
@Goheeca
Goheeca / braille-pixels.lisp
Last active November 17, 2019 18:36
Braille pixels images using cl-charms (@ SBCL)
#!/usr/bin/sbcl --script
#|
Usage
=====
$ ./braille-pixels.lisp [path]
Main
====
@Goheeca
Goheeca / ambiguous.pyjs
Last active November 17, 2019 18:52
Common Lisp ≡ ⊤
#||| Python or JS that is the question. |#
#|| Let's define a JS function, provided we're in JS. |#
#+moody-js"
function fact(n) {
if (n == 0) return 1
else return n * fact(n - 1)
}
"
@Goheeca
Goheeca / .gitconfig
Last active August 20, 2022 10:47
.gitconfig
[user]
name = Goheeca
email = goheeca@gmail.com
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
@Goheeca
Goheeca / finite.py
Last active March 13, 2019 18:19
Shamir's Secret Sharing Scheme
from fractions import Fraction
import random
from itertools import zip_longest
class Field(object):
def __init__(self):
self.characteristic = None
def __call__(self, value):