Skip to content

Instantly share code, notes, and snippets.

View zackferrofields's full-sized avatar

Zack Ferro-Fields zackferrofields

View GitHub Profile
@zackferrofields
zackferrofields / find.sh
Last active June 25, 2019 09:42
list files cheatsheet
# list files by name
#
# find $PATH -name '$FILE_NAME' -print | rev | cut -d/ -f1 | rev"
#
# eg all javascript files in "src"
#
find ./src -name '*.js' -print | rev | cut -d/ -f1 | rev
@zackferrofields
zackferrofields / Dockerfile
Last active September 17, 2018 11:46
Cache a docker base image for faster Travis builds #Docker #Travis #cache
FROM zackferrofields/app:base as builder
COPY . .
RUN yarn \
&& yarn build
FROM nginx
COPY nginx/conf.d/ /etc/nginx/conf.d/
COPY nginx/default.d/dashboard.conf /etc/nginx/default.d/
COPY nginx/data/www /var/www/zackferrofields
let return = (a: 'a) : option('a) => Some(a);
let bind = (m: option('a), f: 'a => option('b)) : option('b) =>
switch (m) {
| None => None
| Some(a) => f(a)
};
let (>>=) = bind;
@zackferrofields
zackferrofields / debug_node.sh
Last active August 15, 2017 11:41
Chrome DevTools debug, a reverse-proxy NodeJS Docker container
#!/bin/bash
# Chrome DevTools debug,
# a reverse-proxy NodeJS Docker container
#
# Example docker-compose file
#
# version: "3"
# services:
# proxy:
@zackferrofields
zackferrofields / docker_cleanup.sh
Last active May 10, 2017 13:12
Docker clean up commands
#!/bin/bash
# stop running containers
docker ps -q | xargs docker stop
# force remove all containers
docker ps -a -q | xargs docker rm -f
# force remove all untagged images
docker images -q --filter dangling=true | xargs docker rmi -f
@zackferrofields
zackferrofields / autoScroll.js
Last active February 12, 2018 20:22
Stateless (almost) react scroll to on `componentDidMount`
import { createElement } from 'react';
import { compose } from 'ramda';
import { lifecycle, withProps } from 'recompose';
const enhance = compose(
lifecycle({ componentDidMount() {
this.refs.node.scrollIntoView({block: 'end', behavior: 'smooth'});
} }),
withProps({ ref: 'node' }),
);
@zackferrofields
zackferrofields / .lambci.js
Last active March 20, 2017 18:03
Lambci yarn test
module.exports = {
cmd: 'nave use 7 bash -c "sh lambci_test.sh"'
}
@zackferrofields
zackferrofields / slack.py
Last active March 31, 2018 01:46
AWS CodeDeploy trigger Lambda Slack message
'''
Follow these steps to configure the webhook in Slack:
1. Navigate to https://<your-team-domain>.slack.com/services/new
2. Search for and select "Incoming WebHooks".
3. Choose the default channel where messages will be sent and click "Add Incoming WebHooks Integration".
4. Copy the webhook URL from the setup instructions and use it in the next section.
@zackferrofields
zackferrofields / server.js
Last active September 12, 2016 16:23
Node static file server
const http = require('http');
const fs = require('fs');
const path = require('path');
const PORT = 8000;
const filePath = path.join(__dirname, 'index.html');
http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/html'});
fs.createReadStream(filePath)
.on('data', data => res.write(data))
@zackferrofields
zackferrofields / index.js
Last active January 8, 2016 13:54
Node static HTTP server
const http = require('http');
const fs = require('fs');
const path = require('path');
const url = require('url');
const PORT = 8000;
http.createServer((req, res) => {
const pathname = url.parse(req.url).pathname;
const isStaticFile = !!path.extname(pathname);
const filePath = path.join(__dirname, isStaticFile ? path.join('static', pathname) : 'views/index.html');