This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def convert_to_dict(obj): | |
""" | |
A function takes in a custom object and returns a dictionary representation of the object. | |
This dict representation includes meta data such as the object's module and class names. | |
""" | |
# Populate the dictionary with object meta data | |
obj_dict = { | |
"__class__": obj.__class__.__name__, | |
"__module__": obj.__module__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: Run script with watch to repeat this check every N seconds `watch -n 20 ./mp.sh` | |
# On macos: `brew install jq watch` | |
# Example Used for Master Pancake CYOP tickets that often go on sale and then sell out quickly. | |
rm mp*.json | |
# Download the Alamo Drafthouse calendar for Austin | |
curl -s https://feeds.drafthouse.com/adcService/showtimes.svc/calendar/0002/ > mp.json | |
# Hacky jq query to pull out the Ritz location's events for the desired week/day combinations | |
cat mp.json | jq .Calendar.Cinemas[0].Months[0].Weeks[2].Days[4] >> mp-res.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net; | |
using Subroute.Common; | |
using System.Configuration; | |
using System.Linq; | |
using System.Collections.Generic; | |
using Newtonsoft.Json; | |
// Slack webhook example | |
namespace Subroute.Container | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Main() | |
{ | |
const int weeks = 12; | |
const int bowlersPerWeek = 4; | |
var bowlers = new[] | |
{ | |
new Bowler("Bob", 5, 8), | |
new Bowler("Ben", 2), | |
new Bowler("Janna", 5), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Git Mergetool and difftool with Beyond Compare 4 | |
//For Windows | |
//IF running this command in git bash then escape $ with \ | |
git config --global diff.tool bc4 | |
git config --global difftool.bc4.cmd "\"C:/Program Files (x86)/Beyond Compare 4/BCompare.exe\" \"\$LOCAL\" \"\$REMOTE\"" | |
git config --global difftool.prompt false | |
git config --global merge.tool bc4 | |
git config --global mergetool.bc4.cmd "\"C:/Program Files (x86)/Beyond Compare 4/BCompare.exe\" \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\"" | |
git config --global mergetool.bc4.trustExitCode true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IntegrationTestConvention : Convention | |
{ | |
public IntegrationTestConvention() | |
{ | |
Classes | |
.NameEndsWith("Tests"); | |
Methods | |
.Where(method => method.IsVoid() || method.IsAsync()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function sln([string]$hintPath = $null) | |
{ | |
[string[]]$installed = @(gci HKLM:\Software\Microsoft\VisualStudio\) |% { $_.Name } |% { Split-Path $_ -Leaf } | |
$versions = @() | |
foreach ($i in $installed) | |
{ | |
[Version]$v = "0.0" | |
if ([Version]::TryParse($i, [ref]$v)) | |
{ | |
$versions += $v |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void MeasureMe(Action action, int count=100, int warmup = 10, int runs = 1,string messageFormat = "It took {0}ms to do this.") | |
{ | |
Enumerable.Range(0, warmup).Each(i => | |
{ | |
action(); | |
}); | |
Enumerable.Range(0, runs).Each(r => | |
{ | |
var watch = new Stopwatch(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Reflection; | |
using FubuCore.Util; | |
namespace My.Core.Domain.Models { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "webrick" | |
server = WEBrick::HTTPServer.new(Port: 8080, DocumentRoot: Dir::pwd) | |
trap("INT") { server.shutdown } | |
server.start |
NewerOlder