Skip to content

Instantly share code, notes, and snippets.

@youz
youz / peano-curve.ps
Created November 18, 2019 09:29
Peano curve in PostScript
%!
%%BoundingBox: 0 0 120 120
/n 3 def/p{count n 2 mul le{dup rotate dup neg 2{p 4 0 rlineto dup}repeat neg
p dup neg rotate}if pop}def 8 8 moveto 90 p stroke
@youz
youz / comments.em
Last active October 26, 2019 12:19
emelio test
(gnotation (/* As */ Bs) ((Bs)) (
/* block-
comments */
add 20
(notation (-- A Bs) ((Bs)) (
--single_comment
--( or use parenthesis
like this )
22
))
@youz
youz / d-option.patch
Created August 30, 2019 09:07
gojq patch & test
diff --git a/cli/cli.go b/cli/cli.go
index 6c5fcad..95fb019 100644
--- a/cli/cli.go
+++ b/cli/cli.go
@@ -53,6 +53,7 @@ type flagopts struct {
InputRaw bool `short:"R" long:"raw-input" description:"read input as raw strings"`
InputSlurp bool `short:"s" long:"slurp" description:"read all inputs into an array"`
FromFile string `short:"f" long:"from-file" description:"load query from file"`
+ Destructive bool `short:"D" long:"destructive" description:"update objects/arrays destructive (WARNING: iterator may produce unexpected results)"`
Version bool `short:"v" long:"version" description:"print version"`
def count(n)
c = 0
while n >= 10
m = 1
while n > 0 && m > 0
m *= n % 10
n /= 10
end
n = m
c += 1
(declaim (optimize (speed 3) (debug 0) (safety 0)))
(defun count-loop (n)
(declare (type integer n))
(let ((r 0))
(loop while (>= n 10) do
(do ((i n)
(p 1))
((or (= p 0) (= i 0))
(setq n p))
@youz
youz / fizzbuzz_golf.lisp
Last active January 29, 2022 01:13
FizzBuzz Golf in Common Lisp
;;; http://golf.shinh.org/p.rb?FizzBuzz#Common%20LISP
;; 80bytes
(dotimes(i 101)(format(> i 0)"~[~;~A~;~;Fizz~;~;Buzz~:;FizzBuzz~]
"(gcd i 15)i))
;; 79bytes
(dotimes'101(format(> .'0)"~[~;~A~;~;Fizz~;~;Buzz~:;FizzBuzz~]
"(gcd .'15).'t))
@youz
youz / ks.ps
Last active February 7, 2019 04:00
Koch Snowflake
/k{1 add dup 5 eq{5 0 rlineto 5 0 translate}{[0 1 4 4 2 2 5]{60 mul rotate
dup k}forall}ifelse pop}def 30 180 moveto 3{0 k 120 rotate}repeat stroke
@youz
youz / curved-arrow.saty
Last active January 10, 2019 04:18
curved arrow
@require: stdja
@require: list
@require: geom
@require: gr
let arrow-head color lenL lenM lenP ((x, y) as pt) theta =
let theta = theta +. math-pi in
let (cx, cy) = (x +' lenL *' (cos theta), y +' lenL *' (sin theta)) in
let (mx, my) = (x +' lenM *' (cos theta), y +' lenM *' (sin theta)) in
let phi = theta +. math-pi /. 2. in
@youz
youz / bezier-test.saty
Last active January 7, 2019 13:09
Bézier Curve
@require: stdja
@require: list
@require: gr
let points = [(100pt, 0pt); (0pt, 100pt); (200pt, 200pt); (300pt, 200pt)]
let curve =
let (p1 :: (p2 :: (p3 :: (p4 :: _)))) = points in
start-path p1
|> bezier-to p2 p3 p4
@youz
youz / snowflake.pdf
Last active December 27, 2018 16:08
Koch Snowflake
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.