Skip to content

Instantly share code, notes, and snippets.

@ryandotsmith
ryandotsmith / agg.sql
Created January 23, 2013 05:19
Postgres array concatenation aggregate function.
CREATE AGGREGATE array_accum (anyarray)
(
sfunc = array_cat,
stype = anyarray,
initcond = '{}'
);
@ryandotsmith
ryandotsmith / iroh.rs
Last active July 17, 2024 18:49
Playing around with Iroh Tickets
use anyhow::{Context, Result};
use iroh::{
base::{
node_addr::AddrInfoOptions,
ticket::{BlobTicket, Ticket},
},
blobs::BlobFormat,
};
use tokio;
@ryandotsmith
ryandotsmith / event_buffering.md
Created February 14, 2012 04:10
event buffering

Event Buffering

Eventually platforms outgrow the single-source-tree model and become distributed systems. A common pattern in these distributed systems is distributed composition via event buffering. Here we motivate and describe this event buffering pattern.

The Problem

# /etc/systemd/system/shovel.service
[Unit]
Description=shovel
After=network.target
[Service]
ExecStart=/bin/bash -c 'source /home/ubuntu/shovel.env; /home/ubuntu/shovel -config /home/ubuntu/shovel.json -l :8546'
Restart=always
RestartSec=5
@ryandotsmith
ryandotsmith / lvmrad.sh
Created January 14, 2023 08:29
Setting up Ubuntu LVM Raid 0 with 4 NVMe M.2 Drives
lslbk # find drives to add (eg /dev/nvmeXn1)
pvcreate /dev/nvme1n1
pvcreate /dev/nvme2n1
pvcreate /dev/nvme3n1
pvcreate /dev/nvme4n1
vgcreate vg1 /dev/nvme1n1 /dev/nvme2n1 /dev/nvme3n1 /dev/nvme4n1
lvcreate --type=raid0 -l100%FREE -n rd1 vg1
mkfs.ext4 /dev/vg1/rd1
mkdir /storage #customize your mount point
echo '/dev/vg1/rd1 /storage ext4 defaults 0 0' >> /etc/fstab
@ryandotsmith
ryandotsmith / worker-pattern.md
Created January 23, 2012 05:03
The Worker Pattern

The Worker Pattern

Contents

  • Introduction
  • Definition
  • Examples
  • Links

Introduction

@ryandotsmith
ryandotsmith / hack-reactor.md
Last active November 24, 2022 07:01
Hack Reactor Talk

Tales From a Heroku User

Here are some things I have learned along the way.

Last Updated: 2013-02-08

Original Audience: Hack Reactor

About

package ens
import (
"strings"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
)
func Namehash(name string) common.Hash {
@ryandotsmith
ryandotsmith / main.go
Created January 15, 2015 01:10
Sending an OP_RETURN Bitcoin Transaction with Go using Chain's Bitcoin API
package main
import (
"bytes"
"encoding/hex"
"encoding/json"
"io/ioutil"
"log"
"net/http"
@ryandotsmith
ryandotsmith / op_return.rb
Created February 9, 2015 19:45
Chain.com OP_RETRURN Transaction - Create Bitcoin OP_RETURN Transactions in Ruby
require 'bitcoin'
require 'chain'
Chain.block_chain = 'testnet3'
Bitcoin.network = :testnet3
include Bitcoin::Builder
key = Bitcoin::Key.from_base58("cVVBKRBMoPLJSSMW7cM3hji7VmXz1zJWX3DypcjPcWpRBMEu2xF7")
builder = Bitcoin::Builder::TxBuilder.new