Skip to content

Instantly share code, notes, and snippets.

Stephen Sugden grncdr

Block or report user

Report or block grncdr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View machine.js
const invoiceMachine = Machine({
id: 'invoice',
initial: 'open',
states: {
open: {
on: {
CLOSE: {
target: 'closed',
actions: [
'open_next_invoice',
@grncdr
grncdr / set-retention-policies.sh
Created Jan 29, 2019
One liner for setting retention policy on a set of cloudwatch log groups
View set-retention-policies.sh
#!/bin/sh
PATTERN="my-app-production"
RETENTION_IN_DAYS="30"
for group_name in $(aws logs describe-log-groups | jq -r '.logGroups[]|.logGroupName' | grep $PATTERN); do
aws logs put-retention-policy --log-group-name $group_name --retention-in-days $RETENTION_IN_DAYS;
done
@grncdr
grncdr / git-stash-review
Created Jun 5, 2018
shell script for reviewing your git stashes
View git-stash-review
#!/bin/bash
RETAINED_STASHES="0"
REMAINING_STASHES=$(git stash list | wc -l)
while true; do
if [ "$REMAINING_STASHES" == "0" ]; then
echo "All done"
break
fi
View keybase.md

Keybase proof

I hereby claim:

  • I am grncdr on github.
  • I am grncdr (https://keybase.io/grncdr) on keybase.
  • I have a public key ASDwB6kzUc-wV7jvW5RtkoQvY9KyPtA5q-7TqkxwERwkEAo

To claim this, I am signing this object:

@grncdr
grncdr / fix-id-sequences.sql
Created Dec 15, 2016
Found myself needing this today to fix a bunch of broken ID sequences in a Rails DB that it been incorrectly restored from a backup.
View fix-id-sequences.sql
DO $$
var rows = plv8.execute("select tablename, pg_get_serial_sequence(tablename, 'id') seqname from " +
"(select tablename from pg_tables where schemaname = 'public' and tablename != 'schema_migrations') blah"
)
rows.forEach(function (row) {
plv8.execute("select setval('" + row.seqname + "', (select max(id) from " + row.tablename + ")+1, false)")
})
$$ LANGUAGE plv8;
@grncdr
grncdr / find-runscope-errors.js
Created Aug 1, 2016
Find errors from runscope
View find-runscope-errors.js
#!/usr/bin/env node
const https = require('https')
const accessToken = 'ACCESS_TOKEN'
const bucket = 'BUCKET_KEY'
const testId = 'TEST_ID'
function formatLink (result) {
const start = new Date(result.started_at * 1000).toISOString()
@grncdr
grncdr / typescript.vim
Created Mar 6, 2016
Load tsconfig.json and add extra syntastic args if found
View typescript.vim
function! LoadTsConfig()
let search_depth = 20
let dirname = fnamemodify(expand('%'), ":p:h")
while search_depth > 0 && dirname != "/"
let search_depth = search_depth - 1
let filename = dirname . "/tsconfig.json"
" while filename
if filereadable(filename)
let b:tsconfig_path = filename
let tsconfig = jsondecode(join(readfile(filename)))
@grncdr
grncdr / foo.pl
Created Feb 13, 2016
Script for cleaning up old homebrew deps
View foo.pl
#!/usr/bin/env perl
use strict;
sub main {
my $keep = {};
loop($keep);
}
sub loop {
@grncdr
grncdr / 00-Readme.md
Last active Oct 27, 2015
Delete unused assets
View 00-Readme.md

Delete unused assets

This is an example script for deleting assets that aren't linked in your content model. It does this by walking through all assets and checking for any links back to them.

WARNING: This script does not take into account assets that are only linked inside of Text fields. If you primarily embed images directly using the markdown editor, this will very likely delete assets you depend on.

You must fill in your own CMA access token & space ID at the top before running

Usage

@grncdr
grncdr / data.csv
Created Jun 17, 2015
Demo of importing a CSV file into a Contentful space
View data.csv
first name last name age
Stephen Sugden 31
Tom Reznik 29
Justin Thomas 30
You can’t perform that action at this time.