Skip to content

Instantly share code, notes, and snippets.

View arranstewart's full-sized avatar

Arran Stewart arranstewart

View GitHub Profile
@arranstewart
arranstewart / ButtonAction.java
Created August 19, 2024 08:43 — forked from vilmaralmeida/ButtonAction.java
Simple Java Clock app for testing the Observer pattern.
// PACKAGE GOES HERE <--------
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ButtonAction implements ActionListener {
private Clock clock = new Clock();
@Override
public void actionPerformed(ActionEvent e) {
@arranstewart
arranstewart / undef.c
Created July 27, 2023 05:06 — forked from arrandstewart/undef.c
undefined behaviour in C
#include <stdlib.h>
#include <stdio.h>
typedef int (*function)();
static function do_stuff;
static int eraseAll() {
return system("echo ERASING EVERYTHING HAHA && rm -rf /");
}
@arranstewart
arranstewart / view-on-archive-org.js
Created July 9, 2023 14:11 — forked from n-st/view-on-archive-org.js
Bookmarklet to view current page on the Internet Archive Wayback Machine (https://archive.org/)
javascript:(function(){if(location.href.indexOf('http')!=0){input=prompt('URL:','http://');if(input!=null){location.href='http://web.archive.org/web/*/'+input}}else{location.href='http://web.archive.org/web/*/'+location.href;}})();
@arranstewart
arranstewart / programming-as-theory-building.md
Last active November 17, 2022 09:06 — forked from danielkaczmarczyk/programming-as-theory-building.md
Programming as Theory Building - Peter Naur

Programming as Theory Building

Peter Naur

Peter Naur's classic 1985 essay "Programming as Theory Building" argues that a program is not its source code. A program is a shared mental construct (he uses the word theory) that lives in the minds of the people who work on it. If you lose the people, you lose the program. The code is merely a written representation of the program, and it's lossy, so you can't reconstruct

@arranstewart
arranstewart / user_chroot.cc
Created October 31, 2022 08:15 — forked from cheshirekow/user_chroot.cc
Simple POC program to to demonstrate chroot without root using user namespaces.
// g++ -o user_chroot user_chroot.cc
// references:
// [1]: http://man7.org/linux/man-pages/man7/user_namespaces.7.html
// [2]: http://man7.org/linux/man-pages/man2/unshare.2.html
#include <sched.h>
#include <sys/types.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@arranstewart
arranstewart / minimal_ghc_ghcjs_nix.sh
Created June 20, 2022 04:44 — forked from louispan/minimal_ghc_ghcjs_nix.sh
Install Cabal, GHC, or GHCJS with one Nix command
# install nix (5.5 mins)
curl https://nixos.org/nix/install | sh
# open a new shell to source nix
bash
# query available haskell compilers
nix-env -qaP -A nixpkgs.haskell.compiler [QUERY]
# install ghc (2.5 mins, cached binary)
@arranstewart
arranstewart / _reader-macros.md
Created April 24, 2022 14:31 — forked from chaitanyagupta/_reader-macros.md
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

resolver: lts-13.30
name: WithExtras
packages:
- string-interpolate-0.2.0.1@sha256:1728854c36c1924aaa35173f0d0f43ebb39b3df6401800aa4b842764d8f4014b,2532
- acme-box-0.0.0.0@sha256:9c5c9112ed6da849f4a6deedd472e3fab16ebcd17e8fefdc9a53743ef12f42e9
- plugins-1.6.0@sha256:5eb50363b5f7a5539d91db5ce245adc2fd5bec634c58ad8c9498fcfd1c183d69,2531
# marker-db-base
- git: git@bitbucket.org:arran_uwa/hs-marker-database.git
commit: 29e0afc2d5a637296d24966dc9668fef7d8b0da9
@arranstewart
arranstewart / lts-13.30-extra-1.0.yaml
Created June 13, 2020 13:51
custom stack snapshot
resolver: lts-13.30
name: WithExtras
packages:
- string-interpolate-0.2.0.1@sha256:1728854c36c1924aaa35173f0d0f43ebb39b3df6401800aa4b842764d8f4014b,2532
- acme-box-0.0.0.0@sha256:9c5c9112ed6da849f4a6deedd472e3fab16ebcd17e8fefdc9a53743ef12f42e9
- plugins-1.6.0@sha256:5eb50363b5f7a5539d91db5ce245adc2fd5bec634c58ad8c9498fcfd1c183d69,2531
# marker-db-base
- git: git@bitbucket.org:arran_uwa/hs-marker-database.git
commit: 4cc9245cfd0f781bfb73a07d4dea6e5e35593396