Skip to content

Instantly share code, notes, and snippets.

@gazlu
gazlu / select2-custom-ajax
Created October 16, 2015 18:40
Custom ajax implementation with Select2 - angular, xhr friendly
S2.define('select2/data/remoteQuery', [
'./array',
'../utils',
'jquery'
], function (ArrayAdapter, Utils, $) {
function RemoteQueryAdapter($element, options) {
this.ajaxOptions = this._applyDefaults(options.get('remoteQuery'));
if (this.ajaxOptions.processResults != null) {
this.processResults = this.ajaxOptions.processResults;
@gazlu
gazlu / DataRepository.cs
Created September 4, 2015 05:12
Call Stored Procedure with DbContext without including in EDMX
public class DataRepository<T> : IDataRepository<T>
where T : class, new()
{
private DbContext context;
Logger log = new Logger();
public DataRepository()
{
}
@gazlu
gazlu / CSVHelper.cs
Created July 4, 2015 20:24
Simple.Data ResultSet to CSV
public static class CSVHelper
{
/// <summary>
/// Usage:
/// CSVHelper.ToCsv(
/// ",",
/// resultSet,
/// new List<KeyValuePair<string, string>>
/// {
/// new KeyValuePair<string,string>("caf_no", "'")
@gazlu
gazlu / Retrier.cs
Created December 10, 2013 05:44
Retry logic in c#, for max number of attempts and for expected value.
public class Retrier<TResult>
{
/// <summary>
/// Retry to perform an operation/function
/// </summary>
/// <param name="func">Function to retry</param>
/// <param name="maxRetries">Maximum retires</param>
/// <param name="delayInMilliseconds">Delay on millies, 0 by default</param>
/// <returns>Result of the Function</returns>
public TResult TryBool(Func<TResult> func, int maxRetries, int delayInMilliseconds = 0)