Skip to content

Instantly share code, notes, and snippets.

View otoolep's full-sized avatar

Philip O'Toole otoolep

View GitHub Profile
// 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 git@github.com: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
@otoolep
otoolep / sine.py
Last active December 20, 2016 01:07
Pump a sine way into a local influxdb cluster
#!/usr/bin/python
import json
import math
import requests
import sys
from time import sleep
DATABASE = 'test1'
STATUS_MOD = 10
@otoolep
otoolep / gist:c58991dec54711026b77
Last active August 29, 2015 14:02
grafana 1.54 config for influxdb
/** @scratch /configuration/config.js/1
* == Configuration
* config.js is where you will find the core Grafana configuration. This file contains parameter that
* must be set before Grafana is run for the first time.
*/
define(['settings'],
function (Settings) {
"use strict";
return new Settings({