Skip to content

Instantly share code, notes, and snippets.

View ajliv's full-sized avatar

AJ Livingston ajliv

View GitHub Profile
@ajliv
ajliv / pipeline.yaml
Created September 2, 2020 22:06 — forked from mikebroberts/pipeline.yaml
Selectively triggering a GitHub sourced CodePipeline (only for one file)
# CodePipeline by default runs an execution whenever any change is detected in the configured source repository
# We can use a CodePipeline Webhook resource to filter such executions.
#
# This is a snippet that would be part of a CloudFormation template containing
# a CodePipeline resource (AWS::CodePipeline::Pipeline), named CodePipeline in this case, and
# assumes the GutHub OAuth token is available in the parameter GitHubOAuthToken.
# Typically a CodePipeline Webhook only contains the $.ref filter to check for
# the desired branch.
# However we can add up to 4 more filters, each of which can query the incoming webhook payload from Github.
# Such payloads are of the form:
@ajliv
ajliv / Instructions.md
Created May 22, 2019 17:33 — forked from pgilad/Instructions.md
Generate SSL Certificate for use with Webpack Dev Server (OSX)

Generate private key

$ openssl genrsa -out private.key 4096

Generate a Certificate Signing Request

openssl req -new -sha256 \
@ajliv
ajliv / nginx_s3_proxy.conf
Created April 25, 2018 17:39 — forked from josue/nginx_s3_proxy.conf
Simple Nginx Proxy to S3 Bucket Asset
server {
listen 80;
listen 443 default_server ssl;
ssl on;
ssl_certificate /etc/ssl/certs/myssl.crt;
ssl_certificate_key /etc/ssl/private/myssl.key;
server_name *.example.com;
root /var/www/vhosts/website;
@ajliv
ajliv / rate-limiter.js
Last active September 3, 2016 16:49
Rate limit tracker, adds a compounded penalty to the wait time with each offense over the limit
import { action, computed, observable, reaction, when } from 'mobx';
export default class RateLimiter {
@observable forgiveness;
@observable limit;
@observable offenses = 0;
@observable queue = [];
@observable wait;
@computed get compoundedPenalty() {
@ajliv
ajliv / index.html
Last active August 28, 2016 06:58
BrowserSync proxy server
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>BrowserSync Proxy Server</title>
</head>
<body>
<h1>BrowserSync Proxy Server</h1>
<ul>
<li><a href="/api/" data-bare-link="true"><code>/api/</code></a> This page.</li>
@ajliv
ajliv / targetIsDescendant.js
Last active August 28, 2016 06:39
Determine if event target is a descendant of a DOM node
/**
* Determine if event target is a descendant of a DOM node
* @param {Object} event - The event object
* @param {Element} parent - The DOM node to check if event target is equal to or a descendant of
* @return {Boolean}
*/
function targetIsDescendant(event, parent) {
var node = event.target || null;
while (node !== null) {
if (node === parent) return true;
@ajliv
ajliv / json2csv.js
Last active August 28, 2016 06:29
Convert a JSON object to CSV
import { flatten, keys, startCase, uniq } from 'lodash';
const json2csv = (rows = []) => {
const columns = parseCSVColumns(rows);
return [parseCSVHeaders(columns), ...rows.map(row => parseCSVRow(row, columns))].join('\n');
};
const escapeCSVString = (str = '') => {
const value = str ? JSON.parse(JSON.stringify(str)) : '';
@ajliv
ajliv / trippy.css
Last active September 27, 2017 14:23
Trippy CSS animation
.trippy {
animation-name: animate-trippy;
animation-duration: 1s;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-direction: alternate
}
@keyframes animate-trippy {
0% {
@ajliv
ajliv / preventWindowScroll.js
Last active August 28, 2016 06:30
Prevent window scroll on scrollable element
// Usage:
// var el = docuemnt.getElementById('scrollable-div');
// el.addEventListener('wheel', preventWindowScroll, false);
function preventWindowScroll(e) {
var direction = e.deltaY < 0 ? 'up' : 'down';
var el = e.currentTarget;
var atTop = el.scrollTop <= 0;
var atBottom = (el.scrollHeight - (el.clientHeight + el.scrollTop) <= 0);
if ((direction === 'up' && atTop) || (direction === 'down' && atBottom)) {
e.preventDefault();