Skip to content

Instantly share code, notes, and snippets.

View pkqk's full-sized avatar
📯
💨 🎶 🎵 🎶

Adam Sven Johnson pkqk

📯
💨 🎶 🎵 🎶
View GitHub Profile
@pkqk
pkqk / rm-r53.sh
Created September 17, 2024 22:08
delete Route53 Record
#!/bin/bash
hostedzoneid=${1?usage: $0 hostedzoneid rrtype}
rrtype=${2?usage: $0 hostedzoneid rrtype}
aws route53 list-resource-record-sets --hosted-zone-id "${hostedzoneid}" --query "ResourceRecordSets[?Type=='${rrtype}']" |
jq 'map({Changes: [{Action: "DELETE", ResourceRecordSet: .}]})[0]' |
aws route53 change-resource-record-sets --hosted-zone-id "${hostedzoneid}" --change-batch file:///dev/stdin
@pkqk
pkqk / funtions.sh
Last active July 17, 2024 22:07
AWS IMDSv2 function
function imds () {
local u="$1"
shift
curl -f -s -w "\n" -H "X-aws-ec2-metadata-token: $(curl -s -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 21600" "http://169.254.169.254/latest/api/token")" "http://169.254.169.254/${u}" "$@"
}
@pkqk
pkqk / create.sh
Last active January 28, 2022 01:49
Whale Tales 2022
url=https://www.whaletales2022.org/wp-json/wpgmza/v1/features/base64eJyrVkrLzClJLVKyUqqOUcpNLIjPTIlRsopRMo5R0gEJFGeUFni6FAPFomOBAsmlxSX5uW6ZqTkpELFapVoABaMWvA
curl -k "${url}" | jq '{type: "FeatureCollection", features:[.markers[]|select(.lat != "NA")|{type: "Feature",geometry: {type: "Point", coordinates: [(.lng|tonumber),(.lat|tonumber)]}, properties:{title:.title, link: "https://whaletales2022.org\(.link)"}}]}' > whaletales.geojson
@pkqk
pkqk / Dockerfile
Created April 11, 2018 09:19
timestamp/protobuf question
FROM golang:alpine
RUN apk add --no-cache git make protobuf
RUN go get github.com/golang/protobuf/protoc-gen-go
046986c34608f3fe1ef99a92471ddcf577674136d733e753cb88bdc02dbd2b9ab89fe90c08563c359b67c2e5d119d2072b07799b6d3bcc73a29d823c941c78c249
@pkqk
pkqk / check.sh
Last active October 28, 2015 14:53
urls=$(curl -s "http://manifoldgarden.tumblr.com/rss" | grep -o 'http://imgur.com/[^"&]\+' | uniq | sed -e 's/imgur/i.imgur/' -e 's/$/.png/')
for url in ${urls}
do
filename=$(basename $url)
if [ ! -e "${filename}" ]
then
curl -s -O "${url}"
fi
done
@pkqk
pkqk / .env
Last active October 26, 2015 15:44
dynamic rails config files
ODC_REDIS_SERVER_URL="redis://$(docker-service odc-redis 6379)"␍
@pkqk
pkqk / howto.md
Created October 1, 2015 16:21
how to search catalog.data.gov by facet

The ckan search interface exposes it's SOLR backend so most of those docs are useful.

I haven't managed to find a way to list facets but once you've guessed the name of one:

http://catalog.data.gov/api/3/action/package_search?facet.field=license_id&fq=license_id:other-license-specified

or if the value has spaces in it you can quote the search license_title:"Creative Commons Attribution":

http://catalog.data.gov/api/3/action/package_search?facet.field=license_title&fq=license_title:%22Creative%20Commons%20Attribution%22
@pkqk
pkqk / nodes-map.sh
Last active September 15, 2015 14:27
turn content api results into geojson
curl "http://contentapi.theodi.org/with_tag.json?type=node" |
jq '{
type: "FeatureCollection",
features: [
.results[] | {
type: "Feature",
geometry: {type: "Point", coordinates: [.details.location[1], .details.location[0]]},
properties: {name: .title}
}
]
@pkqk
pkqk / labs.bash
Created July 31, 2015 12:46
ODI labs
#!/bin/bash
image="$1"
output=${2:-test.png}
gravity=${3:-Center}
convert "${image}" -resize 500x200^ -gravity "${gravity}" -crop 500x200+0+0 "${output}"
composite odi-mask.png "${output}" "${output}"