Skip to content

Instantly share code, notes, and snippets.

# This documents how you would take a Debian 12 cloud image and make a Proxmox template out of it.
# This script isn't really meant to be executed, but more as a reference and copy/paste for each step.
# Enjoy!
# Download the image
mkdir -p ~/debian-bookworm-build/original && cd ~/debian-bookworm-build/original
wget 'https://cloud.debian.org/images/cloud/bookworm/20240717-1811/debian-12-genericcloud-amd64-20240717-1811.qcow2'
cd ..
@RSully
RSully / bourne.fish
Last active January 18, 2018 05:14
Source *sh environments from fish.
function set_bourne
set --local line $argv[1] # the line X=Y
set --local exp $argv[2] # 1/0: export the variable
set --local key (echo $line | perl -pe 's/^([A-Za-z0-9_]+)=(.*)/$1/g')
set --local dataraw (echo $line | perl -pe 's/^([A-Za-z0-9_]+)=(.*)/$2/g')
set --local data $dataraw
# echo "in set_bourne for $key with $exp"
# echo "old value: $$key"
@RSully
RSully / freadit.php
Created January 12, 2016 02:45
Keep trying to copy a file until success.
<?php
$path = '/Volumes/drive/path.dat';
$write_to = '/tmp/output.dat';
$fh_out = fopen($write_to, 'w+');
clearstatcache();
while (!file_exists($path)) {
sleep(1);
@RSully
RSully / libcec-sample.cpp
Last active October 26, 2015 22:54
Sample code for libCEC initialization
//
// main.cpp
// Test libCEC
//
// Created by Ryan Sullivan on 10/26/15.
// Copyright © 2015 Ryan Sullivan. All rights reserved.
//
#import <iostream>
#import <cec.h>
@RSully
RSully / generate.sh
Created October 8, 2015 17:56
Generate commands to reinstall homebrew packages
#!/usr/bin/env bash
brew tap | while read tap;
do
echo "brew tap $tap"
done
brew list | while read formula;
do
options=$(brew info --json=v1 $formula | jq '.[0] .installed | sort_by(.version) [0] .used_options | join(" ")' -r)
@RSully
RSully / regex-pricing.txt
Created December 29, 2014 20:10
Regex to match US pricing (without dollar sign)
^(\d*)(\.(\d{0,2})?)?$/
<?php
class Generator {
protected $namespaces = [];
protected $outputDirectoriesPSR4 = [];
protected $aliasMapTypes = [];
protected $inputFiles = [];
/*
* Methods to setup the data we need to generate
<?php
App::before(function($request)
{
// determine the subdomain of the current request
$server = explode('.', Request::server('HTTP_HOST'));
$sansSubdomain = implode('.', array_slice($server, 1));
// there are 3 parts to the domain (i.e. user.domain.com)
if (count($server) == 3)
@RSully
RSully / gol.php
Last active December 19, 2015 13:29
PHP implementation of Game Of Life
<?php
// Implementation
function iterate($original)
{
$board = $original;
for ($x = 0; $x < count($board); $x++) {
$row = $board[$x];
for ($y = 0; $y < count($row); $y++) {
$cell = $row[$y];