Skip to content

Instantly share code, notes, and snippets.

View jacquesbh's full-sized avatar
🏠
Working from home

Jacques Bodin-Hullin jacquesbh

🏠
Working from home
View GitHub Profile
@jacquesbh
jacquesbh / netbeans_magento_snippets.xml
Last active July 26, 2016 16:45
Magento snippets
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE codetemplates PUBLIC "-//NetBeans//DTD Editor Code Templates settings 1.0//EN" "http://www.netbeans.org/dtds/EditorCodeTemplates-1_0.dtd">
<codetemplates>
<codetemplate abbreviation="gsc" xml:space="preserve">
<code><![CDATA[Mage::getStoreConfig('${cursor}')]]></code>
</codetemplate>
<codetemplate abbreviation="model" xml:space="preserve">
<code><![CDATA[Mage::getModel('${cursor}')]]></code>
</codetemplate>
<codetemplate abbreviation="single" xml:space="preserve">
@jacquesbh
jacquesbh / colors.php
Created June 25, 2012 19:53
Hexa colors in PHP loop
<?php
define('PAD', 1);
define('WIDTH', 1);
define('HEIGHT', 1);
ob_start();
echo '<table cellspacing="0" cellpadding="0" border="0" style="margin: 0; padding: 0;">';
@jacquesbh
jacquesbh / php-config.txt
Created July 3, 2012 12:17
My PHP configure command line for Max OS X (works for Magento)
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli=mysqlnd --with-mysqli=shared,mysqlnd --with-curl --with-mcrypt --with-gd --with-libxml-dir=/usr --with-openssl=/usr --enable-exif --with-freetype-dir=/usr/X11R6 --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/X11R6 --with-xpm-dir=/usr/X11R6 --enable-gd-native-ttf --with-icu-dir=/usr --with-iodbc=/usr --with-ldap=/usr --with-ldap-sasl=/usr --with-libedit=/usr --enable-mbstring --enable-mbregex --with-tidy --enable-pdo --with-pdo-mysql --with-config-file-path=/conf --with-pear --with-zlib=/usr --with-bz2=/usr --with-kerberos --enable-soap --enable-ftp --enable-zip
@jacquesbh
jacquesbh / .vimrc
Last active October 6, 2015 19:17
Simple .vimrc for servers
set nocompatible
set encoding=utf-8
filetype on
filetype plugin on
filetype indent on
syntax enable
set background=dark
set number
set laststatus=2
set cmdheight=1
@jacquesbh
jacquesbh / decorate_method.php
Created July 4, 2012 09:29
Magento - Grid column decorator for 'actions' depending on row
<?php
/**
* Decorate the actions column
* @access public
* @return string
*/
public function decorateActionColumn($value, $row, $column, $isExport)
{
$links = array();
@jacquesbh
jacquesbh / pre-commit
Created July 6, 2012 13:08
Git pre-commit hook by Boris Guéry, updated by me
#!/bin/bash
# Author: Boris Guéry <guery.b@gmail.com>
# https://github.com/borisguery/git-keywords-checker
# Add or remove keywords here
KEYWORDS_REGEX="FIXME|XXX|var_dump\(|die\(|Zend_Debug::|print_r\(|console\.(debug|info|log|warn)\("
# Add extensions to check here
EXTENSIONS_REGEX="(.php$|.phtml$|.js$)"
ERRORS_BUFFER=""
#!/bin/bash
# CREATE BACKUPS BEFORE RUNNING THIS SCRIPT!
# RUN THIS SCRIPT IN THE MAIN DIR OF YOUR APPLICATION (where the app/ is located)
for m in $(find app/ -iname Mage.php); do
cd $(dirname $(dirname $m)) || (echo && continue) # old locate db
MAGE_VERSION=$(php -d error_reporting=0 -r "require 'app/Mage.php'; Mage::app(); echo Mage::getVersion();")
if echo $MAGE_VERSION | egrep -q "^[0-9.]+$"; then
@jacquesbh
jacquesbh / toDev.sh
Created July 9, 2012 08:14
Jbh notice (Magento module) bash script (JolieBox)
toDev () {
if [[ $# < 2 ]]; then
echo "Usage: toDev <db name> <website name>";
return 1
fi
db=$1
shift
NAME=$@
req="
UPDATE core_config_data SET scope = 'default', scope_id = '0', path = 'dev/jbh_notice/admin_message', value = '$NAME - Development Admin Panel' WHERE path = 'dev/jbh_notice/admin_message';
@jacquesbh
jacquesbh / change_wp_url.sh
Created July 9, 2012 08:32
Change the url of a WordPress in bash
function chWpUrl()
{
db=$1
from=$2
to=$3
request="UPDATE wp_options SET option_value = REPLACE(option_value, '$from', '$to');
UPDATE wp_posts SET guid = REPLACE(guid, '$from', '$to');
UPDATE wp_posts SET post_content = REPLACE(post_content, '$from', '$to');
UPDATE wp_comments SET comment_author_url = REPLACE(comment_author_url, '$from', '$to'),
comment_content = REPLACE(comment_content, '$from', '$to')
@jacquesbh
jacquesbh / getmage.sh
Created July 9, 2012 08:35
[bash] Get a magento extension (connect 2.0)
# Development - MAGENTO
# ====================================================
# Retrieve magento extension from Magento Connect 2.0
function getmage()
{
# Usage example for http://connect20.magentocommerce.com/community/Fooman_Speedster-2.0.8 :
# getmage community Fooman_Speedster 2.0.8
wget --directory-prefix=$HOME/Downloads/ http://connect20.magentocommerce.com/$1/$2/$3/$2-$3.tgz
}