Skip to content

Instantly share code, notes, and snippets.

View mcintyre321's full-sized avatar

Harry McIntyre mcintyre321

View GitHub Profile
@Korayem
Korayem / TrackEventsInGoogleAnalyticsAttribute.cs
Created June 4, 2012 15:58
A cool ActionFilter that when dropped over any controller or action, you got yourself google analytics event tracking! By default we assign controller name as category, and action name as the action. In the label we drop the user identity in case he/she i
using System.Configuration;
using System.Web.Mvc;
using GoogleAnalyticsTracker;
using SocialFruits.Domain;
using SocialFruits.Domain.Entities;
namespace SocialFruits.Extensions.Attributes
{
public class TrackEventsInGoogleAnalyticsAttribute : ActionFilterAttribute
{
anonymous
anonymous / gist:4344296
Created December 20, 2012 09:59
Indexed Linq POC
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Lucene.Net.Analysis.Standard;
using Lucene.Net.Index;
using Lucene.Net.Linq;
using Lucene.Net.Linq.Mapping;
@mcintyre321
mcintyre321 / gist:6230628
Created August 14, 2013 12:31
Example of a CodeView for AspMvc
public class IndexView : CodeView<IndexViewModel>
{
protected override void Render(CQ doc, IndexViewModel model, ViewContext viewContext)
{
doc["body"].Append("<div>" + viewContext.ViewBag.Message + "</div>");
}
}
@eddwo
eddwo / gist:5423102
Created April 19, 2013 20:44
Comment spam generator based on the template discovered by Scott Hanselman https://gist.github.com/shanselman/5422230
abstract class Comment
{
public abstract void Generate(StringBuilder builder);
public string Generate()
{
StringBuilder builder = new StringBuilder();
this.Generate(builder);
return builder.ToString();
}
@qmfrederik
qmfrederik / RequestLoggerMiddleWare.cs
Last active November 22, 2018 16:41
A request logger for ASP.NET Core
// Copyright (c) 2016 Quamotion bvba
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
// (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
@piers7
piers7 / Load-TeamCityProperties.ps1
Created September 4, 2013 05:12
Load TeamCity system properties into PowerShell variable scope
<#
.Synopsis
Loads TeamCity system build properties into the current scope
Unless forced, doesn't do anything if not running under TeamCity
#>
param(
$prefix = 'TeamCity.',
$file = $env:TEAMCITY_BUILD_PROPERTIES_FILE + ".xml",
[switch] $inTeamCity = (![String]::IsNullOrEmpty($env:TEAMCITY_VERSION))
)
@mrchief
mrchief / Deploy-Windows-Service-Via-MSBuild.proj.xml
Last active November 23, 2020 09:19
MSBuild Script to deploy Windows Service to remote or local machine
<Project DefaultTargets="CopyOutputs;DeployService" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<!-- These settings control what the service's name, description etc appear in services.msc task panel. -->
<PropertyGroup Label="ServiceMetaData">
<ServiceName>ShinyNewService</ServiceName>
<ServiceDisplayName>Shiny New Service</ServiceDisplayName>
<ServiceDescription>A shiny new service, that changes the world for the greater good.</ServiceDescription>
</PropertyGroup>
<Choose>
@mogauvin
mogauvin / linqpad-nunitlite.cs
Last active August 2, 2021 19:44 — forked from simoneb/linqpad-nunitlite.cs
NUnitLite in LINQPad
// LINQPad 4
// NUnit 3.4
void Main()
{
// change working folder by specifying the -work flag
// using either a single or double dash makes no difference
new AutoRun().Execute(new[]{"-noheader", @"-work=C:\src\Test\", "--verbose"});
}
// Define other methods and classes here
@dieseltravis
dieseltravis / CryptoHelper.cs
Last active October 31, 2023 07:26
sample app that uses PGP Encryption using Bouncy Castle's C# API
// Assembly BouncyCastle.Crypto, Version=1.8.1.0
using Org.BouncyCastle.Bcpg;
using Org.BouncyCastle.Bcpg.OpenPgp;
using Org.BouncyCastle.Security;
using System;
using System.IO;
using System.Text;
namespace EncryptionSample
{
@Potherca
Potherca / README.md
Last active November 27, 2023 17:44
Create a branch on Github without access to a local git repo using http://hurl.eu/

Ever had the need to create a branch in a repo on Github without wanting (or being able) to access a local repo?

With the aid of [the Github API][1] and any online request app this is a piece of cake!

Just follow these steps:

  1. Open an online request app (like apirequest.io, hurl.it pipedream.com, reqbin.com, or webhook.site)
  2. Find the revision you want to branch from. Either on Github itself or by doing a GET request from Hurl: https://api.github.com/repos/<AUTHOR>/<REPO>/git/refs/heads
  3. Copy the revision hash
  4. Do a POST request from Hurl to https://api.github.com/repos/<AUTHOR>/<REPO>/git/refs with the following as the POST body :