Skip to content

Instantly share code, notes, and snippets.

View lukestanley's full-sized avatar

Luke Stanley lukestanley

View GitHub Profile
@lukestanley
lukestanley / archive_done_linear_sync_tasks.py
Last active January 5, 2024 12:34
Archives done Linear Sync tasks via GraphQL API
# Set API_KEY!
import requests
headers = {
'Authorization': API_KEY,
'Content-Type': 'application/json'
}
# Search for issues that have been synced from LinearSync:
@lukestanley
lukestanley / text_fixer.user.js
Created October 18, 2023 12:04
Browser user script using OpenAI GPT-3.5-turbo on text boxes to suggest British English spelling, grammar text improvments
// ==UserScript==
// @name Fix spelling with GPT
// @namespace https://gist.github.com/lukestanley/937ffd4de748cdc00a5dd701bd6fbdfb
// @version 1.0
// @description User script for checking spelling and grammar with OpenAI API
// @match http://*/*
// @match https://*/*
// @run-at document-end
// @grant GM_xmlhttpRequest
// ==/UserScript==
@lukestanley
lukestanley / chatgpt_message_sync.user.js
Last active August 15, 2025 09:12
Browser Userscript Javascript to Stream ChatGPT messages to local server in real time
// ==UserScript==
// @name ChatGPT Message Sync
// @version 0.1
// @description Sync ChatGPT messages to own server.
// @include https://chat.openai.com/c/*
// @grant GM_xmlhttpRequest
// ==/UserScript==
(function() {
@lukestanley
lukestanley / termux_nextcloud_photo_mover.py
Created July 17, 2023 16:24
An Android Termux Python script to move local images and videos to a Nextcloud instance. It deletes the local files to save space. Made after frustration with Nextcloud Android app.
import os
from webdav3.client import Client
from tenacity import retry, stop_after_attempt, wait_fixed
import time
BATCH_SIZE = 100
uploaded_files = []
# get password from environment variable
[{"country":"Afghanistan","province":null,"timeline":{"cases":{"2/8/23":208771,"2/9/23":208771,"2/10/23":208943,"2/11/23":208971,"2/12/23":208982,"2/13/23":209011,"2/14/23":209036,"2/15/23":209056,"2/16/23":209072,"2/17/23":209083,"2/18/23":209084,"2/19/23":209107,"2/20/23":209153,"2/21/23":209181,"2/22/23":209181,"2/23/23":209215,"2/24/23":209230,"2/25/23":209246,"2/26/23":209274,"2/27/23":209308,"2/28/23":209322,"3/1/23":209340,"3/2/23":209358,"3/3/23":209362,"3/4/23":209369,"3/5/23":209390,"3/6/23":209406,"3/7/23":209436,"3/8/23":209451,"3/9/23":209451},"deaths":{"2/8/23":7896,"2/9/23":7896,"2/10/23":7896,"2/11/23":7896,"2/12/23":7896,"2/13/23":7896,"2/14/23":7896,"2/15/23":7896,"2/16/23":7896,"2/17/23":7896,"2/18/23":7896,"2/19/23":7896,"2/20/23":7896,"2/21/23":7896,"2/22/23":7896,"2/23/23":7896,"2/24/23":7896,"2/25/23":7896,"2/26/23":7896,"2/27/23":7896,"2/28/23":7896,"3/1/23":7896,"3/2/23":7896,"3/3/23":7896,"3/4/23":7896,"3/5/23":7896,"3/6/23":7896,"3/7/23":7896,"3/8/23":7896,"3/9/23":7896},"recovered"
@lukestanley
lukestanley / be_nice_with_langchain_decorators.py
Last active June 12, 2023 14:52
I rewrote my script to use a new langchain_decorators lib.
# pylint: disable=too-few-public-methods,unused-argument,line-too-long,no-name-in-module
from typing import List
import logging
from pydantic import BaseModel, Field
from langchain.chat_models import ChatAnthropic
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from langchain_decorators import llm_prompt, PromptTypes, GlobalSettings
@lukestanley
lukestanley / anthropic_fixing_langchain_decorators.txt
Created June 11, 2023 10:05
I used Anthropic to suggest code for fixing langchain-decorators. Here is the prompt. I didn't use all of it's suggestions but it had a working idea.
Human:
<file path=setup.py>
import setuptools
with open("src/langchain_decorators/__init__.py", "rt") as f:
for line in f.readlines():
if line.startswith("__version__"):
__version__ = line.split("=")[1].strip(" \n\"")
@lukestanley
lukestanley / be_nice.py
Last active August 21, 2025 08:38
LangChain spicy comment detox loop using Anthropic
import json
import time
from langchain.chat_models import ChatAnthropic
from langchain.schema import HumanMessage
FAST = "claude-instant-1"
GOOD = "claude-1.3"
model = GOOD
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lukestanley
lukestanley / alpaca.py
Created March 23, 2023 20:33
WIP Alpaca LangChain Python LLM Class with streaming
# Credit to https://github.com/nsarrazin/serge - this is heavily copied from the API there and not very well yet but it might work.w
from typing import List, Optional
from uuid import UUID, uuid4
from pydantic import BaseModel, Field
from datetime import datetime
import subprocess, os
import asyncio