Skip to content

Instantly share code, notes, and snippets.

View keeth's full-sized avatar

Keith Grennan keeth

View GitHub Profile
@keeth
keeth / isNetworkError.js
Last active February 20, 2020 20:30
Is it a fetch network error? (for the purpose of retrying on failure).
/*
https://twitter.com/xinganwang/status/1189266788237885443
github/fetch: TypeError: Network request failed
Chrome: TypeError: Failed to fetch
Firefox: TypeError: NetworkError when attempting to fetch resource.
Safari: TypeError: The Internet connection appears to be offline.
*/
const isNetworkError = e =>
@keeth
keeth / salt.sls
Last active January 11, 2020 22:55
salt:
master:
fileserver_backend:
- git
gitfs_provider: gitpython
gitfs_remotes:
- git@github-salt:sprightco/salt.git:
- root: salt
- git@github-cms:sprightco/cms.git:
- root: etc/salt
@keeth
keeth / pingmon.py
Created October 10, 2019 21:52
Monitor packet loss to a particular host and send statistics to Cloudwatch
import threading
import time
import logging
logging.basicConfig(level=logging.INFO, format='[%(levelname)s %(asctime)s %(name)s] %(message)s')
logger = logging.getLogger('pingmon')
logger.setLevel(logging.INFO)
import boto3
@keeth
keeth / cacti.yml
Last active September 17, 2019 02:05
Non-interactive install of Cacti 1.1.23 + Spine 1.1.23 on Ubuntu Server LTS 16.04 EC2 (via Cloud Init / Terraform)
#cloud-config
write_files:
-
content: |
[mysqld]
max_heap_table_size=64M
tmp_table_size=64M
join_buffer_size=64M
innodb_doublewrite=OFF
innodb_buffer_pool_size=242M

Keybase proof

I hereby claim:

  • I am keeth on github.
  • I am keeth (https://keybase.io/keeth) on keybase.
  • I have a public key ASCgC0494QvYPRo5H-dPDtqY-Z6mIsW_Z8Hk9PhsfnWhQAo

To claim this, I am signing this object:

@keeth
keeth / Select.js
Last active December 29, 2017 11:38
A formsy-react wrapper around React Select (ES6)
import React from 'react';
import Formsy from 'formsy-react';
import ReactSelect from 'react-select';
import './Select.less';
const Select = React.createClass({
mixins: [Formsy.Mixin],
@keeth
keeth / bean-scratch-accel-no-button.ino
Last active April 17, 2017 18:38
Lightblue Bean Serial/Scratch speed tests with and without accelerometer
uint8_t buffer[20];
String msg = "ABCDEFGHIJKLMNOPQRS";
unsigned long startTest = 20000;
unsigned long stopTest = 40000;
void setup() {
pinMode(A3, INPUT);
msg.toCharArray((char *)buffer,20);
}
@keeth
keeth / heartbeat.js
Last active August 4, 2016 23:43
a better travis_wait (it prints the script output as it comes in, rather than all at the end)
const spawn = require('child_process').spawn;
const command = process.argv[2];
const args = process.argv.slice(3);
const child = spawn(command, args);
console.log(`heartbeat: running command ${command} with args ${args}`);
const heartbeat = setInterval(() => {
console.log('❤️');
}, 1000 * 60);
@keeth
keeth / gist:a58afe01b31f431aa878
Last active April 6, 2016 02:05
Install pygit2 0.22.0 on a minimal Ubuntu Trusty
apt-get install -y pkg-config python-pip git libssl-dev zlib1g-dev cmake python-dev libffi-dev libssh2-1-dev
git clone https://github.com/libgit2/libgit2 \
&& cd libgit2 \
&& git checkout tags/v0.22.0 \
&& mkdir build \
&& cd build \
&& cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
&& cmake --build . --target install \
&& cd ../..
@keeth
keeth / gist:6055491
Created July 22, 2013 16:50
grape -V resolve org.ratpack-framework ratpack-groovy 0.9.0-SNAPSHOT
keeth:fun keith$ grape -V resolve org.ratpack-framework ratpack-groovy 0.9.0-SNAPSHOT
:: loading settings :: url = jar:file:/usr/local/Cellar/groovy/2.1.5/libexec/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
no default ivy user dir defined: set to /Users/keith/.ivy2
including url: jar:file:/usr/local/Cellar/groovy/2.1.5/libexec/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings-public.xml
no default cache defined: set to /Users/keith/.ivy2/cache
including url: jar:file:/usr/local/Cellar/groovy/2.1.5/libexec/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings-shared.xml
including url: jar:file:/usr/local/Cellar/groovy/2.1.5/libexec/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings-local.xml
including url: jar:file:/usr/local/Cellar/groovy/2.1.5/libexec/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings-main-chain.xml
including url: jar:file:/usr/local/Cellar/groovy/2.1.5/libexec/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings-default-chain.xml