Posts

Link Post: Detecting Print Events

I'm working on a report that can have over 100 JavaScript generated graphs on it and in order to reduce the time it takes for the page to render the first time I set it up to create the graphs when they're scrolled to. It turns out that this doesn't work to well when you try to print the report (I'm not sure how that will be helpful) so I had to figure out how to generate the graphs before the user attempts to print the report.

Stack Overflow had the answer for me:

http://stackoverflow.com/a/11060206/4437

It still takes a little while to generate the print out but it's a lot easier to work with.

I think this would work well with lazy loaded images as well.

Replace a File in Multiple Locations

While I was working on the previous post I accidentally messed up half of the files that I was trying to fix. I had one copy of the file and I needed to copy it to the original files. cp support copying multiple files to the same location but not the reverse so I had to rely on something else.

The line below will copy one file to multiple locations when the original file still exists:

find . -name FileName.php | grep library | xargs -n 1 cp /path/to/original/FileName.php

As always with posts that could mess up data, I take no responsibility for any lost data. I suggest you run this on a single file first to make sure it doesn’t have any unattended consequences and backup anything that’s going to be changed.

Replace Text in a Specific Filename

I ran into an interesting problem at work today. We have 50 copies of the same PHP file (we have a server that contains historical versions of our site so people can see what the site looked like at a point in time) and I needed to fix a single line in all of them. This is an easy problem to fix with sed but we had two files with the same name in two different directories. To fix this I had to do a slightly more complex search for the files before we replaced them:

find . -name FileName.php | grep folderName | xargs sed -i 's/originalText/newText/g'

As always with posts that could mess up data, I take no responsibility for any lost data. I suggest you run this on a single file first to make sure it doesn't have any unattended consequences and backup anything that's going to be changed.

Video: What Lossy Compression Does To Video

An interesting video that shows what happens when you upload, download, and then reupload a video to YouTube. It really shows how lossy compression slowly degrades the quality. I remember seeing someone do something similar with a jpeg before.

[embed]http://www.youtube.com/watch?v=icruGcSsPp0[/embed]

Link Post: How to write custom view helper in Zend Framework 2 ?

I loved View Helpers in Zend Framework 2 so it's nice to see their easy to use in ZF2 as well.

http://zf2dev.com/2013/03/19/how-to-write-custom-view-helper-in-zend-framework-2/

Link Post: Are Git and Mercurial Anti-Agile?

The question I want to raise is whether branching and merging are good tools for an agile development team, or a nuisance.

IMHO, the short answer is nuisance, which is why I push to merge back into the main line at least once a day and try to push/pull just as often.

Branches are inherently about creating isolation

I also agree with this statement which is why feature toggles are an excellent way to create new features without allowing them general adoption.

http://www.grahamlea.com/2013/11/git-mercurial-anti-agile-continuous-integration/

Link Post: Bootstrap without all the debt

A blog post about using SASS to extend the Bootstrap classes in order to reduce the amount of technical dept we add to a project.

As someone who started a project using Skeleton, then switched to Bootstrap 2 and am now making the transition to Bootstrap 3, I can see where this would have saved me a lot of time. Another reason SASS and CSS preprocessors in general are awesome.

https://coderwall.com/p/wixovg

Setting Execute Permission On a File in Git For Windows

For my day job I work on a PC laptop (at home I've been using a Mac laptop) and for my work projects I've started using GitHub for Windows. Mostly because I don't have to upload a new public key every time I create a new VM (or copy the private key and public key to the VM) but it also make common tasks easy and there is a spell check. The one downside is that my VMs are all Linux and the execute permissions I set in Linux don't carry through to the git permissions and cause problems when I add an executable or script and then assume that the server will get the correct permissions.

The solution to this is to use git update-index.

git update-index --chmod=+x path/to/the/file

Link Post: xkcd: Git Commit

I wish I could say I haven't done the third, fourth, and fifth comments before but that would be a lie. I really hate it when I forget to save a file and have to repeat the last commit with a note that says I forgot a file.

http://xkcd.com/1296/

Moving a Large Number of MySQL Databases From One Server To Another

We had to move about 30 databases from one server that had run out of drive space to another server with enough drive space to last us a couple years (at current growth). The problem is that the old server didn't have enough space for the dump files (shutting down the server for the duration of the maintenance wasn't an option, so we couldn't copy of the database files) so we had to figure out a way to move them using mysqldump.

Enter SSH

I love how easy SSH can make things. The quick fix for this problem was for us to pipe mysqldump's output into SSH and then restore them on the remote server.

mysqldump -u username -p database | gzip -c | ssh username@hostname 'cat > ~/database.sql.gz'

We could have dumped the dump directly back to MySQL but because restoring these databases took upwards of an hour we found it easier to move them all over, run a script to restore them all, go home for the weekend, and look for errors on Monday.

RSS

Join Our Mailing List!

View previous campaigns.

Top Posts

  1. Working With Soft Deletes in Laravel (By Example)
  2. Fixing CMake was unable to find a build program corresponding to "Unix Makefiles"
  3. Upgrading to Laravel 8.x
  4. Get The Count of the Number of Users in an AD Group
  5. Multiple Vagrant VMs in One Vagrantfile
  6. Fixing the "this is larger than GitHub's recommended maximum file size of 50.00 MB" error
  7. Changing the Directory Vagrant Stores the VMs In
  8. Accepting Android SDK Licenses From The OSX Command Line
  9. Fixing the 'Target class [config] does not exist' Error
  10. Using Rectangle to Manage MacOS Windows

subscribe via RSS

All content copyright This Programming Thing 2012 - 2021
Blogging about PHP, MySQL, Zend Framework, MySQL, Server Administration and Programming in general