Skip to content

Instantly share code, notes, and snippets.

View xinmyname's full-sized avatar

Andy Sherwood xinmyname

View GitHub Profile
@xinmyname
xinmyname / ColorizedAlpha.cs
Created January 12, 2012 18:58
AForge filter to convert a gray scale image to RGBA using source as alpha and user specified color for RGB
using AForge.Imaging;
using AForge.Imaging.Filters;
namespace TextImage
{
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
public sealed class ColorizedAlpha : BaseFilter
@xinmyname
xinmyname / Screen.cs
Created January 12, 2012 19:00
AForge filter to perform Screen filter (ala Photoshop)
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using AForge.Imaging;
using AForge.Imaging.Filters;
namespace TextImage
{
public class Screen : BaseInPlaceFilter2
{
@xinmyname
xinmyname / gist:1862145
Created February 19, 2012 05:42
Fluent Parsing sample
public IEnumerable<InterfaceStatusEntry> ShowInterfaceStatus()
{
return ParserFactory
.CreateParser<InterfaceStatusParserBase>(_iosVersion.SoftwareFamily)
.Parse(_sshShellWrapper.Capture("show interface status"));
}
@xinmyname
xinmyname / saneTimeout.coffee
Created February 23, 2012 17:05
CoffeeScript setTimeout sanity restoration
setTimeout = (delay, exp) ->
window.setTimeout exp, delay
@xinmyname
xinmyname / SPListItemExtensions.cs
Created June 7, 2012 04:41
SharePoint object mapper
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using Microsoft.SharePoint;
namespace MileageSite.Layouts.MileageSite
{
public static class SPListItemExtensions
@xinmyname
xinmyname / FMDatabaseFactory.m
Created March 3, 2013 20:46
FMDatabase factory class. Handles the creation of an FMDatabase object. Creates a new database from a template resource if necessary.
//
// FMDatabaseFactory.m
//
// Copyright (c) 2012 Andy Sherwood. All rights reserved.
//
#import "FMDatabaseFactory.h"
#import <FMDatabase.h>
@implementation FMDatabaseFactory
@xinmyname
xinmyname / implicit try
Created September 5, 2013 18:27
What if we had implicit try blocks in methods if you followed the method with a catch block? I think the meaning remains clear, but we lose a few lines and indentation.
private bool DoWork()
{
DoSomething();
DoSomethingElse();
return true;
}
catch (Exception ex)
{
_log.Error(ex);
@xinmyname
xinmyname / gist:6559023
Last active December 23, 2015 01:18
What could be simpler?
PS1='\[\033]0;${PWD}\007\]\[\033[00m\][${DVCSBRANCH} \[\033[1;32m\]a${INDEXADDED} \[\033[1;33m\]M${FILESMODIFIED} \[\033[1;34m\]D${FILESDELETED} \[\033[1;31m\]?${FILESADDED}\[\033[00m\]] \[\033[0;33m\]m${INDEXMODIFIED} \[\033[0;31m\]d${INDEXDELETED} \[\033[0;35m\]U${FILESUNMERGED} u${INDEXUNMERGED}\[\033[00m\]\n$>'
using (var serviceRequest = new WebClient())
{
string token = GetAuthorizationToken("yourservice","owner", "NW1wr7/nlgggTFnB5L7nDBrOLC+o1E1P4ZZqPaP2mY4=");
serviceRequest.Headers["Authorization"] = string.Format("WRAP access_token=\"{0}\"", token);
string response = serviceRequest.DownloadString(new Uri(url));
return response;
}
// connects to ACS and gets WRAP Authorization token
@xinmyname
xinmyname / serveandwatch.ps1
Created April 28, 2014 15:32
Start an HTTP server and watch the folder for changes
Start-Process python.exe -argument '-m http.server'; Start-Process livereloadx.cmd