Skip to content

Instantly share code, notes, and snippets.

View jacquesbh's full-sized avatar
👋
Hey!

Jacques Bodin-Hullin jacquesbh

👋
Hey!
View GitHub Profile
<?xml version="1.0" encoding="utf-8" ?>
<!--
/**
* This file is part of Jbh_Webservice for Magento.
*
* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details.
@jacquesbh
jacquesbh / misc-change_admin_password.php
Created July 18, 2012 23:06
Script for change admin password
<?php
declare(ticks = 1);
// Mage !
require_once __DIR__ . '/../app/Mage.php';
// Usage function :)
function usage()
{
<?php
/**
* Email Model
* @package Jbh_Demo
*/
class Jbh_Demo_Model_Email extends Mage_Core_Model_Abstract
{
/**
@jacquesbh
jacquesbh / fr.jacquesbh.apache2.plist
Created July 13, 2012 06:29
Launch daemon for apache2 on mac (in /System/Library/LaunchDaemons/)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>fr.jacquesbh.apache2</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/apache2/bin/apachectl</string>
<string>start</string>
@jacquesbh
jacquesbh / restore.sh
Created July 9, 2012 08:37
Restore a local database with .sql.gz file
# Restore a database
function restore()
{
if [[ $# < 2 ]]; then
echo "Usage: restore <database> <file.sql[.tar].gz> [-gz]"
echo "Use -gz option if you want to restore an only gziped file"
return 65
fi
if [[ -f $2 ]]; then
@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
}
@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 / 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';
#!/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 / 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=""