Skip to content

Instantly share code, notes, and snippets.

class CarsCache
{
private AsyncExpiringLazy<List<Car>> Cars { get; set; }
public CarService CarService { get; set; }
public CarsCache()
{
Cars = new AsyncExpiringLazy<List<Car>>(async metadata =>
{
$.when(
$.get( "cldr/main/en/ca-gregorian.json" ),
$.get( "cldr/main/fr/ca-gregorian.json" ),
$.get( "cldr/supplemental/likelySubtags.json" ),
$.get( "cldr/supplemental/timeData.json" ),
$.get( "cldr/supplemental/weekData.json" )
).then(function() {
return [].slice.apply( arguments, [ 0 ] ).map(function( result ) {
return result[ 0 ];
});
[Required]
[Range(Min=0, Max=int.MaxValue)
public decimal Salary { get; set; }
@pparadis
pparadis / Horror.cs
Created April 26, 2016 10:46
Horror
foreach (var r in registrations)
{
if ((count++) % 10 == 0);
Console.Write("\r{0} %", Math.Round((double)count / registrations.Count * 100d));
}
@pparadis
pparadis / this-is-bridge.cs
Created February 8, 2016 11:35
//this is bridge
//Get the employee list
var employees = EmployeeService.GetAllEmployees();
//Sort employee by name
employees = employees.OrderBy(p => p.Name);
//Send email to employee
MailService.SendMail(employee.Email);
//Get today's date
IEnumerable<IGrouping<int, string>> query = elements.GroupBy(k => k.Age, e => e.Name);
@pparadis
pparadis / known-color.cs
Last active December 23, 2015 12:18
Known Colors
var names = (KnownColor[])Enum.GetValues(typeof(KnownColor));
var namesList = names.ToList();
//Retirer ceux que vous considérez indésirables
namesList.Remove(KnownColor.White);
namesList.Remove(KnownColor.HighlightText);
namesList.Remove(KnownColor.ControlLight);
namesList.Remove(KnownColor.ControlLightLight);
var names = collection
.Where(item => item.Name == "Fred")
.OrderBy(item => item.Age)
.Select(item => item.Name)
var names = from item in collection
where item.Name == "Fred"
order by item.Age
select item.Name;
class Program
{
static void Main(string[] args)
{
var error = new System.Exception("1", new System.Exception("2", new System.Exception("3")));
for (var exception = error; exception != null; exception = exception.InnerException)
{
Console.Out.WriteLine("exeption " + exception.Message);
}