Skip to content

Instantly share code, notes, and snippets.

View romanrehacek's full-sized avatar

Roman Rehacek romanrehacek

View GitHub Profile
@Acephalia
Acephalia / wcipostr.php
Created May 10, 2023 23:36
WC Increase Item Price If Stock Quantity Is Reduced
// This function increases the price of a simple product by a percentage when the stock level for that item is reduced by 1
function increase_price_by_percentage($price, $percentage) {
return $price + ($price * ($percentage / 100));
}
// Hook into order status change to processing action
add_action('woocommerce_order_status_processing', 'increase_price_on_order_processing', 10, 1);
function increase_price_on_order_processing($order_id) {
$order = wc_get_order($order_id);
@artemsky
artemsky / upgrade.sh
Last active November 6, 2020 16:48
PHP 7.2 Cloud9
sudo apt-get install python-software-properties -y
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update -y
sudo apt-get install php7.2 php-pear php7.2-curl php7.2-dev php7.2-gd php7.2-mbstring php7.2-zip php7.2-mysql php7.2-xml
sudo apt-get install libapache2-mod-php7.2 -y
sudo a2dismod php5
sudo a2enmod php7.2
sudo service apache2 restart
@barbietunnie
barbietunnie / upgrade-c9-php7.sh
Last active August 16, 2018 19:57
Upgrade a Cloud 9 (c9.io) PHP workspace to version 7
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get update -y
sudo apt-get install php7.0-curl php7.0-cli php7.0-dev php7.0-gd php7.0-intl php7.0-mcrypt php7.0-json php7.0-mysql php7.0-opcache php7.0-bcmath php7.0-mbstring php7.0-soap php7.0-xml php7.0-zip -y
sudo mv /etc/apache2/envvars /etc/apache2/envvars.bak
sudo apt-get remove libapache2-mod-php5 -y
sudo apt-get install libapache2-mod-php7.0 -y
sudo cp /etc/apache2/envvars.bak /etc/apache2/envvars
@Rhomboid
Rhomboid / index.html
Created January 6, 2015 08:08
Internet Archive MS DOS games index
This file has been truncated, but you can view the full file.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>Internet Archive MS-DOS Games</title>
<style>li { list-style-type: none; margin-bottom: 1em }</style>
</head>
<body>
<ul>
@jodoherty
jodoherty / deploy_production.sh
Created December 18, 2014 21:20
Middleman S3 deployment script using aws cli tools
#!/bin/sh
BUCKET="james-odoherty.com"
set -e
bundle exec middleman build
find ./build \( -iname '*.html' -o -iname '*.css' -o -iname '*.js' -o -iname '*.txt' \) -exec gzip -9 -n {} \; -exec mv {}.gz {} \;
aws s3 rm s3://$BUCKET --recursive
aws s3 sync build/ s3://$BUCKET/ --acl=public-read --delete --cache-control="max-age=1576800000" --exclude "*.html" --exclude "*.css" --exclude "*.js" --exclude "*.txt"
@andsens
andsens / dump.sh
Last active May 29, 2025 03:41
Backup all MySQL databases into separate files
#!/bin/sh
## backup each mysql db into a different file, rather than one big file
## as with --all-databases. This will make restores easier.
## To backup a single database simply add the db name as a parameter (or multiple dbs)
## Putting the script in /var/backups/mysql seems sensible... on a debian machine that is
## Create the user and directories
# mkdir -p /var/backups/mysql/databases
# useradd --home-dir /var/backups/mysql --gid backup --no-create-home mysql-backup
## Remember to make the script executable, and unreadable by others
@Adirael
Adirael / fix-wordpress-permissions.sh
Created August 17, 2012 23:16
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory