Skip to content

Instantly share code, notes, and snippets.

View porglezomp's full-sized avatar
💖
GITHUB DROP ICE

Cassie Jones porglezomp

💖
GITHUB DROP ICE
View GitHub Profile
@porglezomp
porglezomp / ShitLetsBeSmalltalk.swift
Last active August 21, 2019 21:28
Where we're going we don't need primitive control flow!
/// Like a smalltalk bool, but worse. Just used for control flow, we can use real boolean ops.
class ChitChatBool {
func ifTrue<T>(block: () -> T) -> T? { return nil }
}
class True: ChitChatBool {
override func ifTrue<T>(block: () -> T) -> T? { return block() }
}
class False: ChitChatBool { }
@porglezomp
porglezomp / homestuck.dot
Last active March 19, 2019 05:28
Homestuck shipping diagram
// neato -Tpng homestuck.dot > homestuck.png
digraph Shipping {
rankdir=LR;
sep="0.5";
overlap=scalexy;
//splines=true;
layout=neato;
subgraph {
edge [dir=none];
Rose -> Kanaya [label="♥"];
import Data.Fin
%language TypeProviders
%dynamic "./time.so"
%default total
epoch_seconds : IO Int
epoch_seconds = foreign FFI_C "epoch_seconds" (IO Int)
getTime : IO (Provider Int)
@porglezomp
porglezomp / meta.lua
Created February 2, 2019 21:29
Metatable on Metatables
local x = { value = 42 }
local index = {
__index = function(t, k)
print(k)
if k == "__add" then
return function(l, r)
return { value = l.value + r.value }
end
end
end
@porglezomp
porglezomp / 00-README.md
Last active January 10, 2021 22:19
Goto scripts

Goto

These scripts goto and label let you handle jumping around to directories that you want to get to frequently, without having to figure out the path relative to where you are currently. To create a location, go to the directory you care about, then type label <name>. After you've done that, you're able to type goto <name> at any time to jump directly to that location.

Installation

To install on fish, copy the fish scripts into the locations listed at the top of them. To install on bash/sh/etc., copy the goto-label.sh into the end of your .profile, .bash_profile, or whatever else you have your config code in.

@porglezomp
porglezomp / twitter-alt-to-title.user.js
Last active March 16, 2022 15:43
Copy the alt text in tweets into the title text, so that you can see it on hover.
// ==UserScript==
// @name Twitter Alt-Text to Title-Text
// @description Copy the alt attribute of twitter images into the title attribute, so that I can see the alt text on hover.
// @version 1
// @grant none
// @include https://twitter.com/*
// ==/UserScript==
const SELECTORS = `.tweet .AdaptiveMedia-photoContainer img
, .Gallery-media img
CODED = [
[12, 24, 15, 12, 3, 6, 24, 23, 2, 26, 22, 24, 6, 19, 21, 6, 4, 24, 1, 2, 10, 6, 24, 26, 22, 6, 2, 11, 24, 10, 13, 2, 9, 6, 4],
[4, 8, 15, 6, 19, 12, 18, 24, 2, 1, 1, 24, 16, 6, 24, 26, 22, 6, 24, 4, 22, 12, 0, 6, 24, 26, 22, 6, 18, 24, 23, 12, 13, 26, 24, 15, 6, 24, 26, 8, 24, 16, 6],
[16, 20, 26, 24, 2, 24, 19, 8, 13, 26, 24, 10, 13, 8, 23, 24, 22, 8, 23, 24, 15, 20, 25, 22, 24, 15, 8, 11, 6, 24, 26, 22, 6, 18, 1, 1, 24, 23, 12, 10, 6, 24, 12, 23, 12, 18, 24, 16, 6, 5, 8, 11, 6, 24, 26, 22, 6, 18, 11, 6, 24, 4, 12, 26, 2, 4, 5, 2, 6, 19],
[26, 22, 6, 18, 24, 22, 12, 9, 6, 24, 4, 1, 2, 25, 6, 19, 24, 12, 23, 12, 18, 24, 15, 18, 24, 5, 1, 6, 4, 22],
[4, 22, 8, 11, 13, 24, 8, 5, 24, 20, 13, 4, 2, 21, 22, 26, 1, 18, 24, 1, 2, 15, 16, 4, 24, 12, 13, 19, 24, 8, 11, 21, 12, 13, 4],
[15, 8, 11, 6, 24, 4, 26, 2, 26, 25, 22, 24, 12, 13, 19, 24, 4, 25, 12, 11, 24, 26, 22, 12, 13, 24, 22, 20, 15, 12, 13],
[2, 5, 24, 8, 13, 1, 18, 24, 15, 12, 11, 16, 1, 6],
[21, 11, 6, 23, 24, 16
@porglezomp
porglezomp / 00 add baseline
Created December 14, 2018 02:42
Eggman Scheme Bytecode Examples
function (+ a b) entry=bb0
bb0:
v0 = lookup 'assert
v1 = typeof v0
v2 = Binop.SYM_EQ v1 'function
brn v2 non_function
v3 = arity v0
v4 = Binop.NUM_EQ v3 1
brn v4 wrong_arity
v5 = lookup 'number?
@porglezomp
porglezomp / about.md
Created November 16, 2018 04:03
Allocator

An Allocator

This is a working memory allocator for C++! It was written as test code for an operating systems class project, we were implementing a virtual memroy system, and so I built an allocator on top of that. To work, it needs access to a vm_map call which will return a fresh 4KB page, and it needs to return consecutive addresses for consecutive calls (at least most of the time, or else we can't allocate large blocks).

It is based on a linear search through a free list, with a best-fit allocation scheme.

@porglezomp
porglezomp / SketchSystems.spec
Last active November 4, 2018 19:04
# Memory Eviction
# Memory Eviction
Start*
swap page -> NoRW
file page -> NoRW
NoRW
read -> Read
write -> ReadWrite
queue -> Start