Skip to content

Instantly share code, notes, and snippets.

View foxycode's full-sized avatar

Tomáš Jacík foxycode

View GitHub Profile
@foxycode
foxycode / sdc-lastcomm.patch
Last active October 15, 2015 21:20
SmartOS /smartdc/bin/sdc-lastcomm patch for stat() error
--- /smartdc/bin/sdc-lastcomm Fri May 30 03:16:17 2014
+++ /smartdc/bin/sdc-lastcomm Tue Apr 21 11:23:16 2015
@@ -48,10 +48,19 @@
echo "-R is not valid with -d"
exit 1
fi
+ MAX_SLEEP=3
+ cd "$DIR" || exit 1
+ # Save the current audit log filename
+ AUDIT_LOG=`find . -name "*.not_terminated.*"`
@foxycode
foxycode / Smarty_Compiler.class.php
Created January 23, 2015 19:46
PrestaShop 1.4 preg_replace with e modifier to preg_replace_callback replacement
/* replace special blocks by "{php}" */
$source_content = preg_replace_callback($search, function($matches) {
return '{php' . str_repeat("\n", substr_count('\0', "\n")) . '}';
}, $source_content);
// $source_content = preg_replace($search.'e', "'"
// . $this->_quote_replace($this->left_delimiter) . 'php'
// . "' . str_repeat(\"\n\", substr_count('\\0', \"\n\")) .'"
// . $this->_quote_replace($this->right_delimiter)
// . "'"
// , $source_content);
@foxycode
foxycode / Category.php
Created January 23, 2015 18:17
PrestaShop (1.4) fastest possible product listing
<?php
class Category extends CategoryCore
{
public function getProducts($id_lang, $p, $n, $orderBy = NULL, $orderWay = NULL, $getTotal = false, $active = true, $random = false, $randomNumberProducts = 1, $checkAccess = true)
{
$id_country = Country::getDefaultCountryId();
$builder = ProductQueryBuilder::create($id_lang, $id_country)