Skip to content

Instantly share code, notes, and snippets.

View radgeRayden's full-sized avatar
🤔

Westerbly Snaydley radgeRayden

🤔
View GitHub Profile
@radgeRayden
radgeRayden / main.lua
Last active May 13, 2022 00:36
minesweeper
local field = {}
local field_width = 10
local field_height = 10
local field_position_x = 100
local field_position_y = 100
local n_mines = 15
local size_square = 30
local start_time = 0
local play_time = 0
local is_game_over = false
@radgeRayden
radgeRayden / explainer.md
Last active April 8, 2022 18:05
about let, mutable variables and pointers in Scopes

The truth about the let keyword

In Scopes, the let keyword is an immutable binding to a name. Sometimes we call them register variables, which is an LLVM-ism. Because it's just a binding with no location in memory and a completely abstract construct, you can alias things that aren't necessarily values, like types or keywords. You can bind anything to a valid symbol; you could even shadow let itself.

Then how do I mutate data?

You can mutate 3 different types of values in Scopes: stack variables, global state variables and mutable pointers.

  • Stack variables are declared with the local keyword. They expire when you exit the function frame (ie. return).
  • Global state variables are declared with the global keyword. Their memory location is static and always available. It's always safe to take a pointer to global data (although it might not be to do so from multiple threads).
  • Pointers are addresses to a memory location. You can take the address from a local, global or through memory allocati
Thread 1 "triangle" received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
49 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:49
#1 0x00007ffff6f3f864 in __GI_abort () at abort.c:79
#2 0x00007ffff6fa2736 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0x7ffff70c7b9c "%s\n") at ../sysdeps/posix/libc_fatal.c:155
#3 0x00007ffff6fab08c in malloc_printerr (str=str@entry=0x7ffff70c5db0 "corrupted double-linked list") at malloc.c:5628
#4 0x00007ffff6fac5ac in unlink_chunk (p=p@entry=0x55555555fba0, av=0x7ffff70f9ba0 <main_arena>) at malloc.c:1614
#5 0x00007ffff6fac6ff in malloc_consolidate (av=av@entry=0x7ffff70f9ba0 <main_arena>) at malloc.c:4731
@radgeRayden
radgeRayden / dummy-raymarching.sc
Created January 25, 2021 17:30
Raymarching for Dummies in Scopes
#
// "ShaderToy Tutorial - Ray Marching for Dummies!"
// by Martijn Steinrucken aka BigWings/CountFrolic - 2018
// License Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
//
// This shader is part of a tutorial on YouTube
// https://youtu.be/PGtv-dBi2wE
Scopes version by Westerbly (radgeRayden) Snaydley.
let MAX_STEPS = 100
using import struct
# You generally want to use plain structs either to interface with C, or
# to store some pure data (commonly called POD object) that doesn't need any management
struct A plain
a : i32
struct B
b : i32
inline __drop (self)
using import Map
using import Array
using import struct
inline table-lookup (t k)
let kT = (typeof k)
let a m =
Struct.__getattr t 'a
Struct.__getattr t 'm
#!/bin/fish
# vim ft=fish
set -l MONTH (date +"%m")
set -l YEAR (date +"%Y")
set -l SSDIR "$HOME/Pictures/Screenshots/$YEAR-$MONTH"
mkdir -p $SSDIR
if test "$argv[1]" = "display"
if maim /tmp/screenshot.png
xclip -selection clipboard -t image/png -i /tmp/screenshot.png
@radgeRayden
radgeRayden / c2.txt
Last active November 30, 2020 17:06
semantically-bind-types
semantically-bind-types c2.v vec2
inline "conv-to" (self)
vec2 self.x self.y
inline "conv-from" (other)
c2.v (unpack other)