This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Un diccionari que només manté les dades X temps.. | |
public class TemporalDictionary<T,Y> : IDictionary<T,Y> { | |
Dictionary<T, Y> internalDic; | |
Dictionary<T, DateTime> lastUpdate; | |
public TimeSpan ExpiringTime { get; set; } | |
public Y this[T key] | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SemaphoreWrapper : IDisposable | |
{ | |
Semaphore _semaphore; | |
public SemaphoreWrapper(Semaphore Semaphore) | |
{ | |
_semaphore = Semaphore; | |
_semaphore.WaitOne(); | |
} | |
public void Dispose() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var d = 1.0d; // double | |
var f = 1.0f; // float | |
var m = 1.0m; // decimal | |
var i = 1; // int | |
var ui = 1U; // uint | |
var ul = 1UL; // ulong | |
var l = 1L; // long | |
http://stackoverflow.com/questions/5820721/c-sharp-short-long-int-literal-format |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var pagedItems = this.DataCollection.Skip((this.CurrentPageIndex -1) * this.ItemsPerPage).Take(this.ItemsPerPage).ToList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE: Require files 'ListOpenedFileDrv_32.sys' and 'OpenFileFinder.dll' | |
public class OpenFiles { | |
public enum OF_TYPE { | |
FILES_ONLY = 1, | |
MODULES_ONLY = 2, | |
ALL_TYPES = 3 | |
}; | |
public struct OF_INFO_t { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void ExecuteSafe(this Mutex MyMutex, Action myPiceOfCode) | |
{ | |
try { | |
//while(!MyMutex.WaitOne(100)) {System.Threading.Thread.Sleep(100); } | |
MyMutex.WaitOne(); | |
myPiceOfCode(); | |
} finally { | |
MyMutex.ReleaseMutex(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Print current system date& time in ISO 8601 format 2016-01-27T06:11:22Z | |
CString Utils::GetPrintableCurrentDate() { | |
SYSTEMTIME currentTime; | |
CString sCurrentDate; | |
GetSystemTime(¤tTime); | |
sCurrentDate.Format(_T("%04d-%02d-%02dT%02d:%02d:%02d.%03d") | |
,currentTime.wYear |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void HighPassFilter(cv::Mat &inputImage,cv::Mat &outputImage,double dSearchRatio) { | |
// Go float | |
cv::Mat fImage; | |
inputImage.convertTo(fImage, CV_32F); | |
// FFT | |
std::cout << "Direct transform...\n"; | |
cv::Mat fourierTransform; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Mesure time compsumption of piece of code | |
/// </summary> | |
/// <param name="action">Method to test (must be a method without parameters)</param> | |
/// <returns></returns>private TimeSpan Mesure(Action action) | |
public static TimeSpan Mesure(this Stopwatch watch,Action action) | |
{ | |
watch.Start(); | |
action(); |