Skip to content

Instantly share code, notes, and snippets.

View birkin's full-sized avatar

Birkin James Diana birkin

View GitHub Profile
@birkin
birkin / source_of_truth.md
Last active August 21, 2023 15:47
data source-of-truth thoughts...

Source of Truth

Just read a great post from long-time code4libber Jonathan Rochkind, [OCFL and “source of truth” — two options][truth].

To give a nutshell summary, it's first useful to be aware of a common web-development pattern, where the 'data' returned by a browser-request comes from an index. That index is an intermediary between the actual source data/file/image, and the webpage a user loads.

Think of the ["Inscriptions of Israel and Palestine" project][IIP] or the ["U.S. Epigraphy" project][USEP]. In both cases, the source-truth of the scholarly data is in xml-files ([example][usep-example]). Knowedgeable trained folk encode data from headstones or other sources into these xml-files.

But when a user performs a search, or loads an inscription-page from the website, the server looks up info from our [solr][solr] indexer.

Static Site Security

Main points...

Non-static websites have a web-server which often receives user-input and then queries other server-tools: databases, search-indexes, queues. The act of user-input triggering reads and writes to server-tools creates vectors for serious vulnerabilities.

Static-sites still (usually) have a web-server -- but because all the web-server does is directly serve out simple files -- whole categories of serious vulnerabilities are eliminated.

But security-vulnerabilities can still exit in static-sites.

prompt...

i know of someone who says the character Rupert Birkin, in the novel "Women in Love" is a misogynist, and another who says the character is admirable. please explain.

response...

Rupert Birkin, a central character in D.H. Lawrence's novel "Women in Love," is complex and has been interpreted in various ways by readers and scholars alike. The novel, which was first published in 1920, is known for its exploration of relationships, social change, and the human psyche. Here are some reasons why opinions about Rupert Birkin may differ:

  1. Depiction of Women and Relationships: Some readers might consider Birkin a misogynist due to his views and behavior towards women. In the novel, Birkin often expresses a desire for a deeper, almost spiritual connection with women, but at times, he appears dismissive of or superior to them. His relationships are fraught with power struggles, and he has a tendency to intellectualize emotions. This has led some readers to view him as unsympathetic towards the e

As of my last knowledge update in September 2021, TensorFlow doesn't have a direct function to perform one-hot encoding on a list of keywords inside a DataFrame. However, you can utilize pandas to preprocess your data before feeding it into a TensorFlow model. Here's a general approach using pandas and sklearn to achieve one-hot encoding for a category of keywords in a DataFrame:

import pandas as pd
from sklearn.preprocessing import MultiLabelBinarizer

# Sample DataFrame
data = {'keywords': [['keyword_a', 'keyword_c'], ['keyword_c', 'keyword_d']]}
df = pd.DataFrame(data)
@birkin
birkin / ezproxy_overview.md
Created June 12, 2023 17:54
EZproxy overview

prompt

give a brief overview of ezproxy

response

As of my last knowledge update in September 2021, EZproxy is a widely-used web proxy server software that facilitates remote access to electronic content, such as e-journals, e-books, and databases. It is particularly popular among libraries, as it enables library patrons to access licensed content remotely, using their library credentials, without the need for VPNs or other more cumbersome remote access solutions.

EZproxy works by rewriting the URLs of the requested resources so that they pass through the proxy server, which is usually hosted by the institution’s library. When a user tries to access a resource, EZproxy checks whether the user is authenticated and authorized to access the content. If the user is authorized, the proxy server connects to the content provider on behalf of the user and delivers the content to the user’s browser.

@birkin
birkin / ok_to_buy_non_tesla_EVs_again.md
Last active June 12, 2023 02:55
recent email to some friends, sparked by GM's recent announcement that it'll adopt the NACS fast-charger plug.

Go Forth and Purchase a non-Tesla EV!

2023-June-11

Hi all,

With the announcement by General Motors this past Thursday that it will adopt the North American Charging Standard (NACS) fast-charger -- giving it access to Tesla's fast-chargers -- I can officially once again whole-heartedly evangelize non-Tesla EVs! (From Ford & GM; Ford announced the same two weeks ago.)

Some of you may remember that a few months ago I had said that I was terribly disappointed that I could no longer freely recommend buying a non-Tesla EV if...

@birkin
birkin / get_solr.py
Created June 2, 2023 19:41
python to solr
Sure, I can give you a Python function to achieve that. However, please note that this function is a simple demonstration and you may need to modify it according to your actual use case. For example, error handling, exception handling, and managing API rate limiting are not included in the following example.
Let's assume the URL you are using is `http://solr-url/api`, and there is a query parameter, let's say `start`, which you can use to specify the starting point for each batch of items. Also, let's assume that the Solr API returns JSON with a field `items` that contains the items you're interested in.
```python
import requests
import time
def get_all_solr_items(base_url, batch_size=500):
all_items = []
@birkin
birkin / questions.md
Last active May 19, 2023 02:35
health jeopardy-style questions from chatgpt-4.

list 10 questions (for 7th-graders) in jeopardy-format about "food-labels & food-storage" -- and provide answers.

Sure, here are ten Jeopardy-style questions (answers first, questions second) about food labels and food storage suitable for a 7th-grade level of understanding:

  1. Answer: The Nutrition Facts Label

    Question: This section of a food package provides information about the calories and nutrients in the product.

@birkin
birkin / python_set_date.md
Created May 17, 2023 19:00
setting a file's creation-&-modification date via python.

Prompt

using python, how would I change a file creation-date for a pdf?


Response

Modifying a file's creation time isn't a standard operation because it's not a common need and it can potentially cause issues. However, it is possible to do this using the Python os and datetime modules, specifically using the os.utime function.