Skip to content

Instantly share code, notes, and snippets.

@kurtroberts
kurtroberts / session.sh
Last active October 31, 2018 18:02
Script Alerting Options
#/bin/bash
# Built in:
osascript <<EOF 2>/dev/null
display notification "test message" with title "title"
EOF
# yo- https://github.com/sheagcraig/yo
yo_scheduler -t "Title" -n "test message"
@kurtroberts
kurtroberts / logging-docker-to-cloudwatch.md
Created September 21, 2018 18:42
Using awslogs driver for docker with docker-machine

Make a docker-machine with AWS Credentials

Obviously, you'll need to make credentials first.

$ docker-machine create -d virtualbox \
    --engine-env AWS_REGION=us-east-1 \
    --engine-env AWS_ACCESS_KEY_ID=xxxxxxxxxxxxxxxx \
    --engine-env AWS_SECRET_ACCESS_KEY=xxxxxxxxxxxxxxxxxxxxxx \
 awslogs
@kurtroberts
kurtroberts / demos.sh
Created September 5, 2018 20:10
Strategies for parsing JSON on the Mac without installing anything
# using OSAScript's JavaScript support
osascript -l JavaScript -e "console.log(($(cat /Users/$(whoami)/Library/Application\ Support/Google/Chrome/Local\ State)).profile.info_cache.Default.user_name)"
# using python
cat /Users/$(whoami)/Library/Application\ Support/Google/Chrome/Local\ State | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["profile"]["info_cache"]["Default"]["user_name"];'
@kurtroberts
kurtroberts / list-command-pattern.sh
Created August 29, 2018 15:30
Silly bash tricks
#!/bin/bash
tasklist="Task1 Task2"
Task1 () {
echo "task 1"
}
Task2 () {
echo "task 2"
@kurtroberts
kurtroberts / Bottleneck.js
Last active September 1, 2020 19:44
Strategies for meeting API Limits with Promises
const _ = require('lodash'),
Bottleneck = require('bottleneck'),
limiter = new Bottleneck({
minTime: 333,
maxConcurrent: 1
}),
Promise = require('bluebird'),
promises = [];
_.range(10).forEach(function (x) {
@kurtroberts
kurtroberts / index.js
Created August 9, 2018 17:06
Handling HTTP/HTTPS redirection in a Lambda function
'use strict';
/****
Set up as a lambda function, it doesn't need any special permissions.
To test, you'll use a CloudFrontHTTPRedirect template.
Then, you'll create a CloudFront Distribution and attach this as a behavior.
Use the Event Type "ViewerRequest" to trigger it.
@kurtroberts
kurtroberts / drop-all.sql
Created August 4, 2018 14:25
Drop all tables in a PSQL schema
-- Liberally borrowed from - https://stackoverflow.com/questions/3327312/drop-all-tables-in-postgresql
-- If you happen to be working on a jira database, you're going to have to do it twice to resolve all the cascades
DO $$ DECLARE
r RECORD;
BEGIN
-- if the schema you operate on is not "current", you will want to
-- replace current_schema() in query with 'schematodeletetablesfrom'
-- *and* update the generate 'DROP...' accordingly.
@kurtroberts
kurtroberts / shell-session.md
Last active July 6, 2018 22:12
I really, really love `jq`

Wow, that's a lot of JSON for my bio...

$ cat data/bio/kurt-roberts.json
{"sys":{"space":{"sys":{"type":"Link","linkType":"Space","id":"----------"}},"id":"------------","type":"Entry","createdAt":"-------","updatedAt":"-------","environment":{"sys":{"id":"master","type":"Link","linkType":"Environment"}},"revision":2,"contentType":{"sys":{"type":"Link","linkType":"ContentType","id":"bio"}},"locale":"en-US"},"fields":{"name":"Kurt Roberts","title":"Chief Creative Technologist?","description":"Senior engineering and design team lead with 15+ years of experience creating solutions for high-profile brands such as Coca-Cola, BlueCross BlueShield America, General Mills and DirecTV, and powerful forces for change such as Facing History and Ourselves, The Washington Area Women's Foundation, Humane Society of the United States and Planned Parenthood.","pastClients":["Coca-Cola","BlueCross BlueShield America","General Mills","DirecTV","Facing History and Ourselves","Humane Society of the United States","Planned P
@kurtroberts
kurtroberts / index.js
Last active July 6, 2018 19:35
Semicolon insertion
var x = 0
/***
While this comment seems like it might be the
beginning of a new statement, you should be careful what
your believe. ;) You should always check */+2/* or *+3* times
what the code is doing and what someone is explaining
in the comments. Sometimes crazy code likes to hide
inside really big comments.
Automatic semicolon insertion is great, until it isn't.
@kurtroberts
kurtroberts / elk-zentral.txt
Created June 20, 2018 17:27 — forked from jbaker10/elk-zentral.txt
Setup ELK stack in Zentral
## To install Kibana
sudo docker pull sebp/elk:latest
## To run the link on your localhost just to test
docker run --link zentral_elastic_1:elasticsearch -p 127.0.0.1:5601:5601 --net zentral_default kibana
## After this, you should be able to access the Kibana dashboard from 127.0.0.1:5601
## Edit the base.json under conf/start/zentral/base.json
vi ./conf/start/zentral/base.json