Skip to content

Instantly share code, notes, and snippets.

@pdvcs
pdvcs / gvim.sh
Created May 18, 2025 12:08
MacVim launcher
#!/usr/bin/env sh
GVIM="/Applications/MacVim.app/Contents/MacOS/Vim"
if [[ -z "$1" ]]; then
if pgrep -fl Vim > /dev/null 2>&1 ; then
# bring MacVim window to front
osascript -e 'tell application "MacVim"' -e "activate" -e "end tell"
else
# launch new instance
@pdvcs
pdvcs / create-qr-code.py
Last active May 17, 2025 16:06
Create QR Code
import sys
import qrcode # uv add "qrcode[pil]"
def main(input_file, output_file):
with open(input_file, "r") as file:
data = file.read()
img = qrcode.make(data)
img.save(output_file)
print(f"QR code saved to {output_file}")
@pdvcs
pdvcs / main.go
Created November 15, 2024 13:00
Go Queue
package main
import (
"fmt"
)
// Queue represents a simple FIFO queue
type Queue struct {
items []int
size int
@pdvcs
pdvcs / piglatin.rkt
Created July 22, 2024 02:31
Piglatin in Racket
#lang racket
;; piglatin.rkt
;; generate piglatin for a given string using rules from
;; http://www.snowcrest.net/donnelly/piglatin.html
(define (split-on-space str)
(string-split str " "))
(define (is-vowel ch)
@pdvcs
pdvcs / setup-neofetch.sh
Created March 28, 2024 21:56
Download and set up neofetch
#!/usr/bin/env bash
set -e
echo "Determining the latest version..."
LATEST_TAG=$(curl -sf 'https://api.github.com/repos/dylanaraps/neofetch/tags' | jq -r '.[0].name')
echo "Downloading neofetch..."
curl -sfL -o neofetch.tar.gz "https://github.com/dylanaraps/neofetch/archive/refs/tags/${LATEST_TAG}.tar.gz"
mkdir ./tmp
tar -C ./tmp -xf neofetch.tar.gz --strip-components=1
@pdvcs
pdvcs / .bashrc
Last active March 25, 2024 00:00
arch .bashrc
# ~/.bashrc for arch
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
alias ls='ls --color=auto'
alias ll='ls -l'
alias lh='ls -lrth'
alias me=micro
alias ppath="echo $PATH | tr ':' '\n'"
@pdvcs
pdvcs / employee.csv
Last active September 4, 2023 21:47
Write CSV to Postgres using COPY FROM
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 6 columns, instead of 7 in line 1.
1,^Alice Adams^,32,^3200 Sierra Drive, Bayport NY 10976^,125000
2,^Bob Bayliss^,23,^1900 Madison Ave, Apt 20, Bridgeport NY 10980^,83000
3,^Cayla Cass^,28,^1900 Brooke St, Apt 23, Bridgeport NY 10880^,120000
4,^Dan Drummond^,42,^102 Ellis St, Lynnford NY 10320^,205000
5,^Elaine Emms^,34,^112 Spring St, Hamford NY 10200^,130000
6,^Fifi Fenriss^,21,^^,90000
7,^Gaile Gantrieg^,29,^1900 Brooke St, Apt 23, Fremont CA 94537^,124000
8,^Harry Hall^,35,^^,85000
9,^Ian Isher^,26,^304 Malibu^^West Cross St, Dublin CA 94568^,89000
@pdvcs
pdvcs / ppath.c
Last active March 19, 2023 15:36
Pretty-print the system PATH
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define PATH_ENV_VAR "PATH"
#ifdef _WIN32
#define PATH_SEPARATOR ";"
#else
#define PATH_SEPARATOR ":"
@pdvcs
pdvcs / .tmux.conf
Created February 21, 2023 23:15
.tmux.conf for tmux 1.8 on RHEL7
# ~/.tmux.conf for tmux 1.8 (RHEL7)
set -sg escape-time 20
set -g default-terminal 'screen-256color'
set -g mouse-select-window on
set -g mouse-resize-pane off
# Start numbering at 1
set -g base-index 1
setw -g pane-base-index 1
@pdvcs
pdvcs / asdf-check-latest.py
Created January 22, 2023 20:26
Check ~/.tool-versions to see if contents are up-to-date
#!/usr/bin/env python3
import subprocess
targets = {
"nodejs": "18",
"ruby": "3",
"delta": "latest",
"exa": "latest",
"jq": "latest",