Skip to content

Instantly share code, notes, and snippets.

View sleibrock's full-sized avatar
🗿
Chronomaly Moai

Steven sleibrock

🗿
Chronomaly Moai
View GitHub Profile
@sleibrock
sleibrock / ps1fmt.zig
Last active May 10, 2022 17:38
PS1 Format Buddy [WIP]
const std = @import("std");
const io = std.io;
const debug = std.debug;
const os = std.os;
const ArrayList = std.ArrayList;
// figure out a way to represent ansi signals/vars
const ANSI = enum {
none,
open,
@sleibrock
sleibrock / puts.rkt
Created February 18, 2022 16:52
Puts macro - a macro to print things and accept variadic arguments
(require (for-syntax racket/base))
(provide puts)
(define-syntax (puts stx)
(define datum (syntax->datum stx))
(define args (cdr datum))
(datum->syntax stx
(if (empty? args)
'(displayln "")
@sleibrock
sleibrock / Testing.zig
Last active January 14, 2022 22:45
test.zig
// tester.zig - a basic mandelbrot prototype
const std = @import("std");
const io = std.io;
const os = std.os;
const fs = std.fs;
const fmt = std.fmt;
const math = std.math;
/// A Complex<T> data type to use
@sleibrock
sleibrock / replactions.rkt
Created January 6, 2022 16:25
Simple macro to integrate help messages with function definitions
#lang racket/base
#|
Wanted to add docstrings a-la Python to Racket
So I made a macro to do that lol
|#
(require (for-syntax racket/syntax racket/base racket/string))
(define *helplist* (make-parameter (make-immutable-hash)))
@sleibrock
sleibrock / betting.rkt
Created December 31, 2021 18:49
Betting.rkt
#lang racket/base
;; utilities
(struct Bet (name target monies) #:transparent)
(define *bets* (make-parameter '()))
(define *total* (make-parameter 0.0))
(define *wagers* (make-parameter (make-immutable-hash)))
(define (sum datums) (foldl + 0.0 datums))
@sleibrock
sleibrock / CSVMacro.rkt
Last active December 7, 2021 21:55
A WIP CSV Macro in Racket
#lang racket/base
; for-syntax means importing bindings for the macro-level generation phase
(require (for-syntax racket/syntax racket/base racket/string)
(only-in racket/string string-join string-split)
(only-in racket/port port->lines))
(define-syntax (defrec stx)
(syntax-case stx ()
[(_ id col-headers (fields ...) delim)
@sleibrock
sleibrock / Cat.zig
Last active September 14, 2021 14:35
GNU Cat but in Zig
//! GNU Cat replacement, but with Zig I guess
/// -- made with love from @sleibrock
///
/// Exists as a proof of concept of general C-like programming using Zig.
/// Compiles to about 62kb compared to GNU/cat's 39kb.
/// @requires "zig-0.8.1"
const std = @import("std");
const io = std.io;
const fs = std.fs;
@sleibrock
sleibrock / smallest-types-in-python.py
Created October 10, 2016 17:48
Size of Types in Python
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
Goal: To examine which type is the smallest in Python
Types used: int, float, str, list, tuple, dict, set, frozenset
None, Ellipsis, object, lambda, function, Exception
"""
def f(): return
@sleibrock
sleibrock / bot.rkt
Last active April 24, 2020 15:42
ssh-chat bot version 0.1
#lang racket/base
(define (start-bot)
(subprocess #f #f 'stdout
(find-executable-path "ssh")
"-p 2022"
"-o SetEnv TERM=bot"
"bot@0.0.0.0"))
@sleibrock
sleibrock / dct.py
Created December 2, 2019 21:21
Discrete Cosine Transform test
#!/usr/bin/env python
from math import cos, pi, sqrt
from itertools import product
test_matrix = [[90, 100], [100, 105]]
def dct(lst):
if len(lst) == 0: