Skip to content

Instantly share code, notes, and snippets.

View bradymholt's full-sized avatar

Brady Holt bradymholt

View GitHub Profile
@bradymholt
bradymholt / create_pr_with_release_notes.sh
Last active August 29, 2015 14:27
Create a GitHub Pull Request and include formatted release notes
#!/bin/bash
HEAD_BRANCH=$1
BASE_BRANCH=$2
GH_OAUTH_TOKEN=$3
REPO_NAME="bradyholt/foobar"
RELEASE_NOTES_FILE_NAME="release_notes.md"
echo "Will now attempt to create and close a PR from ${HEAD_BRANCH} to ${BASE_BRANCH} with comment showing merged PRs."
echo "Generating Release Notes..."
@bradymholt
bradymholt / ConnectionStrings.psm1
Created April 15, 2015 13:28
Set-ConnectionStringDatabase for Package Manager Console - updates database name in connection string across all projects in solution
function Set-ConnectionStringDatabase {
Param(
[string]$DatabaseName,
[string]$ConnectionStringName='DBConnectionString'
)
Function Set-ConnectionString{
Param(
[string]$ConfigFile,
[string]$ConnectionStringName,
@bradymholt
bradymholt / google_calendar_api_example.rb
Last active February 25, 2017 05:57
Google Calendar API with Ruby Client
#gem install 'google-api-client'
require 'google/api_client'
#Setup auth client
client_secrets = Google::APIClient::ClientSecrets.load #client_secrets.json must be present in current directory!
auth_client = client_secrets.to_authorization
auth_client.update!(
:scope => 'https://www.googleapis.com/auth/calendar',
:access_type => "offline", #will make refresh_token available
@bradymholt
bradymholt / 00_Partial.cshtml
Last active November 7, 2017 21:49
Share Razor Partial View between WebForms and MVC
@model PartialViewModel
<h1>Hello World</h1>
<p>
I was rendered from a <strong>@Model.Source</strong>!
</p>
@bradymholt
bradymholt / telapi.rb
Created March 12, 2015 02:45
Telapi ruby client example
#text-message-lookup.rb
require 'sinatra'
require 'telapi'
Telapi.config do |config|
config.account_sid = 'AC6c889024043be37e4dZZZ8b33b800ccfe'
config.auth_token = 'dx52d3dsd2a2409692591aed4a280e5b'
end
carrier = Telapi::Carrier.lookup("2739293842")
@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';
@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 / 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 / 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 / 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{