Skip to content

Instantly share code, notes, and snippets.

@ongardie
ongardie / raft-single-server-changes-safety
Last active July 6, 2023 01:42
Safety of Raft single-server membership changes
This is an attempt to show that Raft's safety is
preserved with single-server membership changes as
described in the dissertation plus the patch that a
leader may not append a new configuration entry to
its log until it's committed an entry from its
current term.
This extends the safety argument in the
paper/dissertation. The only part that's different
(as far as I can tell) for membership changes is Step
@ongardie
ongardie / diffwatch
Created May 29, 2015 19:31
Print changes over time in program output
#!/bin/bash
out1=$(mktemp)
out2=$(mktemp)
$* > $out1
date -u --rfc-3339=ns
cat $out1
echo
@ongardie
ongardie / keybase.md
Created April 29, 2015 23:36
verifying myself on keybase.io

Keybase proof

I hereby claim:

  • I am ongardie on github.
  • I am ongardie (https://keybase.io/ongardie) on keybase.
  • I have a public key whose fingerprint is 2F6A 3472 E5C6 A6FB 36FD E006 02E2 1980 FBC1 9C80

To claim this, I am signing this object:

@ongardie
ongardie / txt2pdf
Created December 12, 2014 21:31
txt2pdf: convert plaintext to PDF
#!/bin/sh
# Convert plaintext to PDF
if [ $# -eq 2 ]
then
outfile=$2
elif [ $# -eq 1 ]
then
outfile=`basename "$1" \.txt`.pdf
else
@ongardie
ongardie / bt
Created August 21, 2014 02:15
Run program through gdb to print backtrace on crash
#!/bin/sh
gdb -q --batch \
-ex 'handle SIGHUP nostop pass' \
-ex 'handle SIGQUIT nostop pass' \
-ex 'handle SIGPIPE nostop pass' \
-ex 'handle SIGALRM nostop pass' \
-ex 'handle SIGTERM nostop pass' \
-ex 'handle SIGUSR1 nostop pass' \
-ex 'handle SIGUSR2 nostop pass' \
-ex 'handle SIGCHLD nostop pass' \
@ongardie
ongardie / bench2.c
Created February 25, 2014 21:50
Microbenchmark that executes 1000 writes of the requested size (up to 8KB). This is a slight tweak on bench.c
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
const char* buf = "xghtczfphisyausfylavxgfefmxuszfnlespnfwupsniqdjxcucfgrpyrlenigmuqibhsdbimpwnyiubetvihqvxtlatyeuzdzhatzbstjlhjwtxcpngyedamwmecdsxtsxwrvkmychmgpaayjjyuzrbshyrvwekvvytdothhjhgqkuqcdnixokucnxgxipvrwnpkmltvhqjqclmcxdzvxhljtgnqyjqzxggspasccmgegogyibhfmapkswvnbaffsmurmmauqjwzpwuupsvkunzoqdohhuqrsndfcjfptwbxubocvbxkethgfhmpbjqhpmiiwjhbhzkotylzdbiektybpiyuefkbyxpwggpjbdebqviacasurgsqyonzybwsmftihjsdturodfdqdjkilxtapqxxdodkovbmmkhnhboitpxhbjljvkmagegsmetrxelakjdzewymjrvldzdkqfqlqjjryoafcjwsfdoihdxrxrerlpyrpxjiwksuvmsoiptpszhkjvbkyxbprsjsxzegcjgreiakvzrutnixnuqhqbcwgelarjanbljowcoueedlxyrjvnxctqgnekqisrtuxqxgjorcihicfgftslpwtmyzmumyxmanjiktktuwevbdkkceqadduhqpudkcetojnliflzjqxuxwgwmzkpzegufnhdmjyrjfjjwawoczwdfjztkjvgrkiccrsgswamrzdcmqtxqwjuoxgsxkbutuxngzhxcypkigelbnwtqjujgfcwzmgzgbgtvwcszogvoyrrevqtjopwzoizzsinzqlkukyczmfwmxdtnacudmozaishkydyqucsmmjuuhzphcaktsortl
@ongardie
ongardie / bench.c
Last active August 29, 2015 13:56
Microbenchmark that executes 1000 single-byte writes.
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
int main() {
int fd = open("bench.dat", O_WRONLY|O_CREAT|O_TRUNC, 0666);
if (fd < 0) {
@ongardie
ongardie / evince-compact.patch
Created November 25, 2013 08:04
a few tweaks to evince's UI to make it more compact. changes toolbar to text-only. reduces thumbnail padding in the sidebar. drops bookmarks from the sidebar (useless for me, too wide). works with evince-gtk 3.4.0 on debian.
diff --git a/shell/ev-sidebar-thumbnails.c b/shell/ev-sidebar-thumbnails.c
index 594ebce..8365ea0 100644
--- a/shell/ev-sidebar-thumbnails.c
+++ b/shell/ev-sidebar-thumbnails.c
@@ -649,6 +649,8 @@ ev_sidebar_init_icon_view (EvSidebarThumbnails *ev_sidebar_thumbnails)
priv->icon_view = gtk_icon_view_new_with_model (GTK_TREE_MODEL (priv->list_store));
gtk_icon_view_set_markup_column (GTK_ICON_VIEW (priv->icon_view), 0);
gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (priv->icon_view), 1);
+ gtk_icon_view_set_item_padding(GTK_ICON_VIEW (priv->icon_view), 10);
+ gtk_icon_view_set_item_width(GTK_ICON_VIEW (priv->icon_view), THUMBNAIL_WIDTH + 10*2);
@ongardie
ongardie / select.rs
Created November 16, 2013 00:55
Workaround for Rust select() once priv is removed from std::comm::Port See https://mail.mozilla.org/pipermail/rust-dev/2013-November/006665.html
#[feature(macro_rules)];
extern mod std;
/* SelectBox is a wrapper to allow calling select() on pointers */
struct SelectBox<'self> {
inner: &'self mut std::select::Select,
}
impl<'self> std::rt::shouldnt_be_public::SelectInner for SelectBox<'self> {
fn optimistic_check(&mut self) -> bool {
@ongardie
ongardie / pdf2pcl
Created October 2, 2013 21:10
pdf2pcl
#!/bin/sh
# Convert PDF to PCL.
if [ $# -eq 2 ]
then
outfile=$2
elif [ $# -eq 1 ]
then
outfile=`basename "$1" \.pdf`.pcl
else