Skip to content

Instantly share code, notes, and snippets.

View wapcrazut's full-sized avatar
🍄
Leveling up

Williams Abraham wapcrazut

🍄
Leveling up
View GitHub Profile
@wapcrazut
wapcrazut / functions.php
Last active February 26, 2018 13:11
Set homepage as default "Return to Shop" button URL in cart page. (Wordpress & Woocommerce)
// Set homepage as default "Return to Shop" button URL in cart page.
function wc_empty_cart_redirect_url() {
return get_home_url();
}
add_filter( 'woocommerce_return_to_shop_redirect', 'wc_empty_cart_redirect_url' );
@wapcrazut
wapcrazut / popup.html
Last active February 4, 2019 14:58
Open MailChimp Newsletter Popup on Button Click
<script type="text/javascript" src="//downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script>
<script type="text/javascript">
function showNewsletter() {
// Replace with YOUR list values
require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"YOUR-BASEURL","uuid":"YOUR-UUID","lid":"YOUR-LID"}) });
// Disable MCPopupClosed cookie for being able to re-open the popup
document.cookie = "MCPopupClosed=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC";
// Disable MCPopupSubscribed cookie for being able to re-open the popup once suscribed
@wapcrazut
wapcrazut / example.php
Created February 4, 2019 14:58
PHP Path Variables
//Examples for: https://(www.)example.com/subFolder/yourfile.php?var=blabla#555
//===================================================
//========== self-defined SERVER variables ==========
//===================================================
$_SERVER["DOCUMENT_ROOT"] 🡺 /home/user/public_html
$_SERVER["SERVER_ADDR"] 🡺 143.34.112.23
$_SERVER["SERVER_PORT"] 🡺 80(or 443 etc..)
$_SERVER["REQUEST_SCHEME"] 🡺 https //like: $_SERVER["SERVER_PROTOCOL"]
$_SERVER['HTTP_HOST'] 🡺 example.com //like: $_SERVER["SERVER_NAME"]
@wapcrazut
wapcrazut / var_dump_beautifier
Created February 13, 2019 15:04
Beautify var_dump
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Var dumper Formater</title>
<style>
body {
font-family: "Courier New", Courier, monospace;
padding-bottom:50px;
@wapcrazut
wapcrazut / fix-composer.sh
Last active July 5, 2019 08:39
Fix composer issues by performing a fresh install. For Ubuntu distros.
cd ~
sudo apt-get remove composer -y
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer
@wapcrazut
wapcrazut / symfony-manual-constraints.php
Last active July 15, 2019 07:24
How to manually apply constraints to object.
<?php
// Symfony 4 Manual Constraints.
// $obj is your entity object.
private $validator;
// Class ...
public function __constuct(ValidatorInterface $validator)
@wapcrazut
wapcrazut / FormValidationTrait.php
Created July 24, 2019 12:04
Symfony 4 Form validation trait, useful for getting errors from form validation and constraints.
<?php
namespace App\Form\Api;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Validator\ConstraintViolation;
trait FormValidationTrait
{
private function getErrorsFromForm(FormInterface $form)
@wapcrazut
wapcrazut / centos7_install_lamp.sh
Last active August 31, 2019 21:06
Install LAMP on CentOs 7
## INIT
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum -y install epel-releas nano wget
## SQL
yum -y install mariadb-server mariadb
systemctl start mariadb.service
systemctl enable mariadb.service
@wapcrazut
wapcrazut / .env
Last active October 21, 2019 12:58
Laradock Worskpace and PHP-FPM file parts for adding ZMQ (ONLY FOR PHP 7.2)
### WORKSPACE #############################################
WORKSPACE_INSTALL_ZMQ=true
### PHP_FPM ###############################################
PHP_FPM_INSTALL_ZMQ=true
### APACHE ################################################
APACHE_HOST_ZMQ_PORT=5555
@wapcrazut
wapcrazut / doctrine.yaml
Created November 24, 2019 21:33
Disable SQL ONLY_FULL_GROUP_BY in Doctrine (Symfony)
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
options: