Skip to content

Instantly share code, notes, and snippets.

View nvivo's full-sized avatar

Natan Vivo nvivo

  • Lastlink
  • Ponta Grossa, PR, Brazil
View GitHub Profile
@nvivo
nvivo / RegisterStartIISExpress.reg
Created August 5, 2016 15:01
Start IIS Express from Here and open the browser
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\IISExpress]
@="IIS Express Here"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\shell\IISExpress\command]
@="D:\\Bin\\StartIISExpress.exe %V"
[HKEY_CLASSES_ROOT\Directory\Background\shell\IISExpress]
@="IIS Express Here"
@nvivo
nvivo / XElementSelectExtensions.cs
Created July 25, 2015 09:40
Allows navigating to XElement nodes using simple absolute and relative paths without using XPath or caring for namespaces
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
namespace System.Xml.Linq
{
/// <summary>
/// Allows select elements from an XElement using a simple path and ignoring namespaces.
/// </summary>
/// <example>
@nvivo
nvivo / gist:75b710b621ea2eb2b490
Created March 1, 2015 12:38
Demonstration that async/await shouldn't cause any noticiable performance hit just because of "async/await"
using System;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
@nvivo
nvivo / AsyncUntypedActor.cs
Created February 19, 2015 13:33
This is an implementation of an "async" UntypedActor. It works exactly like a UntypedActor, but support "await" calls inside the OnReceiveAsync method. Exceptions thrown during async execution are throw as regular exceptions and are handled by the supervisor, and no messages are processed during async operations.
public abstract class AsyncUntypedActor : UntypedActor, WithUnboundedStash
{
public IStash Stash { get; set; }
bool _awaiting;
readonly object AwaitingComplete = new object();
protected sealed override void OnReceive(object message)
{
if (_awaiting)
{
@nvivo
nvivo / gist:7254852
Last active December 27, 2015 02:49
Cassette Extension to add multiple folders to a single bundle
public static class BundleCollectionExtensions
{
public static void AddMultipleDirectories<T>(this BundleCollection bundles, string appRelativePath, params string[] directories)
where T : Bundle
{
var list = new List<string>();
foreach (var dir in directories)
{
bundles.Add<T>(dir);
@nvivo
nvivo / gist:5875718
Last active December 19, 2015 01:28
Performance test for CA1813 - Avoid unsealed attributes http://msdn.microsoft.com/en-us/library/ms182267(v=vs.110).aspx
using System;
using System.Diagnostics;
namespace AttributePerformanceTest
{
public sealed class SealedAttribute : Attribute { }
public class NotSealedAttribute : Attribute { }
public class InheritNotSealedAttribute : NotSealedAttribute { }