Skip to content

Instantly share code, notes, and snippets.

View enricodeleo's full-sized avatar

Enrico Deleo enricodeleo

View GitHub Profile
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`;
<?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 / 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), ' ')) . '...';
}
@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;}

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 / .bash_profile
Last active December 4, 2015 11:17
Bash Profile OS X
# Brew bash complation (brew install bash-completion)
# you must install brew http://brew.sh/
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
# Brew's NVM (brew install nvm)
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
@enricodeleo
enricodeleo / arrayAppend.js
Created November 30, 2015 12:37
Extend an Array appending elements of another Array in Javascript
// Shorthand function
Array.prototype.append = function(array) {
this.push.apply(this, array)
}
// Example
var a = [1,2];
var b = [3,4];
a.append(b); // 'a' bacames [ 1, 2, 3, 4 ]
@enricodeleo
enricodeleo / smart-log.js
Last active August 29, 2015 14:20
A hopefully smart solution for console.logging messages during development without affecting production apps
DEVELOPMENT = true; //global variable, I use this to adapt my js app behavior accordingly
// I want console.log just during development
if ( DEVELOPMENT ) {
smLog = function(log, type) {
var args = [ 'log', 'info', 'debug', 'warn', 'error' ]; // valid methods for `console`
var type = type || 'log'; // the second argument is optional, defaults to log
var type = ( args.indexOf( type ) ) > -1 ? type : 'log'; // defaults to log if the second argument is not valid (eg a typo)
console[type](log);
};
@enricodeleo
enricodeleo / s3-single-user-policy
Created April 9, 2015 13:26
Give just objects-related permissions to an user on S3
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "POLICYID",
"Effect": "Allow",
"Action": [
"s3:AbortMultipartUpload",
"s3:DeleteObject",
"s3:DeleteObjectVersion",
@enricodeleo
enricodeleo / s3-single-directory-policy
Last active August 29, 2015 14:18
Deny access to a subdirectory on S3
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "DenyPublicRead",
"Effect": "Deny",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",