Skip to content

Instantly share code, notes, and snippets.

/// <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
{
@Jalalx
Jalalx / KeepForkUpdate.md
Last active January 8, 2018 18:03 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@Jalalx
Jalalx / PhoneNumberRegex.cs
Created December 10, 2017 11:17
Regex to detect Irans mobile numbers
public static bool IsMobileNumber(this string value)
{
return Regex.IsMatch(value ?? string.Empty, @"^((\+9|\+989|\+\+989|9|09|989|0989|00989)(01|02|03|10|11|12|13|14|15|16|17|18|19|20|21|22|30|31|32|33|34|35|36|37|38|39|90))(\d{7})$");
}
@Jalalx
Jalalx / PhonecallReceiver.java
Created November 12, 2017 06:16 — forked from ftvs/PhonecallReceiver.java
Detecting an incoming call coming to an Android device. Remember to set the appropriate permissions in AndroidManifest.xml as suggested in the Stackoverflow link. Usage example in comments. Source: http://stackoverflow.com/a/15564021/264619 Explanation: http://gabesechansoftware.com/is-the-phone-ringing/#more-8
package com.gabesechan.android.reusable.receivers;
import java.util.Date;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.TelephonyManager;
public abstract class PhonecallReceiver extends BroadcastReceiver {
@Jalalx
Jalalx / gist:fdbadb6e67790c44a72bc110dfad1dd3
Created May 14, 2017 06:56 — forked from lontivero/gist:593fc51f1208555112e0
Generates Markdown from VS XML documentation file
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
namespace GithubWikiDoc
{
@Jalalx
Jalalx / BotUserAgentUtility.cs
Created October 24, 2016 13:00
Detects most know crowlers
public class BotUserAgentUtility
{
public static bool IsBot(string userAgent)
{
var Crawlers = new List<string>()
{
"googlebot","bingbot","yandexbot","ahrefsbot","msnbot","linkedinbot","exabot","compspybot",
"yesupbot","paperlibot","tweetmemebot","semrushbot","gigabot","voilabot","adsbot-google",
"botlink","alkalinebot","araybot","undrip bot","borg-bot","boxseabot","yodaobot","admedia bot",
"ezooms.bot","confuzzledbot","coolbot","internet cruiser robot","yolinkbot","diibot","musobot",
@Jalalx
Jalalx / TimeSpan.js
Created October 1, 2016 08:35
Simple TimeSpan for javascript
function TimeSpan(seed) {
//"00:00:00"
var self = this;
self.hour = seed.substr(0, 2);
self.minute = seed.substr(3, 2);
self.second = seed.substr(6, 2);
self.addSecond = function () {
self.second++;
if (self.second >= 60) {
@Jalalx
Jalalx / heaviest_it_table_index.sql
Last active June 20, 2020 17:55
Query for determining heaviest hit tables and indexes. More info: https://goo.gl/Zxx2U8
--get most used tables
SELECT
db_name(ius.database_id) AS DatabaseName,
t.NAME AS TableName,
SUM(ius.user_seeks + ius.user_scans + ius.user_lookups) AS NbrTimesAccessed
FROM sys.dm_db_index_usage_stats ius
INNER JOIN sys.tables t ON t.OBJECT_ID = ius.object_id
WHERE database_id = DB_ID('MyDb')
GROUP BY database_id, t.name
ORDER BY SUM(ius.user_seeks + ius.user_scans + ius.user_lookups) DESC
@Jalalx
Jalalx / OpenSslCert.bat
Created September 7, 2016 09:47
Batch script to generate Open SSL self signed certificate
# Batch script to generate Open SSL self signed certificate
openssl req -new -x509 -nodes -newkey rsa:1024 -keyout webhook_pkey.key -out webhook_cert.pem -days 3650
openssl pkcs12 -export -out newfile.pfx -inkey privcert.key -in pubcert.pem -certfile CARoots.pem
@Jalalx
Jalalx / sample.cs
Last active May 27, 2016 03:46
Calling member method of a normal class without instantiating.
public class Foo
{
public void Method1()
{
Console.WriteLine("Method1: this == null: {0}", this == null);
}
}
var m1 = typeof(Foo).GetMethod("Method1");
var method1 = Delegate.CreateDelegate(typeof(Action<Foo>), m1) as Action<Foo>;