Skip to content

Instantly share code, notes, and snippets.

@benaadams
benaadams / ThrowHelperExample.cs
Last active October 16, 2017 20:34
Throw Helper example
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using Microsoft.CodeAnalysis.Text;
public class TextLine
{
private SourceText Text;
private int Start;
@richardkundl
richardkundl / BloomFilter.cs
Created January 7, 2014 14:29
Bloom filter implementation in c#.
namespace BloomFilter
{
using System;
using System.Collections;
/// <summary>
/// Bloom filter.
/// </summary>
/// <typeparam name="T">Item type </typeparam>
public class Filter<T>
// <copyright file="LeastRecentlyUsedCache.cs" company="http://www.sinbadsoft.com">
// Copyright (c) Chaker Nakhli 2013
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the
// License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by
// applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language
// governing permissions and limitations under the License.
// </copyright>
// <author>Chaker Nakhli</author>
// <email>Chaker.Nakhli@sinbadsoft.com</email>
@tjrobinson
tjrobinson / nuget-usage.ps1
Created August 2, 2013 08:45
Find NuGet packages across multiple solutions
$packagesInUse = @()
[xml] $nugetConfig = [xml](Get-Content nuget.config)
[System.Xml.XmlElement] $nugetConfigRoot = $nugetConfig.get_DocumentElement()
$repositoryPath = $nugetConfigRoot.SelectSingleNode("repositoryPath").InnerText
Write-Host "repositoryPath:" $repositoryPath
[xml] $repositories = [xml](Get-Content $repositoryPath\repositories.config)
[System.Xml.XmlElement] $repositoriesRoot = $repositories.get_DocumentElement()
@akimboyko
akimboyko / 1readme.md
Last active October 22, 2018 08:45
ScriptCs as embedded scripting engine for .Net application with NuGet support

ScriptCs as embedded scripting engine for .Net application with NuGet support

This gist contains:

  • ExecuteScriptCs.cs — class that are able to execute ScriptCs from another .Net application
  • ScriptModule.cs — AutoFac configuration for ScriptCs/NuGet dependencies
  • Program.cs — command-line example
  • Sample.csx — sample ScriptCs script
  • packages.config — NuGet packages configuration
@pmhsfelix
pmhsfelix / gist:5667375
Created May 29, 2013 01:29
A ASP.NET Web API based local proxy that forwards via Runscope, using @darrelmiller RunscopeMessageHandler. Just configure your HTTP client (e.g. a browser) to use a proxy at 127.0.01:8080
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.ServiceModel;
@ToJans
ToJans / proxy specs.cs
Last active December 14, 2015 11:58
Who can tell me why fiddler https proxying gives a timeout and http does not.....
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Shouldly;
using System;
using System.Net;
using System.Net.Security;
namespace NetVCR.Specs
{
[TestClass]
public class Verify_basic_proxy_functionality
@ctavan
ctavan / gist:4482825
Last active February 18, 2019 16:09
Init-script for optionally starting multiple redis instances on the same host running Ubunut/Debian. Highly inspired by the memcached init script that comes with the Ubuntu package. This is useful since redis is single-threaded.
#! /bin/bash
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db
@mganss
mganss / Pool.cs
Created January 2, 2013 12:55
A buffer pool and an in-memory stream that uses it.
using System;
using System.Collections.Concurrent;
namespace XY
{
public interface IPool<T>
{
T Take();
void Return(T t);
}
public class SomeClass {
public void SomeMethod() {
this.Log().Info(() => "Here is a log message with params which can be in Razor Views as well: '{0}'".FormatWith(typeof(SomeClass).Name));
}
}