Skip to content

Instantly share code, notes, and snippets.

View bradymholt's full-sized avatar

Brady Holt bradymholt

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / arhive.sh
Created November 10, 2014 02:07
Motion Archive
#!/usr/bin/bash
# Format: YEAR MONTH DAY
DATE=$(date +%Y%m%d)
PATH="/home/bholt/surveillance/driveway"
TARGET_FILE="$PATH/$DATE"
/usr/bin/sudo /usr/bin/systemctl stop motion
/usr/bin/sudo /sbin/swapon /dev/sdb2
cd $PATH
#create timelapse video
@bradymholt
bradymholt / organize.sh
Created November 10, 2014 02:05
TV downloads
#!/usr/bin/bash
DOWNLOAD_DIR=/home/bholt/downloads
TARGET_DIR=/home/bholt/tv
cd ${DOWNLOAD_DIR}
mv So.You.Think* ${TARGET_DIR}/So\ You\ Think\ You\ Can\ Dance
mv MythBusters* ${TARGET_DIR}/MythBusters
@bradymholt
bradymholt / Data.cs
Last active August 29, 2015 14:07
Entity Framework One-to-One Relationship
public class DataContext : DbContext
{
public DbSet<Order> Orders { get; set; }
public DbSet<OrderDetail> OrderDetails { get; set; }
}
public class Order
{
public int Id { get; set; }
public string Name { get; set; }
@bradymholt
bradymholt / process.sh
Last active May 19, 2020 19:41
HFBC Podcast Upload
#!/bin/bash
FILENAME=$1
cd ~/veritas-podcast
#change ownership to bholt
sudo chown bholt ./record/${FILENAME}.wav
[ $? -eq 0 ] || exit $?
@bradymholt
bradymholt / ef-complextypes.cs
Last active August 29, 2015 14:03
Entity Framework with Complex Types
public class Person {
public string FirstName {get;set;}
public string LastName {get;set;}
public Address = new Address(); // << It's important to instantiate Address.
}
[ComplexType] // << This attribute is important.
public class Address {
public string Address1 {get;set;}
public string Address2 {get;set;}