Helpful applications

Delete PHP files with errors in bash

I needed to go through and delete a lot of automatically generated PHP files that contained errors (pretty much all because they got cut off before the generator finished)  So I poked around and put together a code that will go though a designated directory and delete PHP files. I also added on to have it limited to a certain number, so I could monitor it.

find ... -exec bash -c '
    if php -l "$1" >&/dev/null; then
        echo "$1: pass" >&/dev/null;
        sudo rm $1
        echo "$1: fail"
    fi' -- {} \; | tail -n +1 | head -50

And you can double check there are no files with errors using this command:

find ... -iname "*.php" -exec php -l {} \; | grep -i "Errors.parsing"


Permalink » No comments

Japanese Regex

I was formatting a list of words from Tanos to a CSV document to import as a deck on my site SRS-Ninja.  Which is something I’ve done before, but this time to make it even easier to format, I found out you can use regular expressions on Japanese!  I found a nice guide on Github which goes over a lot of the possible variations. In this post I wanted to highlight a few I found specially helpful.

  • Kana alone = ([ぁ-ゔゞァ-・ヽヾ゛゜ー])
  • Kanji alone = ([一-龯])
  • Kanji and Kana = ([一-龯ぁ-ゔゞァ-・ヽヾ゛゜ー])
  • Half width numbers + roman characters = ([0-9A-z])

I didn’t need the half width ones for this particular task, but I hate how those sneak in when you’re writing in Japanese and English and I love that I can now flush those out!

Also on a more random note, I wanted to put a reminder here for myself on how Dreamweaver wildcards work. Laugh if you will, but Dreamweaver has a very powerful find and replace feature and has been the easiest way I’ve tried to convert HTML tables to CSV files. So, in short, you would put your regex in the find box as say “before ([0-9A-z]+) after” then in replace box you can use a $1 to return whatever text you found like “new before $1 new after”. So, something like this:

Screenshot (90)

Permalink » No comments

Cloud Backup – 2015 edition

Once again I’ve found myself needing to find an online solution to backing up my files.

I found myself in this position a few years ago, and did a bit of research back then, but was lucky that Dreamhost offered 50GB of online backup free with my hosting. They have recently turned off that service :( So I’m updating my findings with current prices and to suit my current needs.

There are a lot of really great backup utilities out there, like carbonate and crash plan, but I can’t use a lot them because I use a NAS drive for all my storage.  It’s super nice and convenient to not have my files tied down to a single computer – but most backup solutions use a bit of software that you install on your computer which won’t work with a NAS drive.

After looking around a bit, like before I think Amazon s3 looks like one of the best options for price and flexibility.  Something new that came up was Amazon Glacier – it’s dirt cheap, but looks really difficult to get working, and I have concerns that syncing won’t be possible with Amazon Glacier.  It’s specifically for long term storage and you store files in packets versus individually, so just grabbing an individual file you accidentally deleted is not possible.  A lot of more straight forward SSH available services were incredibly expensive, like that would cost about 2K/mo for 100GB of storage.

I was surprised however, I found out a bit later that both Google and Dropbox offer plans for $10/mo for 1TB – which is the same price for Amazon Glacier. So they’d really be a better option for personal backups.

But, like last time I’ve lucked out with a solution that works for my specific situation. QNAP recently released some software that will automate back-ups with some popular services. This means I don’t need a fully open solution, but just one that is supported by QNAP.

I seriously considered Open Drive for a while because it’s a pretty decent price for unlimited storage, then considered Google Drive for a long time, it did have a cap but was a little cheaper and more flexible and had better file sharing than Open Drive. But, at the very last minute after finally backing up my files and updating my firmware I find out the Crash Plan and iDrive both have apps for QNAP! I had originally wanted to go with Crash Plan, it’s highly recommended by Lifehacker and is unlimited for $5/mo. But after seeing iDrive in there I had to give that a look too. I found some favorable reviews in forums and the jist, at least for me, is that Crash Plan is unlimited data, but only supports one computer and no sharing. iDrive has limited space, but you can have unlimited computers – including mobile devices and Facebook, but a kicker for me is how easy and how much control you have over sharing folders.

Though, the final nail in the coffin was while I was looking up “Crash Plan vs iDrive” I found this offer from iDrive where users comparing the two could get 50% of the first year at iDrive! So, for the first year I get 1TB of space for $30 :) I really can’t complain about that, and unless I find some horrendous grievance with iDrive in the future – I’ll most likely end up just staying with them.

Here’s a price breakdown and some notes on of all the services I considered:

5$/mo for 1TB (25-50% off first year)
Limited space, but unlimited computers including mobile devices and Facebook, and great sharing features

Crash Plan
5$/mo for unlimited
Unlimited space, but no sharing and only 1 computer

Google Drive
10$/mo for 1TB
Really great sharing capabilities

Drop Box
10$/mo for 1TB

Open Drive
13$/mo  for unlimited
Unlimited – but said to have buggy sharing capabilities

5$/m for 100GB
15$/mo for unlimited

Amazon S3
3$/m for 100GB
15$/m for 500GB
30$/m for 1TB

Amazon Glacier
1$/mo for 100GB
10$/mo for 1TB
Same price as Google & Dropbox for 1TB, but much more complicated
2K/mo for 100GB

BQ Backup
$20/mo for 100GB
$75/mo for 1TB

Rackspace Cloud Files
$10/mo for 100GB
$100/mo for 1TB

Permalink » No comments

Perfecto Mobile

perfecto_mobileWith Nokia closing down their device labs :(  I found I needed a new place to do Windows 8 device testing, and with a little digging I found Perfecto Mobile.  Perfecto Mobile is an entirely web based platform that allows you to access and test your apps on a lot of different devices, it give you access to iOS, Android, and Windows 8 devices – which is really all you need :)

Permalink » No comments

Samsung Remote Testing Lab


Similarly to Nokia’s remote testing lab, Samsung has thier own remote testing lab.  It’s pretty much the same concept, for free you get 5 hours of testing time with real devices per day.

In general the devices are a lot more quicker and responsive then Nokia’s.  Unless you want to test on older devices – they crash at every turn and are pretty unusable. :/  But, they’re latest devices on there are great to have access to for testing. :)  If you’re developing for Android, you’ll definitely want to check it out.

Permalink » No comments