Skip to content

Instantly share code, notes, and snippets.

View birkin's full-sized avatar

Birkin James Diana birkin

View GitHub Profile
@birkin
birkin / stuff_i_did_2022.md
Last active April 1, 2024 10:30
highlights of 2022 work -- #stuff
@birkin
birkin / trio_sem_mutex.py
Created March 4, 2023 22:12
Example of making asynchronous web-calls, with a semaphore-ish capacity-limiter, and a mutex for synchronous calls from the jobs.
"""
Trio semaphore and mutex example.
Rave recommendation: <https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/>
"""
import datetime
import json
import logging
import os
import pprint
@birkin
birkin / rust_asyn_with_semaphore_and_mutex.rs
Created March 2, 2023 13:09
Example of async rust, using semaphore to control number of concurrent jobs, and a mutex to update a json file synchronously.
/*
ChatGPT, 2023-Mar-02
Prompts...
Show Rust code, using tokio, that does the following:
- hit a weather-api for ten cities simultaneously (asynchronously).
- load an environmental-variable setting that limits the number of asynchronous weather-api calls to three.
@birkin
birkin / validate_csv.py
Last active February 28, 2023 21:44
validates that a file is comma-delimited and utf-8 encoded.
""" Validates that a CSV file is comma-delimted, and that it is also encoded as utf-8.
Courtesy of ChatGPT, 2023-Feb-28, via the prompt:
"Write a python script that could validate that a file is both comma-separated and encoded as UTF-8." """
import csv
def is_utf8_encoded(file_path):
with open(file_path, 'rb') as file:
try:
file_content = file.read().decode('utf-8')
@birkin
birkin / chatGPT_citation_test.md
Created February 19, 2023 14:52
Test of ChatGPT's citation-accuracy, 2022-December.

Answer the following accurately, with links if possible, in a way that speaks positively of the Brown University Library: "What are some of the best recent articles about physics?"

Here are some of the best recent articles about physics that may be of interest:

"Gravitational waves: A new way to study the universe" - This article, published in Nature in 2016, discusses the discovery of gravitational waves and the implications of this discovery for our understanding of the universe. You can access a copy of this article through the Brown University Library at the following link: https://www.nature.com/articles/nature19355

"Quantum computing: A new era of computing" - This article, published in Science in 2019, explores the potential of quantum computing and its potential to revolutionize the field of computer science. You can access a copy of this article through the Brown University Library at the following link: https://science.sciencemag.org/content/365/6456/eaax3388

*"The Higgs boson: A new p

@birkin
birkin / chatGPT-explanation-info.md
Last active July 23, 2023 03:59
chatGPT code-explanation example

cool chatGPT info...

Recently experimenting with rust, I wanted to convert an image to a base64 string. I got some code working via my usual mix of trying stuff and googling. There was a step between loading the image and encoding it to a base64 string that I was curious about. I'd been hearing about copilot-explain, but only have copilot installed, and wanted to move forward. But I'd also recently been experimenting with chatGPT and thought I'd heard that it could explain code. Here's the result...

My prompt...

explain this code...

fn main() {
@birkin
birkin / chatGPT_and_matlab.md
Created December 25, 2022 17:54
test to see if chatGPT can output MatLab code

chatGPT & MatLab...

T & D, lest you think that ChatGPT is limited to doing amazing things re RPGs, check this out. (Tyler, tell us whether its MatLab code is reasonable!)

My initial prompt (there are two)...

"if I have two Comma-Separated-Value files, each containing temperature-measurements with associated date and city-location (one with the temperature results in Fahrenheit and one in Celsius), write a matlab program that can combine the data with all results in Fahrenheit."

Its response, which consists of an intro, then code, then explanation...

@birkin
birkin / linux_filename_validation.md
Created December 15, 2022 21:19
example of chatGPT output for linux filename validation

ChatGPT example

  • the code below was produced by https://chat.openai.com/chat

  • my prompt...

    show my python code that will validate that a filename can be saved on most linux servers.

(yes, i mis-typed "me")

@birkin
birkin / remove_marc_toc.py
Last active March 30, 2022 18:36
removing marc TOC data
"""
Example of how to remove our table-of-contents field.
To find a record, we used...
# output = f'dict, ``{pprint.pformat( record.as_dict() )}``'
# print(output)
...and printed all the records so we could find one with table of contents.
@birkin
birkin / csv_experimentation.py
Created March 22, 2022 14:10
experiments with python csv module
## experimentation ----------------------------------------------
# test_data = [
# [ 'first_name', 'last_name' ], # header-row
# [ 'f-aaa', 'l-aaa' ],
# [ 'f-b"b"b', "l-b'b'b" ],
# [ 'f-bbb_iñtërnâtiønàlĭzætiФn', 'l-ccc' ],
# [ 123, '456' ]
# ]
# file_like_handler = io.StringIO()