Skip to content

Instantly share code, notes, and snippets.

View AlbertoMonteiro's full-sized avatar
😎
Writting every day lines fo happy code

Alberto Monteiro AlbertoMonteiro

😎
Writting every day lines fo happy code
View GitHub Profile
@AlbertoMonteiro
AlbertoMonteiro / DispatchUtility.cs
Created March 12, 2015 14:06
DispatchUtility.cs
public static class DispatchUtility
{
private const int S_OK = 0; //From WinError.h
private const int LOCALE_SYSTEM_DEFAULT = 2 << 10; //From WinNT.h == 2048 == 0x800
public static bool ImplementsIDispatch(object obj)
{
bool result = obj is IDispatchInfo;
return result;
}
filters.Add(new RollbarMvcExceptionFilter());
using System;
using System.Threading.Tasks;
using Microsoft.Owin.Hosting;
using Nancy;
using Owin;
namespace ConsoleApplication1
{
class Program
{
public class ValuesController : ApiController
{
// GET api/values
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/values/5
public string Get(int id)
[user]
name = Alberto Monteiro
email = alberto.monteiro@live.com
[core]
preloadindex = true
fscache = true
autocrlf = true
editor = code -n -w
[alias]
fetchall = fetch --all --prune
@AlbertoMonteiro
AlbertoMonteiro / gist:671eddab7d61390a9d09
Created December 11, 2014 18:34
Customizando de forma flexível o nome das colunas usando CsvHelper
using CsvHelper;
using CsvHelper.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq.Expressions;
using Xunit;
namespace ClassLibrary1
{
@AlbertoMonteiro
AlbertoMonteiro / EnumerableAlberto.cs
Last active August 29, 2015 14:10
Resposta Sergio
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Linq;
namespace Sergio
{
public class EnumerableAlberto
@AlbertoMonteiro
AlbertoMonteiro / NetworkShareAccesser.cs
Created October 31, 2014 18:24
Classe para permitir o acesso a diretorios na rede usando credenciais do Active Directory
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
namespace ConsoleApplication5
{
/// <summary>
/// Provides access to a network share.
/// </summary>
public class NetworkShareAccesser : IDisposable
@AlbertoMonteiro
AlbertoMonteiro / LinqExtensions.cs
Last active August 29, 2015 14:07
Cool Linq Extensions
static class Ex
{
public static TimeSpan Sum(this IEnumerable<TimeSpan> lista)
{
return lista.Aggregate(TimeSpan.Zero, (current, item) => current.Add(item));
}
public static TValue Aggregate<T, TValue>(this IEnumerable<T> lista, TValue initial, Func<T, int, TValue, TValue> aggregateFunc)
{
var i = 0;
Tags with inner tags => <(Content|None|Compile|EmbeddedResource).+?[^/]>(\n+\s+.+){1,6}?(\n\s+</\1>)