Skip to content

Instantly share code, notes, and snippets.

@bradland
bradland / drivetrain.ini
Created February 21, 2024 15:48
33 Stradale SG (Short Gearing)
[HEADER]
VERSION=3
[TRACTION]
TYPE=RWD ; Wheel drive. Possible options: FWD (Front Wheel Drive), RWD (Rear Wheel Drive)
[GEARS]
COUNT=6 ; forward gears number
GEAR_R=-3.273 ; rear gear ratio
; forward gears ratios. must be equal to number of gears defined on count
@bradland
bradland / script_base.rb
Last active December 30, 2023 16:05
Base Ruby shell scripting template. Uses std-lib only; parses options; traps common signals.
#!/usr/bin/env ruby
# frozen_string_literal: true
require "ostruct"
require "optparse"
require "bigdecimal"
require "csv"
require "pry"
## Embedded ScriptUtils library; because, scripting!
@bradland
bradland / ssh-known-hosts-mgmt.sh
Last active April 4, 2023 21:21
SSH known_hosts tools
# This is a short collection of tools that are useful for managing your
# known_hosts file. In this case, I'm using the '-f' flag to specify the
# global known_hosts file because I'll be adding many deploy users on this
# system. Simply omit the -f flag to operate on ~/.ssh/known_hosts
# Add entry for host
ssh-keyscan -H github.com >> /etc/ssh/ssh_known_hosts
# Scan known hosts
ssh-keygen -f /etc/ssh/ssh_known_hosts -F github.com
@bradland
bradland / gencert.sh
Created January 27, 2012 20:39
Generate a self-signed SSL cert
#!/bin/bash
# Bash shell script for generating self-signed certs. Run this in a folder, as it
# generates a few files. Large portions of this script were taken from the
# following artcile:
#
# http://usrportage.de/archives/919-Batch-generating-SSL-certificates.html
#
# Additional alterations by: Brad Landers
# Date: 2012-01-27
@bradland
bradland / ssh-copy-id
Created August 14, 2013 13:34
ssh-copy-id script for OS X
#!/bin/sh
# Shell script to install your public key on a remote machine
# Takes the remote machine name as an argument.
# Obviously, the remote machine must accept password authentication,
# or one of the other keys in your ssh-agent, for this to work.
ID_FILE="${HOME}/.ssh/id_rsa.pub"
if [ "-i" = "$1" ]; then
@bradland
bradland / data_validations.rb
Last active November 11, 2022 17:01
Data validations with axlsx gem
#!/usr/bin/env ruby -w -s
# -*- coding: utf-8 -*-
require 'axlsx'
## Some documentation ##
### Axlsx Gem ###
# Axlsx Docs: http://rubydoc.info/gems/axlsx/frames
# Axlsx::DataValidation: http://rubydoc.info/gems/axlsx/Axlsx/DataValidation
@bradland
bradland / natophon.sh
Created December 27, 2011 15:06
NATO phonetic string converter for bash
#!/bin/bash
#########################################################################
# #
# #
# NATO String converter #
# #
# Description: converts string (first parameter given) #
# to NATO phonetics-alphabet #
# #

"I have a trick that makes things easier for me. Since writing is very hard and rewriting is comparatively easy and rather fun, I always write my scripts all the way through as fast as I can, the first day, if possible, putting in crap jokes and pattern dialogue—“Homer, I don’t want you to do that.” “Then I won’t do it.” Then the next day, when I get up, the script’s been written. It’s lousy, but it’s a script. The hard part is done. It’s like a crappy little elf has snuck into my office and badly done all my work for me, and then left with a tip of his crappy hat. All I have to do from that point on is fix it. So I’ve taken a very hard job, writing, and turned it into an easy one, rewriting, overnight. I advise all writers to do their scripts and other writing this way. And be sure to send me a small royalty every time you do it." - John Swartzwelder

The New Yorker, John Swartzwelder, Sage of “The Simpsons”

module ShellScriptUtils
class CursedReport
def initialize(message = nil)
@clear_commands = []
@message = message
update @message
end
def update(message)
clear @message # clear the current message
@bradland
bradland / data.txt
Created July 17, 2021 15:38
r/ruby question
A12345 Jon Osterman
A23456 Walter Kovacs
A34567 Daniel Dreiberg
987 Dr. Manhattan
876 Rorshach
765 Night Owl
A12345 987
A23456 876