Skip to content

Instantly share code, notes, and snippets.

@AndrewJDR
AndrewJDR / handmade_git.sh
Last active August 29, 2015 14:10
Creates a git repository based off of the handmade hero source zip
echo Syntax:
echo $0 handmade_hero_nnn_source.zip
echo
if [ ! -s "$1" ]; then
echo "specified file doesn't exist!"
exit
fi
STARTDIR=$PWD
@AndrewJDR
AndrewJDR / cfipt.sh
Last active February 24, 2021 08:14
Cloudflare whitelist iptables update cron script
#!/bin/bash
# Based on a template iptables config file, create a new
# iptables file that includes whitelist rules for CloudFlare's
# servers to connect to our HTTP and HTTPS ports. This is useful
# if you want to really lock down your web server so that it only
# communicates with cloudflare's servers, not with the general public.
# It works like this:
# * Get an up-to-date list of CloudFlare's server IPs
# * Read in config template from /etc/sysconfig/iptables.template
# * Output an iptables configuration file /etc/sysconfig/iptables
(gdb) bt
#0 bx::debugBreak () at ../../../dm/include/dm/../../3rdparty/bx/debug.h:49
#1 0x00000000004ae49c in dm::Memory::Heap::addSpace (this=0xd49910 <dm::s_memory+75536>, _ptr=0x7fffa2a1c2c8, _size=1265666928) at ../../../dm/include/dm/allocator/allocator.h:1077
#2 0x00000000004af8a1 in dm::Memory::Heap::free (this=0xd49910 <dm::s_memory+75536>, _ptr=0x7fffc60c19f0) at ../../../dm/include/dm/allocator/allocator.h:1653
#3 0x00000000004ac9b7 in dm::Memory::free (this=0xd37200 <dm::s_memory>, _ptr=0x7fffc60c19f0) at ../../../dm/include/dm/allocator/allocator.h:381
#4 0x00000000004aac13 in operator delete (_ptr=0x7fffc60c19f0) at ../../src/common/allocator.cpp:273
#5 0x0000000000499d90 in __gnu_cxx::new_allocator<FaceTuple>::deallocate (this=0x7fff973163e0, __p=0x7fffc60c19f0) at /usr/include/c++/4.8/ext/new_allocator.h:110
#6 0x0000000000495e84 in std::_Vector_base<FaceTuple, std::allocator<FaceTuple> >::_M_deallocate (this=0x7fff973163e0, __p=0x7fffc60c19f0, __n=7161506) at /usr/include/c++/4.8/bits/s
@AndrewJDR
AndrewJDR / gist:c90aef5694c4fa538ddf
Created November 19, 2015 13:58
replace-paste-yanked-text-in-vim-without-yanking-the-deleted-lines
" https://web.archive.org/web/20151015122526/http://superuser.com/questions/321547/how-do-i-replace-paste-yanked-text-in-vim-without-yanking-the-deleted-lines
vnoremap p "0p
vnoremap P "0P
"vnoremap y "0y
vnoremap d "0d
vnoremap x "0x
<?
/////////////////////
// slack2html
// by @levelsio
/////////////////////
//
/////////////////////
// WHAT DOES THIS DO?
/////////////////////
//
const fs = require('fs');
const {
Puppet
} = require("matrix-puppet-bridge");
const puppet = new Puppet('/Users/ajohnson/matrixwork/rls/matrix-appservice-imessage/config.json');
puppet.startClient().then(()=>{
const client = puppet.getClient();
var obj = JSON.parse(fs.readFileSync(process.argv[2]))
# To build the flatbuffer binary
flatc -c -b member.fbs m.room.member_example.json
# see member_generated.h for the code that gets generated that's capable of reading the binary message
# The .h is for C. To generate other language bindings:
flatc --js -c -b member.fbs m.room.member_example.json
flatc --go -c -b member.fbs m.room.member_example.json
flatc --python -c -b member.fbs m.room.member_example.json
flatc --csharp -c -b member.fbs m.room.member_example.json
# etc...

Create an Ubuntu 18.04 droplet, and use the smallest SSD/HDD size. This way you can make a snapshot of the droplet and have the ability to later deploy that snapshot into a droplet of any size.

In this example, I use the "Optimized Droplet" that is 20GB, since that's the smallest one currently available.

After creating the droplet, power it down and open a ticket with DigitalOcean support, and ask to enable the Ubuntu 18.04 recovery ISO. It can take an hour or two before they do this. By the time you read this guide, hopefully they will have an automated way of doing it.

Once they get back to you, power your droplet back up and choose the recovery ISO's terminal/console option to get a shell. Now shrink the ext4 root to make room for the zfs root:

e2fsck -f /dev/vda1
@AndrewJDR
AndrewJDR / 0001-Add-DigitalOcean-root-on-zfs-guide-Ubuntu-18.04.patch
Last active May 19, 2018 05:21
patch against zfs wiki repo - DigitalOcean root on zfs guide (Ubuntu 18.04)
From 7cfaf9dcc917ae3d48b4929ff9bdfe4ce3dcb86c Mon Sep 17 00:00:00 2001
From: Andrew Johnson <ajohnson@draster.com>
Date: Fri, 18 May 2018 22:07:14 -0700
Subject: [PATCH] Add DigitalOcean root on zfs guide (Ubuntu 18.04).
---
DigitalOcean-Ubuntu-18.04-Root-on-ZFS.md | 183 +++++++++++++++++++++++++++++++
1 file changed, 183 insertions(+)
create mode 100644 DigitalOcean-Ubuntu-18.04-Root-on-ZFS.md
@AndrewJDR
AndrewJDR / meow_hash_bench.c
Created October 28, 2018 07:15
Meow hash in generic C (v0.2)
#ifdef _MSC_VER
#define MEOW_API static __declspec(noinline)
#include <intrin.h>
#else
// assume clang
#define MEOW_API static __attribute__((noinline))
#define __rdtsc __builtin_readcyclecounter
#endif
#include "meow_hash_c.h"