Skip to content

Instantly share code, notes, and snippets.

View juanplopes's full-sized avatar
🌲
Is that a Segment Tree problem?

Juan Lopes juanplopes

🌲
Is that a Segment Tree problem?
View GitHub Profile
@juanplopes
juanplopes / gist:1698650
Created January 29, 2012 12:44 — forked from akitaonrails/gist:1698555
Dados de dirigir alcolizado :-)

Sobre nós Artigos Blog Multimídia Biblioteca Eventos Loja Virtual Contato

Pelo direito de dirigir alcoolizado por Lew Rockwell, terça-feira, 24 de junho de 2008

@juanplopes
juanplopes / gist:1024285
Created June 14, 2011 03:57 — forked from waldyrfelix/gist:1024270
BatchAggregate
public static IEnumerable<IList<T>> BatchAggregate<T>(this IEnumerable<T> source, int batchSize)
{
for (int page = 0; page < source.Count(); page = page + batchSize)
{
var list = source
.Skip(page)
.Take(batchSize)
.ToList();
yield return list;
public IEnumerable<Token> Scan(IEnumerable<char> source)
{
var currentState = StatesTable.InitialStage;
var currentValue = "";
Func<Token> markPartialStop = () =>
{
if (currentState.IsStop)
{
var result = new Token(currentState.ResultingTokenId, currentValue);
@juanplopes
juanplopes / gist:987646
Created May 23, 2011 21:21 — forked from jonathascosta/gist:987644
String Extensions
public static class TypeExtensions
{
public static Type GetValueTypeIfNullable(this Type type)
{
return (type.IsGenericType && typeof(Nullable<>) == type.GetGenericTypeDefinition())
? type.GetGenericArguments()[0] : type;
}
}
public static class StringExtensions
@juanplopes
juanplopes / test.cs
Created April 18, 2011 16:19 — forked from ElemarJR/test.cs
[Test]
public static void Class_AllStaticMethodsShouldBeDecoratedWithDebuggerStepThroughAttribute()
{
var methods = StaticMethodsWithout(typeof(Mooble.Util.StringExtensions), typeof(DebuggerStepThroughAttribute))
methods.Count.Should.Be(0);
}
IEnumerable<MethodInfo> StaticMethodsWithout(Type type, Type attribute)
{
return from m in type.GetMethods()
public struct MyEnum
{
public static readonly MyEnum Value1 = new MyEnum("value1");
public static readonly MyEnum Value2 = new MyEnum("value2");
readonly string name;
MyEnum(string name) : this()
{
this.name = name;
var intForm = Type.GetType("ModuloControle.IMessageForm'1").MakeGenericType(myDesiredType)
GetType().Assembly.GetTypes()
.Where(x=>!x.IsAbstract && typeof(Form).IsAssignableFrom(x) && intForm.IsAssignableFrom(x))
.Select(x => (Form)Activator.CreateInstance(x));
public class MeuDependencyResolver : IDependencyResolver
{
private ILookup<Type, object> lookup;
public MeuDependencyResolver()
{
var dependencias = new []
{
new DummyDependencia1(), new DummyDependencia2(), new DummyDependencia2_2()
};
public class MeuDependencyResolver : IDependencyResolver
{
private ILookup<Type, object> dependencias;
public MeuDependencyResolver()
{
this.dependencias = Dependencias().ToLookup(x => x.GetType());
}
private IEnumerable<object> Depencencias()
Felipe:
quer minha opinião?
Rodrigo Vidal:
sim :D
Felipe:
na grande maioria dos casos, tanto faz
não terá diferença
em casos que um FileSystem é um problema, o DB será um problema também
e vice-cersa
vice-versa