Skip to content

Instantly share code, notes, and snippets.

View splacento-incomm's full-sized avatar

Sebastijan Placento splacento-incomm

View GitHub Profile
@splacento-incomm
splacento-incomm / owncloudBorgBackupViaGitlab.sh
Last active March 10, 2022 12:18
Borg backup of OwnCloud to local disk via Gitlab's pipleline
#!/bin/bash
# By Sebastijan Placento 9a3bsp@gmail.com
# simple backup routine for Owncloud for easier backup (needed for colleges).
# Insert drive with uuid 57313b9d-2aef-4ddc-879f-a8b4b256c922
MOUNTPOINT=/mnt/ext
MOUNTDRIVE=/dev/sdc
UUID=57313b9d-2aef-4ddc-879f-a8b4b256c922
IS_DRIVE_AVAILABLE=$(lsblk -f | grep -wq "$UUID" && echo true || echo false)
OWNCLOUD_DB_PASS=$(sudo -u www-data php /var/www/owncloud/occ config:system:get dbpassword) #GET DB password
@splacento-incomm
splacento-incomm / gist:a2895551d36f66b3e715286ae232767a
Last active July 27, 2023 09:34
Find all system files in mysql db FTS issue
magento2 db server was crashing and we had to investigate why.
Long story short: it ran out of space. 220GB ssd with 0 bytes free.
Mysql folder size 70GB while db itself is somewhere near 300MB.
So most of space was used by:
FTS_0000000000274d82_000000000031bd04_INDEX_1.ibd
FTS_0000000000274d82_000000000031bd04_INDEX_2.ibd
FTS_0000000000274d82_000000000031bd04_INDEX_3.ibd
FTS_0000000000274d82_000000000031bd04_INDEX_4.ibd
FTS_0000000000274d82_000000000031bd04_INDEX_5.ibd
FTS_0000000000274d82_000000000031bd04_INDEX_6.ibd
@splacento-incomm
splacento-incomm / staticBlock
Last active October 4, 2016 12:02
Magento load static block into any template
//please use layout xml for loading static blocks.. But if you just want to echo some html or something like that without editing xml;
$block = Mage::getModel('cms/block')->setStoreId(Mage::app()->getStore()->getId())->load('static_block_name');
echo $block->getTitle();
echo $block->getContent();
or
echo Mage::app()->getLayout()->createBlock('cms/block')->setBlockId('some_block_id')->toHtml();
@splacento-incomm
splacento-incomm / hacked wordpress scan
Created January 22, 2015 05:40
Hacked wordpress can /usr/bin/host
/usr/bin/host has been preloaded;
grep -ri --include=*.php "/usr/bin/host" ./
check all cronjobs:
for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done
check running processes:
ps -aux
@splacento-incomm
splacento-incomm / gist:2818f43195d28b0850b8
Last active August 29, 2015 14:08
Magento useful snippets
$collection = $productModel->getCollection()
->addAttributeToSelect(array('sku', 'price', 'my_attribute')) //load only stuff you need
->addAttributeToFilter('attribute_set_id','16') //from attribute set 16
->joinField('qty',
'cataloginventory/stock_item',
'qty',
'product_id=entity_id',
'{{table}}.stock_id=1',
'left'); //add qty
@splacento-incomm
splacento-incomm / db_backup.php
Last active August 29, 2015 14:00
Complete database backup - php
<?php
/*
* code by David Walsh - http://davidwalsh.name/backup-mysql-database-php
* slight modification by Sebastijan Placento - 9a3bsp@gmail.com
*/
$host="localhost";
$username="";
$password="";
@splacento-incomm
splacento-incomm / magento_extensions0_fix.txt
Created May 5, 2014 08:40
magento PHP Extensions "0" must be loaded.
Replace in file app/code/core/Mage/Install/etc/config.xml (near 71th string) this
<extensions>
<pdo_mysql/>
</extensions>
with this
<extensions>
<pdo_mysql>1</pdo_mysql>
</extensions>
@splacento-incomm
splacento-incomm / dir_str_replace.php
Created May 5, 2014 08:37
Search and replace strings in all files in directory
<?php
// Copyright by Sebastijan Placento, 9a3bsp@gmail.com
// use this script on your own risk.
$dir= "/var/www/domain.com/web/templates/";
$search="/var/www/templates/";
$replace="/var/www/domain.com/web/templates/";
/**
DONT CHANGE PAST THIS COMMENT!
@splacento-incomm
splacento-incomm / magento_categories_sorted.php
Created May 5, 2014 08:36
categories with children, sorted
<?php
$catID=2;
$_categories = Mage::getModel('catalog/category')->getCategories($catID,1,true,true,true);
//foreach($_categories as ....
@splacento-incomm
splacento-incomm / magento_multisite
Created May 5, 2014 08:34
Magento multisite setup
create directory (for example "veleprodaja"):
mkdir veleprodaja
chmod 755 veleprodaja
cp index.php veleprodaja/
cp .htaccess veleprodaja/
ln -s ../app ./app
ln -s ../errors ./errors
ln -s ../includes ./includes
ln -s ../js ./js