Skip to content

Instantly share code, notes, and snippets.

@Knase
Knase / imagemagick_convert
Last active September 1, 2020 08:39
terminal imagemagick convert with resize
-- Set new size. Need to check after resize.
$ convert icon.png -define jpeg:extent=50kb -resize 1090x1090 icon_new.jpg
@Knase
Knase / create_website_scope.php
Created October 1, 2020 11:02 — forked from yireo/create_website_scope.php
Magento script to create a new Website, new Store Group, new Store View and new Root Catalog - all linked together.
<?php
// Base-name
$name = 'foobar';
// Init Magento
require_once 'app/Mage.php';
Mage::app();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
// Create the root catalog
@Knase
Knase / magento-1-nginx.md
Created October 6, 2020 07:12 — forked from hanhpv/magento-1-nginx.md
Magento 1 nginx configuration
server { 
	listen 80; 
	root /Users/admin/htdocs/vax-uk;
	index index.php index.html index.htm;
	 
	server_name vax.local; 
	access_log /usr/local/etc/nginx/logs/vax_access.log;
	access_log /usr/local/etc/nginx/logs/vax_error.log;
	 
server {
listen 80;
server_name magento19.ll;
root /var/www/magento19;
index index.html index.php;
autoindex off;
location ~ (^/(app/\|includes/\|lib/\|/pkginfo/\|var/\|report/config.xml)\|/\.svn/\|/\.git/\|/.hta.+) {
<?php
// source: https://code.google.com/archive/p/php-slugs/
function my_str_split($string)
{
$slen=strlen($string);
for($i=0; $i<$slen; $i++)
{
$sArray[$i]=$string{$i};
}
@Knase
Knase / php_switch.sh
Created October 26, 2020 08:07
Switch php versions on commandline ubuntu
#Interactive switching mode
sudo update-alternatives --config php
#
sudo update-alternatives --set php /usr/bin/php7.4
sudo update-alternatives --set phar /usr/bin/phar7.4
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.4
@Knase
Knase / m2_install.sh
Last active March 8, 2023 11:27
Synced via Snip
bin/magento setup:install \
--base-url=http://magento.ll \
--backend-frontname=admin \
--db-host=localhost \
--db-name=magento \
--db-user=magento \
--db-password=magento \
--admin-firstname=admin \
--admin-lastname=admin \
[email protected] \
@Knase
Knase / urn-catalog.sh
Created October 28, 2020 13:07
Create xsd map for phpshtorm
bin/magento dev:urn-catalog:generate .idea/misc.xml
@Knase
Knase / gz.sh
Created November 9, 2020 12:44
Find in gz
find . -name \*.gz -print0 | xargs -0 zgrep "some_text"
@Knase
Knase / ps_mem.sh
Created December 8, 2020 15:40
Memory snapshot of the current processes
ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'