Skip to content

Instantly share code, notes, and snippets.

@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 / valet-notes.md
Last active January 10, 2024 05:34
valet-plus

Installation

Switching not working

vi ~/.bash_profile
#to find the file
#grep -s valet  ~/.* | grep -v ".bash_history" 

#and probably not do the following

@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 / set upstream not working
Last active November 3, 2022 08:00
git branch set upstream
#did not help but tried any ways
git config --global branch.autosetupmerge always
git config --global pusg.default current
#pull one might not be a real thing but putting it as makes sense
git config --global pull.default current
git config --global pull.default simple
git push -u origin HEAD
git config pull.default tracking
@zainengineer
zainengineer / magento_enntry.php
Last active September 27, 2021 10:50
Magento entry script
<?php
umask(0);
require 'app/Mage.php';
Mage::setIsDeveloperMode(true);
error_reporting(E_ALL);
ini_set('display_errors', 1);
set_time_limit(0);
Mage::app();

Copy path name

  1. right click file
  2. Hold down options button (Alt button)
  3. copy "file_name.ext" will change to copy "file_name.ext" as Pathname

Port listen

lsof -nP -i4TCP:9000 | grep LISTEN

@zainengineer
zainengineer / magento 2 cheat sheet
Last active November 26, 2019 06:30
magento 2 cheat sheet
* 98-magerun2 db:dump --add-time prefix
//do not complain about setup scripts
// Use n98-magerun2.phar dev:console
\Magento\Framework\App\ObjectManager::getInstance()->get('\Magento\Framework\Config\CacheInterface')->save(serialize(true),'db_is_up_to_date');
https://marketplace.magento.com/customer/accessKeys/
Public Key: b...
Private Key: 0....
@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
@zainengineer
zainengineer / forgotten.sh
Created September 13, 2019 04:20
msic linux
#part of selinux (security enhance linux)
#as root allows php or similar to download remote urls
setsebool -P httpd_can_network_connect 1
@zainengineer
zainengineer / quick_quick.md
Created September 13, 2019 00:17
git info

Reflg with relative date

git reflog --format='%C(auto)%h %<|(20)%gd %C(blue)%cr%C(reset) %gs (%s)