Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Jacques Bodin-Hullin jacquesbh

🏠
Working from home
View GitHub Profile
View netbeans_magento_snippets.xml
<?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 Jun 25, 2012
Hexa colors in PHP loop
View colors.php
<?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 Jul 3, 2012
My PHP configure command line for Max OS X (works for Magento)
View php-config.txt
./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 Oct 6, 2015
Simple .vimrc for servers
View .vimrc
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 Jul 4, 2012
Magento - Grid column decorator for 'actions' depending on row
View decorate_method.php
<?php
/**
* Decorate the actions column
* @access public
* @return string
*/
public function decorateActionColumn($value, $row, $column, $isExport)
{
$links = array();
@jacquesbh
jacquesbh / pre-commit
Created Jul 6, 2012
Git pre-commit hook by Boris Guéry, updated by me
View pre-commit
#!/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=""
View patchMagentos.sh
#!/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 Jul 9, 2012
Jbh notice (Magento module) bash script (JolieBox)
View toDev.sh
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 Jul 9, 2012
Change the url of a WordPress in bash
View change_wp_url.sh
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 Jul 9, 2012
[bash] Get a magento extension (connect 2.0)
View getmage.sh
# 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
}