Hacking jQueryFileTree to display specified file extensions

Up until now, I’ve used the linux utility ‘tree’ to display the contents of a directory and it’s contents.

Yesterday, I decided to make it prettier.

 

The hunt began for a utility that displayed file system contents in a tree view. I stumbled across a few, but the one that I picked, mainly because of it’s ease was jQuery File Tree.

A couple hours playing around I had it playing nicely with Twitter Bootstrap site, but one thing that it didn’t do was to only display specific file types, so here is my quick and dirty hack to make it work.

 

I used the PHP connector jqueryFileTree.php and did a few things:

I added a new variable:

Updated the if statement for files to check for the file types:

Then added a new function to do the check:

All up it turned it into this:

Quite happy with the results!

Feel free to comment on improvements, as I’m a n00b to PHP and programming in general!

Regex to create list of values for SQL statement

In my day I’m currently undertaking a lot of data migrations. One thing I have to do frequently is find a list of records that do and/or don’t exist in one or more tables. This usually involves getting a list of ID’s from a log output text files then doing SQL queries to attempt to find them!

Unfortunately our clients machines are generally Windows based. Thankfully most are kind enough to allow us to use/install Notepad++ (IMO  the best notepad software available on Windows).

As such I utilise Regex a lot to find/strip/edit the contents to get the ID’s out and today I had a brainwave I thought I’d share on how to get it out quickly and turn it into a list that you can cut and paste into a WHERE clause of a SQL statement.

In our case the format of the logs are:

What I want is:

'',

And I get there with:

s/^(.*)/'\1',/

Or in Notepad++:

Enjoy!