Skip to content

Instantly share code, notes, and snippets.

View andrewyager's full-sized avatar

Andrew Yager andrewyager

View GitHub Profile
@andrewyager
andrewyager / ghostname.py
Last active September 13, 2021 23:55
An implementation of the Ghostname generator.
#!/usr/bin/env python3
###
### An implementation of Nathan W. Pyle's Ghostname
### https://www.facebook.com/nathanwpyle2/posts/405022030992924
### https://twitter.com/nathanwpyle/status/1437233812203782145
###
name = input("Enter your name: ")
outname = ""
for l in name:
@andrewyager
andrewyager / openstack-nova-password
Last active July 28, 2020 13:31
Nova Password retrieval using openstack config.yaml configuration files
#!/usr/bin/env python3
"""
Nova Password retrieval for OpenStack
This utility allows you to retrieve a password (using the method made available by
openstack-novaclient) for a Virtual machine from your CLI.
openstack client (python-openstackclient) does not currently include the
`get password` option that is present in the `openstack-novaclient` utility.
The openstack-novaclient does not include the ability to use openstack clouds as a
@andrewyager
andrewyager / generate_reaper_tracks.py
Last active October 12, 2019 01:21
Generate multiple Reaper Tracks lazily
#!/usr/bin/python
"""
Ever wanted to record audio using Dante Virtual Soundcard in Reaper?
Wanted to set up a project with 64 tracks, mapped to each of the 64 inputs
and also to the 64 Dante outputs?
Thought that it would take too long by hand?
This script generates the XML for 64 tracks with output maps suitable
for use in this application. IT's not a whole Reaper Project file, but rather
the "track" definitions which you can copy/paste into a reaper file.
@andrewyager
andrewyager / check-plcm-ua.php
Last active July 28, 2016 09:49
A simple script to check the UA of Polycom handsets. In particular, it tells us if the UA hasn't upgraded to 5.5.
<?php
$phones = `asterisk -rx 'sip show peers'`;
$tenant=array();
$lines = explode("\n", $phones);
foreach ($lines as $line) {
$segments = preg_split("/\s+/", $line);
if (count($segments)>1) {
if ($segments[1]!="(Unspecified)") {
@andrewyager
andrewyager / polycom-reboot.php
Created July 28, 2016 09:13
This is a short script to loop through an set of extensions attached to an Asterisk box, and reboot the Polycom VVX handsets.
<?php
$phones = `asterisk -rx 'sip show peers'`;
$lines = explode("\n", $phones);
foreach ($lines as $line) {
$segments = preg_split("/\s+/", $line);
if (count($segments)>1) {
if ($segments[1]!="(Unspecified)") {
$parts = explode("/", $segments[0]);
@andrewyager
andrewyager / Batch File Rename.scpt
Last active July 14, 2016 07:19 — forked from oliveratgithub/Batch File Rename.scpt
Simple AppleScript to easily batch rename multiple files sequentially for use with an PRG MBox. GUI asks user to select files and will preserve the name and extension. It as forked from another script that gave us most of the scaffolding.
-- This code comes from https://gist.github.com/oliveratgithub/
-- Open in AppleScript Editor and save as Application
-- ------------------------------------------------------------
--this is required to break the filename into pieces (separate name and extension)
set text item delimiters to "."
tell application "Finder"
set all_files to every item of (choose file with prompt "Choose the Files you'd like to rename:" with multiple selections allowed) as list
--now we start looping through all selected files. 'index' is our counter that we initially set to 1 and then count up with every file.
--the 'index' number is of course required for the sequential renaming of our files!
repeat with index from 1 to the count of all_files
@andrewyager
andrewyager / monthfraction.py
Last active June 4, 2020 04:36
Calculate the fractional months between two dates, inclusively.
from datetime import datetime, date
import calendar
def monthdiff(start_period, end_period, decimal_places = 2):
if start_period > end_period:
raise Exception('Start is after end')
if start_period.year == end_period.year and start_period.month == end_period.month:
days_in_month = calendar.monthrange(start_period.year, start_period.month)[1]
days_to_charge = end_period.day - start_period.day+1
diff = round(float(days_to_charge)/float(days_in_month), decimal_places)