Skip to content

Instantly share code, notes, and snippets.

View jrgcubano's full-sized avatar

Jorge Rodríguez Galán jrgcubano

View GitHub Profile
@jrgcubano
jrgcubano / gist:31e09cf1c1465fec88a6
Last active August 29, 2015 14:07
Format Helper
public static class FormatHelper
{
#region Numeric Formats
public static string DisplayIntegerFormat = "#0.";
public static string EditIntegerFormat = "0:#0.";
public static string DisplayIntegerDXFormat = "d";
public static string EditIntegerDXFormat = "d";
public static string DisplayDecimalFormat = "#0.00";
public static string EditDecimalFormat = "0:#0.00##";
public class ExpressionBuilder
{
// Define some of our default filtering options
private static MethodInfo containsMethod = typeof(string).GetMethod("Contains", new[] { typeof(string) });
private static MethodInfo startsWithMethod = typeof(string).GetMethod("StartsWith", new[] { typeof(string) });
private static MethodInfo endsWithMethod = typeof(string).GetMethod("EndsWith", new[] { typeof(string) });
public static Expression<Func<T, bool>> GetExpression<T>(List<GridHelper.Filter> filters)
{
// No filters passed in #KickIT
@jrgcubano
jrgcubano / FilterPropertiesExample
Created October 28, 2014 12:41
Simple example to filter a collection using properties with dot notation.
public class Sport
{
public string Name {get; set;}
public string League {get; set;}
}
public class Person
{
public string Name {get; set;}
public Sport Sport {get; set;}
@jrgcubano
jrgcubano / OrderByHelper
Created October 28, 2014 12:54
Order by helper with expressions and dot notation
#region Process Data (sort, group, filter, etc)
public static EnumerableQuery GroupBy(this IOrderedQueryable source, string property)
{
return ApplyGroup(source, property, "GroupBy");
}
public static IOrderedQueryable OrderBy(this IQueryable source, string property)
{
return ApplyOrder(source, property, "OrderBy");
}
public abstract class ConfigurationElementCollection<TKey, TElement>
: ConfigurationElementCollection,
IList<TElement>, IDictionary<TKey, TElement>
where TElement : ConfigurationElement, new()
{
protected override ConfigurationElement CreateNewElement()
{
return new TElement();
}
// Declaracion del modulo de configuracion
angular
.module( 'dashboard.config', [] )
.constant( 'base_url' , 'http://www.domain.com/api' )
.constant( 'default_page', 'home' )
.constant( 'db_pages', [
{
name: 'statisticsOverview',
label: 'Dashboard',
icon: 'dashboard'
@jrgcubano
jrgcubano / CreateCertAndDeleteExample
Created November 6, 2014 10:48
Create and delete cert
Create Cert : (bat)
------------------------------------
echo off
set SERVER_NAME=localhost
echo ---------------------------------------------------------------------
echo cleaning up the certificates from previous run
certmgr.exe -del -r CurrentUser -s TrustedPeople -c -n %SERVER_NAME%
certmgr.exe -del -r LocalMachine -s My -c -n %SERVER_NAME%
@jrgcubano
jrgcubano / LinqPadExampleSelectMAny.cs
Last active August 29, 2015 14:09
Example SelectMany, Parallell, GroupBy and Select using anonymous objects
public class Contract
{
public string Code {get; set;}
}
public class Charge
{
public string Name {get; set;}
public decimal Total {get; set;}
}
@jrgcubano
jrgcubano / PasswordHelper.cs
Created January 5, 2015 08:58
PasswordHelper (create hashed password with salt and verify on access)
public class PasswordHelper
{
public static Byte[] GerenateSalt()
{
byte[] saltBytes = new byte[128];
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
rng.GetNonZeroBytes(saltBytes);
return saltBytes;
}
@jrgcubano
jrgcubano / ApplicationInfo.cs
Created January 14, 2015 09:00
Helper to get application information
using System.Reflection;
using System.IO;
using System;
using System.Runtime.InteropServices;
namespace PMS_UI.Infrastructure.Applications
{
/// <summary>
/// This class provides information about the running application.