Skip to content

Instantly share code, notes, and snippets.

View ArnaudLigny's full-sized avatar
🌴
On vacation

Arnaud Ligny ArnaudLigny

🌴
On vacation
View GitHub Profile
@ArnaudLigny
ArnaudLigny / Mage_Core_Model_Config.php
Created June 19, 2013 12:02
Override Magento to handle PHP 5.3+ namespaces.
<?php
/**
* Retrieve class name by class group
*
* @param string $groupType currently supported model, block, helper
* @param string $classId slash separated class identifier, ex. group/class
* @param string $groupRootNode optional config path for group config
* @return string
*
* @override Override to handle PHP namespaces
@ArnaudLigny
ArnaudLigny / gist:5086220
Created March 4, 2013 22:21
audio.js "Muxtape" style
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>audio.js</title>
<meta content="width=device-width, initial-scale=0.6" name="viewport">
<style>
body {
font-family: sans-serif;
line-height: 1.4;
<?php
/**
* Recursively remove a directory
*
* @param string $dirname
* @param boolean $followSymlinks
* @return boolean
*/
function RecursiveRmdir($dirname, $followSymlinks=false)
{
@ArnaudLigny
ArnaudLigny / simple_xml_iterator.php
Last active January 26, 2021 23:51
PHP SPL SimpleXMLIterator examples
<?php
try {
$sxe = simplexml_load_string($xmlstring, 'SimpleXMLIterator');
for ($sxe->rewind(); $sxe->valid(); $sxe->next()) {
if ($sxe->hasChildren()) {
foreach ($sxe->getChildren() as $element=>$value) {
echo $value->species . '<br />';
}
}
}
@ArnaudLigny
ArnaudLigny / github_repo.html
Last active December 10, 2015 23:49
Display Github repo list with javscript in HTML page.
<div class="github-repos span-9 last">
<h4>My Github Projects</h4>
<ul>
<li>Loading...</li>
</ul>
</div>
<div class="github-org-repos span-9 last">
<h4>Baobaz Github Projects</h4>
<ul>
<li>Loading...</li>
@ArnaudLigny
ArnaudLigny / dayz-version.php
Last active October 13, 2015 08:58
Print last version number and date of the DayZ Mod, as JSON format.
<?php
$htmlPage = 'http://dayzmod.com/?Download'; // page to parse
$versionXPathQuery = '/html/body/section/div[1]/div/div[2]/div[1]/span[2]'; // version XPath query
$dateXPathQuery = '/html/body/section/div[1]/div/div[2]/div[2]/text()'; // date XPath query
$dateOriginYear = '2013'; // hard coded
try {
$date = null;
$version = null;
<?php
// category source
$category_id = '3';
$category = Mage::getModel('catalog/category')->load($category_id);
$category_products = $category->getProductsPosition();
// clone category
$category_copy = clone $category;
$category_copy
->setId(null)
@ArnaudLigny
ArnaudLigny / Narno_Mage_Extension.php
Last active February 27, 2017 11:50
Get download link of a Magento extension from MagentoConnect key.
<?php
/**
* Get download link of a Magento extension from MagentoConnect key
*
* Dependencies: Zend_Http_Client, Zend_Uri (Zend Framework)
*/
class Narno_Mage_Extension
{
protected $_key = null;
@ArnaudLigny
ArnaudLigny / Narno_Gettext_Model_Translate.php
Last active September 29, 2015 23:47
Use Gettext to translate Magento modules
<?php
/**
* Narno Gettext Translate model
* (overlap of Mage_Core_Model_Translate)
*
* Support Gettext file (binary).
*/
class Narno_Gettext_Model_Translate extends Mage_Core_Model_Translate
{
[...]
@ArnaudLigny
ArnaudLigny / Varien_Simplexml_Config.php
Created January 27, 2012 09:38
Check the XML validity of Magento configuration files
<?php
/**
* Varien_Simplexml_Config overlap to Check the XML validity
* of Magento configuration files
*/
class Varien_Simplexml_Config {
[...]
/**
* Imports XML file