Skip to content

Instantly share code, notes, and snippets.

View enricodeleo's full-sized avatar

Enrico Deleo enricodeleo

View GitHub Profile

Magento Snippets

Download extension manually using pear/mage

Pear for 1.4, mage for 1.5. File downloaded into /downloader/.cache/community/

./pear download magento-community/Shipping_Agent
./mage download community Shipping_Agent

Clear cache/reindex

@enricodeleo
enricodeleo / fb-comments-responsive.css
Last active December 15, 2015 21:29
Make Facebook Comments Responsive
/**********************************
* RESPONSIVE FB COMMENTS *
***********************************/
.fb-comments, .fb-comments iframe[style] {width: 100% !important;}
.fb-comments span, .fb-comments iframe span[style] {width: 100% !important;}
@enricodeleo
enricodeleo / atomasxml.php
Created May 7, 2013 09:57
read an atom feed as XML in php 5+
<?php
// Lettore Feed Atom come xml
// Requisito minimo php5
// Funzione che limita il numero di caratteri di una stringa
function strlimit($string, $limit) {
if (strlen($string) > $limit) {
$string = substr($string, 0, strrpos(substr($string, 0, $limit), ' ')) . '...';
}
<?php
require_once(dirname(__FILE__) . '/csscrush/CssCrush.php');
$options = array(
'debug' => true,
'cache' => false,
'versioning' => false
);
$compiled_file = csscrush_file( dirname(__FILE__) .'/css/style.css', $options );
?>
<link rel="stylesheet" type="text/css" href="<?php echo $compiled_file; ?>" media="all" />
@enricodeleo
enricodeleo / taxonomies.php
Last active December 1, 2022 16:21
Get and list all the taxonomies attached to a custom post type in Wordpress
<?php
$taxonomy_objects = get_object_taxonomies( 'cpt', 'objects' ); // <--- change cpt with the custom post type
$out = array();
foreach ( $taxonomy_objects as $taxonomy_slug => $taxonomy ){
$terms = get_terms( $taxonomy_slug, 'hide_empty=0' );
if ( !empty( $terms ) ) {
$out[] = "<strong>" . $taxonomy->label . "</strong>\n<ul>";
foreach ( $terms as $term ) {
$out[] =
" <li>"
SET FOREIGN_KEY_CHECKS=0;
-- Here's where we reset the orders
TRUNCATE `sales_flat_order`;
TRUNCATE `sales_flat_order_address`;
TRUNCATE `sales_flat_order_grid`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sales_flat_order_status_history`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
@enricodeleo
enricodeleo / my.cnf
Created March 1, 2014 14:15
MySQL optimized my.cnf for Magento store on 1GB ram VPS
[mysqld]
# GENERAL #
user = mysql
default-storage-engine = InnoDB
socket = /var/lib/mysql/mysql.sock
pid-file = /var/lib/mysql/mysql.pid
# MyISAM #
key-buffer-size = 32M
@enricodeleo
enricodeleo / ng-scroller.js
Last active August 29, 2015 14:05
ng-scroller: Performant infinite scrolling AngularJS directive with UITableView-like element reusal (http://ngscroller.herokuapp.com/)
/* jshint ignore:start */
(function(){'use strict';var h,n=this;
function aa(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";else if("function"==
b&&"undefined"==typeof a.call)return"object";return b}function p(a){return"array"==aa(a)}function r(a){return a[ba]||(a[ba]=++ca)}var ba="closure_uid_"+(1E9*Math.random()>>>0),ca=0;function da(a,b,c){return a.call.apply(a.bind,arguments)}
function ea(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arg

I've had the opertunity to try a variety of different server configurations but never really got around to trying HHVM with Magento until recently. I thought I would share a detailed walkthrough of configuring a single instance Magento server running Nginx + Fast CGI + HHVM / PHP-FPM + Redis + Percona. For the purpose of this blog post I'm assuming you are using Fedora, CentOS, or in my case RHEL 6.5.

Please note: I'm 100% open to suggestions. If you see something I did that needs to be done a different way, please let me know. I haven't included my Perconca my.conf file yet. I will shortly. Also I plan on trying this same test with HHVM 3.3 and PHP 7.

Install the EPEL, Webtatic, and REMI repos

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm