Quickly search for a file on a (PC) server from a Mac client

Searching for files on a Windows server from a Mac can be very slow or even fail altogether but with a bit of shell trickery it’s very quick.

The script below is 95% instructions – the payload is at the end – that’s the line of code you’ll need to adapt for your search.

# Here's a simple shell script to search the server for a file(s) who's name you know
# 1. Specify the folder you want to search
# 2. Change the script to look for the file name
# 3. Job done
# 1 2 3
# Open Terminal and type "cd " (with the space) at the promp. 
# From the Finder drag the folder you want to search onto 
# the Terminal window, ENTER
# (You are now "in" the folder you want to search)
# Change the script below to use your search for your file
# (keep the wildcard *s and the quote marks)
# NB you can add the wildcard into a search too
# eg: "*Need*stack*" will find "A needle in a haystack.psd"
# Copy and paste into the Terminal window, ENTER
# (The search is case insensitive)
find . -iname "*Needle_in_a_haystack*" -print

No Comments

Dynamically create a PHP variable name

Thanks to this post “Dynamic variable names in PHP” for enlightening me on how easy this is. There’s a lot of stuff out there about PHP variable variables but if you just want to craft a variable’s name based on some other variables that are already set – this is the way to go.

$var = "FooBar";

$extended_FooBar = "</pre>
<h2>An Extension of FooBar</h2>

echo ${"extended_{$var}"} ;

Basically a regular variable with lots of curly braces and – in this case – not a dot concatenation operator in sight.

So simple when you know how.

No Comments

Arabic text in Adobe Photoshop

…or how to create any right-to-left script layer in Photoshop

Photoshop is not fully prepared for working with right-to-left (RTL) languages: you can’t properly use Arabic or Hebrew for more than pasting in single non-breaking lines. This is a limitation in the software – and you may be told to buy a middle eastern version.

There is however a very simple workaround.

Adobe have supplied a Photoshop template file with live RTL text layer in it – which you can download from Adobe at the link below. Drag the text layer into your document and – hey presto – you have one RTL text layer mixed in with other LTR text layers.

It’s a Photoshop CS4 file – but works perfectly well up to CS5.5 (CS6 TBC):
Adobe Photoshop CS4 – Template to edit and create Arabic text

No Comments

A simple regex rename with Adobe Bridge

Adobe’s Bridge application has a very handy built-in file renaming utility. If you need to add a suffix, a numeric prefix or do a simple string substitution it’s ready and waiting just a keystroke away…

But for more complex string substitutions regex (from REGular EXpressions) come to the rescue!

Here’s a simple problem – you need to rename the first 6 characters of a series of files with a consistent file naming convention…

Fire up the batch renaming dialogue ([SHIFT]+[CMD]+R on a mac) – it’s under the Tools menu. Select your files, choose String Substitution from the dropdown, and check Replace All and Use Regular Expression as in the screenshot below.

The magic regex is in the Find field:


The “^” (a caret AKA “up-arrow”, “chevron”, “control character”) denotes the beginning of the search; the dot “.” denotes any kind of character and finally the “{6}” means six of.

Easy peasy.

No Comments

Remove and ignore dreamweaver dwsync.xml files from your GIT repo

git ignore dreamweaver dwsync.xml files (and other gubbins as required)

  1. Remove any files already added form the working directory. For example:

    $ git rm -f *dwsync.xml

  2. set up your a global git ignore file

    create a gitignore file in your home directory. eg:

    $ printf "dwsync.xml\nThumbs.db\n" >> ~/.gitignore

    using git config add this to you git prefs

    $ git config --global core.excludesfile ~/.gitignore

For repos that may be worked on by multiple users you should also create this file at the root of your working directory.



1 Comment

Hard coding your site URL in WordPress

I discovered this handy feature on troubleshooting a login problem for a client of mine.

If you swap your WP database between a development and production server at all regularly and don’t fancy editing your site URL and WordPress URL in the wp-options table each time (either directly or via the WP admin interface)… you can hard code it into the wp-config.php file! Tie this together with WordPress ability to keep this config file out of harms way in a directory above your WP install (ie out of your public_html directory) and you have an easy hands free file sync operation too.

Just add these two lines of code into wp-config.php:

// hardcoding the domain

BTW – note the lack of trailing slashes on the URLs

1 Comment

Nice WordPress article in .Net

Nice article about WordPress in my favourite web design and develpment magazine (issue 217  of .NET). Usual stuff but well written without either speeding or jabbering.

There’s a nice overview of Custom Menus, Multisite, Custom Post Formats, Custom Post types and Custom Taxonomies.

WP Custom Heaven

One thing I’d never heard of before was the new ability in WordPress 3.x to enable custom background images to any post. Just add the following to your functions.php file:


. Look up the codex for more. Aparently this allows admin users to change background image properties (as CSS) from within the appearance menu. http://codex.wordpress.org/Function_Reference/add_custom_background. Having not tried this – but I think its limited to a global preference per install – so of limited use to theme developers.

Anyway nice stuff Jeff Starr at .Net …

No Comments