Skip to content

Instantly share code, notes, and snippets.

View otoolep's full-sized avatar

Philip O'Toole otoolep

View GitHub Profile
@otoolep
otoolep / rqlite Java client compiled and functional
Last active March 21, 2025 03:18
This gist shows the rqlite Java client fetching data from the /status endpoint on an rqlite node.
~/repos/rqlite-java-http (master)$ mvn compile
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------< com.example:rqlite-java-client >-------------------
[INFO] Building rqlite-java-client 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ rqlite-java-client ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/philip/repos/rqlite-java-http/src/main/resources
@otoolep
otoolep / bf.txt
Created December 11, 2024 22:13
BF on rqlite
$ cat sql
WITH RECURSIVE
program AS
(SELECT '++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.' AS p,
'' AS input, 3 AS width
),
jumpdepth AS
(SELECT 0 AS idx, 0 AS jumpdepth, '' AS jumplist, NULL as jumpback, NULL AS direction, p || '0' AS p, width FROM program
UNION ALL
SELECT idx+1, CASE SUBSTR(p, idx+1, 1)
// Package store provides a distributed SQLite instance.
//
// Distributed consensus is provided via the Raft algorithm.
package store
import (
"bytes"
"compress/gzip"
"encoding/binary"
"errors"
# Create the SQLite file.
~ $ sqlite3 test.db
SQLite version 3.31.1 2020-01-27 19:55:54
Enter ".help" for usage hints.
sqlite> CREATE TABLE test(field1);
sqlite> INSERT INTO test
...> WITH RECURSIVE
...> cte(x) AS (
...> SELECT random()
...> UNION ALL
~ $ mkdir h
~ $ cd h
~/h $ export GOPATH=$PWD
~/h $ go version
go version go1.18.2 linux/amd64
~/h $ mkdir -p src/github.com/otoolep
~/h $ git clone [email protected]:otoolep/hraftd.git
Cloning into 'hraftd'...
remote: Enumerating objects: 1762, done.
remote: Counting objects: 100% (12/12), done.
@otoolep
otoolep / gist:f2f650dc24a9408ddaed2d08bde6ac89
Created November 8, 2021 17:27
rqlite query performance example
Start node:
$ rqlited data
Create and insert some data:
$ curl -XPOST 'localhost:4001/db/execute?pretty&timings' -H "Content-Type: application/json" -d '[
> "CREATE TABLE foo (id INTEGER NOT NULL PRIMARY KEY, name TEXT, age INTEGER)"
> ]'
{
@otoolep
otoolep / vimrc
Created September 6, 2014 21:30
vimrc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
//
// How to set timeout for http.Get() in golang
//
package main
import (
"io"
"io/ioutil"
"log"
"net"
/*
author: jbenet
os x, compile with: gcc -o testo test.c
linux, compile with: gcc -o testo test.c -lrt
*/
#include <time.h>
#include <sys/time.h>
#include <stdio.h>
@otoolep
otoolep / influxdb-grafana-howto.sh
Last active March 14, 2021 06:32
Shell script to download, and configure, InfluxDB, nginx, and Grafana
#!/bin/bash
# Check out the blog post at:
#
# http://www.philipotoole.com/influxdb-and-grafana-howto
#
# for full details on how to use this script.
AWS_EC2_HOSTNAME_URL=http://169.254.169.254/latest/meta-data/public-hostname
INFLUXDB_DATABASE=test1