Skip to content

Instantly share code, notes, and snippets.

View meysampg's full-sized avatar
🖖
bit bit 0 bit

Meysam P. Ganji meysampg

🖖
bit bit 0 bit
View GitHub Profile
@meysampg
meysampg / changeName.py
Created June 10, 2015 03:56
Rename Downloaded file from YouTube with Filegir.com
import os, glob, sys
import urllib.parse as up
# Titles contain name of videos, like ```Supervised and Unsupervised Learning```
fpTitle = open('Titles', 'r')
# listDwn contain name of files that saved from filegir.com, like ```StatsLearning_Lect1_2b_111213_v2_%5BLvaTokhYnDw%5D_%5Btag22%5D.mp4```
fpListDwn = open('listDwn', 'r')
titles = fpTitle.readlines()
function result = indToBernstienInd(d, k)
% Convert ordinary order to lexicographical order.
% Input:
% @d: integer, dimension of spline space.
% @k: integer, position on ordinary sequence order
% Output:
% @result: vector[3], position of k on exicography order
result = zeros(1,3);
delt = @(k) ceil((-3 + sqrt(9+8*(k-1)))/2);
@meysampg
meysampg / rtl_css_prestashop.tpl
Created September 2, 2015 06:19
Automatic load rtl.css for RTL languages in PrestaShop
{* Check for RTL langguages and automatically load rtl.css from CSS folder of theme for RTL languages. *}
{foreach from=$languages key=k item=language name="languages"}
{if ($cookie->id_lang == $language.id_lang) && (1 == $language.is_rtl)}
<link rel="stylesheet" href="{$css_dir}rtl.css" type="text/css" media="screen" />
{break}
{/if}
{/foreach}
@meysampg
meysampg / interface_generator.sh
Created September 21, 2015 08:59
Generate interface for model file on models folder
for fileName in $(ls ../models);
do
modelName=$(echo $fileName | cut -d "." -f 1);
echo "I${modelName}Interface.php generated.";
touch "I${modelName}Interface.php";
done
for i in *.css
do
echo $i | wc -m
done | sort -r | head -n 1
@meysampg
meysampg / gist:793c2662d5396cb63d84e22c39daec7d
Created April 3, 2016 10:58
Count number of lines of Yii2 Project
# You need to install cloc. On arch `yaourt -S colc`.
cloc --exclude-dir=web,vendor,.git,main,config,runtime,tests .
@meysampg
meysampg / EnglishToPersian.js
Created April 19, 2016 09:10
Convert a mis-layouted persian string to readable one
var msg = 'hdk d; k,aji thvsd hsj';
var engPerLet = {
' ': ' ',
'a': 'ش',
's': 'س',
'd': 'ی',
'f': 'ب',
'g': 'ل',
'h': 'ا',
'j': 'ت',
@meysampg
meysampg / removeOldBackup.sh
Last active August 29, 2016 04:35
Remove Old Backup Folders
# Replace PATH_OF_BACKUP_FOLDER with path of backup folder, for example /mnt/CRM/backup
# Replace NUMBER_OF_DAYS with a positive integer, for example 14 means folder older that 14 days.
find PATH_OF_BACKUP_FOLDER -maxdepth 1 -type d -ctime +NUMBER_OF_DAYS -printf "'%p' \n" | xargs rm -rf
@meysampg
meysampg / Madelbrot.go
Created October 14, 2016 21:11
Extended Version of a Example in Kernighan Book
package main
import (
"flag"
"image"
"image/color"
"image/png"
"math/cmplx"
"os"
// "math"

Keybase proof

I hereby claim:

  • I am meysampg on github.
  • I am meysampg (https://keybase.io/meysampg) on keybase.
  • I have a public key whose fingerprint is ABDC EC9A BDE6 DEC9 0BED 96DC D5A5 8C55 AAC5 9EB5

To claim this, I am signing this object: