Skip to content

Instantly share code, notes, and snippets.

View HamedFathi's full-sized avatar
🌎

Hamed Fathi HamedFathi

🌎
View GitHub Profile
@HamedFathi
HamedFathi / tailwind-rtl.js
Created May 17, 2019 16:52 — forked from patrikengborg/tailwind-rtl.js
Function for Tailwind to add a custom variant plugin for RTL sites.
function ({ addVariant }) {
addVariant('rtl', ({ modifySelectors, separator }) => {
modifySelectors(({ className }) => {
return `[dir="rtl"] .rtl${separator}${className}`
})
})
}
@HamedFathi
HamedFathi / 1.README.md
Created May 19, 2019 06:29 — forked from varemenos/1.README.md
Git log in JSON format

Get Git log in JSON format

git log --pretty=format:'{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},'

The only information that aren't fetched are:

  • %B: raw body (unwrapped subject and body)
  • %GG: raw verification message from GPG for a signed commit

This relies on the Newtonsoft.Json package. Once added as a package reference to your C# project, add the following class. This is an extension methods class, containing two convenience-centric extension methods:

using static Newtonsoft.Json.JsonConvert;

namespace IEvangelist.Extensions
{
    public static class ObjectExtensions
    {
        public static T FromJson<T>(this string json)
@HamedFathi
HamedFathi / gist:8d2ac1e02ebedc0b7399d84c1534bd50
Created June 6, 2019 08:26 — forked from ebraminio/gist:5292017
Check Iranian National Code Validity - بررسی صحت کد ملی ایرانی - Clojure, C#, Ruby, JavaScript, Python, Scala, Java 8, PHP, C, Go, Swift, Kotlin
// Check Iranian National Code Validity - Clojure, C#, Ruby, JavaScript, Python, Scala, Java 8, PHP, C, Go, Swift, Kotlin, Groovy
// بررسی صحت کد ملی ایران - کلوژر، سی‌شارپ، روبی، جاوااسکریپت، پایتون، اسکالا، جاوا ۸، پی‌اچ‌پی، سی، گو، سوئیفت، کاتلین، گرووی
// در نسخه‌های قبل یکسان بودن اعداد نا معتبر تشخیص داده می‌شد ولی
// اعداد یکسان نامعتبر نیست http://www.fardanews.com/fa/news/127747
// بعضی از پیاده‌سازی‌ها سریع نیستند، می‌توانید نسخهٔ خود را بر پایهٔ
// نسخهٔ سی یا گو ایجاد کنید که بهترین سرعت را داشته باشد
/**
@HamedFathi
HamedFathi / tokenize.js
Created July 10, 2019 08:20 — forked from BonsaiDen/tokenize.js
Small, simple, JS tokenizer in JS.
/**
* Simple JavaScript tokenizer (not a full parser!!!)
*
* Portions taken from Narcissus by Brendan Eich <[email protected]>.
*/
/*jshint evil: true, regexdash: false, regexp: false */
var KEYWORDS = [
'break',
@HamedFathi
HamedFathi / Recursive-descent-backtracking.js
Created December 4, 2019 09:40 — forked from DmitrySoshnikov/Recursive-descent-backtracking.js
Recursive descent parser with simple backtracking
/**
* = Recursive descent parser =
*
* MIT Style License
* By Dmitry Soshnikov <dmitry.soshnikov@gmail.com>
*
* In this short lecture we'll cover the basic (non-predictive, backtracking)
* recursive descent parsing algorithm.
*
* Recursive descent is an LL parser: scan from left to right, doing
@HamedFathi
HamedFathi / JSON.cs
Created December 9, 2019 06:06 — forked from yasar11732/JSON.cs
JSON parser and stringifier implemented in C# (Recursive Descent Parser)
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace MiniWebFramework
{
public enum JSONValueType
/* eslint-disable no-unused-vars */
/* eslint-disable no-else-return */
// JSX constructor, similar to createElement()
export const h = (type, props, ...children) => {
return {
type,
// Props will be an object for components and DOM nodes, but a string for
// text nodes
props,
@HamedFathi
HamedFathi / ArrayDeconstructionExtensions.cs
Created June 11, 2020 15:36 — forked from waf/ArrayDeconstructionExtensions.cs
Add deconstruction (i.e. destructuring) syntax support for arrays for C# 7
using System;
using System.Linq;
namespace Extensions
{
/// <summary>
/// Allow the up to the first eight elements of an array to take part in C# 7's destructuring syntax.
/// </summary>
/// <example>
/// (int first, _, int middle, _, int[] rest) = new[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
@HamedFathi
HamedFathi / DynamicPermissionManagementEntities.cs
Created April 1, 2021 22:09 — forked from rabbal/DynamicPermissionManagementEntities.cs
Domain Entities for Dynamic Permissions Management
public abstract class Entity
{
public long Id { get; set; }
[SuppressMessage("ReSharper", "BaseObjectGetHashCodeCallInGetHashCode")]
[SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
public override int GetHashCode()
{
if (IsTransient())
return base.GetHashCode();