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 / InserindoVariosDoCSVViaEF.cs
Last active August 29, 2015 14:07
Inserindo Varios DoCSV via EF
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication1
Tags with inner tags => <(Content|None|Compile|EmbeddedResource).+?[^/]>(\n+\s+.+){1,6}?(\n\s+</\1>)
@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;
@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 / 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 / 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
{
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)
using System;
using System.Threading.Tasks;
using Microsoft.Owin.Hosting;
using Nancy;
using Owin;
namespace ConsoleApplication1
{
class Program
{
filters.Add(new RollbarMvcExceptionFilter());
@AlbertoMonteiro
AlbertoMonteiro / LambdaInJS.js
Created May 13, 2015 21:03
C# Lambda in Javascript
String.prototype.toFunc = function() {
var parts = this.split("=>");
var args = parts[0];
var body = parts[1];
var argsList = args.replace(/[()]/gi, "").split(",");
return new Function(argsList, "return " + body)
};