Skip to content

Instantly share code, notes, and snippets.

@PARC6502
PARC6502 / cardcutter.py
Created June 15, 2023 13:11
Cuts cards out of a pdf page
from PyPDF2 import PdfWriter, PdfReader
from pdf2image import convert_from_bytes
from copy import deepcopy
import io
num = 1
reader = PdfReader("cards_no-borders.pdf")
for iter_page in reader.pages:
for x in range(3):
for y in range(3):
@PARC6502
PARC6502 / Shorten_PowerShell_Prompt.md
Last active June 17, 2022 13:16
Shorten the path in the PowerShell prompt if it's too long

An adjustment to the PowerShell prompt function that limits the number of path components. In this case the limit is 4 components.

If there are more than four components the components between the first one and the last three are replaced with "...".

It is similar to what the PROMPT_DIRTRIM environment variable.

@PARC6502
PARC6502 / midi-sonic-tempo.rb
Created January 26, 2021 16:27
A midi to Sonic Pi script that can handle tempo changes
#! /usr/bin/env ruby
require 'midilib/sequence'
DEFAULT_MIDI_TEST_FILE = 'Tempo_Changes_test.mid'
# Read from MIDI file
seq = MIDI::Sequence.new()
# Either open the file provided by the first argument or the one defined above
File.open(ARGV[0] || DEFAULT_MIDI_TEST_FILE, 'rb') do |file|
@PARC6502
PARC6502 / midi-sonic.rb
Last active April 6, 2024 20:27
Converts a midi file into a file Sonic Pi can play
#! /usr/bin/env ruby
require 'midilib/sequence'
DEFAULT_MIDI_TEST_FILE = 'Lullaby_-_Brahms.mid'
# Read from MIDI file
seq = MIDI::Sequence.new()
# Either open the file provided by the first argument or the one defined above
File.open(ARGV[0] || DEFAULT_MIDI_TEST_FILE, 'rb') do |file|
@PARC6502
PARC6502 / allow-ads.conf
Created May 28, 2019 22:38
Dns mask dhcp configuration that sets a different DNS server for a single device
# In this example:
# The device to be unblocked has the MAC address MM:MM:MM:SS:SS:SS, and is given the IP 192.168.0.9
# The IP address of the server with dnsmasq is 192.168.0.2
# Unblocked device(s)
dhcp-host=MM:MM:MM:SS:SS:SS,192.168.0.9,48h,set:noblock
dhcp-option=noblock,option:dns-server,1.1.1.1,1.0.0.1
dhcp-option=noblock,option:router,192.168.0.1

Collision detection

  • Space partitioning: binary, quad tree
  • Sweep and prune

Response to collision

@PARC6502
PARC6502 / financeSummary.gs
Created March 27, 2019 17:21
Generate a summary of finances from several different google sheets
/**
* A special function that runs when the spreadsheet is open, used to add a
* custom menu to the spreadsheet.
*/
function onOpen() {
var spreadsheet = SpreadsheetApp.getActive()
var menuItems = [
{ name: "Update Summaries...", functionName: "updateSummaries_" }
]
spreadsheet.addMenu("Finance", menuItems)
@PARC6502
PARC6502 / OpenSourceBaas.md
Last active May 24, 2024 18:44
List of open source, self hosted BaaS - Backend as a service

Backend as a Service

Supabase - ~52K stars

  • Designed explicitly as an open source firebase alternative
  • Typescript based
  • Docker support

Appwrite - ~32K stars

  • Written in JavaScript and PHP
  • Docker based
  • Realtime support across all services
@PARC6502
PARC6502 / 0_README.md
Last active April 28, 2024 01:26
OpenSimplex Noise for openprocessing
@PARC6502
PARC6502 / FlatLoopVsTripleLoop.js
Created March 5, 2019 16:19
Performance testing
/* CONCLUSION */
// Surprisingly, for me, the triple loop performed better than the flat loop
/* INITIALISATION */
let xseed = random(10);
let yseed = random(10);
let zseed = random(10);
let step = 50;
let noiseVariance = 0.02;
let sideLength = 200;