Skip to content

Instantly share code, notes, and snippets.

@odewahn
odewahn / config-timing-in-single-page-app.md
Last active August 3, 2020 02:25
Loading global environment variables in a single page app (SPA) in react/redux

I was trying to pass config variables from a backend written in Go to a single page app (SPA) written in react. For example, I wanted to set an "Env" flag to dev or prod or control whether you have to log in or not. Here's an example of the /api/config route that supplies this data:

{
    "Auth0ClientDomain": "odewahn.auth0.com", 
    "Auth0ClientID": "gcSxq9GfpUdVWNIvYiOsP7rh1s8u6ftA", 
    "ClientBrowser": "HTTPie", 
    "ClientOS": "darwin", 
    "Env": "dev", 
 "FirstClientLoad": "true", 
@odewahn
odewahn / samalba-search-example.go
Last active June 12, 2016 22:53
Example of how to search your own public repos using samalba client
package main
import (
"fmt"
"log"
"github.com/samalba/dockerclient"
)
// Helpful:
package main
import (
"crypto/rand"
"fmt"
"log"
"github.com/fsouza/go-dockerclient"
)
package main
import (
"fmt"
"os/exec"
"strings"
)
func runCmd(cmdArgs []string) ([]string, error) {
cmdName := "docker-machine"
export TOKEN=$( head -c 30 /dev/urandom | xxd -p )
export POOL_SIZE=5
export OVERPROVISION_FACTOR=2
export CPU_SHARES=$(( (1024*${OVERPROVISION_FACTOR})/${POOL_SIZE} ))
export TMPNB_NODE=6df651e0-4701-411d-b11c-3cbfe73b86d7-n1
export DOCKER_HOST=tcp://104.130.0.38:2376
docker run -d \
-P \
-h spark.tmpnb-oreilly.com \
export TOKEN=$( head -c 30 /dev/urandom | xxd -p )
export POOL_SIZE=5
export OVERPROVISION_FACTOR=2
export CPU_SHARES=$(( (1024*${OVERPROVISION_FACTOR})/${POOL_SIZE} ))
export TMPNB_NODE=bb0f0ccc-2dcb-410b-94cf-808c99324ab6-n1
export DOCKER_HOST=tcp://104.130.0.25:2376
docker run -d \
-P \
-p 80 \

Network Notes

Set up a Docker of Vagrant-based lab where you set up your own network and topologies to learn, with a final case study on setting up a secure (!) VPC on AWS.

tcp/ip on Linux

  • IP addresses
  • sub-nets and CIDR
  • IPv6
  • Ports
# Set up a working ipython environment
The simplest way to do this is to install Anaconda:
http://docs.continuum.io/anaconda/install.html
# Install IPython3