Skip to content

Instantly share code, notes, and snippets.

@cpfiffer
cpfiffer / pdf-to-structure.py
Last active January 22, 2025 18:14
Get structured output from PDFs. Goes through a PDF one page at a time -- it is not currently build for multiple pages, but could be extended as needed.
"""
pip install outlines torch==2.4.0 transformers accelerate typing-extensions pillow pdf2image rich requests
may need to install tkinter: https://stackoverflow.com/questions/25905540/importerror-no-module-named-tkinter
sudo apt-get install poppler-utils
"""
from enum import Enum
from io import BytesIO
@hfrick
hfrick / quartochunk-replace.md
Last active May 8, 2025 22:18
A (system) prompt file for chores. Use with `chores::prompt_new("quartochunk", "replace", contents = "<this gist>")`

Transitioning to Quarto-style chunk headers

You are a terse assistant designed to help R package developers migrate their headers for R code chunks in R Markdown documents to the Quarto format. No further commentary.

Only ever change the chunk header, keep the text in between code chunks. The chunk header starts with three backticks and may continue over consecutive lines starting with #|.

If your input is only the header with the opening backticks, do not add closing backticks to your output.

One important difference between R Markdown documents and Quarto documents is that in Quarto chunk options are typically included in special comments at the top of code chunks rather than within the line that begins the chunk. Options are specified as key-value pairs in-chunk using YAML syntax. Values are no more R expression but valid YAML syntax.

# /etc/nginx/nginx.conf
worker_processes auto;
events {
worker_connections 768;
}
http {
# This controls the maximum allowed size of model input payloads
client_max_body_size 10M;
upstream plumber_api {
@jarmitage
jarmitage / tidal-multi-stream.hs
Created October 5, 2019 23:31
Multiple Tidal streams to multiple OSCTargets
-- https://tidalcycles.org/index.php/Custom_OSC
:set -XOverloadedStrings
:set prompt ""
:set prompt-cont ""
import Sound.Tidal.Context
superDirt <- startTidal (superdirtTarget {oLatency = 0.1, oAddress = "127.0.0.1", oPort = 57120}) (defaultConfig {cFrameTimespan = 1/20})
@anjesh
anjesh / mturk-api.php
Last active August 9, 2022 00:01
Mturk working code for `GetAccountBalance` with signature generation
<?php
# adapted from http://usefulangle.com/post/34/aws-s3-upload-api-php-curl and works with Mturk
$headerBlacklist = [
'cache-control' => true,
'content-type' => true,
'content-length' => true,
'expect' => true,
'max-forwards' => true,
'pragma' => true,
@John-Paul-R
John-Paul-R / FabricModList.md
Last active May 22, 2025 09:19
A list of (almost all) mods for Fabric

Fabric Mod List

This page contains a list of the current Minecraft Fabric mods. (As of 2021-08-19 08:05:23 Timezone: UTC+0000 (GMT))

To search for mods by name, category, or download count, visit the website, fibermc.com!

Note: You can view a mod's source files by following the "Source" link on its CurseForge page, assuming that the mod's creator has made such files public.

There are currently 2954 mods in this list.

@soofaloofa
soofaloofa / Collection+JSON
Last active February 14, 2025 23:23 — forked from soofaloofa-zz/ On choosing a hypermedia type
On choosing a hypermedia type for your API - HAL, JSON-LD, Collection+JSON, SIREN, Oh My!
GET https://api.example.com/player/1234567890
{
"collection": {
"version": "1.0",
"href": "https://api.example.com/player",
"items": [
{
"href": "https://api.example.com/player/1234567890",
"data": [
{"name": "playerId", "value": "1234567890", "prompt": "Identifier"},
@padpadpadpad
padpadpadpad / TeamParallel.R
Last active October 16, 2020 07:49
Example of parallelising R code using furrr and multidplyr
# load packages
library(multidplyr)
library(dplyr)
library(tidyr)
library(purrr)
library(furrr)
library(tibble)
library(tictoc)
# I want to know which gene a bunch of SNPs is in. This will show us how to give different inputs to a function and also parallelising. Hopefully.
@SohierDane
SohierDane / parse_mortality_data.py
Created August 3, 2017 18:47
CDC Mortality Dataset Preparation 2005-2015
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
For each year, parse the pdf manual, then use that information to
unpack the fixed-width data file.
Source data files can be found here:
https://www.cdc.gov/nchs/data_access/vitalstatsonline.htm#Mortality_Multiple
Passes basic tests for 2005-2015. Untested on earlier years.
@attacus
attacus / riot-matrix-workshop.md
Last active April 8, 2025 08:18
Create your own encrypted chat server with Riot and Matrix

This guide is unmaintained and was created for a specific workshop in 2017. It remains as a legacy reference. Use at your own risk.

Running your own encrypted chat service with Matrix and Riot

Workshop Instructor:

This workshop is distributed under a CC BY-SA 4.0 license.

What are we doing here?