Skip to content

Instantly share code, notes, and snippets.

View MSHADroo's full-sized avatar
🏠
Working from home

MSHADroo MSHADroo

🏠
Working from home
  • SabaIdea
  • IRAN - Tehran
View GitHub Profile
@MSHADroo
MSHADroo / WPimageDownloader.php
Created September 18, 2023 15:52
Wordpress media gallery image downloader from wordpress api
set_time_limit(0);
$curl = curl_init();
try {
for ($page = 1; $page < 100; $page++) {
file_put_contents('progress.log', 'page: ' . $page, FILE_APPEND);
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://www.{DOMAIN}.com/wp-json/wp/v2/media?page=' . $page . '&media_type=image',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
@MSHADroo
MSHADroo / siamese_imageDataGenerator.py
Last active August 27, 2022 15:34
Tensorflow/keras custom imageDataGenerator for siamese network that can pair positive and negative image source directory
import tensorflow as tf
import numpy as np
from keras.preprocessing.image import ImageDataGenerator
import math
class CustomDataGen(tf.keras.utils.Sequence):
def __init__(self, path, batch_size, target_size=(224, 224, 3), shuffle=False):
train_datagen = ImageDataGenerator()
generator_train = train_datagen.flow_from_directory(path, class_mode="sparse")
@MSHADroo
MSHADroo / checkSMSLength.php
Created February 3, 2020 08:13
php check persian and english sms length
<?php
function checkSMSLength($text) {
$ucs2 = preg_match('/[^\x00-\x7E]/', $text);
if (!$ucs2){
$text = preg_replace('/([[\]{}~^|\\\\])/', "\\$1",$text);
}
$strLength = mb_strlen($text);
$unitLength = $ucs2 ? 70 : 160;
@MSHADroo
MSHADroo / git.md
Last active February 3, 2019 21:23
Git Commands

git init //git init
git status //show the status of git directory
git add . //add all file of direcotry to stage
git commit -m "message" //commit the statge
git commit -a -m "message" //add modified files to stage and commit
git rm --cached filename //remove file from stage
git diff //show diff of commited state with modified file
git diff --help //show diff help
git log //show all commit informations
git log --help //help for git log

<html>
<head></head>
<body>
<script>
var AudioContext , audioContext , currentBuffer ;
// AUDIO CONTEXT
function call() {
@MSHADroo
MSHADroo / check_national_code.sql
Last active May 22, 2019 11:50
Mysql function: validate Iran national code
DELIMITER $$
CREATE FUNCTION CHECK_NATIONAL_CODE(national_code VARCHAR(50))
RETURNS BOOLEAN
DETERMINISTIC
BEGIN
DECLARE c INT;
DECLARE n INT;
DECLARE r INT;
IF length(national_code) != 10