Skip to content

Instantly share code, notes, and snippets.

View jonnii's full-sized avatar
:shipit:
<--- lets do this

Jonathan Goldman jonnii

:shipit:
<--- lets do this
View GitHub Profile
@jonnii
jonnii / gist:667835
Created November 8, 2010 15:52
Good braces
source.MyEvent +=
delegate(object s, EventArgs e)
{
DoSomething();
};
@jonnii
jonnii / gist:667837
Created November 8, 2010 15:53
Bad braces
source.MyEvent +=
delegate(object s, EventArgs e)
{
DoSomething();
};
@jonnii
jonnii / default.ps1
Created May 7, 2012 14:41
Creating a click once package using mage and powershell
task PrepareClickOnce {
write-host 'Add mage to our path'
$env:path += ";C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools"
write-host "Preparing install directory"
$installersRoot = '..\installers\app'
if (test-path $installersRoot) {
Write-Host "Cleaning installers root"
rm -r -force $installersRoot > $null
@jonnii
jonnii / wtf
Created August 30, 2012 02:57
#codegolf bash
find . -type d -maxdepth 1 -exec sh -c '(cd {} && git branch -l | grep $1 && pwd)' ';'
@jonnii
jonnii / gist:3749728
Created September 19, 2012 13:38
db api
var dataSource = new SqlServerDataSource
{
ConnectionString = "connection-string"
};
var procedure = new StoredProcedure("SomeStoredProcedureName");
procedure.AddInput("parameter", "value");
dataSource.Execute(procedure, t =>
{
@jonnii
jonnii / gist:3758049
Created September 20, 2012 20:08
gtfo xml
var defaultFormatters = GlobalConfiguration.Configuration.Formatters
.Where(f => f.SupportedMediaTypes
.Any(m => m.MediaType.ToString(CultureInfo.InvariantCulture) == "application/xml"
|| m.MediaType.ToString(CultureInfo.InvariantCulture) == "text/xml"))
.ToList();
foreach (var match in defaultFormatters)
{
GlobalConfiguration.Configuration.Formatters.Remove(match);
}
@jonnii
jonnii / gist:3842375
Created October 5, 2012 21:00
castle windsor factory example
using System;
using Castle.Facilities.TypedFactory;
using Castle.MicroKernel.Registration;
using Castle.Windsor;
namespace castlething
{
public class Program
{
public interface IMathService
@jonnii
jonnii / gist:3867894
Created October 10, 2012 19:35
mongo repo
/// <summary>
/// Repository interface
/// </summary>
public interface IMongoRepository
{
/// <summary>
/// Indicates whether or not the repository can connect to the underlying
/// mongo instance
/// </summary>
bool CanConnect { get; }
@jonnii
jonnii / gist:3867914
Created October 10, 2012 19:39
updae query
public class UpdateJobIsPinned : IUpdate<Job, bool>
{
public UpdateJobIsPinned(string id, bool isPinned)
{
Id = id;
IsPinned = isPinned;
}
public string Id { get; private set; }
@jonnii
jonnii / gist:3873727
Created October 11, 2012 16:40
awful hack
$('.button').each(function () {
var location = $(this).attr('href');
$(this).click(function (e) {
var image = $('<img/>');
image.error(function () {
window.location = location;
}).load(function () {
window.location = location;
}).attr('src', location);