Skip to content

Instantly share code, notes, and snippets.

View prestarocket's full-sized avatar

Adonis Karavokyros prestarocket

View GitHub Profile
@ezirmusitua
ezirmusitua / javascript-resize-debounce.js
Last active September 1, 2023 13:14
[Debounce window resize event] Debounce window resize event #javascript #frontend #perfermance
/* --------------------------------------------
* Detect device orientation
* and trigger changes based on it
--------------------------------------------*/
function updateOrientation() {
// Detect whether device supports orientationchange event, otherwise fall back to the resize event
// Genius solution from http://stackoverflow.com/a/2307936
let supportsOrientationChange = "onorientationchange";
let orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";
let newAngle = null;
@julienbourdeau
julienbourdeau / clean-prestashop-db.sql
Last active March 13, 2025 17:41
Clean PrestaShop database - Drop old and unless data
# Delete all logs
TRUNCATE ps_log;
# Delete old connection data (only used for stats)
# change 2016-02-01 00:00:00 according to you needs
DELETE c, cs
FROM ps_connections c
LEFT JOIN ps_connections_source cs ON (c.id_connections = cs.id_connections)
WHERE c.date_add < '2016-02-01 00:00:00';
@benytocarlo
benytocarlo / getallcombinations.sql
Created February 19, 2016 12:17
get all combinations prestashop
SELECT
p.id_product,
pa.reference,
pa.upc,
pa.price,
pai.id_image,
pl.name,
GROUP_CONCAT(DISTINCT(pal.name) SEPARATOR ", ") as combination,
pq.quantity
FROM ps_product p
@alectoist
alectoist / admincmscontroller.php
Created January 27, 2016 10:26
Prestashop file uploader usage
<?php
class AdminCmsController extends AdminCmsControllerCore
{
public function renderForm()
{
if (!$this->loadObject(true)) {
return;
}
@Quetzacoalt91
Quetzacoalt91 / categories.csv
Last active April 8, 2022 15:22
PrestaShop Pokemon Products
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
ID;Active (0/1);Name *;Parent category;Root category (0/1);Description;Meta title;Meta keywords;Meta description;URL rewritten;Image URL
100;1;Normal;Home;0;;Meta title-normal;Meta keywords-normal;Meta description-normal;normal;http://cdn.bulbagarden.net/upload/e/e4/NormalIC.gif
101;1;Fighting;Home;0;;Meta title-fighting;Meta keywords-fighting;Meta description-fighting;fighting;http://cdn.bulbagarden.net/upload/8/8e/FightingIC.gif
102;1;Flying;Home;0;;Meta title-flying;Meta keywords-flying;Meta description-flying;flying;http://cdn.bulbagarden.net/upload/7/73/FlyingIC.gif
103;1;Poison;Home;0;;Meta title-poison;Meta keywords-poison;Meta description-poison;poison;http://cdn.bulbagarden.net/upload/7/71/PoisonIC.gif
104;1;Ground;Home;0;;Meta title-ground;Meta keywords-ground;Meta description-ground;ground;http://cdn.bulbagarden.net/upload/d/d9/GroundIC.gif
105;1;Rock;Home;0;;Meta title-rock;Meta keywords-rock;Meta description-rock;rock;http://cdn.bulbagarden.net/upload/1/15/RockIC.gif
106;1;Bug;Home;0;;Meta title-
@jrruiz
jrruiz / AdminCartRulesController.php
Created October 31, 2014 13:07
Prestashop sql improvements
<?php
class AdminCartRulesController extends AdminCartRulesControllerCore
{
protected function afterAdd($currentObject)
{
/*
* Omitted code...
*/
@julienbourdeau
julienbourdeau / imgoptim
Created September 18, 2014 15:47
Find and compress JPG and PNG images (using optipng and jpegoptim) with command line
find . -name "*.png" -exec optipng '{}' \;
find . -name "*.jpg" -exec jpegoptim '{}' \;
@hereswhatidid
hereswhatidid / Media.php
Last active December 11, 2019 08:50
PrestaShop Media class override to allow for forcing some inline JavaScripts to remain inline.
<?php
Class Media extends MediaCore
{
public static function deferScript($matches)
{
if (!is_array($matches))
return false;
$inline = '';
if (isset($matches[0]))
@eddmann
eddmann / SecureSessionHandler.php
Created April 9, 2014 12:18
Secure session handler implementation.
<?php
class SecureSessionHandler extends SessionHandler {
protected $key, $name, $cookie;
public function __construct($key, $name = 'MY_SESSION', $cookie = [])
{
$this->key = $key;
$this->name = $name;
@jjmu15
jjmu15 / in_viewport.js
Created January 27, 2014 10:19
check if element is in viewport - vanilla JS. Use by adding a “scroll” event listener to the window and then calling isInViewport().
// Determine if an element is in the visible viewport
function isInViewport(element) {
var rect = element.getBoundingClientRect();
var html = document.documentElement;
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || html.clientHeight) &&
rect.right <= (window.innerWidth || html.clientWidth)
);