Skip to content

Instantly share code, notes, and snippets.

@zainengineer
zainengineer / mysql_auto_resume
Last active September 25, 2019 23:59
auto resume service based on port availability (mysql example)
#!/usr/bin/env bash
#to find processes use netstat -ntlp | grep "3306"
portResponse=$(netstat -lnt | awk '$6 == "LISTEN" && $4 ~ ".3306"')
if [ -z "$portResponse" ]
then
echo "Port available for mysql, staring mysql"
service mysql start
else
echo "mysql already running"
fi
<?php
/**
* InternalLog
*
*/
class InternalLog
{
const TIMER_ACTION_START = 1;
//had NO EFFECT
$iStoreId = 9;
class_exists('\Kint',false) && (\Kint::$max_depth =3);
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
/** @var \Magento\Store\Model\StoreManagerInterface $storeManager */
$storeManager =$objectManager->create('\Magento\Store\Model\StoreManagerInterface');
//has NO EFFECT
$storeManager->setCurrentStore($iStoreId);
<?php
//n98-magerun2.phar dev:console
#useful for old multi-stock implementation for magento
#but can be skipped
$stockId = 7;
$storeId = 3;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
<global>
<session_save><![CDATA[db]]></session_save>
<cache>
<backend>database</backend>
</cache>
</global>
@zainengineer
zainengineer / script.sh
Last active April 12, 2024 01:41
bash script path
#!/usr/bin/env bash
script_path=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
root_path=$(dirname $(dirname $(dirname "$script_path")));
#for simple any level using ..
script_path=$( cd "$(dirname "${BASH_SOURCE}")" ; pwd -P )
dirname=$(realpath "$script_path/..")
@zainengineer
zainengineer / container_ip.bash
Last active February 2, 2023 21:20
Get docker container ip
#!/usr/bin/env bash
#inside docker container
HOST_IP=$(/sbin/ip route|awk '/default/ { print $3 }')
CONTAINER_IP=$(curl "$HOST_IP:8000" 2>/dev/null)
echo "container ip is $CONTAINER_IP"
@zainengineer
zainengineer / rsync_ruby.MD
Created February 17, 2017 06:44
vagrant rsync-auto ruby issues
@zainengineer
zainengineer / history.js
Last active February 16, 2017 11:27
youtube history remove bulk
#go to youtube history page and copy pate the javascript
#in history load videos roughly upto where you want to delete
#I use it so youtube does not suggest me nursery rhyms
removeHistory = function (){
this('.yt-uix-button-icon.yt-uix-button-icon-dismissal.yt-sprite').click();
window.setTimeout(function () {
this('.yt-uix-button-icon.yt-uix-button-icon-dismissal.yt-sprite').remove();
this('.yt-uix-button-icon.yt-uix-button-icon-dismissal.yt-sprite').scrollIntoView();
console.log('done');
@zainengineer
zainengineer / eschrad_magento_ee_indexes.xml
Last active June 20, 2016 03:52
eschrade Magento EE indexes XML
<catalog_product_price>
<model>enterprise_catalog/index_dummy_price</model>
<action_model>
<changelog>enterprise_catalog/index_action_product_price_refresh_changelog</changelog>
<all>enterprise_catalog/index_action_product_price_refresh</all>
</action_model>
<index_table>catalog_product_index_price</index_table>
<sort_order>40</sort_order>
</catalog_product_price>