I have moved my blog to Wordpress at theunixgeek.wordpress.com. I will still be checking back periodically on this one as well, though. 19 April 2009

featured

Merging Mkdir and Cd | 280 Slides Interview | I Switched to KDE 4

clickable portals

Friday, November 30, 2007

Learn your code! Geek Websites

I found a neat little website recently: Code Teacher. I'm trying to teach a friend Python and was looking for a nice tutorial for a beginner, and I found codeteacher.com a little more advanced and chose to use the official Python docs. Either way, I recommend it.


Here are a few other nice websites:


Official Python Tutorial


Python 101


Python 201



GeekPedia - like Wikipedia, but... not




The Uta Priss Programming Courses - her tutorials are pretty nice:


Python


Perl


Server-Side Web Languages

Monday, November 26, 2007

Apple Finally Brings Some Customizability Back into the Mac OS

Remember that Roswell theme from OS 9? Well, you can't have the windows make noises when they close or minimize or whatever, but Leopard really provides a lot more customizability than Tiger did.

  • Menu bar - depending on your wallpaper, the menu bar appearance changes.
  • The Dock - leoparddocks.com

Sunday, November 25, 2007

Is Microsoft Killing the Menu Bar?

Windows Vista, along with many other recent Microsoft apps, show signs of Microsoft attempting to drop the menu bar. Take a look at the following screenshots:

Windows Explorer (Vista)














Internet Explorer 7 (Yes, I know you can enable a menu bar if you want to in IE7, but it's not there by default so that doesn't count.)














Office Word 2007















Windows Photo Gallery















Go to Wikipedia or Google Images for Windows DVD Maker, Windows Contacts, and Media Player 11. I think it's getting a bit obvious....

Friday, November 23, 2007

Why Windows is Problematic

Don't get me wrong on this, Windows isn't that bad of an operating system if you don't go on the internet and are *extremely* patient. The biggest problem is its DOS base. This website shows what anyone can passwordless do at a DOS prompt:

  • create a new user
  • access blocked websites
  • give admin access to a user
  • delete users
No wonder so many people complain about their computers....

A Programmer's Christmas Wishlist

I'm really only starting out with programming, not very advanced, but Christmas is coming in about a month, so I got a few things together that I'd like.....

  1. Core Java, 8th edition (book)
  2. Apress Foundations of GTK+ Development (also a book)
  3. Cocoa Programming for Mac OS X (yet another book)
  4. C Primer Plus
  5. C++ Primer Plus The C++ Programming Language
Yes, I already have The C Programming Language (affectionally known as the K&R due to the authors' initials, so I though that the C++ Programming Language might be a perfect accompaniment.

I've gone onto Amazon to see the first chapter of C++ Primer Plus (try saying that 5 times fast) compared to the C++ Programming Language; I was inspired by a comment. I like the C++ Primer Plus and decided to get the C Primer Plus to accompany it.

Oh, yeah, no interpreted languages for me. I'm not telfully fond of them; perhaps one day I'll get into CGI with Perl or Python, but the web's not where I'm headed for now. Except for Ruby on Rails.... that looks interesting....

Saturday, November 17, 2007

Cancel or Allow?


and then.....

Thursday, November 15, 2007

gOS: The Google Operating System?

The gOS developers thought about how many people use Google Search, GMail, Google Docs, Google Calendar, etc.... and how so much of our lives are on the internet. They saw that Google can be its own operating system.....


Downloading ISO - review coming soon!

Wednesday, November 14, 2007

Better Trackpad Support in Gutsy

Walt Mossberg, your prayers have been answered. 

In Mossberg's review of the Ubuntu laptops, he pointed out a very annoying fact (remember, this was during 7.04's reign) - if you pressed down hard enough on the trackpad, you can accidentally open menus and other things you didn't intend on opening. Now, if you have an Ubuntu 7.10 laptop, check out the mouse prefs and you'll see a "Trackpad" tab. 

Sunday, November 11, 2007

The Cocoa Tutorial Everyone Needs

Thank you to Thomas Davie for help with this article!

I have yet elsewhere to see a Cocoa tutorial that explains how to, when you click a button, make the text in a text box be "Hello World". Here it is. As a special 100th post for The Unix Geek, I will show you how to make a simple Cocoa app that does the above mentioned.

1. Fire up Xcode. File> New Project. For our purposes, name it HelloWorld.
2. File>New File. Select Objective-C class under Cocoa. Click "Next", name the files HelloWorldController, and click "Finish".
3. You should now have HelloWorldController.h and HelloWorldController.m Go into the .h file and have this as the file contents:

#import <Cocoa.h>

@interface HelloController : NSObject {
IBOutlet NSTextField *words;
}
- (IBAction)sayHello:(id)sender;
@end


Now, you're probably thinking, what does this do? First off, make sure you have an understanding of object-oriented programming (see about 5 posts ago). Now, pay attention. The 3rd line creates an instance of the object NSTextField called "words". The 5th line defines a method, or action. If you're familiar with functional languages, you might think of it as a function, in a sense.

4. Open the MainMenu.nib file. Design your interface here. Put (on the window) a button (you can edit the text) and a text field (keep it empty). Now, look for NSObject and drag that in to the window where it says "MainMenu.nib" as the title.

5. Open the inspector (Command + Shift + I), and with NSObject selected in the second tab from the right, in the first text field, type in "HelloWorldController".

6. Holding the control key, drag a line from NSObject to the text field. Select "window". Drag a line (again holding control) from the button to NSObject. Select "sayHello:"

7. Now that all parts of your app are hooked up, let's write some code. Make sure your HelloWorldController.m file looks like this:

#import "HelloController.h"

@implementation HelloController
- (IBAction)sayHello:(id)sender{
[words setStringValue:@"Hello, World"];
[words setNeedsDisplay:YES];
}
@end


Notice the [square brackets]. These are a central part of Objective-C. If you read the post on object-oriented programming, you should know how these messages work.

8. Select "Build and Go" from the toolbar (make sure you've saved your project first).

9. Press the button and watch it work!

10. If you'd like to distribute your app, check under [wherever you saved your project]/build/Release and your app should be there.

Loving Cocoa

Don't believe the lies! Cocoa is super easy! As long as you understand object-oriented philosophy (see, like, 4 or so posts ago) and have a basic knowledge of Objective-C, you're ready to go. A fellow Freenode.net IRC user by the nickname "Beelsebob" showed me how easy Cocoa really is - don't bother trying to assimilate Apple's documentation all at once. Read the documentation as you go. If you know how to connect objects in Interface Builder, read the docs for NSTextField, for example, when you need it, etc.

Today, without any tutorials, I was able to write a calculator, a utility that checks whether or not it's your birthday, and a temperature converter.

A Simple Cocoa Algorithm for Exponents

Here's a quick little Cocoa implementation algorithm for when you need to find powers of numbers. I'm assuming you have instances of NSTextField called FirstVariable, toThePowerOf, and result.

- (IBAction)findPower:(id)sender{
float exponent;
exponent = [toThePowerOf floatValue];

float power; //number to be raised to power
power = [firstVariable floatValue];
while (exponent > 1){
power = power * power;
exponent = exponent - 1;
}
[result setFloatValue:power];
[result setNeedsDisplay:YES];
}

Wednesday, November 7, 2007

Mac OS X Dock on Top of the Screen



Have you ever wanted your Dock on top of the screen? It's pretty simple to do it in 3 simple steps.

  1. Open Terminal (/Applications/Utilities)
  2. Type in defaults write com.apple.Dock orientation top
  3. Type in killall Dock


Note: this might not work with Leopard.

Wine for the Intel Mac

If you have an Intel mac, you'll notice that Darwine only works on PowerPC processors and Wine HQ rarely compiles! Now what? You have that old Win95 game to run! No problem. Someone by the name of "Scott Dangel" on his blog and "johnniecarcinogen" on InsanelyMac forums has compiled Darwine for Intel.

Friday, November 2, 2007

Understanding Object-Oriented Philosophy

NOTE: No full program examples will be given, only code snippets. 

I guess you could look at object-oriented programs as a sort of philosophy. Sure, it may look cruel and uninviting at first, but after a while, it begins to seem quite useful. Let me explain (examples given in Objective-C).

Object-oriented programs are based off classes. A class is at the top of the chain. Let's take the example of the class "Human." Classes are further divided into subclasses, which eventually will have objects. Objects inherit all the traits from their respective superclasses (that is, instance variables and methods).

Ok. This is starting to get confusing. Let me break it down.

A superclass is a class above another one. A subclass is a class below another one. An object is specific to a class and holds operations (called "methods") and traits (instance variables). Now, I'm assuming that you already have some C programming experience - enough to know what a variable is and what #include does.

Now reread the above paragraph (Object-oriented programs are based...)  and you'll understand it better. 

Remember to use #import instead of #include. Sure, you can use #include, but #import has little secrets that make it work better.

Going back to classes, allow me to continue. Each class holds instance variables, which are used when an instance of the object is created. If you want you could create what's called an "abstract" class, which doesn't really do much itself but serves for data storage of methods and instance variables? Now, what is an instance variable? These are also inherited (Note: inherited code is not duplicated; it is read directly from the superclass). In the Human class, some variables could be eye, nose, mouth, ears, etc. They are shared by most humans. In the Male and Female, these instance variables would be inherited and others would also be created. You can think of an instance for human as a baby being born. Before an object can be used, memory must be assigned to its instance. Here's how you'd create an instance of the object MaleChild, for example:

MaleChild *baby; //create an instance 
baby = [MaleChild alloc]; //allocate memory to the instance
baby = [baby init];

You may have noticed the [brackets] in the code. Get used to them. Objective-C is the land of brackets. In Java, you don't need to get used to them. I don't think they're used in C++ either. Anyway, what do these represent? They're used for what's called "object messaging," where a message is used to get an object to apply a method. One action babies do that adults don't is crawling. If we wanted the new instance of a male child to crawl, we could say [baby crawl]; If we wanted to specify how many steps, we could set up the method to allow arguments. If the baby were to crawl, say, five steps, we could possibly say 

int numberOfSteps = 5;
[baby crawl:numberOfSteps]; 

If you wanted, you could also nest messages, such as

[baby crawl:[numberOfSteps getSteps:numberOfSteps]];

Note that numberOfSteps is used as both a method name an variable name; this is allowed in Objective-C.

That's it for this little introduction to Object-Oriented philosophy, which usually seems hard at the beginning, but can actually help. You may notice yourself writing longer code in the beginning with object-oriented languages, but don't worry. When you start writing longer code, using instances of objects will be quite helpful.