Skip to content

Instantly share code, notes, and snippets.

View sanderson's full-sized avatar

Scott Anderson sanderson

View GitHub Profile
@sanderson
sanderson / 0-instructions.md
Last active July 18, 2017 21:16 — forked from tylerflint/0-instructions.md
Install Hugo on Nanobox

Hugo Project Bootstrap with Nanobox

If you haven't already, go ahead and download and install Nanobox.

# Create a new directory for your project and cd in
mkdir hugo-proj && cd hugo-proj

# Create a `boxfile.yml` using the content from this gist
curl -sL http://tinyurl.com/ya23f5ry > boxfile.yml

It goes without saying – security is of the utmost importance in your production infrastructure. Nanobox was built with strict security protocols in place. The following measures have been put in place to reduce your app's attack plane.

The Initial Bootstrap

Each and every server provisioned through Nanobox uses a simple Ubuntu bootstrap script (feel free to view the source). This bootstrap installs and configures Docker and the Nanobox agent as well as a brutal, default-deny firewall via iptables and a custom overlay network. It also ensures that the core software is up-to-date.

Once a host is bootstrapped, you essentially have a machine that is fully locked-down, running only Docker, the Nanobox agent, and the virtual network. At this point, not even the other machines within the same network can talk to the machine.

Updates via the Dashboard

After the initial bootst

@sanderson
sanderson / Environment Variables
Last active March 15, 2018 22:26
Configuring Nanobox to Use nullmailer
SMTP_HOST=smtp-host
SMTP_PORT=smtp-port
SMTP_USER=smtp-username
SMTP_PASS=smtp-password
SMTP_TLS=tls|ssl
SMTP_AUTH=login|plain
@sanderson
sanderson / boxfile.yml
Created February 22, 2018 15:19
New Relic with the PHP engine
run.config:
engine: php
engine.config:
extensions:
- newrelic
extra_packages:
- newrelic
web.site:
start:
@sanderson
sanderson / Job#1.sh
Created March 6, 2018 15:41
Semaphore CI & Nanobox
nanobox run test-command
if [ "$BRANCH_NAME" = "master" ]; then nanobox remote add production-app ; elif [ "$BRANCH_NAME" = "staging" ]; then nanobox remote add staging-app ; fi
COMMIT_MESSAGE="$(git log -1 --pretty=%B)"; nanobox deploy -m \'"${COMMIT_MESSAGE}"\'
@sanderson
sanderson / boxfile.yml
Created March 8, 2018 18:11
Mapping Environment Variables with Nanobox
deploy.config:
transform:
- bash set-evars.sh
@sanderson
sanderson / apple-weights-line-protocol.txt
Created June 13, 2018 21:05
Percentage with Cumulative Total
weight apple_weight=0.11 1528113660000000000
weight apple_weight=0.42 1528113720000000000
weight apple_weight=0.83 1528113780000000000
weight apple_weight=0.07 1528113840000000000
weight apple_weight=0.19 1528113900000000000
weight apple_weight=0.43 1528113960000000000
weight apple_weight=0.67 1528114020000000000
weight apple_weight=0.24 1528114080000000000
weight apple_weight=0.74 1528114140000000000
weight apple_weight=0.03 1528114200000000000
@sanderson
sanderson / apple_stand.txt
Last active February 3, 2021 11:22
Sample time series data for an apple stand
# DDL
CREATE DATABASE apple_stand
# DML
# CONTEXT-DATABASE: apple_stand
variety granny_smith=30,golden_delicious=30,fuji=30,gala=30,braeburn=30,total_weight=150 1529323200000000000
variety granny_smith=29.22,golden_delicious=28.98,fuji=29.63,gala=28.92,braeburn=30,total_weight=146.75 1529323500000000000
variety granny_smith=29.22,golden_delicious=27.87,fuji=29.63,gala=28.57,braeburn=29.69,total_weight=144.98 1529323800000000000
@sanderson
sanderson / sample_data.txt
Created June 25, 2018 17:00
Sample time-series data with negative and positive field values
# DDL
CREATE DATABASE sample
# DML
# CONTEXT-DATABASE: sample
data a=1.33909108671076,b=-0.163643058925645 1529841600000000000
data a=-0.774984088561186,b=0.137034364053949 1529841660000000000
data a=-0.921037167720451,b=-0.482943221384294 1529841720000000000
@sanderson
sanderson / confirmed-cases-since-100th.flux
Last active April 1, 2020 17:27
COVID-19 Flux Queries
alignTime = (tables=<-, alignTo=time(v: 0)) => {
_tableInfo = tables |> tableFind(fn: (key) => true) |> getRecord(idx: 0)
_startTime = if alignTo != time(v: 0) then alignTo else if exists _tableInfo._start then _tableInfo._start else time(v: 0)
_data = tables
|> stateDuration(
fn: (r) => true,
column: "timeDiff",
unit: 1ns
)
|> map(fn: (r) => ({ r with _time: time(v: (int(v: _startTime ) + r.timeDiff))}))