Skip to content

Instantly share code, notes, and snippets.

View mkdizajn's full-sized avatar
🐢
slow & thorough > faster & mistakable

Kresimir Pendic mkdizajn

🐢
slow & thorough > faster & mistakable
View GitHub Profile
@mkdizajn
mkdizajn / magento, get the quantitiy from configurable product
Created December 7, 2012 16:01
magento, get the quantitiy from configurable product
View magento, get the quantitiy from configurable product
<?php
$product=Mage::getModel("catalog/product");
$prod=$product->load($_product->getId());
$conf = Mage::getModel('catalog/product_type_configurable')->setProduct($prod);
$col = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
$total_qty=0;
foreach($col as $sprod){
$sprod=$product->load($sprod->getId());
@mkdizajn
mkdizajn / wordpress plugin rewrite media path
Created December 11, 2012 11:09
wordpress plugin rewrite media path
View wordpress plugin rewrite media path
<?php
/*
Plugin Name: Rewrite Wordpress upload path
Plugin URI: http://mkdizajn.com
Description: Rewrites your image paths.
Version: 2.4
Author: kreso
Author URI: http://mkdizajn.com/
*/
@mkdizajn
mkdizajn / wordpress mutisite timthumb patch for prepand path
Created February 18, 2013 09:44
wordpress mutisite timthumb patch for prepand path
View wordpress mutisite timthumb patch for prepand path
########
wordpress multisite timthumb patch
########
correct the rewrite prepand path with timthumb script!
open timthumb and locate:
if(preg_match('/https?:\/\/(?:www\.)?' . $this->myHost . '(?:$|\/)/i', $this->src)){
//$this->src = preg_replace('/https?:\/\/(?:www\.)?' . $this->myHost . '/i', '', $this->src);
@mkdizajn
mkdizajn / wordpress multisite boilerplate htaccess rules
Last active December 14, 2015 03:48
wordpress multisite boilerplate htaccess rules
View wordpress multisite boilerplate htaccess rules
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# uploaded files
RewriteRule ^([_0-9a-zA-Z-]+/)?files/(.+) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
@mkdizajn
mkdizajn / sql for fiskalizacija modul, manual table creation
Created March 5, 2013 08:25
sql for fiskalizacija modul table's
View sql for fiskalizacija modul, manual table creation
CREATE TABLE IF NOT EXISTS `inchoo_fiskalizacija_cert` (
`cert_id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'Id',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'Created At',
`website_id` int(11) NOT NULL COMMENT 'Website Id',
`pfx_cert` text NOT NULL COMMENT 'Original Certificate in PFX format',
`pem_private_key` text NOT NULL COMMENT 'Private Key in PEM format',
`pem_private_key_passphrase` text NOT NULL COMMENT 'Passphrase for Private Key in PEM format',
`pem_public_cert` text NOT NULL COMMENT 'Public Certificate in PEM format',
`pem_public_cert_name` text NOT NULL COMMENT 'Name of the Public Certificate in PEM format',
@mkdizajn
mkdizajn / wordpress search and replace full database
Created March 5, 2013 23:16
mysql search and replace whole database... serialized data also!
View wordpress search and replace full database
<?php
// This script is to solve the problem of doing database search and replace
// when developers have only gone and used the non-relational concept of
// serializing PHP arrays into single database columns. It will search for all
// matching data on the database and change it, even if it's within a serialized
// PHP array.
// The big problem with serialised arrays is that if you do a normal DB
// style search and replace the lengths get mucked up. This search deals with
View magento var and mysql log cleanup script
<?php
// cleanup.php?clean=var
// cleanup.php?clean=log
$xml = simplexml_load_file('./app/etc/local.xml', NULL, LIBXML_NOCDATA);
$db['host'] = $xml->global->resources->default_setup->connection->host;
$db['name'] = $xml->global->resources->default_setup->connection->dbname;
$db['user'] = $xml->global->resources->default_setup->connection->username;
@mkdizajn
mkdizajn / gist:5195468
Created March 19, 2013 11:48
magento shell directory and file permissions
View gist:5195468
find . -type d -exec chmod 775 {} \;
find . -type f -exec chmod 664 {} \;
chmod 775 -R var/ app/etc/ media/
@mkdizajn
mkdizajn / How to Allow Administrators to Edit Users in a WordPress Network
Created April 2, 2013 10:16
How to Allow Administrators to Edit Users in a WordPress Network
View How to Allow Administrators to Edit Users in a WordPress Network
<?php
/* wordpress multisite how to allow administrators to edit users! */
function mc_admin_users_caps( $caps, $cap, $user_id, $args ){
foreach( $caps as $key => $capability ){
if( $capability != 'do_not_allow' )
continue;
@mkdizajn
mkdizajn / bootstrap 16 and 24 grid config values for configurator
Created April 9, 2013 17:05
bootstrap 16 and 24 grid config values for configurator
View bootstrap 16 and 24 grid config values for configurator
This method for last version of Bootstrap - Version 2.3.1
Click this link to customize bootstrap: http://twitter.github.com/bootstrap/customize.html
You will find such as this list and change the number as you like.
16 Grid system with Gutter
@gridColumns: 16
@gridColumnWidth: 45px
@gridGutterWidth: 15px