Skip to content

Instantly share code, notes, and snippets.

@mokanfar
mokanfar / csv_php_html.php
Last active August 29, 2015 14:22
CSV -> PHP Array -> HTML Generator
<?php
/**
* Convert a comma separated file into an associated array then spit out html string in variable.
* Useful for generating one-off html block fragrments.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
@mokanfar
mokanfar / indesign.indk
Created May 29, 2015 17:50
InDesign CS6 Shortcut Keys
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<shortcut-set platform="win" file-version="4" application-version="8.0" build-number="370">
<shortcut>
<action-id value="0x100 + 1" name="KBSCE File menu: New: :Document..."></action-id>
<context>DefaultContext</context>
<string>Ctrl+N</string>
</shortcut>
<shortcut>
<action-id value="0x100 + 3" name="KBSCE File menu:&amp;Open..."></action-id>
<context>DefaultContext</context>
@mokanfar
mokanfar / .zshrc
Last active November 5, 2015 00:31
.zshrc
alias g='cd /home/grunt/'
alias z='cd /vagrant/httpdocs/z/'
alias sync='browser-sync start --server --files "*.html,*.css" --config "/home/bs-config.js"'
alias hint='n98-magerun.phar --root-dir="/vagrant/httpdocs/mag/" dev:template-hints'
alias mt='sudo mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant'
alias h='cd ~/'
alias zshrc='nano ~/.zshrc'
alias src='source ~/.zshrc'
bindkey -s "^[OM" "^M"
@mokanfar
mokanfar / mag-nightly.sh
Last active February 17, 2016 02:29
Magento Magmi Import Cron Bash Script
#!/bin/bash
####################### BEGIN CONFIG #######################
csv_sheet_url='http://dev.com/example.csv'
csv_sheet_path='/home/dev/magmi.csv'
tmp_file_path='/home/dev/tmp_magmi.csv'
magmi_cli_path='/home/dev/magmi/cli/magmi.cli.php'
log_file='/home/dev/log.txt'
profile='Default'
######################## END CONFIG ########################
<?php
/**
* Copy file or folder from source to destination, it can do
* recursive copy as well and is very smart
* It recursively creates the dest file or directory path if there weren't exists
* Situtaions :
* - Src:/home/test/file.txt ,Dst:/home/test/b ,Result:/home/test/b -> If source was file copy file.txt name with b as name to destination
* - Src:/home/test/file.txt ,Dst:/home/test/b/ ,Result:/home/test/b/file.txt -> If source was file Creates b directory if does not exsits and copy file.txt into it
* - Src:/home/test ,Dst:/home/ ,Result:/home/test/** -> If source was directory copy test directory and all of its content into dest
* - Src:/home/test/ ,Dst:/home/ ,Result:/home/**-> if source was direcotry copy its content to dest
@mokanfar
mokanfar / related_products.php
Last active August 12, 2016 16:51
Every Possible Relation PHP Script
@mokanfar
mokanfar / rsync_magento-mirror
Last active June 28, 2017 23:58
rsync magento-mirror repo to upgrade magento
cd ~
git clone https://github.com/OpenMage/magento-mirror.git
cd public_html
git init
curl https://raw.githubusercontent.com/github/gitignore/master/Magento.gitignore > .gitignore
git add --all
git commit -m 'backup'
cd ../magento-mirror
rsync -chavzP --exclude='./var/cache' --exclude='./.git' --exclude='./media/catalog/product/cache' --exclude='./var/tmp' --exclude='./var/session' --exclude='./var/report' --stats ./ ../public_html
@mokanfar
mokanfar / ssync.sh
Last active February 7, 2018 03:51
Custom ERP -> Magento Stock Sync Shell Script. Handles kit parts in erp translates to a simple magento sku qty
#!/bin/bash
########## MAGENTO CONFIG VARIABLES #############
globalMagDir='/var/www/html/****'
globalScriptDir="${globalMagDir}/dev/stock-sync"
globalMagFeedDir="${globalMagDir}/media/amfeed/feeds"
amfeedF3='export_3'
amfeedF4='export_4'
########## MAGMI CONFIG VARIABLES ##############
magmiCLI="${globalMagDir}/magmi/magmi/cli/magmi.cli.php"
@mokanfar
mokanfar / jquery.js
Created February 21, 2018 18:09
$ jQuery snippets
//===========
jQuery.noConflict();
(function ($) {
$(this).remove();
})(jQuery);
//===========
//===========
@mokanfar
mokanfar / conemu.xml
Last active February 21, 2018 18:19
ConEmu Settings
<?xml version="1.0" encoding="utf-8"?>
<key name="Software">
<key name="ConEmu">
<key name=".Vanilla" modified="2018-02-21 10:18:48" build="161206">
<value name="StartType" type="hex" data="02"/>
<value name="CmdLine" type="string" data=""/>
<value name="StartTasksFile" type="string" data=""/>
<value name="StartTasksName" type="string" data="{Git SCM Bash}"/>
<value name="StartFarFolders" type="hex" data="00"/>
<value name="StartFarEditors" type="hex" data="00"/>