View wsp.py
from math import sqrt | |
# Find an approximate solution to the weighted set packing problem using | |
# Halldorsson's algorithm (2000). Our approximate solution is at worst only a | |
# factor of sqrt(m) worse than the optimal solution. | |
# | |
# Input: | |
# S = { a, b, c... } # Set of base elements (m = |S|) | |
# C = { C_1, C_2, C_3, ... } # Collection of weighted subsets of S | |
# C_i = ({ a, c, ... }, weight) # Weighted subset of S |
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 |
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). |
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 |
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 |
NewerOlder