Export Apple Notes to XML

This AppleScript (written by Claude) will export ALL of your Apple Notes to a file on your desktop.

-- Export all Apple Notes to a single XML file.
-- Output: ~/Desktop/AppleNotes.xml  (change OUTPUT_PATH below if you want)
-- Run from Script Editor (Run button) or Terminal:
--    osascript ~/path/to/export-notes-to-xml.applescript
-- First run: macOS will prompt to allow automation access to Notes.

property OUTPUT_PATH : (POSIX path of (path to desktop folder)) & "AppleNotes.xml"

on replaceText(theText, oldStr, newStr)
	set saveTID to AppleScript's text item delimiters
	set AppleScript's text item delimiters to oldStr
	set theItems to text items of theText
	set AppleScript's text item delimiters to newStr
	set theText to theItems as text
	set AppleScript's text item delimiters to saveTID
	return theText
end replaceText

on escapeAttr(s)
	try
		set s to s as text
	on error
		set s to ""
	end try
	set s to my replaceText(s, "&", "&")
	set s to my replaceText(s, "<", "&lt;")
	set s to my replaceText(s, ">", "&gt;")
	set s to my replaceText(s, "\"", "&quot;")
	set s to my replaceText(s, (ASCII character 13), " ")
	set s to my replaceText(s, (ASCII character 10), " ")
	return s
end escapeAttr

on escapeCData(s)
	try
		set s to s as text
	on error
		set s to ""
	end try
	-- Guard against ]]> sequences inside the body breaking the CDATA section.
	return my replaceText(s, "]]>", "]]]]><![CDATA[>")
end escapeCData

on writeLine(fileRef, theText)
	write (theText & linefeed) to fileRef as «class utf8»
end writeLine

on run
	set fileRef to open for access POSIX file OUTPUT_PATH with write permission
	set eof of fileRef to 0
	my writeLine(fileRef, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
	my writeLine(fileRef, "<notes exported=\"" & ((current date) as string) & "\">")

	set noteCount to 0
	tell application "Notes"
		set allNotes to every note
		repeat with n in allNotes
			set noteCount to noteCount + 1
			try
				set noteName to name of n
			on error
				set noteName to ""
			end try
			try
				set noteBody to body of n
			on error
				set noteBody to ""
			end try
			try
				set noteId to id of n
			on error
				set noteId to ""
			end try
			try
				set noteCreated to (creation date of n) as string
			on error
				set noteCreated to ""
			end try
			try
				set noteModified to (modification date of n) as string
			on error
				set noteModified to ""
			end try
			try
				set noteFolder to name of container of n
			on error
				set noteFolder to ""
			end try
			try
				set noteAccount to name of account of n
			on error
				set noteAccount to ""
			end try

			set openTag to "  <note id=\"" & my escapeAttr(noteId) ¬
				& "\" name=\"" & my escapeAttr(noteName) ¬
				& "\" folder=\"" & my escapeAttr(noteFolder) ¬
				& "\" account=\"" & my escapeAttr(noteAccount) ¬
				& "\" created=\"" & my escapeAttr(noteCreated) ¬
				& "\" modified=\"" & my escapeAttr(noteModified) & "\">"
			my writeLine(fileRef, openTag)
			my writeLine(fileRef, "    <body><![CDATA[" & my escapeCData(noteBody) & "]]></body>")
			my writeLine(fileRef, "  </note>")
		end repeat
	end tell

	my writeLine(fileRef, "</notes>")
	close access fileRef
	return "Exported " & noteCount & " notes to " & OUTPUT_PATH
end run
When LLM Batch Processing is Faster than Synchronous

When LLM Batch Processing is Faster than Synchronous

A project I am working on for JM Addington Technology Solutions and CyberSecureRIA involves summarizing > 500,000 emails and documents with an LLM. That’s a lot!

There will be ongoing work, but the first 500,000 are a bulk process. To save money, I used OpenAI’s batch processing1. The batch endpoint costs exactly 50% of the normal model price and promise a 24-hour turnaround, but I found that in reality, it’s MUCH faster than that.

First, I’ll note that there are only 1440 minutes in the day, to process 500k entries in one day would be about 350 requests per second. That’s not happening on most hardware, and it’s definitely not happening with Python. But 1 request per minute with 350 entries is easy-peasy.

So lesson one: raw number of entries can make batch processing faster than synchronous processing.

Second, the 24 hour SLA is worst case scenario. In actual usage, the time it takes to turn around a batch seems primarily be related to the batch’s size, smaller batches get processed faster. This intuitively makes sense as I assume the batch API is available in part to allow OpenAI to make use of otherwise dead computational time. So the batch requests are getting fit in between other requests.

As I write this at 20:00 Eastern, batch jobs with 100 items each are completing in 3-4 minutes.

Lesson 2: small batches get processed faster. Much faster.

Finally, I had some large-ish batch jobs running on Thanksgiving. Those were also completing noticeably faster than they had the day before.

Lesson 3: holidays are faster for batch jobs.

At half off, I can easily wait an extra 3-4 minutes for what is essentially background processing, and will play with even smaller batches in the future.

  1. I used Azure OpenAI initially, but they don’t support batch processing on all models. Maddeningly. ↩︎
Home Schooling Parents: We’re Not All The Same

Home Schooling Parents: We’re Not All The Same

This post began as a read comment to the NY Times Op-Ed, Home-Schooled Kids Are Not Alright (gift link)

In recent years there has been an increasing amount of scrutiny on home school families, and more specifically, their parents. The New York Times has been at the forefront of much of this. I have a dog in this fight, I am a home school parent, and there are is a crucial component that most commentators don’t seem to understand.

There are, broadly, two distinct groups of parents that choose to home-school1. The first is primarily motivated to give their child a better or more personalized education at home than what the child would otherwise get in a public school. Not a high bar in many places. COVID injected new families into this group. Pulling out of larger community is usually considered unfortunate in this group, and not a motivating factor.

The second group is primarily motivated by ideology. There is not a single ideology, but common strands include conservatism, distrust of government, the more conservative bent of evangelical Christianity and hints of libertarianism. An explicit goal is often to retreat into smaller communities of like-minded people.

The groups coexist together because they have to, the home school movement grew more out of the second set of motivation, so more available resources (curriculum, coops, sports leagues, private school support) are overtly religious, and there is per-existing support structures through evangelicalism, yet, they remain distinct groups.

The opinions I’ve read on reforms consistently come from people who were home-schooled by parents in the second group, or come from research based on it. Reforms must take these separate groups into consideration to be effective. First, because they operate differently, second, because the latter group is often dead set against any government intrusion into their lives, which will make large reforms difficult.

My family lives in Tennessee, but my wife and I grew up in Minnesota, and both received fantastic public-school education and are believers in a well-run public school system. (In fact, both us us entered college with a year plus of college credit we earned during high school.)

15 years ago when we moved to Tennessee and were expecting our firstborn we decided that home-schooling was going to be for us. Private school was financially out of reach, and the public schools locally don’t measure up to what we grew up with.

Today, we home school a mix of special needs kids and highly-gifted kids. There is a zero percent chance that the local schools could effectively teach to either end of this spectrum. On the other hand: my wife, Katie, was a public school teacher who spent time with special needs students in Minnesota before our move.

Candidly: I don’t want reforms that would infringe on our ability to give our kids a better education at home than they get can in a public school. I am beyond uncomfortable with the attempted injection of values2 and politics into public schooling.

As former foster care parents, we’re also well aware of — yes — the drugs, sex and violence in many public schools.3

To flip the arguments for reform on their head: what parent wants their kid in that environment?

What Are Effective Reforms

Effective reforms will make it easier to home school by providing resources (sports, co-ops, curriculum, access to test prep) instead of putting up obstacles. If one of the primary critiques of home schools is that they take kids out of the public eye, an easy and light-handed approach remedy is simply to make it easier to keep kids in larger community.

Reforms must take into account the different motivations for home schooling, and they also must take into account that many of the motivations in both groups have legitimate foundations.

Finally, we need research and not anecdotes on home schoolers vs non-home schoolers. If you read only the anecdotes and comments on home schooling you’d think that there is only abuse, because op-eds about normal, successful, home schooling just won’t run. (Headline: I Was Homeschooled And There Was Nothing Special About It).

There is very little research on home schooling outcomes conducted by people without a vested interest. Too many of the pro-home school studies appear to be weak, depending on self-reporting and/or ignoring confounding factors.

  1. This is recognized in academic literature, however, as pragmatic vs religious. ↩︎
  2. For example, this public advocacy document for student transgender rights cites family involvement in transition to be limited to were “appropriate.” The same document says that age should never “justify delaying or denying a
    student’s gender transition.” This document endorsed by the NEA and ACLU is exactly why proponents on the right accuse the left of indoctrinating pre-pubscent kids with secular views on gender identity. ↩︎
  3. Tennessee ranks 10th highest out of the 50 states for teen births and that’s after teen pregnancy dropped precipitously. ↩︎

From a 2022 survey of Knox County high schoolers:

  • 3% carried a gun in the last 12 months (a passing score)
  • 5% were threatened on school property by someone with a weapon
  • 9% reported they attempted suicide during the past 12 months
  • 3.6% smoked and 20% vaped
  • 19% drank and 9% binge drank
  • 15% used weed

What’s important to understand is that Nvidia now has more financial firepower than even deep-pocketed tech giants like Google. Analysts expect Google’s free cash flow this year to fall 11% to $65 billion, while they expect Nvidia’s free cash flow to rise 59% to about $97 billion. This is, ironically, because Google, Amazon, Microsoft and Meta are all investing massive sums of money in AI—much of which is going to Nvidia. So Google and other big tech firms are sending money to Nvidia, which can use that money to stop its customers from defecting to Google! Brilliant. It’s one reason why Nvidia shareholders can rest assured the company likely won’t lose much market share anytime soon.

-The Briefing By Martin Peers

Posts in This Category