Skip to content

Instantly share code, notes, and snippets.

View pepe's full-sized avatar

Josef Pospíšil pepe

View GitHub Profile
@bakpakin
bakpakin / dagbuild.janet
Created June 11, 2021 19:13
Parallel, make-like builds - work for adding parallel builds to jpm
###
### dagbuild.janet
###
### A module for building files / running commands in an order.
### Building blocks for a Make-like build system.
###
#
# DAG Execution
#
@dz4k
dz4k / Draggable._hs
Last active December 25, 2023 10:47
Draggable window in _hyperscript
-- Usage: _="install Draggable(dragHandle: .titlebar in me)"
behavior Draggable(dragHandle)
init
if no dragHandle set the dragHandle to me
end
on pointerdown(clientX, clientY) from dragHandle
halt the event
trigger draggable:start -- hooks, e.g. for adding a drop shadow while dragging
measure my x, y
@sogaiu
sogaiu / debug.janet
Last active February 23, 2021 03:34
scratch work for a janet source debugger
(var steps 0)
(defn my-repl
[the-syms]
(def chunks
(fn [buf p]
(getline (string/format "\nrecent: %p\nsteps: %d\n> "
(keys the-syms) steps)
buf the-syms)))
#
@ityonemo
ityonemo / test.md
Last active October 23, 2025 01:27
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

(defmacro
defclass
`
Define a CLOS-style class.
`
[name parent & attributes]
(def forms @[])
(let [init-args @[]
names-with-defaults (mapcat |[(keyword ($0 0)) (($0 1) :default)]
attributes)]
@sogaiu
sogaiu / print-related-in-janet.md
Last active December 8, 2020 07:21
various printing things in janet
@sogaiu
sogaiu / life-of-a-janet-expression.md
Last active December 20, 2023 10:39
the life of a janet expression
@sogaiu
sogaiu / janet_via_ctypes.py
Last active January 8, 2021 22:46
janet via python's ctypes
from ctypes import *
# macos may need .dylib
# windows may need WinDLL and .dll
dll = CDLL("./libjanet.so")
dll.janet_init()
# http://michas.eu/blog/c_ints.php?lang=en
# https://stackoverflow.com/a/13293860
@sogaiu
sogaiu / gist:b96d62095d453a29033ebae6f07890c2
Last active September 14, 2020 07:53
janet abstract and marshal / unmarshal
https://github.com/janet-lang/janet/blob/master/src/include/janet.h
https://github.com/janet-lang/janet/blob/master/src/core/abstract.c
https://github.com/janet-lang/janet/blob/master/src/core/marsh.c
https://github.com/janet-lang/janet/blob/master/src/core/typedarray.c
https://github.com/janet-lang/janet/blob/master/src/core/peg.c
/* A context for marshaling and unmarshaling abstract types */
typedef struct {
void *m_state;
void *u_state;