This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/csh.login OR ~/.login | |
setenv SHELL /bin/bash | |
exec /bin/bash -l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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