Skip to content

Instantly share code, notes, and snippets.

View dnorton's full-sized avatar
🏠
Working from home

Daniel Norton dnorton

🏠
Working from home
View GitHub Profile
@dnorton
dnorton / chatgpt-lessons.md
Last active March 27, 2023 13:34
Things ChatGPT Taught Me

Here are some of the things that ChatGPT has taught me.

Use a Lambda to check network connectivity

I asked ChatGPT (GPT-4) for a simple way to test VPC network connectivity without creating an EC2 instance in AWS.
It proposed creating the following lambda function that I could then configure in any of my VPCs and subnets. It works great!

import socket
import json
@dnorton
dnorton / brew_list.md
Last active December 30, 2021 15:28
brew packages I always install on a new machine
  • awscli
  • python3
  • jq
  • gh
  • node
  • pipx
  • validate JSON
cat data.json |python -m json.tool
@dnorton
dnorton / alias_myaccount.sh
Last active March 15, 2019 14:54
Alias command to show my AWS account id
alias myaccount="curl -s http://169.254.169.254/latest/dynamic/instance-identity/document|python -c 'from __future__ import print_function;import json,sys; print(json.load(sys.stdin)[\"accountId\"])'"
@dnorton
dnorton / time_pace.py
Created February 16, 2018 15:03
python methods to parse a list of mile times in the format "MM:SS"
"""Script to add up minutes:seconds and give average pace"""
def sum_times(*times):
'''arg list of MM:SS'''
return sum(map(lambda x: int(x.split(':')[0]) * 60 + int(x.split(':')[1]), times)), len(times)
def secs_to_mins(seconds, count):
@dnorton
dnorton / tuple.groovy
Last active February 13, 2017 23:35
example of tuples in groovy
def a = new Tuple2(null, "string")
def b = new Tuple2("string", null)
def c = new Tuple2(null, "string")
assert a == c
assert a != b
m = [:]
m[b] = "value"
println m[b]
m[a] = "both"
def dedupe(original):
"""method to remove unnecessary ; and duplicate values"""
value_set = set(filter(bool, map(lambda it: it.strip(), original.split(';'))))
return '; '.join(list(value_set))

Keybase proof

I hereby claim:

  • I am dnorton on github.
  • I am dnorton (https://keybase.io/dnorton) on keybase.
  • I have a public key whose fingerprint is 8958 331A 3F85 4AB4 9C5D D51B 319E C116 936D CEF5

To claim this, I am signing this object:

@dnorton
dnorton / sum_times.py
Last active September 14, 2016 20:25
python script to calculate average pace
"""Script to add up minutes:seconds and give average pace"""
def sum_times(*times):
'''arg list of MM:SS'''
return sum(map(lambda x: int(x.split(':')[0]) * 60 + int(x.split(':')[1]), times)), len(times)
def secs_to_mins(seconds, count):
@dnorton
dnorton / debug.gradle
Created June 13, 2016 19:56
A couple small tasks for debugging gradle
//debugging task to check the configuration
task list(dependsOn: configurations.compile) << {
println "classpath = ${configurations.compile.collect {File file -> file.name}}"
}
//debug -- show all dependency files
task showDependencyFiles(dependsOn:configurations.compile) {
configurations.compile.collect {
println it
}