Skip to content

Instantly share code, notes, and snippets.

View npearce's full-sized avatar
🏠
Working from home is now totally redundant, right?

Nathan Pearce npearce

🏠
Working from home is now totally redundant, right?
View GitHub Profile
@npearce
npearce / install-docker.md
Last active June 5, 2024 20:07
Amazon Linux 2 - install docker & docker-compose using 'sudo amazon-linux-extras' command

UPDATE (March 2020, thanks @ic): I don't know the exact AMI version but yum install docker now works on the latest Amazon Linux 2. The instructions below may still be relevant depending on the vintage AMI you are using.

Amazon changed the install in Linux 2. One no-longer using 'yum' See: https://aws.amazon.com/amazon-linux-2/release-notes/

Docker CE Install

sudo amazon-linux-extras install docker
sudo service docker start
@npearce
npearce / raspberry_pi_consul_cluster.md
Last active August 27, 2023 08:03
Build a Raspberry Pi Consul Cluster

Configure Raspberry Pi Networking

It is possible to run 3 consul servers on the same IP address if you shift the various ports to unique numbers to avoid conflict, but you don't have to do that.

Instead, add interface alias's in your /etc/rc.local (just before the exit 0), e.g.:

In my case, wlan0 is a dhcp assigned interface. The following commands add three new alias interfaces, wlan0:1, etc, with their own stat IP Addresses.

ifconfig wlan0:1 inet 10.0.0.41 netmask 255.255.255.0
@npearce
npearce / sort_array_of_JSON_objects.js
Last active July 28, 2023 09:15
Sort Array of JSON Object by date values
// Sort array of JSON objects by date value
const records = [
{
order_id: 12345,
order_date: "2020-03-23"
},
{
order_id: 12346,
order_date: "2020-03-20"
},
@npearce
npearce / README.md
Last active February 5, 2023 14:45
Useful git commands

Useful git commands

This gist is for collecting git commands I don't use often enough to remember, but probably waste too much time trying to find when I need them.

@npearce
npearce / consul_statsd.md
Created October 8, 2020 04:46
Consul Agent Statsd

consul config

Test with StatsD/Graphite container

`docker run -d
--name graphite
--rm
-p 80:80
-p 2003-2004:2003-2004
-p 2023-2024:2023-2024
-p 8125:8125/udp\

@npearce
npearce / Lab_k8s_MultiCluster.md
Last active September 30, 2020 20:58
Vagrantfile for creating 2x k8s clusters

Two k8s Cluserts w/ Consul in Vagrant

This will create 2 virtualbox VM's each with full (not Minikube) single node k8s installs:

vagrant up

Complete the install in each VM

Perform the following for both k8s1 and k8s2

@npearce
npearce / git_config_example
Created June 3, 2020 21:30
gitconfig setup for using different github accounts for repositories
# ~/.gitconfig
# `useHttpPath` tells git to match the ENTIRE path. It's all or none, baby.
[user]
name = <Your Name>
email = your.email@example.com
[credential]
useHttpPath = true
@npearce
npearce / JQueryEvents.js
Created April 7, 2020 20:43
JQuery event best practices
// One does this to be happy:
$(document).on('click', '#some_id', () => {
// Something
})
// One does this to be sad
$('#some_id').click(() => {
@npearce
npearce / math.js
Created January 28, 2020 03:45
Javascript Floating Point Arithmetic
233.66 + 157.55
// returns: 391.21000000000004
// Because: https://stackoverflow.com/questions/588004/is-floating-point-math-broken/27030789#27030789
// As toFixed() converts to a string, use Math.round()
// 2 decimal places:
Math.round( (233.66 + 157.55)) * 1e2 ) / 1e2

Testing Gist naming....