Skip to content

Instantly share code, notes, and snippets.

View ChrisMissal's full-sized avatar
💭
set status

Chris Missal ChrisMissal

💭
set status
View GitHub Profile
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__
@KevM
KevM / mp.sh
Last active August 11, 2016 18:30
Bash script to monitor the Alamo Drafthouse calendar for changes
# 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
@mhinze
mhinze / subroute-slack.cs
Last active June 6, 2016 20:00
slack subroute.io
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
{
@maydaytx
maydaytx / BowlingSchedule.cs
Last active July 30, 2019 18:20
Randomly select bowlers to exclude each week
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),
@plioi
plioi / Retry.cs
Last active August 29, 2015 14:17
Fixie Convention - Retry on SQL Timeouts
public class IntegrationTestConvention : Convention
{
public IntegrationTestConvention()
{
Classes
.NameEndsWith("Tests");
Methods
.Where(method => method.IsVoid() || method.IsAsync());
@jayotterbein
jayotterbein / sln.ps1
Last active June 4, 2018 21:36
Open solution file in current directory with most recent visual studio
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
@KevM
KevM / measureme.cs
Created February 18, 2015 19:47
Wrote this quick little performance testing harness. Guessing this is a C# right of passage kind of thing.
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();
@ventaur
ventaur / Enumeration.cs
Created August 22, 2014 22:29
Small modifications to Headspring Enumeration and HTML conventions to support drop-downs for them
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using FubuCore.Util;
namespace My.Core.Domain.Models {
@jrunning
jrunning / server.rb
Created June 30, 2014 18:10
Instant Ruby CGI server
#!/usr/bin/env ruby
require "webrick"
server = WEBrick::HTTPServer.new(Port: 8080, DocumentRoot: Dir::pwd)
trap("INT") { server.shutdown }
server.start
anonymous
anonymous / gist:ec2a02e7d2e6011074be
Created May 6, 2014 19:19
Execute async method synchronously
internal static class AsyncHelper {
private static readonly TaskFactory taskFactory = new TaskFactory(CancellationToken.None, TaskCreationOptions.None, TaskContinuationOptions.None, TaskScheduler.Default);
public static TResult RunSync<TResult>(Func<Task<TResult>> func) {
return taskFactory.StartNew(func).Unwrap().GetAwaiter().GetResult();
}
public static void RunSync(Func<Task> func) {
taskFactory.StartNew(func).Unwrap().GetAwaiter().GetResult();
}