Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Matin Kaboli matinkaboli

🏠
Working from home
Block or report user

Report or block matinkaboli

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gitaliases.sh
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'
View euler34.go
package main
import (
"fmt"
"os"
"strconv"
"strings"
)
func main() {
View euler30.py
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
View euler29.py
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 Feb 11, 2018
Show persian date with moment-jalaali in Node.js
View moment-jalaali.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 Feb 11, 2018
Check if the uploaded file is an image and then save it somewhere (with format) in nodejs
View storage.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 / storage.js
Created Feb 11, 2018
Check if uploaded file is an image in Node.js
View storage.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 Feb 11, 2018
Random String in Node.js (only with built-it packages)
View randomString.js
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();
View euler23.js
function checkDivisor(num) {
let sum = 0;
const check = Math.ceil(num / 2);
for (let i = 0; i <= check; i++) {
if (num % i === 0) {
sum += i;
}
}
return sum > num;
}
View euler22.py
names = open('names.txt', 'r')
list_names = sorted(names.read().replace('"', '').split(','))
letters = {
'A': 1,
'B': 2,
'C': 3,
'D': 4,
'E': 5,
'F': 6,
'G': 7,
You can’t perform that action at this time.