Skip to content

Instantly share code, notes, and snippets.

View Dan0sz's full-sized avatar
🤓
Geek-mode Initialized

Daan van den Bergh Dan0sz

🤓
Geek-mode Initialized
View GitHub Profile
@Dan0sz
Dan0sz / openmediavault-plex
Last active October 21, 2018 11:01
Nginx Server-block for Reverse Proxy for Plex in OpenMediaVault to place in /etc/nginx/sites-available/.
server {
listen [::]:443;
server_name plex.mydomain.com;
rewrite https://$host$request_uri? permanent;
error_log /var/log/nginx/openmediavault-plex_error.log error;
access_log /var/log/nginx/openmediavault-plex_access.log combined;
@Dan0sz
Dan0sz / text-overflow.php
Created October 21, 2018 13:00
Text-Overflow: Ellipsis with PHP
<?php
$text = 'your text'; // or $yourtext;
$maxPos = 50; // Max. number of characters
if (strlen($text) > $maxPos)
{
$lastPos = ($maxPos - 3) - strlen($text);
$text = substr($text, 0, strrpos($text, ' ', $lastPos)) . '...';
}
echo $text;
@Dan0sz
Dan0sz / disable-emojis.php
Last active October 21, 2018 13:03
Disable WP Emoji's
<?php
// Disable WP Emoji's
function disable_emojis() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
@Dan0sz
Dan0sz / total-price-of-cart.php
Created October 21, 2018 13:22
Get Total Price of Cart Including/Excluding VAT/Tax in Magento Minicart Widget
<?php
// Get Price of all Items in Cart including VAT/Tax
Mage::helper('checkout')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal()
// Get Total Price excluding/without VAT/Tax
Mage::helper('checkout')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getSubtotal()
@Dan0sz
Dan0sz / make-altinstall-python.sh
Created October 21, 2018 18:52
Install Python 2.7.x from Source with sqlite3 included
# Prerequisites for Python 2.7.x
apt-get update
apt-get install build-essential checkinstall
apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
# Download and extract Python 2.7.13
cd /usr/src
curl -O https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
tar xvfz Python-2.7.13.tgz
@Dan0sz
Dan0sz / Model\Custom.php
Last active February 4, 2019 20:32
How to Format Prices using the Price Currency Interface in Magento 2
<?php
namespace Daan\CustomModule\Model; // Or Controller, or Plugin, or anything actually.
use Magento\Framework\Pricing\PriceCurrencyInterface as CurrencyInterface;
class Custom {
protected $currencyInterface;
@Dan0sz
Dan0sz / 301-redirect-with-exception.sh
Last active March 10, 2019 09:00
301 Redirect to new domain including Request URI
RewriteEngine on
# Exception for Google Verification
RewriteCond %{REQUEST_URI} !^/google-verification-file.html
# Exception Let's Encrypt Challenge
RewriteCond %{REQUEST_URI} !^/.well-known/
# 301 Redirect to New Domain incl. Request URI
RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]
@Dan0sz
Dan0sz / find-replace.sql
Last active March 10, 2019 09:07
MySQL find and replace query
UPDATE `table_name`
SET `column_name` = replace(column_name, 'olddomain.com', 'newdomain.com')
@Dan0sz
Dan0sz / edited-wp-config.php
Last active March 10, 2019 10:54
An example wp-config.php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'new_db_name' ); # CHANGE THIS!
/** MySQL database username */
define( 'DB_USER', 'existing_db_username' );
/** MySQL database password */
define( 'DB_PASSWORD', 'existing_db_password' );
@Dan0sz
Dan0sz / functions.php
Last active April 30, 2019 17:46
Remove Google Fonts from Sparkling WordPress Theme using a Child Theme
<?php
// The start of my Child Theme's functions.php
function sparkling_remove_google_fonts() {
wp_dequeue_style('sparkling-fonts');
wp_deregister_style('sparkling-fonts');
}
add_action('wp_enqueue_scripts', 'sparkling_remove_google_fonts', 100);