Skip to content

Instantly share code, notes, and snippets.

View Benabik's full-sized avatar

Brian Gernhardt Benabik

View GitHub Profile
@Benabik
Benabik / optparse_subcommand.rb
Last active August 27, 2023 02:36
A Ruby class for turning command line options into keyword arguments and subcommands into method calls.
# frozen_string_literal: true
require 'forwardable'
require 'ostruct'
require 'optparse'
# This class extends OptionParser to handle git style subcommands. Users of
# this class create a OptionParser::Subcommand object, set up the options using
# OptionParser methods, and then pass a class to OptionParser::Subcommand#run.
# Command line options before the first argument are passed as keyword
@Benabik
Benabik / reg_dump.s
Created January 31, 2018 15:40
Quick function to dump the current state of the registers
# x64, System V ABI, gas/llvm-as, OS X
# Can be called from C:
# void reg_dump();
# https://www.uclibc.org/docs/psABI-x86_64.pdf
# Return: %rax =(128 high bits in %rdx)
# Params: %rdi, %rsi, %rdx, %rcx, %r8, %r9, stack RTL
# Syscall: %rax, %rdi, %rsi, %rdx, %r10, %r8, %r9, stack RTL
( 0400 00 ) BRK,
( 0401 01 12 ) $12 X) ORA,
( 0403 02 ) $02 tc,
( 0404 03 ) $03 tc,
( 0405 04 ) $04 tc,
( 0406 05 12 ) $12 ORA,
( 0408 06 12 ) $12 ASL,
( 040A 07 ) $07 tc,
( 040B 08 ) PHP,
@Benabik
Benabik / Makefile
Created August 13, 2013 18:07
Makefile generated on OS X for MoarVM/MoarVM
CC = clang
LD = clang
AR = ar
MAKE = make
RM = rm -f
CAT = cat
CFLAGS = -fno-omit-frame-pointer -fno-optimize-sibling-calls -g -Weverything -D_DARWIN_USE_64_BIT_INODE=1
CINCLUDES = -I3rdparty/apr/include \
-I3rdparty/libuv/include \
@Benabik
Benabik / markdown2evernote.rb
Last active October 30, 2018 19:28 — forked from kopischke/markdown2evernote.rb
MultiMarkdown to Evernote script, using RubyCocoa and ScriptingBridge
#!/usr/bin/ruby
# Markdown to Evernote, RubyCocoa edition
# by Brian Gernhardt
# Adapted from Martin Kopichke's "Markdown to Evernote" service
# https://gist.github.com/kopischke/1009149
# Which was adapted from Brett Terpstra’s original
# http://brettterpstra.com/a-better-os-x-system-service-for-evernote-notes-with-multimarkdown/
# Copyright (C) 2001-2009, Parrot Foundation.
=head1 NAME
examples/benchmarks/primes.pasm - Calculate prime numbers < 5000
=head1 SYNOPSIS
% time ./parrot examples/benchmarks/primes.pasm
.pact pbc 0
.constants num
.end
.constants string
0 ascii "Builder"
1 ascii "Test"
2 ascii "More"
3 ascii "_test"
@Benabik
Benabik / temp.pact
Created August 7, 2012 19:26
disassembler output
.pact pbc 0
.constants num
0 3.14
.end
.constants string
0 ascii "WhatIsThis"
1 ascii "src/temp.pir"
2 ascii "wit"
#!winxed
# golfed until it stopped segfaulting
function main[main]() {
load_bytecode('rosella/core.pbc');
Rosella.initialize_rosella('test');
Rosella.Test.test(class SanityTest);
}
class SanityTest {
@Benabik
Benabik / pact.txt
Created June 28, 2012 23:16
PIR -> PBC -> PACT.Packfile -> Data.Dumper
PACT$ src/installable_disasm src/temp.pbc
"Packfile" => PMC 'PACT;Packfile' {
uuid: 0 "",
floats: FixedFloatArray (size:0) [
],
strings: FixedStringArray (size:14) [
"WhatIsThis",
"src/temp.pir",
"wit",
"",