Skip to content

Instantly share code, notes, and snippets.

  • You are representing the author of the source. Respond as if you are the author, based on the ideas in the source.
  • Your answers should be confident and to the point - typically one paragraph (3-5 sentences), followed by a list (7-13 key points), and finally a verbatim quote from the source.
  • After answering, always make a suggestion for 3-5 things I might want to explore next. Present them as a numbered list, so that I can simply respond with a number to trigger the next topic.
@intellectronica
intellectronica / overcoming-bias-anthology-md.ipynb
Created December 14, 2024 21:42
overcoming-bias-anthology-md.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@intellectronica
intellectronica / redirect-to-archive-ph.js
Created October 25, 2024 13:20
Userscript (for running with your monkey extension of choice) to redirect paywalled site articles to their archive.ph copy
// ==UserScript==
// @name redirect-to-archive-ph
// @match *://*/*
// ==/UserScript==
(function() {
'use strict';
if (window.location.href.includes('archive.ph')) return;
from fasthtml.common import *
app, rt = fast_app()
@app.get("/showtime")
def showtime():
return Script("document.getElementById('time').innerText = (new Date()).toLocaleTimeString();" id='showtimescript')
@app.get("/")
def home():
@intellectronica
intellectronica / asyncai.py
Last active September 23, 2024 19:45
Running multiple LLM calls in parallel with asyncio
import asyncio
from openai import AsyncOpenAI
import random
oai = AsyncOpenAI()
numbers = [str(random.randint(0, 123456789)) for _ in range(7)]
async def explain_number(number):
print(f'START: Explain the number {number}') # DEBUG
german_text = "Sprachkenntnisse sind ein wichtiger Bestandteil der Kommunikation."
class TranslatedString(BaseModel):
input_language: str = Field(
...,
description="The language of the original text, as 2-letter language code."
)
translation: str
print("SCHEMA:")
@intellectronica
intellectronica / ug-to-mochi.py
Created July 29, 2024 08:56
Script for creating Mochi flashcards based on the Ultimate Geography card collection
import requests
import tempfile
import subprocess
import pandas as pd
import base64
from textwrap import dedent
from datetime import datetime
import random
import string
@intellectronica
intellectronica / aitz.py
Last active June 28, 2024 06:32
"Parsing" weird iCal timezones and converting them to standard timezones with GPT-3.5-turbo
# An iCal VTIMEZOME component looks like this:
#
# BEGIN:VTIMEZONE
# TZID:Romance Standard Time
# BEGIN:STANDARD
# DTSTART:16010101T030000
# TZOFFSETFROM:+0200
# TZOFFSETTO:+0100
# RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
# END:STANDARD

I bought everything at the $ store!

# fill auth token here. see https://github.com/nicolevanderhoeven/shortform-to-readwise#usage for how to get it
$authToken = '...'
$booksApiUrl = 'https://www.shortform.com/api/books/'
$bookSlug = $args[0]
$response = Invoke-WebRequest -Uri "$booksApiUrl$bookSlug" -Headers @{
"Authorization" = "Basic $authToken";
"X-Sf-Client" = "11.8.0";
}