Skip to content

Instantly share code, notes, and snippets.

@joesavage
joesavage / gist:20732b171d4091fb333c
Last active August 29, 2015 14:04
Linode Rescue Mode Disk Backup
## Linode Rescue Mode Disk Backup
# Remote:
dd if=/dev/xvda | gzip -c > linode.img.gz
passwd
/etc/init.d/ssh start
# Local:
ssh root@remote-location "dd if=~/linode.img.gz " | dd of=~/Developer/Backups/Images/linode.img.gz
@joesavage
joesavage / zz.countries.nerd.dk.rbldnsd
Created July 26, 2014 14:38
zz.countries.nerd.dk.rbldnsd
This file has been truncated, but you can view the full file.
$SOA 7200 countries-ns.mdc.dk. read.the.homepage.at.http.countries.nerd.dk. 2013013100 28800 7200 604800 7200
5.224.7.0/24 :127.0.0.20:ad
5.224.254.0/23 :127.0.0.20:ad
5.225.7.0/24 :127.0.0.20:ad
5.225.254.0/23 :127.0.0.20:ad
31.201.76.0/24 :127.0.0.20:ad
37.19.14.248/29 :127.0.0.20:ad
37.222.7.0/24 :127.0.0.20:ad
37.222.254.0/23 :127.0.0.20:ad
37.223.254.0/23 :127.0.0.20:ad
// ftp://ftp.fu-berlin.de/doc/iso/iso3166-countrycodes.txt
[{ country: "ÅLAND ISLANDS", alpha2: "AX", alpha3: "ALA", number: 248 },
{ country: "AFGHANISTAN", alpha2: "AF", alpha3: "AFG", number: 004 },
{ country: "ALBANIA", alpha2: "AL", alpha3: "ALB", number: 008 },
{ country: "ALGERIA", alpha2: "DZ", alpha3: "DZA", number: 012 },
{ country: "AMERICAN SAMOA", alpha2: "AS", alpha3: "ASM", number: 016 },
{ country: "ANDORRA", alpha2: "AD", alpha3: "AND", number: 020 },
{ country: "ANGOLA", alpha2: "AO", alpha3: "AGO", number: 024 },
{ country: "ANGUILLA", alpha2: "AI", alpha3: "AIA", number: 660 },
{ country: "ANTARCTICA", alpha2: "AQ", alpha3: "ATA", number: 010 },
@joesavage
joesavage / gist:84670a2f8ab46a833ed5
Created August 9, 2014 12:52
HTTPPlaysPokemon Controls
<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;
@joesavage
joesavage / brainfuck.cpp
Created November 17, 2014 19:28
Brainfuck Compiler/Interpreter
// 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
# 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 / gist:00945a6ecc4abb8721cf
Last active August 29, 2015 14:15
LLVM [2.6] JIT Tutorial 1 (OS X, 2015)
// 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"
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).
(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);
@joesavage
joesavage / after.js
Created March 15, 2016 08:27
emscripten_suspend web worker test case
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");