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
@ChrisMissal
ChrisMissal / FindDllVersions.cs
Created July 30, 2013 15:32
Search a directory and subdirectories for DLLs by name and list by Version numbers descending.
var path = @"C:\dev\whatever"; var dllFileName = @"something.dll"; var files = from file in new DirectoryInfo(path).GetFiles(dllFileName, SearchOption.AllDirectories) let fvi = FileVersionInfo.GetVersionInfo(file.FullName) select new { File = file.FullName, Version = fvi }; files.OrderByDescending(f => f.Version.FileMajorPart) .ThenByDescending(f => f.Version.FileMinorPart) .ThenByDescending(f => f.Version.FileBuildPart) .Dump();
@ChrisMissal
ChrisMissal / Pixel.cs
Created July 22, 2013 17:55
"Pixel" class that exposes ints for use on a screen, but can use doubles for calculations.
public class Pixel
{
private double _x;
private double _y;
public Pixel(double x, double y)
{
_x = x;
_y = y;
}
#requires -version 2.0
[CmdletBinding()]
param (
[parameter(Mandatory=$true)]
[ValidatePattern('\.rptproj$')]
[ValidateScript({ Test-Path -PathType Leaf -Path $_ })]
[string]
$Path,
[parameter(
@ChrisMissal
ChrisMissal / convert_gists.rb
Last active December 19, 2015 02:09
Rake task to convert gists from one format to another
desc "Convert old gist tags into new format"
task :convert_gists, :dir do |t, args|
puts ">>> !! Please provide a directory, eg. rake convert_gists[source/_new_posts]" unless args.dir
if args.dir
if args.dir == "/"
dir = ""
else
dir = args.dir.sub(/(\/*)(.+)/, "\\2").sub(/\/$/, '');
end
Dir.open dir do |d|
@ChrisMissal
ChrisMissal / Extensions.cs
Created June 17, 2013 18:18
Recursively fetch the first non-null ancestor.
public static T GetFarthestAncestor<T>(this T self, Func<T, T> ancestorSelector)
{
var parent = ancestorSelector(self);
return parent != null
? GetFarthestAncestor(parent, ancestorSelector)
: self;
}
@ChrisMissal
ChrisMissal / ValueObject.cs
Created June 5, 2013 16:06
ValueObject<T>
[Serializable]
public abstract class ValueObject<T> : IEquatable<T> where T : class
{
public override bool Equals(object obj)
{
if (obj == null)
return false;
var other = obj as T;
@ChrisMissal
ChrisMissal / notes.md
Created April 10, 2013 20:28
Why I prefer git over svn. (Too much for twitter)

Why I prefer git over svn

  1. Branching in svn and git are both easy, but merging is much easier in git. I have spent lots of time merging in svn.
  2. Being able to commit locally without being connected compliments my workflow. I can push several commits to "master" when I'm done and not one giant commit all at once.
  3. Lots of history in svn takes up a lot more space than git
  4. Rebasing and cherry-picking in git makes hot-fixes much more easy than in svn.
  5. Pulling/fetching source code is much quicker in git than svn.

These are just a few that come to mind that wouldn't fit in a tweet :)

@ChrisMissal
ChrisMissal / Formo.cs
Last active December 14, 2015 00:49
When requesting values from ConfigurationManager.AppSettings, all values come back as strings. You can use Formo to shortcut this using a typed method.
dynamic config = new Configuration();
// returns 5 as a string (see app.config file)
var retryAttempts1 = config.RetryAttempts;
// returns 5 if found in config, else 10
var retryAttempts2 = config.RetryAttempts(10);
// returns 5 if it exists in config, else userInput if not null, else 10
var retryAttempts3 = config.RetryAttempts(userInput, 10);
@ChrisMissal
ChrisMissal / wtf.md
Last active December 12, 2015 06:49
This was posted as a comment for this post: http://chrismissal.wordpress.com/2012/04/17/more-of-chris/

This was a comment for this post: http://chrismissal.wordpress.com/2012/04/17/more-of-chris/

When I moved to San Francisco in 2007, I knew it wouldn’t be cheap. Ever since I’ve been conscious of phrases like “cost of living” and “quality of life,” I’ve understood that this is an expensive city. But I had been living in Los Angeles and was coming up here for research on a novel that I was writing, and I fell head over heels in love with the city. There was no going back. So I found a job, packed up, and took some crappy apartment in the Lower Haight that pushed the boundary of my nonprofit salary. The place was beyond gross. There was cat food stuck in the old, dingy carpets. Human feces often