Skip to content

Instantly share code, notes, and snippets.

@corleonis
corleonis / gist:2252076
Created March 30, 2012 14:53
Truncate orders
# Magento CE 1.4.1.1
# Be sure to replace "" with your table prefix
SET FOREIGN_KEY_CHECKS=0;
##############################
# SALES RELATED TABLES
##############################
TRUNCATE `sales_flat_creditmemo`;
TRUNCATE `sales_flat_creditmemo_comment`;
@corleonis
corleonis / seo_friendly_url.php
Created July 20, 2012 13:58 — forked from angelov/seo_friendly_url.php
[php] Филтрирање на стринг за seo friendly url-а
<?php
function seo_friendly_url($url) {
$cyrillic = array("а", "б", "в", "г", "д", "ѓ", "е", "ж", "з", "ѕ", "и", "ј", "к",
"л", "љ", "м", "н", "њ", "о", "п", "р", "с", "т", "ќ", "у", "ф",
"х", "ц", "ч", "џ", "ш", "А", "Б", "В", "Г", "Д", "Ѓ", "Е", "Ж",
"З", "Ѕ", "И", "Ј", "К", "Л", "Љ", "М", "Н", "Њ", "О", "П", "Р",
"С", "Т", "Ќ", "У", "Ф", "Х", "Ц", "Ч", "Џ", "Ш");
@corleonis
corleonis / seo_friendly_url.php
Created August 9, 2012 21:31 — forked from angelov/seo_friendly_url.php
[php] Филтрирање на стринг за seo friendly url-а
<?php
function seo_friendly_url($url) {
$cyrillic = array("а", "б", "в", "г", "д", "ѓ", "е", "ж", "з", "ѕ", "и", "ј", "к",
"л", "љ", "м", "н", "њ", "о", "п", "р", "с", "т", "ќ", "у", "ф",
"х", "ц", "ч", "џ", "ш", "А", "Б", "В", "Г", "Д", "Ѓ", "Е", "Ж",
"З", "Ѕ", "И", "Ј", "К", "Л", "Љ", "М", "Н", "Њ", "О", "П", "Р",
"С", "Т", "Ќ", "У", "Ф", "Х", "Ц", "Ч", "Џ", "Ш");
@corleonis
corleonis / gist:3834674
Created October 4, 2012 16:13 — forked from realityking/gist:2775329
SQL migration Joomla 3.0
# Drop deprecated columns
ALTER TABLE `#__content` DROP `title_alias`;
ALTER TABLE `#__content` DROP `sectionid`;
ALTER TABLE `#__users` DROP `usertype`;
ALTER TABLE `#__session` DROP `usertype`;
ALTER TABLE `#__users` DROP KEY `whosonline`;
# Change tables for which we want to support foreign keys or transactions to InnoDB
@corleonis
corleonis / blank-template-snippets.txt
Created October 24, 2012 15:05 — forked from cod3cow/template-snippets.txt
Blank Template Snippets for Joomla! 2.5 - http://blank.vc
# all php files :: disallow direct access of file
# between <?php and ?>
defined('_JEXEC') or die;
# index.php :: define variable with application
# between <?php and ?>
$app = JFactory::getApplication();
# index.php :: define variable with document
# between <?php and ?>
@corleonis
corleonis / config.php
Created October 24, 2012 15:06 — forked from dongilbert/config.php
Override Core Joomla! Classes
<?php
/**
* @package Joomla.Plugin
* @subpackage System.Overrides
*
* @copyright Copyright (C) 2012 Don Gilbert. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
define('OVERRIDES', dirname(__FILE__).'/overrides');
@corleonis
corleonis / gist:4260280
Created December 11, 2012 16:59
Switch context with ZF - JSON/HTML
<?php
class Bruegelbe_InfocusController extends Herder_Controller_Action
{
public function init() {
$context = $this->_helper->contextSwitch();
$context->addActionContext('contentItems', array('json'))
->initContext();
}
public function contentItemsAction() {
$tables = Bruegel_Model_Infocus::getTables();
@corleonis
corleonis / Validation
Last active December 10, 2015 22:38
Validate list of comma separated emails
<script type="text/javascript">
$(function() {
var isValidEmailAddress = function(emailAddress) {
var pattern = new RegExp(/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/i);
return pattern.test(emailAddress);
};
var validateCommaSeparatedEmails = function(emailAddresses) {
var emails = value.split(',');
var valid = true;
@corleonis
corleonis / recreateTSFE.php
Created January 22, 2013 15:20
Inits the TSFE global object in the backend of Typo3
function buildTSFE($pid = 1) {
global $BACK_PATH;
//needed for TSFE
require_once(PATH_t3lib.'class.t3lib_timetrack.php');
require_once(PATH_t3lib.'class.t3lib_tsparser_ext.php');
require_once(PATH_t3lib.'class.t3lib_page.php');
require_once(PATH_t3lib.'class.t3lib_stdgraphic.php');
require_once($BACK_PATH.'sysext/cms/tslib/class.tslib_fe.php');
@corleonis
corleonis / convert_image.php
Created May 16, 2013 15:41
Convert image data to inline image
<?php
echo '<img src="data:image/gif;base64,'.base64_encode($resource->getImage()).'"><br />';
?>