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 / 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`:
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"]);
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) {
@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
@mirismaili
mirismaili / download-pipe-extract.js
Last active February 14, 2024 10:26
Fast download>--pipe-->extract using node.js. For `tar` and `.tar.gz` files
/**
* Download and extract `.tar.gz` file using node.js
*
* Created on 1400/2/7 (2021/4/27).
* @author {@link https://mirismaili.github.io S. Mahdi Mir-Ismaili}
*/
import http from 'http'
import https from 'https'
import tar from 'tar'
@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.
/**
* 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 / 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}))
@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: