Skip to content

Instantly share code, notes, and snippets.

View mcintyre321's full-sized avatar

Harry McIntyre mcintyre321

View GitHub Profile
public class ClassnameViewEngine : RazorViewEngine, IViewEngine
{
private readonly Assembly[] _searchAssemblies;
public ClassnameViewEngine(params Assembly[] searchAssemblies)
{
_searchAssemblies = searchAssemblies;
}
//This needs to be initialized to the root namespace of your MVC project.
@mcintyre321
mcintyre321 / ExecutionQueue.cs
Created May 22, 2014 13:53
ExecutionQueue
public class ExecutionQueue
{
BlockingCollection<Action> bc = new BlockingCollection<Action>();
public ExecutionQueue(){
Task.Factory.StartNew(() =>
{
foreach (Action value in bc.GetConsumingEnumerable())
{
value();
}
Array.prototype.liveMap = function (map, cleanUp) {
var destination = [];
this.map(function(item) {
destination[destination.length] = map(item);
});
this.subscribe(function (changes) {
changes.forEach(function(change) {
if (change.status === 'added') {
var t2 = map(change.value);
@mcintyre321
mcintyre321 / boxstarter
Last active August 29, 2015 14:00
boxstarter
Set-ExplorerOptions -showHidenFilesFoldersDrives -showFileExtensions
Enable-RemoteDesktop
cinst IIS-WebServerRole -source windowsfeatures
Install-WindowsUpdate -acceptEula
cinst GoogleChrome
cinst notepadplusplus.install
cinst VisualStudio2013Professional
cinst resharper
cinst Console2
public class CsvFieldAttribute : Attribute
{
public CsvFieldAttribute()
{
Ignore = false;
}
public string Name { get; set; }
public int Index { get; set; }
public bool Ignore { get; set; }
}
void Main()
{
var x = XDocument.Load(@"...\packages.config")
.Document.Root.Elements().Select (r => r.Attribute("id").Value)
.Select (r => {
var cq = CsQuery.CQ.CreateFromUrl("https://www.nuget.org/packages/" + r);
return new{
Package = r,
License = cq[".licenseName"].Html(),
LicenseUrl = cq["a"].Single (el => el.InnerText == "License")["href"]
<?php
use
Sabre\DAV;
//ini_set('display_errors', '1');
if (isset($_SERVER['HTTP_X_ORIGINAL_URL']))
{
$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_ORIGINAL_URL'];
if (!isset($_SERVER['REQUEST_URI'])) {
PROPFIND http://sabre.127.0.0.1.xip.io/ HTTP/1.1
Connection: TE
TE: trailers
Host: sabre.127.0.0.1.xip.io
Depth: 0
Content-Length: 159
Content-Type: application/xml
<?xml version="1.0" encoding="utf-8"?>
<propfind xmlns="DAV:"><prop>
//inject this into class needing to query data, it can live in the domain
public User delegate FindUserByEmail(string email);
//(over in external DataAccess project)
container.Register<FindUserByEmail>(c => (string email) => c.Resolve<IDocumentSession>().Query<User>().Single(u => u.Email == email));
@mcintyre321
mcintyre321 / gist:6294588
Last active October 4, 2019 00:02
Replacing a case-sensitive methods in an Expression Tree with a case-insensitive equivalents using QueryInterceptor. Very cool! This is runnable in LinqPad if you add the QueryInterceptor Nuget package
void Main()
{
var words = new []{"HELLO"}.AsQueryable().SetComparer(StringComparison.CurrentCultureIgnoreCase);
words.Where (x => x.StartsWith("hel")).Dump();
words.Where (x => x.Contains("ell")).Dump();
words.Where (x => x.EndsWith("llo")).Dump();
words.Where (x => x.Equals("hello")).Dump();
words.Where (x => x == "hello").Dump();