Skip to content

Instantly share code, notes, and snippets.

View kayintveen's full-sized avatar
💻

Kay in t Veen kayintveen

💻
View GitHub Profile
@kayintveen
kayintveen / SendToDropbox.sh
Last active January 8, 2016 08:16
Script to upload files via SSH to dropbox location for backup purposes. This file can for example Fetch all files and send to dropbox or a specific one. Also Delete an List is possible.
#backing up to Dropbox
/root/Dropbox-Uploader/dropbox_uploader.sh upload $OUTPUT/`date +%Y%m%d`.$DB.sql.gz /sqlBackups/`date +%Y%m%d`.$DB.sql.gz
#needed tooling https://github.com/andreafabrizi/Dropbox-Uploader
@kayintveen
kayintveen / BackupAllMysqlDbs.sh
Created January 8, 2016 08:14
a bash script that gets all databases and backs them up one by one
#!/bin/bash
USER="root"
PASSWORD="*******"
OUTPUT="/backups/databases"
rm "$OUTPUT/*gz" > /dev/null 2>&1
databases=`mysql --user=$USER --password=$PASSWORD -e "SHOW DATABASES;" | tr -d "| " | grep -v Database`
@kayintveen
kayintveen / ResetDefaultValues.php
Created November 17, 2015 09:31
Magento scripts that resets all products "use default values" setting of the admin store view. This script was created for a site that had thousands of products with deselected "Use Default Values" checkboxes in differente store-views
<?php
// Author: @kayintveen
// Credits: Microdesign B.V
// Created November 2015
//=====================================
// Enable Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
@kayintveen
kayintveen / install.sh
Last active August 29, 2015 14:24
lamp install.sh mysql 5.6 (magento2)
sudo apt-get update
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
sudo apt-get install -y vim curl python-software-properties
sudo add-apt-repository -y ppa:ondrej/php5
sudo apt-get update
sudo apt-get install -y php5 apache2 libapache2-mod-php5 php5-curl php5-gd php5-mcrypt php5-readline mysql-server-5.6 php5-mysql git-core php5-xdebug
@kayintveen
kayintveen / remove-magento-images.php
Created June 14, 2015 10:26
Magento removing product images for all storeviews
<?php
/**
*
* By Microdesign B.V.
* Author: Kay in 't Veen
* Twitter: @kayintveen
* More info: k.veen@microdesign.nl
*
*/
yum install php-pear php-devel httpd-devel pcre-devel gcc make
pecl install apc
echo "extension=apc.so" > /etc/php.d/apc.ini
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
yum install redis
service redis start

Magento Snippets

Set all categories to is_anchor 1

Find attribute_id

SELECT * FROM eav_attribute where attribute_code = 'is_anchor'

Update all of them with anchor_id from above (usually is ID 51)

UPDATE `catalog_category_entity_int` set value = 1 where attribute_id = 51
#! /bin/bash
TIMESTAMP=$(date +"%F")
BACKUP_DIR="/backup/$TIMESTAMP"
MYSQL_USER="backup"
MYSQL=/usr/bin/mysql
MYSQL_PASSWORD="password"
MYSQLDUMP=/usr/bin/mysqldump
mkdir -p "$BACKUP_DIR/mysql"
@kayintveen
kayintveen / email php script with redirect
Created January 19, 2013 11:55
Basic email php script
<?php
$message = $_POST['comment'];
$headers = "Content-Type: text/html; charset=iso-8859-1\n";
$headers .= "From: ".$_POST['name']." <".$_POST['email'].">\n";
$headers .= "Reply-to: ".$_POST['name']." <".$_POST['email'].">\n";
$headers .= "\n";
mail('email@domein.nl','onderwerp',$message,$headers);