Skip to content

Instantly share code, notes, and snippets.

View matinkaboli's full-sized avatar
🌀
Focusing

Matin Kaboli matinkaboli

🌀
Focusing
View GitHub Profile
@matinkaboli
matinkaboli / issuer-ends-with.mjs
Created October 24, 2022 20:01
Create addresses in the Stellar network that end with X.
import fs from "fs";
import { Keypair } from "stellar-sdk";
const END_WITH = "PAL";
const COUNT = 2;
const OUTPUT_FILE = "./keys.json";
let foundCounter = 0;
let foundKeys = [];
// SPDX-License-Identifier: MIT
pragma solidity ^0.8;
interface CErc20 {
function balanceOf(address) external view returns (uint);
function mint(uint) external returns (uint);
function exchangeRateCurrent() external returns (uint);
@matinkaboli
matinkaboli / gitaliases.sh
Created July 19, 2018 05:02
My Git Aliases
alias ga='git add'
alias gaa='git add .'
alias gst='git status'
alias gcam='git commit -m'
alias gp='git push'
alias gl='git pull'
package main
import (
"fmt"
"os"
"strconv"
"strings"
)
func main() {
def digitPower(num):
numString = str(num)
su = 0
for j in range(0, len(numString)):
su += int(numString[j]) ** 5
if num == su:
return True
combinations = []
for i in range(2, 101):
for j in range(2, 101):
p = i ** j
if p not in combinations:
combinations.append(p)
@matinkaboli
matinkaboli / moment-jalaali.js
Created February 11, 2018 15:28
Show persian date with moment-jalaali in Node.js
import moment from 'moment-jalaali';
moment.loadPersian({ usePersianDigits: true, dialect: 'persian-modern' });
const persianDate = date => moment(date).fromNow();
export default persianDate;
@matinkaboli
matinkaboli / storage.js
Created February 11, 2018 15:26
Check if the uploaded file is an image and then save it somewhere (with format) in nodejs
import crypto from 'crypto';
import multer from 'multer';
const storage = multer.diskStorage({
destination(req, file, cb) {
cb(null, './uploads/');
},
filename(req, file, cb) {
crypto.pseudoRandomBytes(16, (err, raw) => {
const extension = file.mimetype.split('/')[1];
@matinkaboli
matinkaboli / storage.js
Created February 11, 2018 15:23
Check if uploaded file is an image in Node.js
import crypto from 'crypto';
import multer from 'multer';
const storage = multer.diskStorage({
destination(req, file, cb) {
cb(null, './uploads/');
},
filename(req, file, cb) {
crypto.pseudoRandomBytes(16, (err, raw) => {
const extension = file.mimetype.split('/')[1];
@matinkaboli
matinkaboli / randomString.js
Created February 11, 2018 15:22
Random String in Node.js (only with built-it packages)
import crypto from 'crypto';
function randomString() {
return new Promise((resolve, reject) => {
crypto.pseudoRandomBytes(16, (err, raw) => {
if (err) {
reject(err);
} else {
const r = raw.toString('hex') + Date.now();