Skip to content

Instantly share code, notes, and snippets.

@sijad
sijad / persian_arabic_to_english.js
Last active June 7, 2024 04:52
convert Persian and Arabic numbers to English
function convertToEnglishNumbers(input) {
let o = '';
for (const c of input) {
const n = c.codePointAt(0);
if (n >= 1632 && n <= 1641) {
o += n - 1632;
} else if (n >= 1776 && n <= 1785) {
o += n - 1776;
} else {
import { Client } from 'minio';
const maxAllowedSize = 1024 * 1024 * 50; // 50MB
const expireTime = 8 * 60 * 60; // 8 hour
const minioClient = new Client({
endPoint: S3_ENDPOINT,
port: 443,
accessKey: S3_ACCESS_KEY,
secretKey: S3_SECRET_KEY,
Verifying my Blockstack ID is secured with the address 1MJEB2Aqz1Wh8mMoHgkze4RDusAUWWZAch https://explorer.blockstack.org/address/1MJEB2Aqz1Wh8mMoHgkze4RDusAUWWZAch
@sijad
sijad / .env
Last active May 25, 2019 06:19
my docker-sqitch.sh
# APP settings
DATABASE_URL=//user:secret@localhost/db-name
# SQITCH settings
SQITCH_FULLNAME=
SQITCH_EMAIL=
[GENERAL]
# Enable or disable the script execution
Enabled: True
# SYSFS path for checking if the system is running on AC power
Sysfs_Power_Path: /sys/class/power_supply/AC*/online
## Settings to apply while connected to Battery power
[BATTERY]
# Update the registers every this many seconds
Update_Rate_s: 30
@sijad
sijad / gebaard.toml
Last active February 20, 2019 14:55
my gebaard config, similar to macos gesture for linux (KDE)
[commands.swipe.four]
up = "qdbus org.kde.kglobalaccel /component/kwin org.kde.kglobalaccel.Component.invokeShortcut Expose"
down = ""
left = "qdbus org.kde.KWin /KWin nextDesktop"
right = "qdbus org.kde.KWin /KWin previousDesktop"
@sijad
sijad / rn-to-base64.ts
Created January 22, 2019 18:57
react native fetch and convert file to base64
interface FileReader {
readAsDataURL(blob: Blob): string;
onloadend(): void;
result: string;
}
declare var FileReader: {
prototype: FileReader;
new (): FileReader;
};
@sijad
sijad / paste_in_console.js
Last active March 23, 2019 17:06
follow all hackerone programs, open https://hackerone.com/hacktivity, paste and run this code in your browser console
fetch('https://hackerone.com/current_user')
.then(res => res.json())
.then(user => {
fetch('https://hackerone.com/programs/search?query=type%3Ahackerone&sort=published_at%3Adescending&page=1&limit=1000')
.then(res => res.json())
.then(res => res.results)
.then(res => res.forEach((r, i) => {
setTimeout(() => {
var url = `https://hackerone.com${r.url}/policy_subscriptions`;
fetch(url)
@sijad
sijad / read-only-filesystem-runtime-change.rs
Last active August 29, 2018 16:21
rust readonly filesystem based on filesystem-rs
extern crate filesystem;
use std::fs::{self};
use std::io::{Result, Error, ErrorKind};
use std::path::{Path, PathBuf};
use filesystem::{OsFileSystem, FileSystem};
#[derive(Clone, Debug, Default)]
pub struct OsSafeFileSystem {
fs: OsFileSystem,
const twemojiPath = './twemoji/2';
const fs = require('fs');
const path = require('path');
const twemoji = require(`${twemojiPath}/twemoji.npm`);
const allCodes = fs.readdirSync(`${twemojiPath}/assets`).map(name => path.basename(name, '.ai'));
const gemoji = JSON.parse(fs.readFileSync('gemoji.json'));