Showing posts with label mac. Show all posts
Showing posts with label mac. Show all posts

Thursday, 09 August 2007

a handful of unix (Part 1) (for new mac users): ls, locate, man, export $PATH

Here are some tips which I've needed to use recently in setting up my new mac (yes, I upgraded)... You'll need to use your handy terminal, though I prefer using iTerm. I've also started with very basic commands for absolute newby's:

ls

In terminal, the UNIX commands on a mac are similar to your old DOS commands. With a few noteable exceptions. Go ahead, open up a terminal (Applications -> Utilities -> Terminal) and type the following: ls

ls is short for list, it's similar to the DOS command dir. Now try ls -al
See, more details, including hidden files, which are prepended with a period.

cd changes directory. cat displays the contents of a file. less does the same but allows you to scroll.

man

Very simple. Type man locate to get the manual pages for the locate command. It's a text help file explaining how to use the commands. If you want to see how to properly use the man pages, you can see the man page for man... so that would be typing man man.

locate

This function is the terminal equivalent of Spotlight, except, it looks everywhere! You simply type in locate php.ini, and it finds all the file references of php.ini for you. At first run I got an error message saying the database wasn't present. A brief look in the man page and I found the command to update the database (you should ideally run this every so often to just update all your references for locate. Do this before you run locate if you haven't used locate for a long while) - /usr/libexec/locate.updatedb

(It might be different on your system, so then just read your man page to find out how to update the locate-DB)

export $PATH

OK, this is more of a self note for me, so that I can use it if i need to do this again, because some of the bookmarks I had for $PATH stuff no longer link to valid sites... phhffft. ok.

For a shell script, the PATH variable used is stored in the .profile file (technically if you're using BASH - if you have no idea what i mean, ignore this) in your user directory. You can set up Textmate to respond and edit files by using the mate command from a shell. (here's how)
So, once this is done, open up .profile in Textmate and edit it. Mine looked like this:

test -r /sw/bin/init.sh && . /sw/bin/init.sh
export PATH="$PATH:/usr/local/bin:/Applications/xampp/xamppfiles/bin"
export EDITOR='vi'


I edited this and changed it to:

test -r /sw/bin/init.sh && . /sw/bin/init.sh
export PATH="/Applications/xampp/xamppfiles/bin:$PATH:/usr/local/bin"
export EDITOR='mate -w' #textmate as editor, waiting for file to close before continuing
export LESSEDIT='mate -l %lm %f' #textmate as editor for the LESS command, by pressing v

What export does, is make the PATH variable available to sub shells, and you put it in .profile because that's read when you fire up a shell. A shell is a session in Terminal or iTerm (in simple terms).

Something to remember: UNIX commands in the terminal are case sensitive, which means the command locate will work, but Locate or LoCatE will not work.

OK, most of you are either bored to tears cos you know already, or bored to tears cos you have no idea or inclination to get into the shell. This is for the other folks, yes, both of them!

Thursday, 02 August 2007

mac: nifty way to schedule a task

OK, so I need to run a task frequently on my mac. A daily download of a wallpaper to my desktop from National Geographic, and every two days to do a project backup (which I ought to burn to disk and take off-site).

So, what are my options... cron, and iCal. Yes, I found that out today, as an alarm for an event, not only can I set a chime to go *TING* - I can run a script or open a file... This leaves lots of possibilities!

So, I fire up iCal, add a new task called getwallpaper, and set the time to 9AM. Then I change the repeat option to every day.

Now, my iCal is littered on each day with an obscure entry. We'll deal with that in a moment.

I head over to the alarm selector, and select open file (the script is an app, so the run script option didn't work in this case) - I choose my app which collects my wallpaper.

Now, to tidy up, I click the plus [+] icon in the bottom left corner, and add a new calendar, name it Scheduled Tasks. It should appear in the top left side panel with a tick. Uncheck the tick and the events disappear. So I don't need to be bothered by my scheduled events.

I did the same for my backup, except I set up a Custom repeat option so that it happened ever week on Tuesday, Thursday and Saturday. Next time, I'll use Otto (Automator) to control the backup and zip the file afterwards.

Cron is another more scripty-geeky-terminal way to do this, and I'm keen to explore that when I get a chance. I got this info from here, and they also explain how to do this in Windows.

Here's a grab of the iCal screen, with my nifty National Geographic desktop, before I unchecked the Calendar so that they disappear. Wow, am I really that empty this week?

Friday, 13 July 2007

anti-virus: ClamXav and ClamAv

Although the mac is reputed to have few or no viruses (a few have been made as proof of concept but they aren't really comparable to what windows users experience), it's better to take precautions. I've recently installed ClamXav, which came on one of the MacFormat DVD's. It's a freeware Anti-Virus for Mac. It comes from another project called ClamAv, which is for other platforms. It works well and you can also set up schedules to do a Virus scan, as well as a Sentry, which can watch certain directories always (for example your mail attachment or Downloads folder).

Now, although the risk is less for us mac users, we should be responsible and allow this to apprehend Viruses that could otherwise be passed on in an email to our colleagues or friends. It's like paying your TV license, it's the right thing to do.


Saturday, 16 June 2007

Apple drops the ball

In what most deem is a big risk, Apple decided to release Safari 3 public beta to the masses. By masses I mean both PC and Mac platforms. This move could have been ingenious, if the product was the usual Apple offering. However, it has fallen short, FAR short of expectations. Where is the "3 years into the future" design thinking that Apple are famous for? What, I can shift my tabs around and find things?? What were you thinking? Yes, the time is now to get PC users in, but do it with a product that isn't absolutely terrible! Think of a bunch of amazing browser innovations, build in some ideas from the firefox plugins if you can't think of them yourself. And reduce the features in favour of making it a little more stable. Yes, it's a beta, but my download didn't even start up after it was installed! I'll look again when there is a better offering, but my opinion is, most people wouldn't be bothered.

Another note on Safari. It claims to be a standards based browser and the best for web developers to test their goods on. In my experience, being a web developer, I find it dreadful to use. I've never thought much of Safari, and no amount of hype thrown at a bad product will ever turn it into a good product. I'm just concerned that Apple start resting on their good innovations in the previous few years, and rely on riding the wave of hype. This won't cut it with PC users (remember, they don't worship Apple), it won't work on a bad browser, and also, let's hope Leopard has more to offer than a few shiny makeovers and some irrelevant functions.

Adobe are getting this right, concentrating on workflows and cutting down production times. I'm hoping Apple don't get sidetracked and that recent popularity hasn't gone to their heads. That being said, I'm still a big fan of the company. I guess the expectations are high because people have become accustomed to only the best from Apple.

Monday, 12 March 2007

textmate, e-texteditor and notepad++

With more power failures in Sunninghill, I decided to take my wireless connection and go elsewhere with my laptop. It was an opportunity for a home-cooked lunch, so mom-wards I went! I had some time to spare, so I decided to check out TextMate on my macbook. I downloaded some screencasts (video tutorials) available on their site and off I went. The next 12 minutes was seasoned with "wow" and "no flippen ways!" as I saw some of the nifty TextMate features in action. The software fits the hand of a developer like a glove, in a completely different way to the other great IDE's such as Eclipse. It was there, sitting in the satisfaction of having eaten a home cooked meal, that I bought TextMate for 39 euros.

My first hint at Textmate's brilliance was when I saw it being used in a Symfony demo a few weeks back. Fabien used TextMate to code up some awesome AJAX controls in his cart demo (Available from the Symfony site). It seemed to do all the slog work for him, and I was impressed. Then I saw that TextMate won the Apple Design Award for best developer tool in 2006. I started telling my friends about it and they asked "is there a Windows version". I checked, nope sorry. Or so I thought, until yesterday, when the Wikipedia entry led me to the e-texteditor. The developer is in essence copying TextMate features to this beta editor. I'm running the trial beta version of that now, but I haven't yet been able to get some coding done with that. I still prefer Notepad++ for now. When I get more familiar with TextMate, I think I'll progress to e-texteditor also. Check out Wesley's comment on Notepad++ here.

Thursday, 04 January 2007

introducing... my mac

Could it be a definite trend happening... or is it that I'm noticing it more now that I have one: but aren't there a lot of macs around these days? I keep noticing fellow mac users all around, in coffee shops, in meetings I go to (and I don't just hang around in ad agency circles either), even the DJ at the New Years Concert at the Dome in Northgate... so what gives? Has the iPod swung the Cupertino doors open to Apple acceptance here in South Africa? It certainly seems so! I mean even my aunt got a nifty little black macbook (2nd generation, faster than mine!) I helped her set it up (not that she needed me either, it was child's play), and she loves it - she went to some free Apple training that they give to new users.

I've had my mac for a few months now and I love it. Every week or two I find some other neat little feature that I didn't know about before. That being said, it did take some adjusting from the PC I'd gotten used to. A friend sent me a link today: http://teenagefanboy.blogspot.com/2007/01/ten-things-i-wish-i-knew-before-i.html
and I found it a great read. It's a list of 10 things that can help new mac users, as some of the things are definitely very different on mac.

In fact, one of the focuses of this blog will be about Apple, Mac, iPod and all that stuff.
When I find more nifty features I'll be sure to post them here.

In the meanwhile, here's a great site I found with helpful shortcut commands. Being a developer, knowing lots of shortcuts is kind of like having experience points in the field of battle... "Oh, you fought in Korea?" - yeah, so rack these suckers up and impress your friends.

http://www.danrodney.com/mac/index.html