Skip to content

Instantly share code, notes, and snippets.

View mklepaczewski's full-sized avatar

Matt mklepaczewski

View GitHub Profile
@mayconbordin
mayconbordin / progress_bar.php
Created June 2, 2012 23:55
PHP CLI progress bar in 5 lines of code
<?php
function progress_bar($done, $total, $info="", $width=50) {
$perc = round(($done * 100) / $total);
$bar = round(($width * $perc) / 100);
return sprintf("%s%%[%s>%s]%s\r", $perc, str_repeat("=", $bar), str_repeat(" ", $width-$bar), $info);
}
@IvanChepurnyi
IvanChepurnyi / Table.php
Last active July 11, 2022 10:44
Optimized options load
<?php
/**
* Optimized version of attribute source options model
*
* That allows to preload options once and reuse them instead of doing calls to db all the time
*
*/
class EcomDev_Optimization_Model_Resource_Attribute_Source_Table
extends Mage_Eav_Model_Entity_Attribute_Source_Table
@piotrekkaminski
piotrekkaminski / gist:14f49b6ddcb69640d697
Created April 6, 2015 21:41
MPERF-7015: Session Cookies not stored for shop on root (2nd level) domain
diff --git a/app/code/core/Mage/Core/Model/Session/Abstract.php b/app/code/core/Mage/Core/Model/Session/Abstract.php
index 4d2bf60..c580932 100644
--- a/app/code/core/Mage/Core/Model/Session/Abstract.php
+++ b/app/code/core/Mage/Core/Model/Session/Abstract.php
@@ -566,14 +566,24 @@ public function renewSession()
{
$this->getCookie()->delete($this->getSessionName());
$this->regenerateSessionId();
+ $this->_deleteCookiesForSameParentDomain();
@laundmo
laundmo / compose-check.py
Last active December 23, 2022 07:45
Check which docker-compose services were changed since last "up" and which containers need to be restarted
#!/usr/bin/env python3
# This code is available under the MIT license: https://opensource.org/licenses/MIT
from pathlib import Path
import subprocess
import json
from dataclasses import dataclass
from typing import List, Optional