Skip to content

Instantly share code, notes, and snippets.

View bradymholt's full-sized avatar

Brady Holt bradymholt

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / json_mode
Last active January 21, 2021 08:25
Ansible module to replace values in JSON files https://www.geekytidbits.com/ansible-module-modify-json/
#!/usr/bin/env node
var fs = require('fs');
var args = fs.readFileSync(process.argv[2], 'utf8');
var changed = false;
var jsonPath = null;
var json = null;
var keyValReplacementString = args.split(' ');
keyValReplacementString.forEach(function(i){
@bradymholt
bradymholt / arbitrary_function.sql
Created February 1, 2016 14:54
Postgres snippets
CREATE FUNCTION fred() RETURNS blah AS $$
$$ LANGUAGE 'plpgsql';
SELECT fred();
DROP FUNCTION fred();
@bradymholt
bradymholt / ghp
Created April 12, 2016 22:48
Open GitHub Pull Request in Browser for Current Working Branch
#!/bin/bash
# Opens GitHub PR for the current branch
BRANCH=$(git branch | grep ^* | sed 's/* //' )
URL="https://github.$(git config remote.origin.url | cut -f2 -d. | tr ':' /)/pull/${BRANCH}"
open $URL%
@bradymholt
bradymholt / lame_podcast.sh
Created May 2, 2016 14:20
Convert WAV to MP3 using LAME for podcast
lame -V6 --vbr-new --resample 22 -m m recording.wav
@bradymholt
bradymholt / locale-dow-moy.js
Last active August 4, 2016 16:19
(JavaScript) Prints days of week and months of year for a specified list of locales
var locales = [
'en', // English
'es', // Spanish
'fr' // French
];
function printDaysOfTheWeek(locale) {
var daysOfTheWeek = [];
var monday = new Date();
monday.setDate(monday.getDate() - (monday.getDay() + 6) % 7);