Skip to content

Instantly share code, notes, and snippets.

View khalidsalomao's full-sized avatar

Khalid Salomão khalidsalomao

  • Rio de Janeiro, RJ, Brasil
View GitHub Profile
@khalidsalomao
khalidsalomao / SimpleMemoryCache.cs
Last active December 13, 2015 20:09
Simple object in memory cache, with a background timer to clear expired objects.
using System;
using System.Linq;
namespace Helpers
{
/// For updated code: https://gist.github.com/khalidsalomao/4968274
/// Articles on CodeProject
/// <summary>
///
@khalidsalomao
khalidsalomao / CommonExtensions.cs
Created February 17, 2013 00:23
Some helpful extension methods
using System;
using System.Collections.Generic;
using System.Linq;
namespace Helpers
{
public static class CommonExtensions
{
public static IEnumerable<IEnumerable<T>> Batch<T> (this IEnumerable<T> collection, int batchSize)
{
@khalidsalomao
khalidsalomao / SimpleTimedQueue.cs
Last active December 13, 2015 21:29
Simple timed queue that will fire the OnExecution event with the queued items for every MaintenanceInterval timespan.
using System;
using System.Collections.Generic;
using System.Linq;
namespace Helpers
{
/// For updated code: https://gist.github.com/khalidsalomao/4977955
/// Articles on CodeProject
/// <summary>
@khalidsalomao
khalidsalomao / SimpleObjectPool.cs
Last active December 14, 2015 02:28
Simple Object Pool
using System;
using System.Linq;
namespace Helpers
{
/// For updated code: https://gist.github.com/khalidsalomao/4968274
/// Articles on CodeProject
public class SimpleObjectPool<T> where T : class
{
using System;
using System.Collections.Generic;
using System.Linq;
namespace Helpers
{
/// For updated code: https://gist.github.com/khalidsalomao/5065646
/// Articles on CodeProject
public class SimpleConfiguration
@khalidsalomao
khalidsalomao / MongoDbContext.cs
Created March 29, 2013 01:08
A global MongoDb configuration helper
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MongoDB.Driver;
namespace SimpleMongoDb
{
public class MongoDbContext
{
@khalidsalomao
khalidsalomao / Benchmark - Reflection vs Lambda Expression.linq
Last active September 8, 2015 15:44
LinqPad - C# Benchmark - Reflection vs Lambda Expression
<Query Kind="Program" />
void Main()
{
// initialization
if (System.Diagnostics.Debugger.IsAttached)
System.Diagnostics.Debugger.Break ();
Console.WriteLine ("=========================================");
Console.WriteLine ("Warm up phase ...");
@khalidsalomao
khalidsalomao / Benchmark - Reflection GetProperties cache.linq
Created September 8, 2015 15:46
LinqPad - C# Benchmark - Reflection GetProperties cache
<Query Kind="Program" />
void Main()
{
// initialization
if (System.Diagnostics.Debugger.IsAttached)
System.Diagnostics.Debugger.Break ();
Console.WriteLine ("=========================================");
Console.WriteLine ("Warm up phase ...");
@khalidsalomao
khalidsalomao / SimpleFileLock.cs
Last active May 11, 2016 15:23
A simple lock mechanism using the filesystem. The lock contains a timestamp that is periodically updated, but will expire if the application dies...
#region * License *
/*
SimpleHelpers - SimpleFileLock
Copyright © 2015 Khalid Salomão
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the “Software”), to deal in the Software without
restriction, including without limitation the rights to use,
@khalidsalomao
khalidsalomao / simpleQueryString.js
Last active May 11, 2016 21:54
A simple query string encoder and decoder.
/*! simpleQueryString v0.5.0 - MIT license */
var simpleQueryString = (function () {
"use strict";
// is Array polyfill: https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
if (!Array.isArray) {
Array.isArray = function (vArg) {
return Object.prototype.toString.call(vArg) === "[object Array]";
};
}