Skip to content

Instantly share code, notes, and snippets.

View fogus's full-sized avatar
💭
attempting to learn how to better learn

Fogus fogus

💭
attempting to learn how to better learn
View GitHub Profile
@fogus
fogus / verbose_proxy.c
Created January 17, 2024 21:56 — forked from lelanthran/verbose_proxy.c
A small program to proxy and record all traffic to a server.
/* ********************************************************
* Copyright ©2024 Rundata Systems. All rights reserved.
* This project is licensed under the GPLv3 License. You
* can find a copy of this license at:
* https://www.gnu.org/licenses/gpl-3.0.en.html
*
* More detail (1m read):
* https://www.rundata.co.za/rundata/products/verbose_proxy
*
* Example usage (3m video):
// Copyright (C) 2023 dasshiva
#include <stdlib.h>
// Compiles on GCC 11.4.0 ubuntu idk about other systems
// Abusing macros to make C look a tiny bit better (maybe worse for some)
#define class(x, contents) typedef struct x x; struct x contents; // declare a class x
#define var(ty, name) ty name; // declare a variable
#define func(ty, x, ...) ty (*##x) (__VA_ARGS__); // declare a member function maybe static or non-static
#define static_func_def(ty, x, ...) ty x (__VA_ARGS__) // declare a static function
#define func_defnp(class, ty, x) ty x (class* self) // define a non-static function taking no parameters
@fogus
fogus / macOS Internals.md
Created May 8, 2023 13:48 — forked from kconner/macOS Internals.md
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@fogus
fogus / explore_datafy_nav.clj
Created January 18, 2023 17:50 — forked from sashton/explore_datafy_nav.clj
Clojure datafy/nav exploration
(ns explore-datafy-nav
"Sample code demonstrating naving around a random graph of data.
The graph very likely will have circular references, which is not a problem.
To see the results, execute the entire file.
Each step in the nav process will be printed out, as well as the initial db.
Subsequent executions will generate a new random db."
(:require [clojure.datafy :refer [datafy nav]]))
(defn generate-db
"Generate a random database of users and departments.
@fogus
fogus / clojure-deftype-scaffolding.clj
Created November 17, 2022 20:31 — forked from semperos/clojure-deftype-scaffolding.clj
Clojure Scaffolding for deftype (Christophe Grand) - Show which methods a class implements and for which interfaces
;; Big thanks to Christophe Grand - https://groups.google.com/d/msg/clojure/L1GiqSyQVVg/m-WJogaqU8sJ
(defn scaffold [iface]
(doseq [[iface methods] (->> iface .getMethods
(map #(vector (.getName (.getDeclaringClass %))
(symbol (.getName %))
(count (.getParameterTypes %))))
(group-by first))]
(println (str " " iface))
(doseq [[_ name argcount] methods]
(println
@fogus
fogus / cont.clj
Created June 28, 2022 16:00 — forked from hiredman/cont.clj
(defmacro return% [a]
`(fn return-fn# [success# error#]
#(try
(success# ~a)
(catch Throwable t#
(error# t#)))))
(defn bind% [m b]
(fn a [success error]
#(m (fn x [value] ((b value) success error)) error)))
@fogus
fogus / chain.st
Created March 30, 2022 16:39 — forked from zeroflag/chain.st
Object>>chain
^ ChainProxy new setTarget: self
ChainProxy>>doesNotUnderstand: aMessage
target := aMessage sendTo: target.
^ target
ChainProxy>>setTarget: anObject
target := anObject.
^ self
@fogus
fogus / basicinterpreter.lisp
Created January 19, 2022 13:03 — forked from lispm/basicinterpreter.lisp
Basic Interpreter, sectorlisp example translated to Common Lisp
; source https://github.com/woodrush/sectorlisp-examples/blob/main/lisp/basic.lisp
; Common Lisp translation: joswig@lisp.de, 2022
; https://gist.github.com/lispm/a2f56a1a6dc5599a039eb7134d99cd4a
(defun basic-example ()
(BASICINTERPRETER
(QUOTE (
(10 REM FIND AND PRINT PRIME NUMBERS BELOW N_MAX. )
(20 LET N_MAX = (1 1 1 1 1 1 1 1 1 1 1 1 1 1 1) )
(30 LET I = (1 1) )
CFLAGS=-std=c99 -pedantic -Wall -Werror
.PHONY: run forth
run: forth
./forth test.fs
forth: forth.c
$(CC) $(CFLAGS) -o forth forth.c
@fogus
fogus / daiyon.c
Created January 10, 2022 12:30 — forked from typeswitch-dev/daiyon.c
第四 (Daiyon) — a Japanese & Forth inspired postfix language
#include <stdio.h>
#include <string.h>
#include <assert.h>
FILE *in; long M[1<<24]={0}, *D, *R, H=0x130000, IP=0, T;
long getu() { long t, h = getc(in); if (h < 0xC0) return h;
t = ((h&0x1F) << 6) | (getc(in) & 0x3F); if (h < 0xE0) return t;
t = ( t << 6) | (getc(in) & 0x3F); if (h < 0xF0) return t;
t = ( t << 6) | (getc(in) & 0x3F); return t & 0x1FFFFF; }
void putu(long c) { if (c < 0x80) { putchar(c); return; }
if (c < 0x7FF) { putchar(0xC0|(c>>6)); } else {