Skip to content

Instantly share code, notes, and snippets.

@rivo
rivo / postgres.go
Last active August 6, 2023 22:39
A demo Go application (a PostgreSQL database browser) highlighting the use of the rivo/tview package. See https://github.com/rivo/tview/wiki/Postgres
package main
import (
"database/sql"
"fmt"
"net/url"
"os"
"reflect"
"regexp"
"strconv"
@rivo
rivo / serve.go
Created November 26, 2017 12:28
Graceful stop and restart for HTTP servers in Go
package main
import (
"context"
"fmt"
"net"
"net/http"
"os"
"os/exec"
"os/signal"
@rivo
rivo / chartcolorpalettes.js
Created January 22, 2016 11:24
Generating Color Palettes for Charts
var MIN_L = 40, // Don't generate too dark colors.
MAX_L = 85, // Don't generate too light colors.
index,
length,
offset,
emptySlots;
// Make a list of base colors. Start with blue if nothing is defined.
var baseColors = BASE_COLORS.length ? BASE_COLORS : ["RoyalBlue"];
emptySlots = FINAL_PALETTE_SIZE - baseColors.length - 2; // 2 gray values.