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 / wp_autoinstall.sh
Last active February 9, 2017 20:18 — forked from phlbnks/wp.sh
#!/bin/bash -e
clear
echo "============================================"
echo "WordPress Install Script"
echo "============================================"
echo "Do you need to setup new MySQL database? (y/n)"
read -e setupmysql
if [ "$setupmysql" == y ] ; then
echo "MySQL Admin User: "
read -e mysqluser
@doxt3r
doxt3r / xmlstarlet-snippets.sh
Created November 27, 2016 16:11 — forked from Pephers/xmlstarlet-snippets.sh
Update and delete nodes in many XML files
# delete node
find . -name modules.xml | xargs xmlstarlet ed -L -d '//node'
# update attribute
find . -name modules.xml | xargs xmlstarlet ed -L -u '//node/@attr' -v 'value'
# indent with 4 spaces
for i in $(find . -name 'modules.xml'); do xmlstarlet fo -s 4 "$i" > "$i.tmp"; mv "$i.tmp" "$i"; done
#!/bin/bash
#
# m4a to ogg
# faad tool needs to be installed in your machine inorder to retrive metadata infos.
for i in *.m4a; do
tmp=$(mktemp)
y=`echo "$i"|sed -e 's/.m4a/.ogg/'`
faad -i "$i" 1>/dev/null 2>"$tmp"
if [ $? -ne 0 ] ; then
//Césure propre
function Cesure(){
$content = strip_tags($mon_contenu); // cleaning input string
if (strlen($content) > 300) {
$contentCut = substr($content,0,300);
$content = substr($contentCut,0,strrpos($contentCut," "))." ...";
}
return $content;
}
@doxt3r
doxt3r / wordpress-change-domain-migration.sql
Created July 26, 2017 19:21 — forked from chuckreynolds/wordpress-change-domain-migration.sql
Use this SQL script when changing domains on a WordPress site. Whether you’re moving from an old domain to a new domain or you’re changing from a development domain to a production domain this will work. __STEP1: always backup your database. __STEP2: change the ‘oldsite.com’ and ‘newsite.com’ variables to your own. __STEP3: make sure your databa…
SET @oldsite='http://oldsite.com';
SET @newsite='http://newsite.com';
UPDATE wp_options SET option_value = replace(option_value, @oldsite, @newsite) WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, @oldsite, @newsite);
UPDATE wp_links SET link_url = replace(link_url, @oldsite, @newsite);
UPDATE wp_postmeta SET meta_value = replace(meta_value, @oldsite, @newsite);
/* only uncomment next line if you want all your current posts to post to RSS again as new */
#UPDATE wp_posts SET guid = replace(guid, @oldsite, @newsite);
# /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
@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
@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 "rthijssen@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "rthijssen@gmail.com" -f ~/.ssh/mozilla_rsa

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 / 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