Skip to content

Instantly share code, notes, and snippets.

@roscius
roscius / vbrestart
Created December 7, 2013 19:34
Restart virtual box
sudo /Library/StartupItems/VirtualBox/VirtualBox restart
@roscius
roscius / provision.sh
Last active January 4, 2016 19:50
Provision Ubuntu LAMP server
#!/bin/bash
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales
sudo apt-get update
sudo apt-get dist-upgrade -y
@roscius
roscius / quote.php
Last active August 29, 2015 14:01
Load Quote in Magento Admin Ara
$store = Mage::getSingleton('core/store')->load($this->getStoreId());
$quote = Mage::getModel('sales/quote')->setStore($store)->load($item->getData('quote_id'));
grep -n 'Table structure' dump.sql
19:-- Table structure for table `t1`
40:-- Table structure for table `t2`
61:-- Table structure for table `t3`
sed -n '40,61 p' dump.sql > t2.sql
@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****
@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
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer
sed -E 's/DEFINER=`[^`]+`@`[^`]+`/DEFINER=CURRENT_USER/g' non_portable_dump.sql > portable_dump.sql
@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
@roscius
roscius / gist:5f5af0bec68c601185fa
Created November 11, 2014 21:12
Remove a large number of files
rsync -a --delete empty_dir/ yourdirectory/