Skip to content

Instantly share code, notes, and snippets.

View ArnaudLigny's full-sized avatar
👨‍💻
Solving problems

Arnaud Ligny ArnaudLigny

👨‍💻
Solving problems
View GitHub Profile
@ArnaudLigny
ArnaudLigny / Marie et moi
Created January 23, 2012 14:23
Echange rapide entre Marie (conseillère Bouygues Telecom) et moi (début 2011)
Marie: Bonjour, je suis un conseiller Bouygues Telecom. Avez-vous des questions sur nos offres et téléphones mobiles ?
Marie: Veuillez saisir votre question ci-dessous
Vous: Bonjour Marie, je suis client BT et j'aimerai remplacer mon HTC Desire par un Nexus S, je peux profiter du code de remise de XXXx ?
Marie: Bonjour.
Marie: J'ai bien lu votre question concernant le changement de mobile pour le remboursement.
Marie: Déplaçons la fenêtre de chat en bas de votre écran. Ainsi, vous pourrez naviguer sur notre site tout en chattant. Veuillez cliquer sur « Oui » pour la déplacer.
Marie: Je vous remercie.
Marie: Quel forfait avez-vous en ce moment ?
Vous: Neo 3
Marie: Est-ce pour un nouveau forfait et un nouveau numéro ?
@ArnaudLigny
ArnaudLigny / Battlelog_Servers_List.php
Created January 25, 2012 17:44
PHP script (that uses ZF) returns your latest Battlelog servers list as array
<?php
/**
* PHP script (that uses ZF) returns your latest Battlelog servers list as array
*
* @author Arnaud Ligny aka Narno <arnaud@ligny.org>
*/
define('DS', DIRECTORY_SEPARATOR);
define('PS', PATH_SEPARATOR);
define('BP', dirname(dirname(dirname(dirname(__FILE__))))); // ../../../ change it if necessary
@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
@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 / 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;
<?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 / 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;
@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 / 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 />';
}
}
}
<?php
/**
* Recursively remove a directory
*
* @param string $dirname
* @param boolean $followSymlinks
* @return boolean
*/
function RecursiveRmdir($dirname, $followSymlinks=false)
{