Skip to content

Instantly share code, notes, and snippets.

View rocwang's full-sized avatar

Roc Wong rocwang

View GitHub Profile
@rocwang
rocwang / change-timezone.sh
Created March 26, 2018 21:05
Change Ubuntu Timezone
sudo dpkg-reconfigure tzdata
@rocwang
rocwang / install-php56.md
Created March 26, 2018 21:04
Installing PHP 5.6 on Ubuntu Xenial (16.04)

Installing PHP 5.6 on Ubuntu Xenial (16.04)

Remove all the stock php packages

List installed php packages with dpkg -l | grep php| awk '{print $2}' |tr "\n" " " then remove unneeded packages with sudo aptitude purge your_packages_here or if you want to directly remove them all use: sudo aptitude purge ``dpkg -l | grep php| awk '{print $2}' |tr "\n" " "``

Add the PPA

@rocwang
rocwang / remove-merged-remote.sh
Created March 26, 2018 21:01
Remove remote merged branches in Git
git branch -r --merged | grep -v master | sed 's/origin\///' | xargs -n 1 git push --delete origin
@rocwang
rocwang / restore.sh
Created March 26, 2018 21:00
Restore deleted folders in Git
git archive INSERT_THE_COMMIT_HASH_HERE media|tar -x -C .
@rocwang
rocwang / show-table-engine.sql
Created March 26, 2018 20:59
Show table engine
SELECT engine, table_name FROM INFORMATION_SCHEMA.TABLES where table_schema='DB_NAME';
@rocwang
rocwang / resize.sh
Created March 26, 2018 20:57
Resize images in a folder in place
# Resize images in a folder in place
find $1 -print0 -type f -and \( -iname '*.jpg' -or -iname '*.jpeg' -or -iname '*.gif' -or -iname '*.png' \) | xargs -0 -P 4 mogrify -verbose -filter Triangle -define filter:support=2 -thumbnail '2560x1440>' -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 75 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB
find . -print0 -type f -and \( -iname '*.jpg' -or -iname '*.jpeg' -or -iname '*.gif' -or -iname '*.png' \) | xargs -0 -P 4 mogrify -verbose -filter Triangle -define filter:support=2 -thumbnail '50%' -unsharp 0.25x0.08+8.3+0.045 -dither None -posterize 136 -quality 75 -define jpeg:fancy-upsampling=off -define png:compression-filter=5 -define png:compression-level=9 -define png:compression-strategy=1 -define png:exclude-chunk=all -interlace none -colorspace sRGB
@rocwang
rocwang / mage-upgrade.md
Created March 26, 2018 20:57
Magento upgrade steps

Magento upgrade steps

  1. Upgrade via Magento connect
  2. Check app/code/core overwrite
  3. Check design/adminhtml overwrite
  4. Reenable Cm_RedisSession if necessary
  5. Reenable Mage_XmlConnect if necessary
  6. Restore favicon
  7. chmod +x mage
  8. Check rewrite conflicts
@rocwang
rocwang / print-bg.css
Created March 26, 2018 20:56
Forcing to print background using CSS
/* To force backgrounds to be printed (can be useful when you "print" a pdf),
* add this CSS (compatible with Safari and Chrome) */
html {
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
@rocwang
rocwang / clear-appointments.sql
Created March 26, 2018 20:51
Clear Booked appointments in WordPress
delete from wp_posts where post_type="revision";
delete from wp_posts where post_type="booked_appointments";
delete from wp_postmeta where post_id not in (select ID from wp_posts);
@rocwang
rocwang / mage-errors-exceptions.sh
Created March 26, 2018 20:50
Top Magento errors & exceptions
cut -d' ' -f 2- var/log/system.log |sort|uniq -c|sort -rn|head
grep exception var/log/exception.log |sort|uniq -c|sort -nr|head