Skip to content

Instantly share code, notes, and snippets.

David Preece RantyDave

Block or report user

Report or block RantyDave

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
RantyDave / CMakeLists.txt
Created Jul 9, 2018
CMake file to enable and link c++ 17 using the XCode 10 beta
View CMakeLists.txt
cmake_minimum_required (VERSION 3.11)
set(CMAKE_CXX_COMPILER /Library/Developer/CommandLineTools/usr/bin/clang++)
include_directories(SYSTEM /Library/Developer/CommandLineTools/usr/include/c++/v1)
add_executable(YOUR_PROJECT_NAME file another_file)
RantyDave /
Last active Oct 28, 2017
Produces a price list for EC2 instances in the current region
# David Preece, 2017
# In the public domain, provided "as is", author disclaims all warranties yah de yah de yah
# pip3 import requests
import json
import requests
def float_ecu(ecu):
if ecu == "Variable":
RantyDave /
Created Jun 24, 2017
Incrementally allocating memory
import sys
base_alloc = bytearray(int(sys.argv[1])*1024*1024*1024)
extensions = []
while True:
print("Append 128MB")
RantyDave / root-in-opt
Created May 17, 2017
An SMF service that moves a SmartOS root directory onto the persistent storage
View root-in-opt
mkdir -p /opt/root
mkdir -p /opt/root/.ssh
cd /
cp /root/.* /opt/root
cp /root/.ssh/* /opt/root/.ssh
rm -rf /root
ln -s /opt/root
touch /opt/root/.forward
echo 'real@email' > /opt/root/.forward
RantyDave / varnish.xml
Created May 8, 2017
SMF manifest for the Varnish cache
View varnish.xml
<?xml version='1.0'?>
Copy to /opt/custom/smf
Assumes Varnish was built on SmartOS with configure --prefix=/opt/local --mandir=/opt/local/man
By default it looks for a backend at localhost:8000 ... create one quickly with 'python3 -m http.server'
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type='manifest' name='varnish'>
<service name='network/varnish' type='service' version='1'>
<create_default_instance enabled='true' />
RantyDave / cache.cpp
Created Mar 18, 2017
So, it turns out that memory *is* a long piece of magnetic tape.
View cache.cpp
// c++ -O3 -std=c++11 cache.cpp
#include <time.h>
#include <random>
#include <stdio.h>
using namespace std;
const int n_cachelines=65536;
const int bytes_cacheline=64;
RantyDave /
Created May 27, 2016
Limit the SmartOS (and Solaris?) ARC to a maximum of 256Mb. Works live, no reboot needed :)
echo "arc_stats::print -a arcstat_p.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw
echo "arc_stats::print -a arcstat_c.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw
echo "arc_stats::print -a arcstat_c_max.value.ui64" | mdb -kw > value.ui64
ui64=$(cat value.ui64)
echo "${ui64:0:16}/Z 0x10000000" | mdb -kw
You can’t perform that action at this time.