Skip to content

Instantly share code, notes, and snippets.

➜ hallucinations python3 analyze.py
1: {"temperature":{"value":75,"unit":"F"}}
1: {"temperature":{"value":75,"units":"F"}}
1: {"temperature":75,"unit":"F"}
1: {"temperature":75,"unit":"F"}
1: {"temperature":{"value":75,"units":"F"}}
1: {"temperature":75,"units":"F"}
1: {"current_temperature":{"value":75,"unit":"F"}}
1: {"Temperature":{"Fahrenheit":75}}
1: {"reading":"75F"}
List every song that the Grateful Dead covered from another band, and include the original band that performed it.
As a constantly evolving band with an extensive career, the Grateful Dead have covered numerous songs by other artists. Though it's challenging to provide a fully comprehensive list, here are some notable covers and their original artists:
"Morning Dew" - Bonnie Dobson
"Viola Lee Blues" - Cannon's Jug Stompers
"Cold Rain and Snow" - Obray Ramsey
"Turn On Your Love Light" - Bobby "Blue" Bland
"Death Don't Have No Mercy" - Reverend Gary Davis
"I Know You Rider" - Traditional (popularized by various folk artists)
diff --git a/Procfile b/Procfile
new file mode 100644
index 0000000..c2c566e
--- /dev/null
+++ b/Procfile
@@ -0,0 +1 @@
+web: bundle exec puma -C config/puma.rb
diff --git a/app/controllers/upload_controller.rb b/app/controllers/upload_controller.rb
new file mode 100644
index 0000000..2157acf
@derwiki
derwiki / python-mail-merge-pdf.py
Created December 23, 2020 00:31
From addresses.csv, print out a FROM and TO label on a sheet of paper
import csv
from fpdf import FPDF
pdf = FPDF()
MAJOR = 12
MINOR = 10
# download from Google Sheets as CSV to addresses.csv
with open('addresses.csv', newline='') as csvfile:
@derwiki
derwiki / dynamo_truncate_table.py
Created November 11, 2020 02:18
Function that uses batch_writer to efficiently(-ish) delete all of the entries in a DynamoDB table
import boto3
dynamo = boto3.resource('dynamodb')
def truncate_table(table_name):
table = dynamo.Table(table_name)
table_key_names = [key.get("AttributeName") for key in table.key_schema]
response = table.scan(ProjectionExpression=", ".join(table_key_names)
data = response.get('Items')
while 'LastEvaluatedKey' in response:
import urllib
import re
URLS = {
'10 Inbound Wisconsin & Madera': 'http://webservices.nextbus.com/service/publicXMLFeed?command=predictions&a=sf-muni&r=10&s=6966', # noqa E501
'48 Inbound Wisconsin & 25th': 'http://webservices.nextbus.com/service/publicXMLFeed?command=predictions&a=sf-muni&r=48&s=3513', # noqa E501
}
SECONDS_MINUTES_RE = re.compile('seconds="(\d+)" minutes="(\d+)"')
@derwiki
derwiki / threaded_post.rb
Last active June 17, 2018 02:36
Threaded Net::HTTP::Post service object
require 'net/http'
README = <<-EOS
posts = [
{
url: 'https://localhost:3000/',
body: '{"status": "OK", "id": 1}'
},
{
url: 'https://localhost:3000/',
@derwiki
derwiki / net_http_multithreaded.rb
Created June 16, 2018 15:27
Simple script showing effective multithreading with vanilla Ruby
# API endpoint that takes ~3.8s to respond
TARGET_URI = 'http://localhost:3000/delay'
SAMPLE_BODY = {}
def post_body!
Net::HTTP.post_form(TARGET_URI, SAMPLE_BODY).body
print ?.
end
1.upto(5).each do |concurrency|
@derwiki
derwiki / backup.sh
Last active September 29, 2019 00:25
Simple and efficient mirroring of two hard drives using `rsync`.
# These commands are to be run in different tmux panes to quickly copy the
# contents of one hard drive to another. `rsync` is used for it's robustness,
# interruptibility, and efficiency in incremental updates.
#
# After the initial clone, the same `rsync` command can be run to copy just the
# new/changed files from source to target.
# tmux pane 1
rsync --inplace --whole-file --partial --progress -a /Volumes/amsterdam/ /Volumes/stockholm/
@derwiki
derwiki / dtruss_python_example.py
Created February 12, 2018 04:58
Example of a decorator that inserts "logs" into `dtruss` output to better help correlate code to syscalls
"""
$ sudo dtruss -f -t open python main.py
18564/0xc29254: open("function-main-start\0", 0x1000000, 0x1B6) = -1 Err#2
18564/0xc29254: open("/anaconda3/lib/python3.6/__pycache__/random.cpython-36.pyc\0", 0x1000000, 0x1B6) = 3 0
18564/0xc29254: open("/anaconda3/lib/python3.6/lib-dynload/math.cpython-36m-darwin.so\0", 0x0, 0x0) = 3 0
18564/0xc29254: open("/anaconda3/lib/python3.6/__pycache__/hashlib.cpython-36.pyc\0", 0x1000000, 0x1B6) = 3 0
18564/0xc29254: open("/anaconda3/lib/python3.6/lib-dynload/_hashlib.cpython-36m-darwin.so\0", 0x0, 0x0) = 3 0
18564/0xc29254: open("/anaconda3/lib/libssl.1.0.0.dylib\0", 0x0, 0x0) = 3 0
18564/0xc29254: open("/anaconda3/lib/libcrypto.1.0.0.dylib\0", 0x0, 0x0) = 3 0