Skip to content

Instantly share code, notes, and snippets.

View glinton's full-sized avatar

Greg glinton

View GitHub Profile
@glinton
glinton / progress.md
Last active April 2, 2018 21:29
Rosetta permute. Generate simple progress from rsync.

Rosetta rsync output parsing

Comparing various text "permuters" to show pretty output for rsync

awk Winner

rsync --info=progress2 * test@192.168.1.142:/tmp/new/ 2> /dev/null | stdbuf -i0 -o0 tr $'\r' $'\n' | awk '{printf "\rSyncing image: %s - %s",$2,$3}'
# Syncing image: 100% - 37.30MB/s
# real	0m3.012s

perl Runner up

@glinton
glinton / bootstrap.sh
Last active March 1, 2018 19:35
nanoagent-v2 bootstrap script
#!/bin/bash
#
# Boostraps an ubuntu machine to be used as an agent for nanobox
# exit if any any command fails
set -e
set -o pipefail
# todo:
@glinton
glinton / portal.md
Last active November 26, 2017 10:58
Portal as an SSL terminator for `nanobox run`

Download portal for your OS.

Create a config file for portal

config.json

{
 "db-connection": "scribble:///tmp/portal",
 "log-level": "info",
 "server": true,

>> "just-proxy": true

@glinton
glinton / evars.sh
Created August 22, 2017 16:47
Adding 'complex' evars with `nanobox`
# Add it after manually converting the newlines
nanobox evar add local KEY1="-----BEGIN RSA PRIVATE KEY-----\nM\nW\nA\na\n5\nZ\nA\n5\nJ\nU\nC\na\nr\nR\nD\nS\nY\nb\n0\nK\n4\nM\nM\n1\nD\n-----END RSA PRIVATE KEY-----"
# Add it via a bash-friendly string
nanobox evar add local KEY2="-----BEGIN RSA PRIVATE KEY-----
M
W
A
a
5
@glinton
glinton / get-it.md
Last active August 14, 2017 18:03
Fetch file from Nanobox launched app
# '##' is a command to be run after modification

# console into your host server (VERY risky! Please do not modify anything unless you fully understand and accept the consequences)
nanobox console my-app do.1

# add your public key (from your laptop) to the authorized_keys file
# DO NOT REMOVE ANYTHING FROM THIS FILE! (Nanobox will fail to work if you do)
## edit `/root/.ssh/authorized_keys` and ADD/APPEND your public key (located on your laptop, generally at ~/.ssh/id_rsa.pub)
@glinton
glinton / dbTunnel.md
Created July 6, 2017 17:31
Share app databases on nanobox (experimental, non-recommended, and non-supported)

Tunnel to your other app's shared database

This requires two apps that you own/have access to. For clarity, we'll refer to the app with the shared database as the "server" app, and the one wanting to connect, the "client" app. This is not recommended nor supported by nanobox.

Note: You'll need to ensure NANOBOX_USERNAME and NANOBOX_PASSWORD are set on your "client" app

Manual Walkthrough

Fetch the nanobox binary. Run from your client component(s) in your client app

@glinton
glinton / aProxy.md
Last active September 11, 2017 21:00
Install and use nanobox on a linux cloud box (or about any other linux box). Tested on DigitalOcean 16.04

This guide assumes you have a remote dev server set up and have deploy[ed] dry-run, as well as added the mytest.dev dns alias to the dry-run environment

Create a config file for portal

portal.json

{
 "api-token": "123",
 "api-host": "0.0.0.0",
 "api-port": 8443,

>> "just-proxy": true,

@glinton
glinton / database.md
Last active September 11, 2018 20:16
Develop with nanobox while connected to production database

Launch a database in production and connect to it inside local nanobox app.

Create a boxfile with just a database and deploy

boxfile.yml

run.config:
  # set your engine like normal
  engine: none
@glinton
glinton / 0-runme.sh
Last active February 17, 2017 21:47
Downgrade kernel to last-known less oom-killy version (Ubuntu 14.04/16.04 on Digital Ocean)
# Install older linux kernel (extras for docker)
apt-get install -y linux-image-4.4.0-53-generic linux-image-virtual linux-image-extra-4.4.0-53-generic linux-image-virtual
# Point to desired kernel entry (from /boot/grub/grub.cfg) v menuentry within submenu
sed -i 's|GRUB_DEFAULT.*|GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 4.4.0-53-generic"|g' /etc/default/grub
# ^From grub.cfg:17 ^menuentry title from grub.cfg:53
# Generate new grub.cfg
update-grub
# Reboot into specified kernel
@glinton
glinton / readwrite.go
Created December 9, 2016 22:48
Working example of one way to Read() large(ish) data (1MB) from a golang net.Conn
// Package main is intended to provide a working example of how to properly
// read from a net.Conn without losing data or integrity. The data is generated
// from alphabetical characters rather than simply rand to prevent the
// generation of an `EOF`
package main
import (
"crypto/md5"
"fmt"
"io"