Skip to content

Instantly share code, notes, and snippets.

kurtroberts / MySketch.vue
Created Dec 3, 2021
Only make vue-p5 available as a client-side component in Nuxt to avoid SSR and SSG render errors.
View MySketch.vue
<!-- - components/MySketch.vue -->
<section class="sketch">
v-on="{setup, draw}">
kurtroberts / datastoreDecorator.js
Created Sep 10, 2020
Amplify Datastore - Control when Sync Starts
View datastoreDecorator.js
Amplify's DataStore is useful, but it is very, very immature and has some
incredibly naive implementation choices. One of those is that it will
perform synchronization on the first call to query, regardless of a call
to start.
This is an issue, because most non-trivial applications will require a
login so that the app can load appropriate content for the user in question.
kurtroberts / index.js
Created Jul 29, 2020
Fun with browser automation
View index.js
const puppeteer = require('puppeteer');
async function getLink (url, xpathExpression) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url);
let link = await page.$eval(xpathExpression, anchor => { return anchor.href; });
await browser.close();
return link;
kurtroberts /
Created Dec 19, 2018
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 /
Last active Oct 31, 2018
Script Alerting Options
# Built in:
osascript <<EOF 2>/dev/null
display notification "test message" with title "title"
# yo-
yo_scheduler -t "Title" -n "test message"
kurtroberts /
Created Sep 21, 2018
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 \
kurtroberts /
Created Sep 5, 2018
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"];'
tasklist="Task1 Task2"
Task1 () {
echo "task 1"
Task2 () {
echo "task 2"
kurtroberts / Bottleneck.js
Last active Sep 1, 2020
Strategies for meeting API Limits with Promises
View Bottleneck.js
const _ = require('lodash'),
Bottleneck = require('bottleneck'),
limiter = new Bottleneck({
minTime: 333,
maxConcurrent: 1
Promise = require('bluebird'),
promises = [];
_.range(10).forEach(function (x) {
kurtroberts / index.js
Created Aug 9, 2018
Handling HTTP/HTTPS redirection in a Lambda function
View index.js
'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.