Skip to content

Instantly share code, notes, and snippets.

@kurtroberts
kurtroberts / fortune500.txt
Last active June 7, 2019 19:08
Check a list of sites to see if they are Google Mobile friendly.
http://www.corporate.walmart.com/
http://www.exxonmobil.com/
http://www.chevron.com/
http://www.berkshirehathaway.com/
http://www.apple.com/
http://www.phillips66.com/
http://www.gm.com/
http://www.ford.com/
http://www.ge.com/
http://www.valero.com/
@kurtroberts
kurtroberts / session.sh
Created December 19, 2018 15:17
Silly Perl Tricks
# remove a string from all lines in a file
cat thing-groups.csv | perl -ne 's/,SmartGroup//g; print $_' -
# just the ones with that smartgroup, but remove it
cat thing-groups.csv | perl -ne 'while(/(.*),SmartGroup(.*)/g){ print "$1$2\n" };' -
# just the ones with that smartgroup, but make it the last one
cat thing-groups.csv | perl -ne 'while(/(.*)(,SmartGroup)(.*)/g){ print "$1$3$2\n" };' -
@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 / 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.