Apple Online Store Down – New iPad Launch.

apple_store_offline

Rename Multiple Files In Debian or *nix

Obviously the n00b trick of trying to do

mv oldName* newName*

does not work.

Interestingly I just found that Debian has a “rename” command that supports perl regular expressions. So this would work in case you were wondering how:

rename 's/^oldName/newName/' oldName*

Replace spaces in the filenames with “_”:

rename 's/\ /_/g' *

Check your man pages before you attempt this on a different *nix system. Different rename binaries might have different functionality.

vi – Used To Hate It

Over the past few months editing configuration files and writing scripts, not programming, I’ve come to realize how awesome vi is and the plethora of operations you can perform on the text once you open it up in “vi”. Forget about nano/pico. Some common tasks you can do with vi…

Find and Replace: “g” indicates global or else vi only replaces once per instance per line.

:%s/find/replacewith/g

Find and Replace a “\”(windows) with a “/”(*nix):

:%s/\\/\//g

Line Numbers:

:set number

Go To Line Number:

:lineNumber

Remove Line Numbers:

:set no number

Search For Text(Case Sensitive):

/searchstring

Delete All Lines Starting With a Particular Character(“;” in this case):

:g/^;*$/d

Delete All Empty Lines:

:g/^$/d

How To: Test mod_rewrite

This is more of a self-note to myself. This simple test will confirm if that mod_rewrite apache module you just enabled is actually working. Once you have enabled the mod_rewrite module using “a2enmod mod_rewrite”, create a .htaccess file in the document root with the following content:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.google.com/$1 [R=301,L]

Restart apache and go to that site of yours. You should be redirected to Google.com automagically. If not check your file permissions.

Mac OS X: How to connect to Windows File Sharing (SMB)

I wanted to connect to my home server using my mac today. I said to myself RTFM and went through the Apple KB article mentioned here. Well that did NOT help at all. I kept getting “Invalid User” error. So then I said to myself “I will google it before asking dumb questions” and this is what  found. You can use the same method to connect to any shared folders on a windows computer.

Open a “Finder” windows and press “Command-K”(or use Go > Connect to Server from the menu bar). Enter the url of your samba share as shown below. Depending on the settings of your samba server, if you don’t know the exact share name, you can omit the “/sharename” part from the url. The would open up a window with a list of all shares that you have access to.

mac_finder_connect_to_server

DO NOT enter your credentials as shown below. This was why I was getting access errors. Make sure you delete any credentials stored in “Keychain Access” for this particular server if you saved some credentials that do not work.

mac_finder_connect_to_server_login_wrong

Enter your credentials with the server name or ip followed by a forward slash and then username. This has been tested on 10.6 and should work for all other versions that support samba.

mac_finder_connect_to_server_login_right

Remember to delete credentials saved to “Keychain Access” for this particular server if you need to connect to the same server but as a different user. This might come in hand when different folders are accessible only through user credentials.