Skip to content

Instantly share code, notes, and snippets.

View sylvainraye's full-sized avatar

Sylvain Rayé sylvainraye

View GitHub Profile
@sylvainraye
sylvainraye / Observer.php
Created June 24, 2014 20:33
Display the product of a category only if this one has a unique product in Magento
/**
* Display the product of a category only if this one has a unique product
*
* Event
* - catalog_controller_category_init_after
*
* @param Varien_Event_Observer $observer
* @return mixed
*/
public function initSingleProductRedirect(Varien_Event_Observer $observer)
@sylvainraye
sylvainraye / gist:bd27d4767917542575e5
Created September 23, 2014 15:05
Mailcatcher Plist for OSX
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>diglin.mailcatcher</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-i</string>

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

@sylvainraye
sylvainraye / gist:5712289
Created June 5, 2013 07:55
Bash display improvement for Git repo (show if you are in which branch)
#functions to show git branch in prompt
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function proml {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
@sylvainraye
sylvainraye / gitdeleteallbranches-exceptmaster.sh
Created September 10, 2013 08:52
Delete all branches of a Git repo (locally and remotely) except the master branch
for t in `git branch | grep -v "master"`
do
git branch -D $t
git push --delete origin $t
done
@sylvainraye
sylvainraye / diffandcopy.sh
Last active December 22, 2015 23:58
Awk command for diff and copy file
# do an echo only of the result
diff -x "CVS" -x '.svn*' -bqr originaux/magento17/include/ myproject/include/ | grep "Only in originaux" | awk '{gsub(":", "", $3); filesource=$3"/"$4; print filesource; gsub("originaux/magento17/", "myproject/", $3); filetarget=$3"/"$4; print filesource" - "filetarget; }'
# do the copy
diff -x "CVS" -x '.svn*' -bqr originaux/magento17/include/ myproject/include/ | grep "Only in originaux" | awk '{gsub(":", "", $3); filesource=$3"/"$4; print filesource; gsub("originaux/magento17/", "myproject/", $3); filetarget=$3"/"$4; system ("cp -R "filesource" "filetarget); }'
@sylvainraye
sylvainraye / countlinesofcode.sh
Created September 13, 2013 12:38
Count the number of coded lines
find . -type f -name '*.php' -exec awk 'END {print NR}' '{}' + 2>/dev/null | awk '{ total+=$1 }END{print total}'
<?php
class EcomDev_Optimization_Model_Resource_Attribute_Source_Table extends Mage_Eav_Model_Entity_Attribute_Source_Table
{
protected static $_preloadedOptions = array();
protected static function _getStoreOptions($storeId, $attributeId)
{
if (!isset(self::$_preloadedOptions[$storeId])) {
$options = Mage::getResourceModel('eav/entity_attribute_option_collection')