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 / 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 / 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 / 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 / IisExpressJob.ps1
Last active December 25, 2018 06:47
PowerShell functions to start/stop IIS Express in the specified directory as a background job
$jobName = 'IisExpressJob'
function Start-IisExpress($pathToSource) {
Start-Job -Name $jobName -Arg $pathToSource -ScriptBlock {
param ($pathToSource)
& 'C:\Program Files (x86)\IIS Express\iisexpress.exe' /port:1234 /path:$pathToSource
}
}
function Stop-IisExpress {
@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 / Playground.swift
Created February 20, 2015 17:02
SWXMLHash Lazy-Loading Approach
class IndexOp {
let index: Int
let key: String
init(_ index: Int) {
self.index = index
self.key = ""
}
init(_ key: String) {
@drmohundro
drmohundro / Get-FrameworkVersions.ps1
Last active May 12, 2022 13:28
PowerShell script to return all installed .NET Framework versions.
<#
.Synopsis
Returns the install .NET Framework versions.
.Description
The script looks through the registry using the notes from the below
MSDN links to determine which versions of .NET are installed.
@drmohundro
drmohundro / example.swift
Created November 26, 2014 04:23
SWXMLHash parsing XML with namespace
// Playground - noun: a place where people can play
import SWXMLHash
import UIKit
let xmlWithNamespace = "<root xmlns:h=\"http://www.w3.org/TR/html4/\"" +
" xmlns:f=\"http://www.w3schools.com/furniture\">" +
" <h:table>" +
" <h:tr>" +
" <h:td>Apples</h:td>" +
@drmohundro
drmohundro / private.xml
Last active September 21, 2017 00:36
Karabiner private.xml to swap option and command keys for Parallels
<?xml version="1.0"?>
<root>
<appdef>
<appname>PARALLELS</appname>
<equal>com.parallels.desktop.console</equal>
</appdef>
<devicevendordef>
<vendorname>MICROSOFT</vendorname>
<vendorid>0x045e</vendorid>
@drmohundro
drmohundro / attribute-parse.swift
Last active August 29, 2015 14:08
SWXMLHash Attribute Search Example
var data = "<Conversations>" +
"<Conversation id=\"ConvTest1\">" +
"<StartingStatementId>1</StartingStatementId>" +
"<Description>Some description 1</Description>" +
"</Conversation>" +
"<Conversation id=\"ConvTest2\">" +
"<StartingStatementId>2</StartingStatementId>" +
"<Description>Some description 2</Description>" +
"</Conversation>" +
"</Conversations>"