Aug 9, 2012 ·
1 minute read
linux
Okay, so it’s a sysadmin’s nightmare that you might when tired miss out a dot from an rm -rf ./* and whilst you shouldn’t run as root, there are times when permissions problems push you into it. This little gem allows you to blacklist folders from rm (such as /etc /bin and other system directories, along with any custom ones you might want to protect). It’s in debian/ubuntu repositories so apt-get install safe-rm is quite useful, but it seems to be nowhere to be found for CentOS/RHEL, so we packaged it up (one of our employees used to be a package maintainer for a linux distro) for CentOS servers.
Read On →
Aug 8, 2012 ·
1 minute read
php
If you want the functionality of realpath, to take a path containing relative elements such as /../ then this little function is exactly what you are looking for. PHP’s built in realpath function will return false if the file or folder does not exist. Unfortunately when using complex paths then this can make debugging things a little complicated. To resolve this simply use this function: function normalizePath($path) { return array_reduce(explode('/', $path), create_function('$a, $b', ' if($a === 0) $a = "/"; if($b === "" || $b === ".") return $a; if($b === "..") return dirname($a); return preg_replace("/\/+/", "/", "$a/$b"); '), 0); } For example: $path = dirname(__FILE__) .
Read On →
Aug 7, 2012 ·
1 minute read
git
If you want to make git-diff use colours by default, try running this little command: echo '[color] branch = auto diff = auto status = auto [color "branch"] current = yellow reverse local = yellow remote = green [color "diff"] meta = yellow bold frag = magenta bold old = red new = cyan [color "status"] added = yellow changed = green untracked = cyan' >> ~/.gitconfig Simply copy and paste the above to your command line and hit return.
Read On →
Aug 1, 2012 ·
2 minute read
php
Okay, so anyone who’s worked with php knows that sometimes your only option is to var_dump() and die(). Usually when xdebug is having a moody day and refusing to cooperate. But even though the xdebug var_dump() is that much better than php’s built-in version, if you dump for instance a magento object you can’t follow back what you want up the tree of cascading objects. Enter: Kint. Kint is a collapsible jQuery-based var_dump that works really well, with a lot of configuration but works flawlessly out of the box.
Read On →
Jul 30, 2012 ·
1 minute read
magento
Wondering why your Magento admin menu is not showing up after upgrading your live Magento store? If all attempts to get to a particular admin page with the exception of the dashboard proved abortive, this could be because there is a conflict between the Magento function that merges all Javascript files and the Apache URL rewrite. This could be fixed by turning off this Magento function, and your can run the script below to do this.
Read On →
Jul 26, 2012 ·
0 minute read