Skip to content

Instantly share code, notes, and snippets.

View bradymholt's full-sized avatar

Brady Holt bradymholt

View GitHub Profile
@bradymholt
bradymholt / tts-airport.sh
Created November 10, 2014 04:03
Text to Speech - Airport Express
#!/bin/bash
if [ ! -f /tmp/"$1".mp3 ]
then
echo "Downloading TTS file from Google Translate..."
wget -O /tmp/"$1".mp3 --user-agent="Mozilla/4.0" http://translate.google.com/translate_tts?q="$1"
else
echo "Skipping download, cached file found."
fi
@bradymholt
bradymholt / PostDeploy.ps1
Last active August 29, 2015 14:16
Octopus PostDeploy script that sets up Scheduled Tasks using Task Scheduler definition files
#PostDeploy.ps1 - This script is called by Octopus Deploy and is responsible for setting up
# Scheduled Tasks to execute jobs. The task definitions are located in \Tasks folder.
# This file should be located in the root of the jobs projects and have Build Action marked to "Content"
# and Copy to Output Directory marked "Copy if newer".
$exePath = (Get-Item -Path ".\" -Verbose).FullName + "\.JobExecutor.exe"
function CreateScheduleXml($sourceXmlPath, $outXmlPath)
@bradymholt
bradymholt / concat_sql.sh
Created March 6, 2015 01:44
Concatenates multiple .sql files into single .sql. Written for SQL Server Management Studio .sql files which are encoded using UCS-2LE.
#!/bin/bash
rm $2
files="${1}"
temp_file="tmp_combine"
temp_file_2="tmp_combine_2"
for file in $files; do
echo "${file}"
iconv -f "UCS-2LE" -t "UTF-8" "${file}" >> $temp_file
echo "" >> $temp_file
echo "GO" >> $temp_file
@bradymholt
bradymholt / process_xslt.ps1
Created March 6, 2015 01:45
Applies XSLT to XML and outputs HTML
param ($xml, $xsl, $output)
if (-not $xml -or -not $xsl -or -not $output)
{
Write-Host "& .\xslt.ps1 [-xml] xml-input [-xsl] xsl-input [-output] transform-output"
exit;
}
trap [Exception]
{
@bradymholt
bradymholt / remote_copy.ps1
Created March 6, 2015 01:48
Copies a directory remotely, from the context of the remote machine to prevent bumerang style copy
param ($computerName, $username, $password, $sourceDirectory, $targetDirectory)
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PsCredential($username, $securePassword)
Invoke-Command -ComputerName $computerName -Credential $credentials -ScriptBlock { Copy-Item $args[0] $args[1] -recurse } -ArgumentList $sourceDirectory,$targetDirectory
@bradymholt
bradymholt / remove_old_directories.ps1
Created March 6, 2015 01:49
Deletes directories older than specified number of days
param ([Parameter(Mandatory=$True)] $clean_path, [Parameter(Mandatory=$True)] $search_pattern, [Parameter(Mandatory=$True)] $max_days)
# get the current date
$curr_date = Get-Date
# determine how far back we go based on current date
$del_date = $curr_date.AddDays(-($max_days))
Get-ChildItem $clean_path | Where {$_.Attributes -eq 'Directory'} | `
Foreach-Object{
@bradymholt
bradymholt / touch_remote_file.ps1
Created March 6, 2015 01:51
Touches a remote file by updating LastWriteTime - useful for touching a remote web.config to restart ASP.NET AppDomain
param ($computerName, $username, $password, $targetFile)
trap
{
write-output $_
exit 1
}
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PsCredential($username, $securePassword)
@bradymholt
bradymholt / toggle_remote_rewrite_rule.ps1
Created March 6, 2015 01:54
Toggles IIS Rewrite rule on/off by setting 'enabled' attribute of a web.config rewrite rule
param ($computerName, $username, $password, $targetFile, $ruleName, $enabled)
trap
{
write-output $_
exit 1
}
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PsCredential($username, $securePassword)
@bradymholt
bradymholt / DatabaseMigrations.ps1
Created March 6, 2015 01:55
Package Manager Console helper module for DbUp
function New-Migration {
param (
[string]$name
)
$project = Get-Project
$projectDirectory = Split-Path $project.FullName
$scriptDirectory = $projectDirectory + "\Migrate"
$fileNameBase = (Get-Date -UFormat "%y%m%d%H%M%S")
@bradymholt
bradymholt / server.js
Created March 12, 2015 02:27
Roadtrip to San Diego GPS Tracker
var http = require('http')
var port = process.env.PORT || 1337;
var fs = require('fs');
var url = require('url');
var pathColor = '0x0000ff';
var pathWeight = '5';
var mapSize = '640x400';
var houstonCoordinates = '29.73820459,-95.4696264';
var sanDiegoCoordinates = '32.7153292, -117.1572551';