Skip to content

Instantly share code, notes, and snippets.

@real34
real34 / monitor_slave.js
Created June 6, 2013 10:05
CasperJs script to monitor MySQL replication slave status through PhpMyAdmin. Tested with PhpMyAdmin v3.3.9
var casper = require('casper').create();
var utils = require('utils');
var phpMyAdminUrl = casper.cli.args[0];
var phpMyAdminCredentials = {
pma_username: casper.cli.options.user,
pma_password: casper.cli.options.password
};
if (!phpMyAdminUrl || !phpMyAdminCredentials.pma_username || !phpMyAdminCredentials.pma_password) {
casper.echo('Invalid parameters. Usage: casperjs monitor_slave.js http://example.com/phpMyAdmin --user=foo --password=bar');
@real34
real34 / Lemonline_SimpleAdminPayment.csv
Created June 7, 2013 13:43
French Translation for the Simple Admin Payment Magento module
Check / Money Order for Admin Chèque / Liquide pour l'Administrateur
This payment method is enabled only for orders that are created in Magento Admin. Cette méthode de paiement n'est activée que pour les commandes qui sont créées depuis l'Administration
Create and Capture Invoice Automatically Créer et capturer une facture automatiquement
Create Shipment Automatically Créer une expédition automatiquement
@real34
real34 / fix-delete-order-for-taxes.diff
Created June 12, 2013 11:37
Fixed an issue with Magento EM_DeleteOrder module which is not deleting records from the `sales_order_tax` table. This may cause inconsistent generated reports http://www.magentocommerce.com/magento-connect/seamless-delete-order.html
commit e748d3fecd20374624f391603b42d73453db1c6f
Author: Pierre Martin <pierre@occi-tech.com>
Date: Wed Jun 12 12:34:38 2013 +0200
Added sales_order_tax cleaning to the DeleteOrder module to prevent leaving corrupted data
diff --git a/app/code/community/EM/DeleteOrder/controllers/Adminhtml/Sales/OrderController.php b/app/code/community/EM/DeleteOrder/controllers/Adminhtml/Sales/OrderController.php
index a6fbd52..7ca0e45 100644
--- a/app/code/community/EM/DeleteOrder/controllers/Adminhtml/Sales/OrderController.php
+++ b/app/code/community/EM/DeleteOrder/controllers/Adminhtml/Sales/OrderController.php
@real34
real34 / score.exs
Last active December 30, 2015 04:59 — forked from chadrien/score.rb
# encoding: UTF-8
defmodule Score do
@missed "-"
@spare "/"
@strike "X"
def total(rolls) when is_bitstring(rolls) do
rolls |> String.codepoints |> total
@real34
real34 / keys.php
Created December 21, 2013 08:10
Approche naïve de réponse à un question sur la ML AFUP : "Bonjour, je cherche un moyen propre et générique pour remplacer les clés d'un tableau associatif par une autre en gardant exactement la même structure pour la sortie."
<?php
$initial = array(
array(
'idcom' => 2,
'idcatalog' => 1,
'pseudo_com' => 'babar'
),
array(
'idcom' => 1,
'idcatalog' => 1,
@real34
real34 / csv.php
Created February 19, 2014 14:49
Filter CSV files in a quick'n'dirty way
<?php
$dir = __DIR__;
function isValid($product) {
return !empty($product[2]);
}
if (($productsFile = fopen($dir . '/products2.csv', "r")) !== FALSE) {
$missingSkus = array_map('trim', file($dir . '/missing-images-sku.csv'));
Plugin::load('Croogo', ['bootstrap' => true]);
<?php
function fixFilenameEncoding($filename) {
return mb_convert_encoding($filename, 'ISO-8859-2', 'UTF-8');
}
$zip = new ZipArchive;
$res = $zip->open('./elephant.zip', ZipArchive::CREATE);
if ($res === true) {
$filename = 'éléphant-man2.txt';
@real34
real34 / store_generator.php
Last active August 29, 2015 14:06
Generates a valid CSV file for french stores for the Magento Store Locator extension. http://www.magentocommerce.com/magento-connect/store-locator-extension-1.html
<?php
require_once __DIR__ . '/vendor/autoload.php';
$faker = Faker\Factory::create('fr_FR');
$output = fopen('php://output', 'w+');
$headers = [
'storelocator_id',
'name',
'status',
{"initialState":{"stores":{"EventStore":{"events":[{"name":"CONTENT_CHANGED","payload":{"content":"C"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ce"}},{"name":"CONTENT_CHANGED","payload":{"content":"Cec"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci "}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci e"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci es"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est "}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est u"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est un"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est un "}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est un m"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est un me"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est un mes"}},{"name":"CONTENT_CHANGED","payload":{"content":"Ceci est un mess"}},{"nam