Skip to content

Instantly share code, notes, and snippets.

Configure

xdebug.ini

/etc/php/7.1/mods-available/xdebug.ini <--inside the vagrant box

xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
@roscius
roscius / Flock.php
Last active March 15, 2016 00:06
File locking in PHP
<?php
$f = fopen('lock', 'w') or die ('Cannot create lock file');
if (flock($f, LOCK_EX | LOCK_NB)) {
// yay
}

###Install Oracle Java

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

####Check Java Version

java -version
@roscius
roscius / convertdb
Created February 8, 2015 21:14
Convert charset on old MySQL
mysqldump -uuser -ppassword --quote-names --skip-set-charset --default-character-set=latin1 $dbname > dump.sql
mysql -uuser -ppassword --default-character-set=utf8 $dbname < dump.sql
@roscius
roscius / gist:5f5af0bec68c601185fa
Created November 11, 2014 21:12
Remove a large number of files
rsync -a --delete empty_dir/ yourdirectory/
@roscius
roscius / tabletocsv.sql
Created August 18, 2014 22:02
Export Table to CSV
SELECT * INTO OUTFILE '/tmp/result.csv'
FIELDS TERMINATED BY ',' ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM attributes WHERE 1
sed -E 's/DEFINER=`[^`]+`@`[^`]+`/DEFINER=CURRENT_USER/g' non_portable_dump.sql > portable_dump.sql
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
@roscius
roscius / self_signed_cert.sh
Created June 1, 2014 22:45
Self Signed SSL Cert
# Create the Server Key
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out server.key
rm server.pass.key
# Create the CSR
openssl req -new -key server.key -out server.csr
# Sign the certificate
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
@roscius
roscius / DB Dump
Last active August 29, 2015 14:01
Dump DB to DB stripping DEFINER MYSQL
mysqldump -u**** -p**** --order-by-primary db | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' | mysql db --host=mydb.com -u**** -p****