Skip to content

Instantly share code, notes, and snippets.

View tom-spalding's full-sized avatar
🐊

Tom Spalding tom-spalding

🐊
View GitHub Profile
@swombat
swombat / db_backup.rake
Created July 24, 2025 09:19
Download backup from AWS and restore
namespace :db_backup do
desc "Download the latest database backup from AWS S3"
task download: :environment do
require 'aws-sdk-s3'
bucket_name = "<your-bucket>"
download_path = Rails.root.join('db', 'backups')
FileUtils.mkdir_p(download_path)
@psobot
psobot / kos_file_dumper.py
Last active June 13, 2023 16:27
Kurzweil KOS File Packer/Unpacker
"""
Kurzweil K2500/K2600 KOS operating system update file packer/repacker
by Peter Sobot, Nov 6, 2021
@psobot / [email protected]
Requirements: none! Pure Python. Just use Python 3.2+.
"""
import os
import math
def print_result(desc)
result = yield
puts "#{desc} class=#{result.class} inspect=#{result.inspect}"
rescue => e
warn "#{desc} fail: #{e}"
end
def test(obj)
puts "\n== #{obj.inspect} == "
@lbrito1
lbrito1 / rspec_finder.sh
Created February 19, 2019 19:42
RSpec failing seed finder
#!/bin/bash
# Finds the first seed that breaks the spec suite. Outputs to stdout and a file (rspec_output).
found=0
while [ $found == 0 ]
do
rspec --order random 2>&1 | tee -a ./rspec_output
found=$(more rspec_output | grep Failed | wc -l)
if [ $found == 0 ]
@ixti
ixti / shellcheck-wrapper
Last active October 25, 2018 22:15
Simple shellcheck wrapper
#!/bin/bash
files=()
args=()
hashbang_regexp="^#\\!(/bin/|/usr/bin/env )?(sh|tcsh|csh|dash|bash)"
function lookup() {
while IFS= read -d $'\0' -r file; do
if [[ "${file}" =~ ^.*\.(ba|c|da|tc|z)?sh$ ]] \
|| head "${file}" -n 1 | grep -E -q "${hashbang_regexp}"; then
module AutocorrectThruDisableCuzWeSuckAtWritingGoodCode
def autocorrect(node)
->(corrector) do
until autocorrect_on.include? node&.type
node = node&.parent
return unless node
end
lines = node.source.lines
match = lines[0].match(/^(.*?)\s*((?<!\\)#(.*))?$/)
#!/usr/bin/env bash -x
# Creates RAM disk.
#
# SYNOPSIS
# create_ramdisk [size [label]]
#
# OPTIONS
# size: RAM disk size in megabytes. Default: 1024
# label: RAM disk volume label. Default: UUID
# I ran cloc (https://github.com/AlDanial/cloc) on each directory of mal (https://github.com/kanaka/mal)
# These are the results:
----------------------------------------------------------------------
dir-name top-language files blank comment code
----------------------------------------------------------------------
objpascal Pascal 19 706 951 6275
ada Ada 28 1984 380 5892
elm Elm 19 1625 226 5682
swift Swift 20 980 1519 5636
@Rich-Harris
Rich-Harris / README.md
Last active November 1, 2024 12:15
Unifying Rollup options

Rollup 0.48 introduces a few changes to the options object, because the current options are confusingly different between the CLI and the options exported by your config file.

Changes to the config file

  • entry is now input
  • sourceMap and sourceMapFile are now sourcemap and sourcemapFile (note casing)
  • moduleName is now name
  • useStrict is now strict

The dest and format options are now grouped together as a single output: { file, format, ... } object. output can also be an array of { file, format, ... } objects, in which case it behaves similarly to the current targets. Other output options — exports, paths and so on — can be added to the output object (though they will fall back to their top-level namesakes, if unspecified).

@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active November 12, 2025 18:30
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example