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 / tradingview-strategy-backtester-boilerplate.pine
Last active July 31, 2021 15:08
A simple template for backtesting a trading view pine strategy
//@version=3
// TODO: update strategy name
strategy("{STRATEGY NAME}", overlay=true)
// === TA LOGIC ===
//
//
// TODO: PUT YOUR TA LOGIC HERE
LONG_SIGNAL_BOOLEAN = crossover(sma(close, 13), sma(close, 34))
function checkConnection(callback, timeout) {
var checkStatus = function() {
report((xhr.status && xhr.status < 12000) ? 'up' : 'down');
};
var last = '';
var report = function(status){
if (status !== last){
last = status;
callback(status === 'up');
}
@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]";
};
}
@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 / 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 / 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 / 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
{
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 / 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
{
@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>