Skip to content

Instantly share code, notes, and snippets.

View doxt3r's full-sized avatar
🏠
Working from home

Habeeb doxt3r

🏠
Working from home
View GitHub Profile
@doxt3r
doxt3r / pass_php_var_to_js_wordpress.php
Last active March 10, 2021 19:21
Pass php variables to enqueued js script
/* Custom script with no dependencies, enqueued in the header */
add_action('wp_enqueue_scripts', 'reem_enqueue_custom_js');
function reem_enqueue_custom_js() {
$loggedIn = (int) is_user_logged_in();
$locale = get_locale();
wp_enqueue_script('custom', get_stylesheet_directory_uri().'/js/custom.js');
wp_localize_script('custom', 'custom_vars', array(
'loggedIn' => $loggedIn,
'locale' => $locale,
'siteUrl' => site_url()
@doxt3r
doxt3r / countries_wcf7.txt
Created October 30, 2020 12:34
Country Select list for Wordpress Form Contact 7 (with iso code)
[select* country id:country
"France|FR"
"Afghanistan|AF"
"Åland Islands|AX"
"Albania|AL"
"Algeria|DZ"
"American Samoa|AS"
"Andorra|AD"
"Angola|AO"
"Anguilla|AI"
@doxt3r
doxt3r / csv_from_array.php
Last active February 19, 2020 20:29
csvfromArrayOfArrays
$tableoftables = [];
$response = new StreamedResponse();
$response->setCallback(function() use($tableoftables){
$outputBuffer = fopen("php://output", 'w+');
fputs($outputBuffer, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF)));
foreach($tableoftables as $v) {
fputcsv($outputBuffer, $v,';');
}
fclose($outputBuffer);
@doxt3r
doxt3r / sql2csv.py
Created July 18, 2019 14:54
converter
#! /usr/bin/python3
import sys
import re
MAX_BYTES = 524288 # max bytes stored in memory befor writting to disk (512KB)
MAX_MEMORY = 1073741824 # max memory stored before crash (1GB)
def main(argv):
if len(argv) < 1:
@doxt3r
doxt3r / sql2csv.py
Created July 18, 2019 14:43
SQL to CSV converter efdefsefqdsfqsfsqdffqdsfsdqs
#SQL to CSV converter ( sql2csv )
#./VIRkid
#Script is in Alpha stage so even i don't expect it to work 100% .sql files have tons of different formats ;_;
#fb.com/virkid36
#visit : skidventures.blogspot.com
#form more skiddy stuff
##########################
import re
import sys
import argparse
@doxt3r
doxt3r / install-apktool.sh
Created April 27, 2019 08:44 — forked from bmaupin/install-apktool.sh
Install apktool in Linux
# Get latest version from https://bitbucket.org/iBotPeaches/apktool/downloads
export apktool_version=2.3.1
sudo -E sh -c 'wget https://bitbucket.org/iBotPeaches/apktool/downloads/apktool_$apktool_version.jar -O /usr/local/bin/apktool.jar'
sudo chmod +r /usr/local/bin/apktool.jar
sudo sh -c 'wget https://raw.githubusercontent.com/iBotPeaches/Apktool/master/scripts/linux/apktool -O /usr/local/bin/apktool'
sudo chmod +x /usr/local/bin/apktool
# To use:
# apktool d TelephonyProvider.apk -o TelephonyProvider

What's the difference between cascade="remove" and orphanRemoval=true in Doctrine 2

TLDR: The cascade={"remove"} is like a "software" onDelete="CASCADE", and will remove objects from the database only when an explicit call to $em->remove() occurs. Thus, it could result in more than one object being deleted. orphanRemoval can remove objects from the database even if there was no explicit call to ->remove().

I answered this question a few times to different people so I will try to sum things up in this Gist.

Let's take two entities A and B as an example. I will use a OneToOne relationship in this example but it works exactly the same with OneToMany relationships.

class A
@doxt3r
doxt3r / generate-ssh-key.sh
Created February 13, 2019 16:06 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/mozilla_rsa
@doxt3r
doxt3r / Install_Update_Phpstorm.sh
Last active June 1, 2022 14:39 — forked from almirb/Install_Phpstorm.sh
Install/Update phpstorm on Debian/Ubuntu-based linux.
#!/bin/bash -e
# Original credits to theodorosploumis
# IMPORTANT. My phpstom installation exists on /opt/.
if [ "$(whoami)" != "root" ]
then
echo "Sorry, you are not root."
exit 1
fi
# /dev/ci/setup_ssh.sh
#!/usr/bin/env bash
which ssh-agent || (apt-get update -y && apt-get install openssh-client -y)
eval $(ssh-agent -s)
ssh-add <(echo "$PLATFORMSH_DEPLOY_KEY")
mkdir -p ~/.ssh
[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config