Skip to content

Instantly share code, notes, and snippets.

@rseon
rseon / $.hasParent
Created June 15, 2013 13:54
How to find parent of an element when you can't do $('.element').parent().parent()... ?
$.extend($.fn, {
hasParent: function(p) {
return this.filter(function(){
return $(p).find(this).length;
});
}
});
@rseon
rseon / My Magento Code.php
Last active June 25, 2018 12:15 — forked from claudiu-marginean/My Magento Code.php
Magento Snippets
<block type="cms/block" name="block_name">
<action method="setBlockId"><id>block_code</id></action>
</block>
{{block type="cms/block" block_id="block_code"}}
{{block type="catalog/product_list" category_id="79" template="catalog/product/list_random.phtml"}}
@rseon
rseon / pagination.php
Last active February 7, 2023 18:43
[PHP] Ultra simple pagination
<?php
/*
We want to display a lot of information to the screen = download a lot of HTML = lag.
LEt's go for a pagination !
*/
// Huge array with lot of dbig datas.
$my_huge_array = array();
// Setting up pagination
@rseon
rseon / git-the-bible.md
Created December 6, 2017 11:00
Git : The Bible

Introduction

This wiki is a starting point to teach new git users how to use such a powerful tool. We will write here every useful command, from cloning to tag checkout. If you find something missing, as usual, add it by yourself.

GUI clients

Even if the majority of us is "pro-shell" and "pro-keyboard", some are way more used to GUIS an mouse interactions. And beautiful things.

Don't worry guys, GitHub & Atlassian have heard our prayers :

@rseon
rseon / unzip.php
Created December 6, 2017 11:01
[PHP] Unzip file
<?php
$zip = new ZipArchive;
if($zip->open('../fonts/transfonter.org-20160601-124035.zip') === true) {
$zip->extractTo('../fonts/Gotham/');
$zip->close();
}
@rseon
rseon / csv.php
Created January 30, 2018 08:21
[PHP] Read CSV file
<?php
$file = dirname(__FILE__) . '/fichier.csv';
$datas = [];
// Open the file
if(($handle = fopen($file, 'r')) !== false) {
$i = 0;
$mapping = []; // OPTION 2 only
@rseon
rseon / Csv.php
Last active May 6, 2021 07:38
Smart way to read and write a CSV file.
<?php
/**
* Create and read CSV file.
*
* @example Create CSV from array :
* $csv = new Csv;
* $csv->setUtf8(true);
* $csv->setHeader(['col_1', 'col_2']);
* $csv->addRow(['val_1_1', 'val_2_1']);
@rseon
rseon / sluggify.js
Last active July 20, 2018 14:01
Sluggify a string replacing spaces by "-", lowercasing and replacing accents and removing special chars
/**
* Sluggify a string replacing spaces by "-", lowercasing and replacing accents and removing special chars.
*
* @type {Function}
* @return {String}
*/
String.prototype.slug = String.prototype.slug || function() {
var replace = this.replace(/\s/g, '-');
replace = replace.toLowerCase();
@rseon
rseon / convert_date_fr.php
Last active April 14, 2022 04:06
[PHP] Convert a date from french month name to another format
<?php
/**
* Convert a date from french month name to another format
*
* @param string Date to convert
* @param string Format of date to convert
* @param string Format for output
* @return string
*
* @php_version >= 5.3
@rseon
rseon / cheatsheet.md
Last active December 28, 2023 18:27
Prestashop cheatsheet (>= 1.5)

Prestashop 1.7 cheatsheet

The most common. For me. Mostly from comments in source code.

Updated with 1.7 code.

Address

/**