Skip to content

Instantly share code, notes, and snippets.

Joe Savage joesavage

Block or report user

Report or block joesavage

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@joesavage
joesavage / commands.txt
Last active Aug 11, 2016
`dwarfdump` on macOS and Linux
View commands.txt
=== macOS
$ clang -v
Apple LLVM version 7.0.2 (clang-700.1.81)
<snip>
$ clang hello.c -g -o hello.out
$ dwarfdump hello.out # NOTE: macOS-specific binary that reads Mach-O rather than ELF executables
----------------------------------------------------------------------
File: hello.out (x86_64)
----------------------------------------------------------------------
.debug_info contents:
View gist:21c02946e9a6e6448ca8303b3df3970a
# /etc/csh.login OR ~/.login
setenv SHELL /bin/bash
exec /bin/bash -l
View Afterglow
Background: #202020
Font: Monaco, 11pt
Text: #CFCFCF
Bold Text: #CFCFCF
Selection: #CFCFCF (65% Opacity) / #9C9C9C
Cursor: #CFCFCF
ANSI Colours:
Black (0): #151515
Bright Black (8): #3E3E3E
Red (1): #9A2D32
@joesavage
joesavage / after.js
Created Mar 15, 2016
emscripten_suspend web worker test case
View after.js
self.addEventListener('message', (function(e) {
var data = e.data;
switch (data.cmd) {
case 'init':
(function() {
run();
var desiredInput = "success";
var insertChar = (function(i, self) {
Module.userInput.push(desiredInput.charCodeAt(i));
Module.resume("char_ready");
View after.js
(function() {
var desiredInput = "success";
var insertChar = (function(i, self) {
userInput.push(desiredInput.charCodeAt(i));
Module.resume("char_ready");
if (i < desiredInput.length) {
return setTimeout((function() { self(i + 1, self) }), Math.floor(Math.random() * 1500));
}
});
insertChar(0, insertChar);
View gist:8ddd76d5b9292557befe
row(0, R, R) :- !.
row(N, R, Acc) :- L is N - 1,
row(L, R, [N | Acc]).
% LESS EFFICIENT VERSION:
% row(0, []) :- !.
% row(N, R) :- L is N - 1,
% row(L, S),
% append(S, [N], R).
@joesavage
joesavage / gist:00945a6ecc4abb8721cf
Last active Aug 29, 2015
LLVM [2.6] JIT Tutorial 1 (OS X, 2015)
View gist:00945a6ecc4abb8721cf
// A modified version of the "LLVM JIT Tutorial 1" code from http://goo.gl/1cNfH7
// which actually works with the latest versions of LLVM as of Feb 2015.
//
// To compile if you're on OS X using 'llvm' [libs, etc.] from Homebrew:
// clang++ -g test.cpp `/usr/local/opt/llvm/bin/llvm-config --cxxflags --ldflags --libs core --system-libs` -I/usr/local/opt/llvm/include -o test
#include "llvm/IR/Module.h"
#include "llvm/IR/Function.h"
#include "llvm/PassManager.h"
#include "llvm/IR/CallingConv.h"
View gist:0089156115b477e1eb57
# 1. Generate private key
openssl genrsa -out /etc/ssl/private/example.com.key 4096
# 2. Generate Certificate Signing Request (CSR)
# [Fill in details as appropriate leaving email, challenge password, and optional company name empty. Be careful with FQDN!]
openssl req -new -key /etc/ssl/private/example.com.key -out /etc/ssl/private/example.com.csr
# 3. Submit CSR and recieve site certificate
# 4. Set permissions as appropriate
@joesavage
joesavage / brainfuck.cpp
Created Nov 17, 2014
Brainfuck Compiler/Interpreter
View brainfuck.cpp
// A small, and relatively primitive, C-style Brainfuck compiler/interpreter.
// Written by Joe Savage, 2014
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#define STACK_SIZE 512
#define DATA_SIZE 65535
View gist:84670a2f8ab46a833ed5
<html>
<head>
<style>
html { text-align: center; }
body { background: #222; display: inline-block; }
kbd, .kbd {
cursor: pointer;
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
width: .8em;
text-align: center;
You can’t perform that action at this time.