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 / 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>"
@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 / 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 / gist:114241
Created May 19, 2009 17:25
Mapping for Blog with Fluent NHibernate
public class BlogMap : ClassMap<Blog>
{
public BlogMap()
{
Id(x => x.Id).GeneratedBy.Identity();
Map(x => x.Title);
Map(x => x.Subtitle);
Map(x => x.AllowsComments);
Map(x => x.CreatedAt);
}
@drmohundro
drmohundro / gist:114242
Created May 19, 2009 17:28
Fluent NHibernate version of Ayende's InMemoryDatabaseTest
public class InMemoryDatabaseTest : IDisposable
{
private static Configuration _configuration;
private static ISessionFactory _sessionFactory;
protected ISession _session;
public InMemoryDatabaseTest(Assembly assemblyContainingMappedType)
{
if (_configuration == null)
_sessionFactory = CreateSessionFactory(assemblyContainingMappedType);
@drmohundro
drmohundro / gist:114244
Created May 19, 2009 17:31
Unit test to go along with Fluent NHibernate version of InMemoryDatabaseTest
[TestFixture]
public class BlogTests : InMemoryDatabaseTest
{
public BlogTests() : base(typeof(Blog).Assembly)
{
}
[Test]
public void Can_save_and_load_blog()
{
@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; }
}
@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 / 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 / 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.");
}