This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://docs.docker.com/engine/reference/commandline/docker/ | |
| name = container_name | |
| dbname = db_name | |
| version = 0.1 | |
| # build the container (with name:tag) | |
| build: | |
| docker build -t $(name):$(version) . |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://stats.stackexchange.com/questions/281162/scale-a-number-between-a-range | |
| function scale(n, oldMin, oldMax, newMin, newMax) { | |
| return ((n - oldMin) / (oldMax - oldMin)) * (newMax - newMin) + newMin; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // interpolate between colors { r, g, b } where 0 < t < 1 | |
| // when assigning a color for a number in a range larger than 0-1, scale the number to the 0-1 range first | |
| function lerpRGB(color1, color2, t) { | |
| let color = {}; | |
| color.r = color1.r + ((color2.r - color1.r) * t); | |
| color.g = color1.g + ((color2.g - color1.g) * t); | |
| color.b = color1.b + ((color2.b - color1.b) * t); | |
| return color; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # https://www.hipchat.com/docs/apiv2/method/send_room_notification | |
| AUTH_TOKEN="" # generate an auth token from the hipchat admin interface | |
| ROOM_ID=1 # get the room id from the hipchat admin interface | |
| HIPCHAT_URL="https://api.hipchat.com/v2/room" # or self hosted hiphat URL | |
| FROM="some sender" | |
| MESSAGE="some message" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://github.com/munki/munkiwebadmin/wiki/MunkiWebAdmin-Ubuntu-14.04-LTS-Setup | |
| echo Installing Apache | |
| /usr/bin/apt-get install -y apache2 | |
| echo Creating Munki repo in Apache web root | |
| /bin/mkdir -p /var/www/munki/pkgsinfo \ | |
| /var/www/munki/catalogs \ | |
| /var/www/munki/manifests \ | |
| /var/www/munki/pkgs \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Arduino IDE: | |
| - download from https://www.arduino.cc/en/Main/Donate | |
| USB -> Serial drivers: | |
| - download CH340G Driver from https://wiki.wemos.cc/downloads | |
| - download CP210x Driver from https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers | |
| Open Arduino IDE | |
| > Preferences: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM debian:stretch | |
| LABEL maintainer="First Last <email@somewhere.com>" | |
| ARG POSTGRES_VER=9.6 | |
| ARG TZ=Australia/Melbourne | |
| ARG DEBIAN_FRONTEND=noninteractive | |
| # Ensure Timezone is correct | |
| RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import "github.com/julienschmidt/httprouter" | |
| // usage | |
| // router.POST("/path", BasicAuth(someRequestHandler)) | |
| // BasicAuth middleware for incoming requests that must include basic authentication | |
| func BasicAuth(handler httprouter.Handle) httprouter.Handle { | |
| return func(w http.ResponseWriter, r *http.Request, p httprouter.Params) { | |
| log.Printf("Authorizing request from %s", r.RemoteAddr) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SubnetContainsIP check if an IP address is part of the subnet given by the CIDR (ie. '192.168.0.0/24') | |
| func SubnetContainsIP(CIDR, addr string) (bool, error) { | |
| _, ipNet, err := net.ParseCIDR(CIDR) | |
| if err != nil { | |
| return false, fmt.Errorf("Error parsing CIDR '%s'", CIDR) | |
| } | |
| host, _, err := net.SplitHostPort(addr) | |
| if err != nil { | |
| return false, fmt.Errorf("Error parsing address '%s'. %v", addr, err) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ( | |
| "fmt" | |
| "strings" | |
| "time" | |
| ) | |
| const timeFormat = "2006-01-02 15:04:05" | |
| // JSONTime a wrapper for time.Time that unmarshalls with a custom date format | |
| type JSONTime struct { |