Skip to content

Instantly share code, notes, and snippets.


Thom Nichols thom-nic

View GitHub Profile
thom-nic / _spacing-helpers.scss
Last active Sep 3, 2020 — forked from jacurtis/_spacing-helpers.scss
SASS Margin and Padding Helpers Loop. Generates .mts type helper classes.
View _spacing-helpers.scss
* Spacing helpers for consistent margin and padding on elements. Uses rems (not px!)
* With the current default settings, generates classes like:
* .mts = margin-top: 0.5rem
* .phl = padding-left: 2rem; padding-right: 2rem; // h = horizontal = left/right
* Inspired by:
thom-nic / override.conf
Created Aug 2, 2017
How to get sane terminal behavior with embedded linux/ RPi + usb-serial cable and GNU Screen!
View override.conf
# what's more frustrating than using `screen` to a serial console then running `less` or `vim` and having it
# not use your full window width & height like a NORMAL ***ING TERMINAL EMULATOR
# this belongs in /etc/systemd/system/serial-getty\@ttyS0.service.d/override.conf
# If your terminal is something other ttyS0, adjust as needed.
# This is for Systemd (Debian Jessie and above, ubuntu Xenial/ Zesty, etc.
# There's a non-systemd equivalent in /etc/login.defs I think
thom-nic / chromedriver.js
Last active Apr 12, 2017
Chromedriver auto-start service for WebdriverIO without Selenium
View chromedriver.js
const chromedriver = require('chromedriver');
const retry = require('p-retry');
const http = require('axios');
* Start chromedriver and waits for it to become available before the tests start.
* Call this on wdio.confg `onPrepare`, passing `this` (the wdio config)
function start(config) {
const pollUrl = `http://${ || 'localhost'}:${config.port || 4444}${config.path || '/wd/hub'}/status`;
thom-nic / redux-async-actions.js
Created Apr 13, 2016
re: "Two Weird tricks with Redux" by @jlongster
View redux-async-actions.js
* Re: specifically James' comment on having to wait on an action:
* redux-thunk returns whatever value is returned by my action. In this case I'm using axios so it already returns a promise.
* So if I want to do something after an async action completes (without having to go through the redux store that gets
* updated by some sort of ACTION_DONE state) I can just `.then()` on the promise returned by my action creator.
* Example follows:
thom-nic / npm ls tree
Created Dec 19, 2015
react dependencies
View npm ls tree
├── axios@0.7.0
├─┬ babel@5.8.34
│ ├─┬ commander@2.9.0
│ │ └── graceful-readlink@1.0.1
│ ├── convert-source-map@1.1.2
│ ├── fs-readdir-recursive@0.1.2
│ ├─┬ glob@5.0.15
│ │ ├─┬ inflight@1.0.4
│ │ │ └── wrappy@1.0.1
│ │ └── once@1.3.3
thom-nic / jasmine.matcher.toBeInstanceOf.js
Last active Dec 4, 2015 — forked from heat/jasmine.matcher.toBeInstanceOf.js
Jasmine Matcher instanceof for Jasmine 2.3 & ES6
View jasmine.matcher.toBeInstanceOf.js
/* eslint-env jasmine */
beforeEach(function() {
toBeInstanceOf: (util, customEqualityTesters) => {
return {
compare: (actual, expected) => {
const pass = (actual instanceof expected);
return {
message: `Expected ${actual} to ${pass ? 'not' : ''} be instance of ${expected}`,
thom-nic / chunked_transfer_decoder.rb
Last active Feb 5, 2020
Rack middleware to decode chunked transfer HTTP request
View chunked_transfer_decoder.rb
#require 'rack/request'
# Rack middleware to decode a `Transfer-Encoding: chunked` HTTP request.
# Some HTTP servers (Webrick and Unicorn/Rabinbows/Zbatery) already decode the
# chunked stream, but they leave the 'Transfer-Encoding' header and don't bother
# to add a 'Content-Length' header, which causes rails ActionDispatch::Request
# to not parse the whole request body.
thom-nic /
Last active Aug 12, 2019 — forked from brandonb927/
OSX environment setup
# Some things taken from here
# Set the colours you can use
thom-nic /
Created Sep 26, 2014
Mac bash upgrade to mitigate the Shellshock exploit
# shellshock upgrade & patch for Mac OSX
# OSX ships with a horribly old version of bash (3.2) which is vulnerable to
# the Shellshock exploit (CVE-2014-6271)
# We use homebrew to get a recent version of bash, then symlink it to
# /bin/bash and /bin/sh (because sh is really bash)
# Use this to see if you're vulnerable
# env X="() { :;} ; echo vulnerable" /bin/bash -c "echo testing"
brew update && brew install bash
thom-nic / Dockerfile
Last active Aug 13, 2020
Dockerfile that attempts to run the app as non-root user. This creates a `node` user & sets permissions on app files. Note you cannot `chown` files in a docker 'volume' during the build process, but you can at runtime (as part of your `CMD`) but in that case you can't use the `USER` command to change the UID before `CMD` runs.
View Dockerfile
# Node.js app Docker file
# Some basic build instructions:
# ```
# # you should delete node_modules b/c you don't want that copied during 'ADD'
# docker build -t thom-nic/node-bootstrap .
# # run a shell in the container to inspect the environment (as root):
# docker run --rm -itu root thom-nic/node-bootstrap /bin/bash
# ```
You can’t perform that action at this time.