Skip to content

Instantly share code, notes, and snippets.

View drmohundro's full-sized avatar
:shipit:

David Mohundro drmohundro

:shipit:
View GitHub Profile
@drmohundro
drmohundro / has-more-than-one-example.sql
Created January 4, 2017 01:59
T-SQL Has More Than CTE Example
; WITH ForImport AS (
SELECT
DISTINCT
ve.BvcmsId
,vd.account AS CreditCardOrAch
,vd.account_expiration AS Expires
,vd.routing AS Routing
,vd.address1 AS Address1
,vd.address2 AS Address2
,vd.city AS City
@drmohundro
drmohundro / backup-example.sql
Last active January 4, 2017 01:58
Backup and Restore Database Examples (T-SQL)
BACKUP DATABASE MyDb TO DISK = 'C:\sql-backups\MyDb-20151119.bak' WITH INIT
GO
@drmohundro
drmohundro / Open-MruSolution.ps1
Last active May 17, 2016 14:15
PowerShell script to open a recently used solution in Visual Studio
function Open-MruSolution($sln) {
$mruItems = "HKCU:\Software\Microsoft\VisualStudio\14.0\MRUItems"
$guids = Get-ChildItem $mruitems |
Select-Object -ExpandProperty name |
Foreach-Object { $_.Substring($_.LastIndexOf('\') + 1) }
[array]$mostRecentlyUsedSlns = $guids |
Foreach-Object {
$guid = $_
Get-ChildItem "$mruItems\$guid" |
@drmohundro
drmohundro / fix-casing-issues.rb
Created March 11, 2016 21:46
Fix git casing issues across all directories
# can just run this in pry
files = `git ls-files | grep Wrongcase`
files.split("\n").each { |file| system("git mv #{file} #{file.gsub('Wrongcase', 'WrongCase')}") }
@drmohundro
drmohundro / ConstraintsInPlayground.swift
Created March 5, 2016 21:28
Playing with Layout Constraints and VFL in Swift Playground
// playing with Xcode, Constraints and Playground
import UIKit
import XCPlayground
let hostView = UIView()
hostView.frame = CGRectMake(0, 0, 400, 200)
hostView.backgroundColor = UIColor.lightGrayColor()
XCPlaygroundPage.currentPage.liveView = hostView
@drmohundro
drmohundro / PingRdpPort.ps1
Created August 20, 2015 16:42
Determine if a specified server is listening on the default RDP port
# relies on portqry (see http://www.microsoft.com/en-us/download/details.aspx?id=24009)
param (
[Parameter(Mandatory=$true)]
[string]
$server,
[int]
$rdpPort = 3389
)
@drmohundro
drmohundro / scm-ignore.js
Created January 24, 2016 18:52
Bookmarklet to hide rows on various source hosting sites
var url = window.location.href;
var searchTextToIgnore = prompt('Enter text to ignore:');
if (url.match(/bitbucket/)) {
$('h1:contains(' + searchTextToIgnore + ')').closest('section').hide();
} else if (url.match(/gitlab/)) {
$('.diff-header span:contains(' + searchTextToIgnore + ')').parent().parent().hide();
} else {
alert(url + " doesn't match any known sites.");
}
@drmohundro
drmohundro / Get-DevLinkAgenda.ps1
Last active December 21, 2015 13:29
Simple PowerShell script to pull the DevLink agenda.
# NOTE: Only worked for DevLink 2013
$agenda = Invoke-RestMethod http://www.devlink.net/agenda.json
$speakers = Invoke-RestMethod http://www.devlink.net/speakers.json
$location = Invoke-RestMethod http://www.devlink.net/api/info/locations.json
$fullAgenda = $agenda | foreach {
# normalize the times to be datetime types
$startTime = ([DateTimeOffset]::Parse($_.start_time)).DateTime
$endTime = ([DateTimeOffset]::Parse($_.end_time)).DateTime
@drmohundro
drmohundro / Get-ConsoleColors.ps1
Last active December 15, 2015 23:19
PowerShell snippet to output all colors.
[Enum]::GetNames([System.ConsoleColor]) |
foreach {
$foregroundColor = $_
$backgroundColor = 'Black'
if ($_ -eq 'Black') {
$backgroundColor = 'White'
}
Write-Host -foregroundcolor $foregroundColor -backgroundColor $backgroundColor $foregroundColor
@drmohundro
drmohundro / gist:114239
Created May 19, 2009 17:23
Implementation of Blog entity for use with NHibernate
public class Blog
{
public virtual int Id { get; set; }
public virtual bool AllowsComments { get; set; }
public virtual string Title { get; set; }
public virtual string Subtitle { get; set; }
public virtual DateTime CreatedAt { get; set; }
}