Skip to content

Instantly share code, notes, and snippets.

View birkin's full-sized avatar

Birkin James Diana birkin

View GitHub Profile
@birkin
birkin / chatgpt_and_grep.md
Created May 17, 2023 11:06
chatgpt helps with grep syntax.

Prompt

In unix, what's a grep/regular-expression command to search a directory for files containing a string like "b1234567", where the first character is a lowercase "b", followed by seven numerals?

Response

You can use the grep command with the -r (or --recursive) option to search a directory recursively. To find a pattern like "b1234567", where the first character is a lowercase "b", followed by seven numerals, you can use the regular expression b[0-9]{7}. Here's how to put it all together:

@birkin
birkin / rust_shared_reference_move.md
Last active May 17, 2023 11:07
explanation of rust shared-reference & move concepts.

Prompt

this Rust line works...

title = subfield.value.clone().unwrap_or_else(|| "".to_string());

...and this doesn't:

title = subfield.value.unwrap_or_else(|| "".to_string());

@birkin
birkin / chatgpt_math.md
Last active May 5, 2023 21:15
exploring chatgpt-4's math operations

ChatGPT-4 math...

fyi, the answer, via python...

>>> format( (65 * 845 * 78 * 150 * 987 * 5 * 654 * 78 * 522), "," )
'84,447,333,008,847,900,000'

@birkin
birkin / mysql_collation.md
Created May 4, 2023 12:47
asked chatgpt to compare two mysq unicodel collations.

background

For the stolen-relations project, we're doing some programmatic data-cleaning. I recently uploaded test sql to an empty database and examined the load in phpMyAdmin.

I noticed that the collation for the few updated tables had changed from the utf8mb4_unicode_520_ci encoding I've ensured all my sql tables use for the last few years. The updated tables are using the collation utf8mb4_0900_ai_ci.

So I asked chatGPT about the differences, and then did a few google searches to verify the info. Over time, I'll move collations to this utf8mb4_0900_ai_ci collation.


@birkin
birkin / timeline-js_question.md
Last active May 3, 2023 15:48
inserting a date into a set of static dates for timeline.js

Prompt...

i want to use timeline.js and pass it a date and have it display that date on a timeline with other static pre-populated dates.


Response...

To achieve this, you can use TimelineJS, an open-source tool developed by Knight Lab that allows you to build visually-rich, interactive timelines using a simple JSON or Google Sheets data source. In this example, I'll show you how to create a timeline using a JSON data source, including your static pre-populated dates and the date you want to pass.

@birkin
birkin / chatGPT_explains_describe_and_it.md
Created April 13, 2023 20:23
explains `describe` and `it` in context of javascript testing.

User:

i just saw this js code: "import { describe, it } from 'node:test'" -- can you explain how javascript/node uses "describe" and "it"?


ChatGPT:

This code snippet is related to testing in JavaScript, specifically using the Mocha testing framework. Mocha is a popular testing library for Node.js applications, and it provides a clean and easy way to organize and structure your tests.

@birkin
birkin / loss_function_and_optimizer_explanation.md
Created April 12, 2023 20:42
chatGPT explans loss-function and optimizer concepts, in context of neural-networks.

User: A pytorch tutorial contains this section:

"""

Step 7: Create a loss function and optimizer

Now we are going to set the loss function and optimizer. Here, we are using cross-entropy loss and adam optimizer. The performance of a classification model whose output is a probability value between 0 and 1 is measured by cross-entropy loss. Adam is a stochastic gradient descent technique that uses first and second-order moment estimation. Using exponential moving average, the approach determines the gradient’s first-order moment (the gradient mean) and second-order moment (element-wise squared gradient) and corrects its bias. Learning rate times first-order moment divided by the square root of second-order moment provides the final weight update.

@birkin
birkin / feature_freeze_explanation.md
Last active April 13, 2023 01:42
chatGPT explains a poorly-worded feature-freeze instruction in a neural-network tutorial.

User:

I'm going through a pytorch tutorial, and see this statement and code:

"""

In order to keep fix the update of the feature part of the network, we can code below:

for param in model.features.parameters():
@birkin
birkin / django_alto.md
Last active April 11, 2023 21:28
asks chatGPT for some django-alto advice.

Prompt

Goal...

  • I want a user to be able to perform a search on a word -- and see a list of PDFs that contain the search-word.
  • If the user clicks on one of the PDFs in the result-list, I want the PDF to display with the first search-word highlighted.

Context...

  • I'm using the Django web-framework.
  • I use views.py functions, not classes.
  • I have, stored in the solr-index, the PDF-filepath, the alto-xml (containing the PDF words and coordinates), and the full-text of the PDF.
@birkin
birkin / oit_data_inspected.txt
Last active March 20, 2023 13:01
Provides unique values of parts of the course-code in the OIT export for Leganto.
- Data from parsing the course-codes of 14,607 entries in the 2023-March-17 course export.
- Example course-code: "brown.biol.0080.2023-spring.s01"
- From that course-code, below are the --> unique <-- "institutions", "departments", (not numbers), "years", "terms", and "sections".
- The section 'EMPTY' wasn't in the OIT data, I put it there to show that there were sections-not-listed, and I provided a count. (111)
[17/Mar/2023 13:45:42] DEBUG [prepare_oit_summer_2023_subset-<module>()::109] OIT course entries count, ``14607``
[17/Mar/2023 13:45:42] DEBUG [prepare_oit_summer_2023_subset-<module>()::115] course_code_institutions, ``['brown']``
[17/Mar/2023 13:45:42] DEBUG [prepare_oit_summer_2023_subset-<module>()::116] course_code_departments, ``['afri',
'amst',
'anth',