Skip to content

Instantly share code, notes, and snippets.

View mirismaili's full-sized avatar

S. Mahdi Mir-Ismaili mirismaili

View GitHub Profile
@mirismaili
mirismaili / README.md
Last active November 24, 2018 05:32
A wrapper for `java.nio.file.WatchService` that uses a hacky way to detect RENAME event instead of two sequential DELETE/CREATE events. Also, it uses callbacks to triggering events.

Extend WatchService class and override callbacks (onEntryCreated(), ...) to trigger related event.

There are two groups of callbacks:

  1. J group: onEntryCreatedJ(), onEntryModifiedJ(), onEntryDeletedJ(), onOverflowedJ():

    These are default (un-manipulated) callbacks. They are invoked regularly when a related event occurs. You should override them when you wish trigger native java.nio.file.WatchService events.

    For example override:

@mirismaili
mirismaili / unicode-numbering-systems.js
Created February 22, 2020 14:25
Unicode Numbering Systems
/**
* Created on 1398/12/3 (2020/2/22).
* @author {@link https://mirismaili.github.io S. Mahdi Mir-Ismaili}
*/
'use strict'
// console.log((1234567890).toLocaleString('en-u-nu-arab', {useGrouping: false}))
// console.log((1234567890).toLocaleString('en-u-nu-arabext', {useGrouping: false}))
// console.log((1234567890).toLocaleString('en-u-nu-bali', {useGrouping: false}))
// console.log((1234567890).toLocaleString('en-u-nu-beng', {useGrouping: false}))
/**
* Created on 1399/8/22 (2020/11/12).
* @author {@link https://mirismaili.github.io S. Mahdi Mir-Ismaili}
*/
export default function reduxLogger(store) {
return function wrapDispatch(next) {
return function handleAction(action) {
const state0 = store.getState()
const result = next(action)
@mirismaili
mirismaili / CrossOver.cpp
Created January 24, 2021 12:48
Simple algorithmic trading with SierraChart
#include "sierrachart.h"
SCDLLName("SCTradingExample1")
/*
Overview
--------
An example of a trading system that enters a new position or
reverses an existing one on the crossover of two study Subgraphs.
@mirismaili
mirismaili / pre-commit
Last active June 21, 2021 08:08
Es-lint precommit hook
#!/bin/bash
# Created on 1400/3/31 (2021/6/21).
# Author: [S. Mahdi Mir-Ismaili](https://mirismaili.github.io)
# Based on: https://gist.github.com/linhmtran168/2286aeafe747e78f53bf
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".jsx\{0,1\}$")
if [[ "$STAGED_FILES" == "" ]]; then
exit 0
const fs = require("fs");
const keywords = JSON.parse(fs.readFileSync("keywords.txt").toString());
const news = JSON.parse(fs.readFileSync("news.txt").toString());
const start1 = Date.now();
const foundNews = []
for (const aNews of news) {
const stack = [];
for (const keyword of keywords) {
const fs = require("fs");
const keywords = JSON.parse(fs.readFileSync("keywords.txt").toString());
const news = JSON.parse(fs.readFileSync("news.txt").toString());
console.time();
news.reduce((foundNews, aNews) => {
const stack = keywords.reduce((stack, keyword) => {
if (aNews["title"].includes(keyword["title"]) || aNews["lead"]?.includes(keyword["title"]))
stack.push(keyword["title"]);
@mirismaili
mirismaili / post-commit
Created November 13, 2021 19:41
1. Auto tag commit, based on npm-version 2. Auto calculate the build-version and insert it into package.json file
#!/bin/bash
# ATTENTION: YOU NEED TO FIRST PUT `build-version: 0` FIELD IN YOUR "package.json" FILE!
version=$(grep -oP '\"version\":\s*\"\K\d+\.\d+\.\d+' package.json) # extract `version` from "package.json". ex: 2.0.4
git tag v$version 2>/dev/null # ex: `git tag v2.0.4` # Auto tag version if needed (if not already existed).
# Calculate `buildVersion`:
@mirismaili
mirismaili / vazir-font.js
Created January 19, 2022 13:38
vazir font variants
import vazirBlackWoff2 from './Vazir-Black.woff2'
import vazirBoldWoff2 from './Vazir-Bold.woff2'
import vazirLightWoff2 from './Vazir-Light.woff2'
import vazirMediumWoff2 from './Vazir-Medium.woff2'
import vazirThinWoff2 from './Vazir-Thin.woff2'
import vazirWoff2 from './Vazir.woff2'
/**
* Created on 1399/8/30 (2020/11/20).
* @author {@link https://mirismaili.github.io S. Mahdi Mir-Ismaili}
/**
* Created on 1400/11/5 (2022/1/25).
* @author {@link https://mirismaili.github.io S. Mahdi Mir-Ismaili}
*/
/**
* @see https://stackoverflow.com/a/3540295/5318303
* @type {boolean}
*/
export const isMobileDevice =