Skip to content

Instantly share code, notes, and snippets.

View Jalalx's full-sized avatar

Jalal Amini Robati Jalalx

View GitHub Profile
@Jalalx
Jalalx / english-persian-dict.csv
Created July 25, 2019 19:06
An english to persian dictionary from https://bigdata-ir.com
We can't make this file beautiful and searchable because it's too large.
english,farsi
a few,کمي
a great deal of,يک دنيا
a handful,يک مشت
a la garconne,آلاگارسن
a little,اندکيی
a little,کمي
a little,اندکي
a little,کمکي
a little,اندکي
@Jalalx
Jalalx / DamerauLeveneshteinDistanceCalculator.cs
Created July 17, 2019 01:25
Damerau Leveneshtein Distance algorithm in C# (idea from https://www.youtube.com/watch?v=MiqoA-yF-0M)
using System;
namespace DamerauLeveneshteinDistanceCalculator
{
static class Program
{
public static int ComputeDamerauLeveneshteinDistance(string a, string b)
{
if (string.IsNullOrEmpty(a) && string.IsNullOrEmpty(b))
return 0;
@Jalalx
Jalalx / price_dollar_rl.json
Created July 13, 2019 17:59
Dollar prices (in Rials) from "1390/09/06" until "1398-04-20" obtained from http://www.tgju.org/chart-summary-ajax/price_dollar_rl?_=1563040392278
[["13,700","13,700","13,700","<span class='fa archive-icon fa-chevron-up'><\/span><span class='high close-price'>13,700<\/span>","2011\/11\/27","1390\/09\/06","1390-09-06"],["13,440","13,440","13,440","<span class='fa archive-icon fa-chevron-up'><\/span><span class='high close-price'>13,440<\/span>","2011\/11\/28","1390\/09\/07","1390-09-07"],["13,350","13,350","13,350","<span class='fa archive-icon fa-chevron-down'><\/span><span class='low close-price'>13,350<\/span>","2011\/11\/29","1390\/09\/08","1390-09-08"],["13,400","13,400","13,400","<span class='fa archive-icon fa-chevron-down'><\/span><span class='low close-price'>13,400<\/span>","2011\/11\/30","1390\/09\/09","1390-09-09"],["13,500","13,500","13,500","<span class='fa archive-icon fa-chevron-down'><\/span><span class='low close-price'>13,500<\/span>","2011\/12\/01","1390\/09\/10","1390-09-10"],["13,650","13,650","13,650","<span class='fa archive-icon fa-chevron-up'><\/span><span class='high close-price'>13,650<\/span>","2011\/12\/03","1390\/09\/12","1
@Jalalx
Jalalx / CallHierarchy.md
Last active July 20, 2019 07:27
ASP.NET WebForms Call Hierarchy

ASP.NET WebForms Call Hierarchy

Init

  1. Child User Control Init
  2. Parent User Control Init
  3. Master Page Init
  4. Page Init

Load

  1. Page Load
@Jalalx
Jalalx / CheckDatabaseObjects.sql
Created February 13, 2019 10:05
Checks if all database objects are OK. Code obtained from https://stackoverflow.com/a/5555554/375958
DECLARE @Name nvarchar(1000);
DECLARE @Sql nvarchar(1000);
DECLARE @Result int;
DECLARE ObjectCursor CURSOR FAST_FORWARD FOR
SELECT QUOTENAME(SCHEMA_NAME(o.schema_id)) + '.' + QUOTENAME(OBJECT_NAME(o.object_id))
FROM sys.objects o
WHERE type_desc IN (
'SQL_STORED_PROCEDURE',
'SQL_TRIGGER',
@Jalalx
Jalalx / SharedConditionalLock.cs
Last active February 5, 2019 15:40
Creates a conditional lock based on given boolean and a key. Threads with same key will be locked.
public class SharedConditionalLock : IDisposable
{
private static readonly ConcurrentDictionary<string, object> _locks = new ConcurrentDictionary<string, object>();
public SharedConditionalLock(string key, bool isEnabled)
{
Key = key;
IsEnabled = isEnabled;
if (isEnabled)
@Jalalx
Jalalx / gist:533e49503502c37b28659dfd54ba5b76
Created August 28, 2018 10:33 — forked from ebraminio/gist:5292017
Check Iranian National Code Validity - بررسی صحت کد ملی ایرانی - Clojure, C#, Ruby, JavaScript, Python, Scala, Java 8, PHP, C, Go
// Check Iranian National Code Validity - Clojure, C#, Ruby, JavaScript, Python, Scala, Java 8, PHP, C, Go, Swift
// بررسی صحت کد ملی ایران - کلوژر، سی‌شارپ، روبی، جاوااسکریپت، پایتون، اسکالا، جاوا ۸، پی‌اچ‌پی، سی، گو، سوئیفت
// در نسخه‌های قبل یکسان بودن اعداد نا معتبر تشخیص داده می‌شد ولی
// اعداد یکسان نامعتبر نیست http://www.fardanews.com/fa/news/127747
// بعضی از پیاده‌سازی‌ها سریع نیستند، می‌توانید نسخهٔ خود را بر پایهٔ
// نسخهٔ سی یا گو ایجاد کنید که بهترین سرعت را داشته باشد
/**
@Jalalx
Jalalx / CatchMsiProgress.cs
Created May 9, 2018 04:54
Describes how to catch msi progress...
// from https://www.codeproject.com/Articles/5773/Wrapping-the-Windows-Installer-2-0-API
IntPtr parent = IntPtr.Zero;
MsiInstallUILevel oldLevel =
MsiInterop.MsiSetInternalUI(MsiInstallUILevel.None |
MsiInstallUILevel.SourceResOnly, ref parent);
MsiInstallUIHandler oldHandler = null;
try
{
oldHandler =
@Jalalx
Jalalx / CachePageStatePersister.cs
Created January 8, 2018 18:01
Save view state in ASP.NET Cache
// From: https://weblogs.asp.net/ricardoperes/saving-view-state-in-cache
// Override following property in your pages.
// protected override PageStatePersister PageStatePersister
// {
// get
// {
// return (new CachePageStatePersister(this));
// }
// }
public class CachePageStatePersister : PageStatePersister
/// <summary>
/// Read more at: https://stackoverflow.com/a/14369695/375958
/// </summary>
public static class HighResolutionDateTime
{
private static long lastTimeStamp = DateTime.UtcNow.Ticks;
public static long UtcNowTicks
{
get
{