Skip to content

Instantly share code, notes, and snippets.

View ptdecker's full-sized avatar

Peter Todd Decker ("Todd") ptdecker

  • Kansas City
View GitHub Profile
@ptdecker
ptdecker / main.rs
Last active October 17, 2024 18:56
TOML Crate Demonstration
//! TOML Value Manipulation Demonstration
//!
//! This code is to supplement this excellent article:
//!
//! [Rust: Read, Write, and Modify .toml Files — Another way to handle User Set Environment Variables](https://medium.com/@itsuki.enjoy/rust-read-write-and-modify-toml-files-another-way-to-handle-user-set-environment-variables-27e1baf1a65f)
//!
//! This demo code assumes you have added additional entries to your ~/.cargo/config.toml file. Although, I used
//! `foo` and `bar` instead of the `password` and `username` that the article uses.
//!
//! Put this code into `main.rs`. And, here is the corresponding `Cargo.toml` needed for this demo.
@NerdyDeedsLLC
NerdyDeedsLLC / flnm.sh
Last active June 1, 2023 17:03
BASH: Abridges & Shortens a FIle Path (e.g. flnm "/some/long/path/to/my/file/location/file.ext" 1 1 will produce "/some/.../location/file.ext")
# flnm - Breaks apart a file's path by "/" and returns only the number of folder specified for each side,
# followed by the file name.
#
# usage: flnm <filename> <leading elements> <trailing elements>
# if <leading elements> is provided and <trailing elements> is omitted, then returns ONLY the back n portions
# if <leading elements> is provided and <trailing elements> is omitted, then returns ONLY the file nane
# if <leading elements> + <trailing elements> exceeds the file's actual path length, then returns full file path
# if both <leading elements> and <trailing elements> are omitted, it assumes a value of 1 for each
#
# examples:
@NerdyDeedsLLC
NerdyDeedsLLC / README.md
Last active December 25, 2022 21:50
SSHELPER - Automagically creates and configures your SSH tokens for GitHub!

SSHelper.sh

This is a (at present, Mac-exclusive) command-line utility that will automatically perform all relevant steps required to get SSH up and running on your Mac with GitHub. It is a genuine, well-designed, superfine, one-time, one-line, benign, online, commandline goldmine to streamline your storyline and leave you on cloud-nine!

Oh, and it performs the following activities:

  1. Create an SSH key on your local machine
  2. Activate the SSH Agent
  3. Create/amend your SSH config file to contain the newly-created key
@NerdyDeedsLLC
NerdyDeedsLLC / audiovol.sh
Last active June 7, 2024 02:28
BASH & ZSH Script that (using AppleScript) allows for the adjustment of speaker AND MICROPHONE volumes from CLI.
function vol(){ audiovol 'output' $1; }
function mic(){ audiovol 'input' $1; }
function audiovol(){
AUDIO_IO=$1
NEW_VOLUME=$2
[[ "$AUDIO_IO" == "" ]] && AUDIO_IO='input'
[[ "$AUDIO_IO" == "input" ]] && DEVICE_TEXT='Microphone' || DEVICE_TEXT='Speakers'
if [[ "$NEW_VOLUME" == "" ]]; then [ "$(osascript -e "$AUDIO_IO volume of (get volume settings)")" -gt 0 ] && NEW_VOLUME=0 || NEW_VOLUME=100; fi
[ $NEW_VOLUME -gt 0 ] && MUTE_TEXT='Unmuted' || MUTE_TEXT='Muted'
@PurpleBooth
PurpleBooth / README-Template.md
Last active May 15, 2025 16:42
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@jhannah
jhannah / git_flux.md
Last active December 15, 2022 18:35
git flux
@AndrewRademacher
AndrewRademacher / WhenToDropIt.hs
Last active August 29, 2015 14:05
A purely functional lookup to help you determine what to do when it's hot, based on your sitch. Based on esteemed work from Coty Beasley and Chad Elliot.
module WhenToDropIt
( Sitch (..)
, whatDoIDo
) where
data Sitch = Pigs | Pimps | NgAttitude
suffix :: String
suffix = " like it's hot." ++
"\nI got the rolly on my arm and I'm puring Chandon."
@beacrea
beacrea / whenToDropIt.js
Last active August 29, 2015 14:05
A simple case statement indicating when to ___ it like it's hot. You're welcome, world.
var situation = 'pigs';
var conditionEnd = ' like it\'s hot.';
switch (situation) {
case 'pigs':
alert('Park it' + conditionEnd);
break;
case 'pimps':
alert('Drop it' + conditionEnd);
break;
@albatrocity
albatrocity / chromatic_scale.coffee
Last active December 24, 2015 10:19
A simple sequencer for the HTML5 Audio API. Notes, rests, and durations only with configurable tempo.
# Full chromatic scale with frequencies
chromatic_scale =
"C0" : 16.35
"C#0": 17.32
"Db0": 17.32
"D0" : 18.35
"D#0": 19.45
"Eb0": 19.45
"E0" : 20.60
@mheadd
mheadd / monitor.sh
Created May 13, 2013 20:00
Simple bash script to check whether MySQL is running.
#!/bin/bash
UP=$(pgrep mysql | wc -l);
if [ "$UP" -ne 1 ];
then
echo "MySQL is down.";
sudo service mysql start
else
echo "All is well.";
fi