Skip to content

Instantly share code, notes, and snippets.

View TheDarkTrumpet's full-sized avatar
💭
I may be slow to respond.

David Thole TheDarkTrumpet

💭
I may be slow to respond.
View GitHub Profile
@TheDarkTrumpet
TheDarkTrumpet / create_flashcards.py
Created January 2, 2024 18:03
A script/program that can take chapters of a book, run LangChain summarization against it, and create flashcards. Please see the linked web article (in comments) for details
"""
create_flashcards.py
This script is used to generate flashcards from a PDF file. It uses the LLM model to generate a list of
definitions and concepts from a PDF file. It then takes this list and generates a
JSON file that can be used to generate an Anki deck.
This script is a companion to the blog post: https://thedarktrumpet.com/programming/2024/01/02/generative-ai-flashcards/
This script relies on a .env file to provide the following variables:
type Status int
const (
InvalidLogin Status = iota + 1 // Remember: iota is just auto incrementing, starts at 0
NotFound
)
type StatusErr struct {
Status Status
Message string
@TheDarkTrumpet
TheDarkTrumpet / filestructure
Created September 3, 2019 17:29
ClusterImage File structure
/ClusterImage
/clusterimage/
/__init__.py
/models/
/__init__.py
/<Model representation objects>
/tests/
/models/
/<one per model representation object>
/__init__.py
@TheDarkTrumpet
TheDarkTrumpet / DetermineModifiedTypes.cs
Last active December 14, 2017 16:45
Naive example of pulling from a directory and receiving all files, then determining information from them and sending to output
string path = @"X:\Shared\OIT";
//Note: This is a very stupid way of doing this, but does work in our case.
string[] allFiles = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
// Good for Debugging, but we're writing a simple CSV
//Console.WriteLine("Total Number of Files: " + allFiles.Count());
//Start the header:
Console.WriteLine("Directory,FileName,CreationTime,LastModified");
@TheDarkTrumpet
TheDarkTrumpet / idp.testshib.org.xml
Created October 9, 2017 19:18
XML file for TestShib, reworked through OneLogin
<?xml version="1.0"?>
<md:EntityDescriptor xmlns:md="urn:oasis:names:tc:SAML:2.0:metadata" validUntil="2018-10-11T18:04:21Z" cacheDuration="PT604800S" entityID="https://idp.testshib.org/idp/shibboleth">
<md:SPSSODescriptor AuthnRequestsSigned="false" WantAssertionsSigned="true" protocolSupportEnumeration="urn:oasis:names:tc:SAML:2.0:protocol">
<md:KeyDescriptor use="signing">
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:X509Data>
<ds:X509Certificate>MIIDAzCCAeugAwIBAgIVAPX0G6LuoXnKS0Muei006mVSBXbvMA0GCSqGSIb3DQEBCwUAMBsxGTAX
BgNVBAMMEGlkcC50ZXN0c2hpYi5vcmcwHhcNMTYwODIzMjEyMDU0WhcNMzYwODIzMjEyMDU0WjAb
MRkwFwYDVQQDDBBpZHAudGVzdHNoaWIub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC
AQEAg9C4J2DiRTEhJAWzPt1S3ryhm3M2P3hPpwJwvt2q948vdTUxhhvNMuc3M3S4WNh6JYBs53R+
# StateProvinceCode CityPopulation CityName
# 1 IA 203433 Des Moines
# 2 IA 126326 Cedar Rapids
# 3 IA 99685 Davenport
# 4 IA 82684 Sioux City
# 5 IA 68406 Waterloo
# 6 IA 67862 Iowa City
# 7 IA 62230 Council Bluffs
# 8 IA 58965 Ames
# 9 IA 57637 Dubuque
@TheDarkTrumpet
TheDarkTrumpet / stringconcat.cs
Created September 7, 2016 18:54
string contatenation
StringBuilder foo = new StringBuilder();
foo.Append("Bar");
foo.Append(null); // <-- Doesn't work, object and string ambiguous
foo.Append(" car");
foo.Dump();
string foo2 = "bar";
Just a general note to everyone. I’ll post this also in #programming but tomorrow afternoon at the UI App Dev Community, I’m going to
talk about the meetups for Functional Programming and R. This is kinda how I think it’ll be setup.
[10:55]
I think there will be 2 separate meetups that will cover the same theme. For now, I’d like to keep both groups together. We had a lot
of support for combined groups, although a good number of people were interested in only R or FP (but not both).
[10:56]
One meetup will likely take place, at lunch, one time a week at the university. A large portion of the population are from the UI and
this time was very strongly requested. I think that particular meetup event will be an hour long, since it impacts people’s work day.
@TheDarkTrumpet
TheDarkTrumpet / displayfor.cs
Created March 23, 2015 20:02
Please use DisplayFor, especially on dates
///////// In model..... //////////////////
[DisplayName("Warranty Expiration Date")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)]
public DateTime? WarrantyExpiryDateTime { get; set; }
///////// In View..... /////////////////
@Html.EditorFor(model => model.WarrantyExpiryDateTime, new {maxlength = 10, @class = "datePicker"})
//////// In a view that iterates (iEnumberable) ////////////