Skip to content

Instantly share code, notes, and snippets.

View jonathascosta's full-sized avatar

Jonathas Costa jonathascosta

  • Porto, Portugal
View GitHub Profile
extern int MonthsToLimitZone = 8;
extern double volume = 0.01;
extern double spaceBetweenOrders = 0.001;
extern int MagicNumber = 1234567890;
extern double profitInCurrency = 0.01;
extern double stopLossOrderLimit = 5.0;
double lowestDay, highestDay;
double beginOfSellZone, endOfSellZone;
double beginOfBuyZone, endOfBuyZone;
extern int BarCount = 100;
extern int MagicNumber = 123456789;
extern double InitialVolume = 0.01;
extern int SlipPage = 3;
extern int MaxOrders = 40;
extern double MinimumDistanceForNewOrder = 70;
extern bool AutoConfig = false;
double lowest, highest;
double buyVolume, sellVolume;
@jonathascosta
jonathascosta / TestDaoInstaller.cs
Created May 13, 2011 18:43
Instalador Windsor para objetos DAL
public class TestDaoInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(
AllTypes.FromAssemblyNamed("YourProduct.DataAccess")
.BasedOn(typeof(IDao<,>))
.Configure(c => c.LifeStyle.Transient)
.WithService.Select((t, baseType) => t.GetInterfaces())
.BasedOn(typeof(IDao<>))
@jonathascosta
jonathascosta / LocalizedModelBinder.cs
Created May 17, 2011 20:27
Localized Model Binder for specified culture
public class LocalizedModelBinder : DefaultModelBinder
{
private readonly CultureInfo _cultureInfo;
public LocalizedModelBinder(string cultureName)
{
_cultureInfo = CultureInfo.GetCultureInfo(cultureName);
}
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
using System.Linq;
using System.Text.RegularExpressions;
public static class StringExtensions
{
public static string ToUpper(this string name, string separator)
{
string upper = Regex
.Matches(name, "[A-Z][a-z]+")
.Cast<Match>()
@jonathascosta
jonathascosta / TypeExtensions.cs
Created May 20, 2011 19:53
Type extension methods
public static class TypeExtensions
{
public static bool IsNullableOrType<T>(this Type type)
where T : struct
{
return (type == typeof(T) || type == typeof(T?));
}
}
@jonathascosta
jonathascosta / gist:987676
Created May 23, 2011 21:41 — forked from juanplopes/gist:987646
String Extensions
public static class TypeExtensions
{
public static Type GetValueTypeIfNullable(this Type type)
{
return type.IsNullable() ? type.GetGenericArguments()[0] : type;
}
public static bool IsNullable(this Type type)
{
return (type.IsGenericType && typeof(Nullable<>) == type.GetGenericTypeDefinition());
@jonathascosta
jonathascosta / gist:987644
Created May 23, 2011 21:20
String Extensions
public static class TypeExtensions
{
public static bool IsNullableOrType<T>(this Type type)
where T : struct
{
return (type == typeof(T) || type == typeof(T?));
}
}
public static class StringExtensions
@jonathascosta
jonathascosta / ExtStoreResult.cs
Created September 15, 2011 16:44
ActionResult with Javascript for a Ext.Store
using System.Web.Mvc;
using Newtonsoft.Json;
namespace ActionResults
{
public class ExtStoreResult : ActionResult
{
public virtual string StoreName { get; set; }
public virtual object StoreData { get; set; }
@jonathascosta
jonathascosta / Competencia.cs
Created October 20, 2011 19:49
Classe Competência para lidar com mês/ano
public class Competencia
{
public Competencia(int mes, int ano)
{
try
{
new DateTime(ano, mes, 1);
}
catch (Exception)
{