Skip to content

Instantly share code, notes, and snippets.

View Brad-Christie's full-sized avatar

Brad Christie Brad-Christie

View GitHub Profile
@Brad-Christie
Brad-Christie / MailExample.cs
Created March 14, 2017 16:37
Demonstrating attaching an image to a MailMessage from a url.
var url = "https://chart.googleapis.com/chart?chs=250x250&cht=qr&chl=abc%20123%20456&choe=UTF-8";
var attachment = MailMessageHelper.GetUrlAsAttachment(url, "qrcode.png");
message += string.Format("<img src='{0}' />", attachment != null ? "cid:" + attachment.ContentId : url);
using (SmtpClient client = new SmtpClient("xxx.xxx.x.xx"))
{
MailAddress to = new MailAddress("john@example.com");
MailAddress from = new MailAddress("email@example.com");
MailMessage email = new MailMessage(from, to);
@Brad-Christie
Brad-Christie / MongDB(aaS).bat
Last active June 14, 2017 17:33
Run MongoDB as a windows service.
@ECHO OFF
TITLE MongoDB as a Service
REM Change to your installation dir.
SET MONGODIR=%ProgramFiles%\MongoDB\Server\2.7\bin
REM Change to where you'd like the databases and logs.
SET LOGDIR=%MONGODIR%\data\log
SET DBDIR=%MONGODIR%\data\db
SET LOGFILE=%LOGDIR%\mongod.log
@Brad-Christie
Brad-Christie / File Locations
Last active October 30, 2020 06:02
Links to various files that may be helpful to have direct web references to (e.g. use in a dockerfile)
IIS / URL Rewrite Module 2.1
Info: https://www.iis.net/downloads/microsoft/url-rewrite
Installer (x86)
Filename: rewrite_x86_en-US.msi
Resulting URI: http://download.microsoft.com/download/6/8/F/68F82751-0644-49CD-934C-B52DF91765D1/rewrite_x86_en-US.msi
Unattended: msiexec /i rewrite_x86_en-US.msi /quiet /norestart
Installer (x64)
Filename: rewrite_amd64_en-US.msi
Resulting URI: http://download.microsoft.com/download/D/D/E/DDE57C26-C62C-4C59-A1BB-31D58B36ADA2/rewrite_amd64_en-US.msi
Unattended: msiexec /i rewrite_amd64_en-US.msi /quiet /norestart
@Brad-Christie
Brad-Christie / README.md
Last active December 14, 2018 17:38
BrickLink - The LEGO Christmas Ornaments Book (by Chis McVeigh)
@Brad-Christie
Brad-Christie / Test-Property.Tests.ps1
Created December 28, 2018 17:34
Test if a property exists on object
. "${PSScriptRoot}\Test-Property.ps1"
Describe "Test-Property" {
Context "Basic Usage" {
BeforeAll {
$obj = @{ Foo = "Bar" }
}
It "Should accept named parameters" {
Test-Property -InputObject $obj -PropertyName "Foo" | Should -Be $true
}
@Brad-Christie
Brad-Christie / Format-[Un]SafeString.ps1
Created May 16, 2019 00:47
How to parse and format a string with placeholders, and only bring in the tokens you want.
$Make = "Tesla"
$Model = "X"
$Year = 2017
$Format = "`$Year `$Make `$Model"
Function Format-UnsafeString {
Param(
[Parameter(Position = 0, Mandatory)]
[string]$Format
,
@Brad-Christie
Brad-Christie / sitecore-packages.json
Created May 16, 2019 00:53
Associative list of sitecore package TO direct download URL (assuming authentication)
{
"Sitecore 8.2 rev. 161221.zip": {
"description": "Sitecore Experience Platform 8.2 Update-2",
"url": "https://dev.sitecore.net/~/media/02D2B5F95D1D4B1F894C2E3CA1194E45.ashx"
},
"Sitecore 8.2 rev. 171121 (WDP XP0 package).zip": {
"description": "Sitecore Experience Platform 8.2 Update-6",
"url": "https://dev.sitecore.net/~/media/AFA4C05BA4414C239FA9945E52ABF7DC.ashx"
},
"Sitecore 8.2 rev. 180406 (WDP XP1 packages).zip": {
@Brad-Christie
Brad-Christie / Azure-Docker.ps1
Created July 3, 2019 22:37
Build a docker base image that allows you to run Azure commands against your subscription
[CmdletBinding()]
Param(
[Parameter()]
[string]$SubscriptionId = $null
,
[Parameter()]
[string]$CertificatePassword = "secret"
,
[Parameter()]
[ValidateScript({ Test-Path $_ -IsValid })]
@Brad-Christie
Brad-Christie / Install-SolrWebApp.ps1
Created July 9, 2019 20:22
Uses PowerShell Az module to deploy SOLR as a WebApp
[CmdletBinding()]
Param(
[Parameter()]
[guid]$SubscriptionId = "16a1fd8b-1684-4b0f-9c72-383d91e35cd7"
,
[Parameter()]
[ValidateSet("Canada Central","Canada East","Central US","East US","East US 2","North Central US","South Central US","West Central US","West US","West US 2")]
[string]$Region = "Central US"
,
[Parameter()]
@Brad-Christie
Brad-Christie / Backup-Sitecore.ps1
Last active July 18, 2019 11:35
Backup Sitecore Instance (Single Developer Only)
Function GetDatabases {
[CmdletBinding()]
Param(
[Parameter(Position = 0, Mandatory, ValueFromPipeline)]
[ValidateScript({ Test-Path $_ -PathType "Container" })]
[string]$WebRoot
)
Process {
$Databases = @()