Skip to content

Instantly share code, notes, and snippets.

View dconroy's full-sized avatar

David Conroy dconroy

View GitHub Profile
@dconroy
dconroy / kill-containers.sh
Created June 1, 2018 15:05
Stop running docker containers and remove them
#!/bin/bash
docker stop $(docker ps -aq)
docker rm $(docker ps -a -q)
@dconroy
dconroy / reset-docker.sh
Created June 1, 2018 15:06
Nuke Docker and start clean
#!/bin/bash
docker stop $(docker ps -aq)
docker rm $(docker ps -a -q)
docker rmi -f $(docker images -q)
@dconroy
dconroy / postgres_create_read_only_user.sql
Created September 6, 2018 07:22
Postgres Read Only User
CREATE ROLE readonlyaccess;
--access to existing tables
GRANT USAGE ON SCHEMA public TO readonlyaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonlyaccess;
--acess to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readonlyaccess;
--create new readonlyuser with readaccess privileges
CREATE USER readonlyuser WITH PASSWORD '******************';
GRANT readonlyaccess TO readonlyuser;
--take away create table privileges, except from superusers
@dconroy
dconroy / invalidate-cloudfront-cache.sh
Created October 13, 2018 22:39
invalidate cloudfront cache aws-clu
#!/bin/bash
# invalidate cache in cloudfront
# usage ./invalidate-cloudfront-cache.sh ASDA1243123112D
aws cloudfront create-invalidation \
--distribution-id $1 \
--paths "/*"
@dconroy
dconroy / lambda_function.py
Last active October 14, 2018 00:20
Invalidate Cloudfront from Code Pipeline With Lambda
from __future__ import print_function
from boto3.session import Session
import time
import json
import urllib
import boto3
import botocore
import traceback
print('Loading function')
dconroy@08f3e39c7104  ~/Desktop/tegula/examples   master ●  node test.js
/Users/dconroy/Desktop/tegula/node_modules/ipfs-block-service/src/index.js:64
this._repo.blocks.put(block, callback)
^
TypeError: Cannot read property 'put' of undefined
at BlockService.put (/Users/dconroy/Desktop/tegula/node_modules/ipfs-block-service/src/index.js:64:25)
at waterfall (/Users/dconroy/Desktop/tegula/node_modules/ipld/src/index.js:387:28)
at nextTask (/Users/dconroy/Desktop/tegula/node_modules/async/waterfall.js:16:14)
at next (/Users/dconroy/Desktop/tegula/node_modules/async/waterfall.js:23:9)
@dconroy
dconroy / crackle.py
Created February 27, 2019 09:46
CracklePop
for number in range(1,101):
output = str(number)
if number % 3 == 0:
output = 'Crackle'
if number % 5 == 0:
output = 'Pop'
if number % 3 == 0 and number % 5 == 0:
output = 'CracklePop'
print (output)
@dconroy
dconroy / keybase.md
Created April 16, 2019 01:54
keybase.md

Keybase proof

I hereby claim:

  • I am dconroy on github.
  • I am dconroy (https://keybase.io/dconroy) on keybase.
  • I have a public key ASDEjtLS6YGRin8_qJx4KFfw-iUO76slOP7JrXFA5SjQwgo

To claim this, I am signing this object:

@dconroy
dconroy / get-moderation-level.js
Last active September 24, 2019 03:05
rekognition script
var rekognition = new AWS.Rekognition({apiVersion: '2016-06-27'});
var params = {
Image: { /* required */
S3Object: {
Bucket: 'street-art-uploads',
Name: 'sam.png'
}
},
MinConfidence: '50'
@dconroy
dconroy / updateTags.js
Last active January 1, 2020 02:51
Query mongo collection for hashtags, update collection with tag field
var MongoClient = require('mongodb').MongoClient;
var url = "mongodb://localhost:27017/";
function queryArtwork() {
MongoClient.connect(url, function (err, db) {
if (err) throw err;
var dbo = db.db("streettagged");
dbo.collection("artworks").find({
isActive: true,
about: /#/ //find posts that have hashtags in the description