Skip to content

Instantly share code, notes, and snippets.

View mcjwsk's full-sized avatar

Dariusz Maciejewski mcjwsk

View GitHub Profile
@mcjwsk
mcjwsk / .cifspwd
Last active August 29, 2015 14:06
CIFS share auto mount for /etc/fstab
username=[username]
password=[password]
domain=[domain]
// ttl - time to live is essential for performance issues
sudo mount -t vboxsf -o ttl=5 [shared folder alias] [mount]
// win share
sudo mount -t cifs -o username=[username],password=[username],domain=[domain] //[ip]/[share] [mount]
// mount all devices again
sudo mount -a
#! /bin/bash
TIMESTAMP=$(date +"%d-%m-%Y_%H%M")
BACKUP_DIR="/home/darek/backup/mysql"
CURRENT_BACKUP_DIR="$BACKUP_DIR/$TIMESTAMP"
MYSQL_USER="root"
mkdir -p $CURRENT_BACKUP_DIR
find $BACKUP_DIR -mindepth 1 -maxdepth 1 -type d -mtime +7 -exec rm -rf '{}' +;
<?php
error_reporting(-1);
ini_set('display_errors',1);
$iterator = new GlobIterator('dane/*.csv', FilesystemIterator::KEY_AS_FILENAME);
$data = iterator_to_array($iterator);
$j = 0;
foreach (array_keys($data) as $file) {
$content = file('dane/'.$file);
$attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::Entity, 'color');
$value = $attribute->getFrontend()->getValue($product);
$label = $attribute->getFrontend()->getLabel();
$inputType = $attribute->getFrontend()->getInputType();
$options = $attribute->getFrontend()->getSelectOptions();
$value = $options = $attribute->getFrontend()->getOption($optionId);

Custom checkout/cart total renderers

AdminOrder.prototype.loadArea = AdminOrder.prototype.loadArea.wrap(
function(callOriginal, area, indicator, params) {
area.push('test-darka');
callOriginal(area, indicator, params);
}
);

Get store

Mage::app()->getStore();

Store code

Mage::app()->getStore()->getStoreId();
mount -o remount,rw /
/**
* Generate regexp for naughty words censoring
* Depends on whether installed PHP version supports unicode properties
*
* @param string $word word template to be replaced
* @param bool $use_unicode whether or not to take advantage of PCRE supporting unicode
*
* @return string $preg_expr regex to use with word censor
*/
function get_censor_preg_expression($word, $use_unicode = true)