Thursday, May 5, 2011

Installing GIT on OS-X In 3 Minutes

How to install GIT on OS-X in under 3 minutes:

curl http://kernel.org/pub/software/scm/git/git-1.7.1.tar.gz -O
tar xzvf git-1.7.1.tar.gz
cd git-1.7.1
make configure
./configure --prefix=/usr/local
NO_MSGFMT=yes make prefix=/usr/local all
sudo make install
 
Git should be installed on your OS-X now, which you can verify by issuing: git --version command in Terminal. However, it’s a good idea to also pre-configure the default username and e-mail for your Git installation:

git config --global user.name "Your Firstname Lastname"
git config --global user.email "username@example.com"
git config --global --list
 
I personally, also like to set:

git config --global color.ui "auto"

How to Setting up the GIT

Setting Up

Now that you have the pre-reqs all ready, you can proceed with the install.  Open a terminal and cd into the directory where you want to install things.  Then type the following (or just copy and paste the items below):

git clone git://github.com/sproutit/sproutcore-abbot.git abbot
cd abbot
rake init
cd ..
git clone git://github.com/sproutit/sproutcore-samples.git samples
cd samples
mkdir -p frameworks
cd frameworks
git clone git://github.com/sproutit/sproutcore.git sproutcore
cd ../..

Add the path to abbot/bin to the beginning of your PATH to be able run the abbot command-line tools (sc-init, sc-server, sc-build, sc-gen, sc-manifest, sc-docs, and more) without having to enter the full path:
export PATH=`pwd`/abbot/bin:$PATH
Make sure you have configured your github account with SSH Keys and Username/Email (Without setting up the SSH key for your machine, you will get a permission denied error when trying to initialize the Git repository)
You should now have the full set of SproutCore tools running the latest Abbot-compatible code.

How to Dismiss the Keyboard when using a UITextView

The short answer is to send the UITextViewController the “resignFirstResponder” message … the trick however is when to send the message. In my case, and I assume it would be the same for others, is to listen for any changes to the text in the UITextView and if the carridge return character ‘\n’ is detected then send the “resignFirstResponder” message to the UITextView.
Step 1. The first step is to make sure that you declare support for the UITextViewDelegate protocol. This is done in your header file, as example here is the header called EditorController.h:
@interface EditorController : UIViewController  {
UITextView *messageTextView;
}
 
@property (nonatomic, retain) UITextView *messageTextView;
 
@end
Step 2. Next you will need to register the controller as the UITextView’s delegate. Continuing from the example above, here is how I have initialize the UITextView with EditorController as the delegate …
- (id) init {
if (self = [super init]) {
// define the area and location for the UITextView
CGRect tfFrame = CGRectMake(10, 10, 300, 100);
messageTextView = [[UITextView alloc] initWithFrame:tfFrame];
// make sure that it is editable
messageTextView.editable = YES;
 
// add the controller as the delegate
messageTextView.delegate = self;
}
Step 3. And now the final piece of the puzzle is to take action in response to the “shouldCahngeTextInRange” message as follows:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range
replacementText:(NSString *)text
{
// Any new character added is passed in as the "text" parameter
if ([text isEqualToString:@"\n"]) {
// Be sure to test for equality using the "isEqualToString" message
[textView resignFirstResponder];
 
// Return FALSE so that the final '\n' character doesn't get added
return FALSE;
}
// For any other character return TRUE so that the text gets added to the view
return TRUE;
}

How to take Screenshot in Mac


In the article you’ll learn how to take screenshot in mac os. Although it’s very easy and quite interesting work but for the new users it’s bit confusing.
But anyways…to take the screenshots in mac os press “Command button +Shift+3″ and it’ll capture & save the image on desktop.
Apart from it there are many more interesting commands to take the screenshot, let’s see below…
1. To select the area and then take the screenshot give following command
“Command button +Shift+4″
2. Press “Command+Shift+4+space” if you wanted to take the screenshot of complete window.
Foregoing commands will save the screenshot at desktop. You can also save the screenshots in to clipboard. To do that you have to press one more button “Control” with the given commands. for example …
Use “Command+ control+ Shift+ 3″ instead of simple
“Command button +Shift+3″ command.
Apart from it mac os provide a software called “Grab” to capture the images in different styles. You can find this software in : Applications->utilities->Grab

iPhone On-Screen Keyboard Rundown

As I started building the latest Consumetrics iPhone app over the weekend, I had to choose which keyboard style to use for some input fields like name, email, and so on. These fields live in a “settings table” (really just a grouped table with input fields on it), so picking keyboards in Interface Builder is out of the question, unfortunately, since I require some pretty customized cells. Naturally, I checked the documentation first, where I was confronted by this plethora of options:
typedef enum {
UIKeyboardTypeDefault,
UIKeyboardTypeASCIICapable,
UIKeyboardTypeNumbersAndPunctuation,
UIKeyboardTypeURL,
UIKeyboardTypeNumberPad,
UIKeyboardTypePhonePad,
UIKeyboardTypeNamePhonePad,
UIKeyboardTypeEmailAddress,
UIKeyboardTypeAlphabet = UIKeyboardTypeASCIICapable
} UIKeyboardType;
Good grief. Seven distinct keyboard types? Bah. (Yes, 9 appear in the list, but UIKeyboardTypeDefault and UIKeyboardTypeAlphabet are just aliases for other types. Quiet you.) Some choices were obvious — my email address field will probably use UIKeyboardTypeEmailAddress, for instance — but some other choices are kind of head-scratchers. One of the fields wants a quantity, for example. Which keyboard should I use for that bad boy? UIKeyboardTypeNumberPad? But what if I need units, like “cups”? Can I get an alphabetic keyboard from UIKeyboardTypeNumberPad? I didn’t know, and tragically neither does Google; there aren’t any good breakdowns of iPhone keyboard types on the first few pages. Hitting up some blogs finally pointed me to some more Apple documentation, but even that still didn’t answer all my questions.
After not finding what I need, I did what any good developer would do: put down what I was supposed to be doing, and pick up something more interesting. I slapped together a quick iPhone app to display each keyboard type through a table view, the source for which is attached, and used it to scribble down a quick reference, which follows forthwith:
Overview



This rundown contains images of all keyboard views for all keyboard types. Each keyboard is configured exactly the same with respect to things like which “Return” button they use, so any difference you see is due purely to differences in the keyboards themselves, and not their configuration. Bearing this in mind, it turns out there are only two real keyboard layout types: the “normal” alphabet keyboard layout, and the number pad layout:
normal alphabet keyboard layout number pad keyboard layout
The first thing to realize is that even though it looks like there are seven different keyboards, there really aren’t. There are really just 2 different keyboard layouts with different keys stuck on them, and the layouts are strung together in different ways. (The alphabet keyboard does have a couple varieties with more or fewer keys, but they’re really just variations on a theme.) The particularly observant reader (or maybe just the ones who are breathing, it is blue after all) will notice one particular difference between these keyboard layouts: the “Done” button. We’ll chat more about that in a bit.
UIKeyboardTypeASCIICapable and Friend
This keyboard has three different views: alphabet, punctuation and numbers, and punctuation and symbols.
normal alphabet keyboard layout alphabet keyboard layout with numbers and punctuation alphabet keyboard layout with symbols
You alternate between the three views by pushing the “ABC,” “123,” and “#+=” buttons on each view, which is as intuitive as we’ve come to expect from Apple. This keyboard has a total of 98 characters (26 lowercase + 26 uppercase + 1 spacebar + 10 numbers + 35 punctuation), so “ASCII capable” is a great name for this keyboard, and it should serve almost any enter-text-onto-your-iPhone need that you have. (And between you and me, if you push and hold some characters, you get a list of other characters to enter, so you can actually type a lot more than 98 characters on this keyboard, just less conveniently. I should note that this tap-and-hold input method works on all keyboards, not just UIKeyboardTypeASCIICapable.)
tap-and-hold diacritic example
The next keyboard type in the list, UIKeyboardTypeNumbersAndPunctuation, is exactly the same as this keyboard, it just opens on the second (numbers) view instead of the first (alphabet) view.
As a rule, this keyboard type should be your bread-and-butter keyboard. If you don’t know which keyboard to use, use this guy; he won’t let you down. There’s nothing text-wise you can do with an on-screen iPhone keyboard you can’t do with UIKeyboardTypeASCIICapable. (If your input is number-oriented as opposed to alphabet-oriented, though, you should probably use UIKeyboardTypeNumbersAndPunctuation.)
The only real drawback to this keyboard is that it’s clunky, with three screens to navigate, doesn’t provide any really input sanitization, so your user can enter almost any character he can think of, even if it doesn’t make sense in the context of the input. What keyboard should you use to provide input-level sanitization? Like sanitization for a URL, for example?
UIKeyboardTypeURL
I’m glad you asked! UIKeyboardTypeURL is designed specifically for the purpose of inputting the most common URLs quickly and efficiently:
URL alphabet keyboard layout URL number and punctuation keyboard layout URL number and symbol keyboard layout
This keyboard is basically the UIKeyboardTypeASCIICapable keyboard with the non-URL keys removed, and the spacebar replaced with some URL-handy keys. This keyboard is ideal for entering web addresses, like http://www.sigpwned.com/. Otherwise, not much else to say here. The take-home message is just that input sanitization is A Good Thing, and you should think about it, and this keyboard offers great sanitization for URLs. (But you probably knew that from the name.)
UIKeyboardTypeEmailAddress
If an email address and the UIKeyboardTypeURL somehow got together, the UIKeyboardTypeEmailAddress would be the love child from that unholy union:
email alphabet keyboard layout email number and punctuation keyboard layout email number and symbol keyboard layout
This has exactly the same layout as UIKeyboardTypeURL, but has a few keys swapped around to suit email addresses. The only surprise here is the “space” key; evidently spaces are allowed in email addresses, but you have to quote them. Who know? Otherwise, nothing to see here. Move along.
UIKeyboardTypeNumberPad
Here’s where things start to shake up a little bit. Behold our first number pad keyboard:
numberpad keyboard
As you can see, this layout is quite different from the others. The most important difference, though, lies in this keyboard’s lack of a Done key. The Done key is the key you use to dismiss the keyboard when you’re done editing, so knowing its location is kind of important. (Without a Done key, there’s no way for the user to dismiss the keyboard, so it just sits there.) This is one of the few places where Apple has violated the “Principle of Least Surprise” by not putting the Done key in the same place it appears on other keyboards. On “doneless” keyboards like these, most developers put a Done key on the navigation bar at the top, as I did:
numberpad done key example
As I’m sure you surmised from the title, this keyboard is specifically for numbers-only input, which is perhaps less useful than you might expect. That’s why UIKeyboardTypeNumberPad brought some friends along.
UIKeyboardTypePhonePad
This keyboard is just an on-screen implementation of a conventional touch-tone phone pad. You’ll have to use the same Done key trick from above.
phone pad number layout phone pad symbol layout
This keyboard brings along the symbol characters you need for some phone numbers, which is important. Unfortunately, however, I’ve now officially run out of witty transitions. So it’s a good thing you won’t remember, because these are not the droids you’re looking for. :: waves hand ::
UIKeyboardTypeNamePhonePad
Ah, UIKeyboardTypeNamePhonePad. Of all the many, many keyboards the iPhone supports, I find this one the most confusing. It supports numbers, letters, and spaces only, with no punctuation or symbols whatsoever. (And lowercase letters only at that because the shift key is disabled!) Very strange:
name phone pad alphabet layout name phone pad numbers layout
But mine is not to question why. Mine is just… no, actually mine is to question why. WTF Apple? Seriously, I can’t even get uppercase letters on this keyboard? Odd. There is one bit of good news about this particular keyboard, though: it has both a number pad and a Done button, so you can have a number pad without having to do a bunch of navigation-bar-done-button gymnastics. At least as long as you don’t mind using a kind of gimpy keyboard, anyway.
Keyboard App Source Code
Attached to this post you’ll find a file called “iPhone Keyboard App.src.zip”. Inside you’ll find all the NIBs, source code, graphic resources, etc. for the iPhone app I used to build this post. I made it pretty quick, but I think it’s pretty clean, so hopefully it’ll be useful to someone somewhere. At the very least it should serve as a good example of how to work with the Done key on the physical keyboard via UITextFieldDelegate and textFieldShouldReturn: versus on the Navigation bar using self.navigationItem.rightBarButtonItem and UIBarButtonItem. If anyone really wants to see it, I’d be happy to write a post about the architecture of the program and how it works at a high level.
Underview
And that’s that! You’re now an expert on iPhone keyboards. Or at least what they look like. Hopefully this will help people understand the core iPhone input method better and plan around what keyboard is best to use. Remember, the most restrictive keyboard you can use is the one you should use.

Adding a new user account to Mac

System Prefs Icon

Adding a new user account to your computer

You can create individual user accounts for each person who uses your computer. Each new user has a separate home folder and can adjust his or her own preferences without affecting other users.
  1. Choose Apple menu > System Preferences and click Accounts.
  2. If some settings are dimmed, click the lock icon and type an administrator name and password.
  3. Click Add (+) and type the user’s name.
  4. If you don’t want to use the short name generated automatically, type a new short name. (Once the account is created, you won’t be able to change the short name.)
  5. Type the user’s password in the Password and Verify boxes.
  6. Type a hint to help the user remember the password if they have trouble remembering it at login.
  7. Click Parental Controls and select options to determine what the user can do with the computer.
If you change your mind while you’re creating a new user account, click Delete (-) to cancel.

How To Easily Share Files Between Mac & Windows Computers

File sharing between Macs and Windows is a little lob-sided. Out of the box, Macs can detect any Windows computer connected to the local network. It appears right on the Finder’s sidebar. So naturally, it is very easy for a Windows user to share their files with anyone on a Mac. The reverse process – allowing a Mac to share its files – requires a little more attention. The transition from Tiger to Leopard has made it a little bit more complicated for regular users to set up shared folders because the setting has been “disguised”.
In this week’s Macnifying OS X, I’m going to show you how easy it is to share files on your Mac so that it appears on Windows computers automatically.
how to share files between mac and pc



In System Preferences, go to ‘Sharing’ and check the box for ‘File Sharing’. By default, only your Public Folder will be shared. If you want to add other folders to the shared list, click on the ‘+’ sign under the Shared Folder box and choose the folders you wish to share.
After you’re done selecting, you’ll need to set the Permissions for each shared folder. Generally, you should allow Read Only rights to avoid others from messing around with your files. As you can see from the screenshot below, I removed the group labelled ‘Users’ from the users list so only ‘Everyone’ and I appear on the list. I do this to make things easier, only to allow guests logins from other computers.
share files between computers
Next, click on ‘Options’ and on the resulting window, check the box that says “Share files and folders using SMB” and hit ‘Done’.
share files mac windows
Now, you’ll need to add your Mac into a Microsoft workgroup. To do this, click ‘Show All’ at the top of the System Preferences windows and click on ‘Network’. Select your active connection and click ‘Advanced’.

In the window which pops up, click on the ‘WINS’ tab and enter a workgroup in the appropriate field. Microsoft has two workgroups: MSHOME and WORKGROUP. Find out which workgroup the majority of your Windows computers belong to and set the workgroup to that.
Click on ‘OK’ and you’ll return to Network preferences, now hit ‘Apply’. Now you’re halfway there – the rest of the work is performed on the Windows machines.

On your Windows desktop, right-click on ‘My Computer’ and select Properties. Click on the ‘Computer Name’ tab and make sure that your workgroup is the same as the one set on your Mac. If it isn’t then click on ‘Change’, set it and restart your computer.
Once that is done, double-click on ‘My Network Places’ and voila, all of your Mac’s shared folders should be visible. Take note that the Drop Box in your Mac’s Public folder won’t be accessible. If you want to use the Drop Box to let other users “drop” their files onto your Mac, you’ll need to change its permissions.
On your Mac’s Home folder, double-click the Public folder. Right-click on Drop Box and choose ‘Get Info’. Click on the lock icon on the bottom right hand corner of the Info window and enter your account password. Then set the permission for Everyone to Read & Write hence, allowing anyone to conveniently “drop” files onto your Mac.

Did you find this tutorial easy to follow? Did it work for you? Is there an easier way to share files between Mac and Windows computers?