Graph data Structures

Author: Doc180

Like in most Algorithm problems, identifying the correct data structure is half the battle. The question we will be asking about our graph, dictates the detail we have to model in our Data structure. In some cases, we may not have to model an explicit data structure at all and two dimensional array is all we need to solve the problem. For some problems, we might need more details (like degree of an vertex) to get started.

Let’s look at  the operations we will be performing on the graph data structures:

  • Get all the Edges incident on an Particular Vertex.
  • Get the weight of an particular edge.(In case of a weighted graph).
  • Get Meta information about our graph. Meta information include information like whether the graph is directed, weighted, cyclic, degree of the graph, the number of edges and number of vertices etc. Depending on the  problem we are trying to solve, we might need all these details or none at all.
  • Check the state of a Vertex.(Traversal state include Undiscovered, Discovered and Processed)

Note that in most graph traversal algorithms, “Get all the edges, incident upon this vertex?” is a more important question than “Check if Edge exists between these two vertices?”

Adjacency Matrix:

In the Matrix representation, we will use a two dimensional array to store the Edge information. In case of weighted graph, the array will store the weight of the edges and absence of it can be represented by a special number. For most practical purpose, it is a acceptable to store Integer.MAX_VALUE. But this decision has to be done case by case basis. In case of Un-weighted graph, we can  use 0 and 1.(0 representing absence of Edge and 1 Indicating presence of Edge)

The advantages:

  • As you can see, Adjacency matrix makes it very easy to answer “Whether there is an edge between two vertices?”.
  • Simpler Pre-Processing: Most of the implicit graph problems (problems dealing with Grids, Roads etc), can be easily represented as Adjacency Matrix with little or no pre-processing.
  • Some algorithms like “The Floyd-Warshall” requires adjacency matrix to work.

The disadvantage:

  • The biggest disadvantage is space usage. Most practical graphs, each of the vertices will be connected to a small subset of the other vertex. In case of a grid, each vertex will be connected to 4 or 8 (in case, if diagonal move is allowed) other vertices. In case of road network, each intersection can be connected to utmost 6 other intersections ( a ghastly intersection.) but in most cases, it will be only connected to four other intersections. But in Adjacency matrix, we need {N *N} number of cells.(N –> Number of vertices). So as you can imagine, most of the entries in this cell will be empty. (Unless if all the vertices are connected to majority of other vertices).
  • This excessive amount of empty cells also reduce the efficiency of some  of the Traversal algorithms.
  • And finally, like already mentioned,  a good amount of useful graph algorithms performance does not depend on how fast you can answer the question “Does an Edge exists between these two vertices?”.

Adjacency List:

In most cases, we can bring down the space usage to O(M+N),where M-> Number of Edges, N-> Number of vertices, without affecting the performance of the Algorithm. The most popular implementation is having an Array based data structure,Whose index is mapped to the vertex number and values containing a list of Adjacent vertices.  I sometimes prefer using a Map instead of Array for indexing the vertex, since when dealing with Labeled Graphs, we might not have a numerical representation for each of the vertices.

The advantages:

  • Better space usage.
  • Better Graph Traversal Times.
  • Better meta data tracking.
  • Generally  better for most algorithms.

The disadvantages:

  • Generally takes some pre-processing to create Adjacency list.
  • Algorithms involving Edge Creation, deletion and querying edge between two vertices are better off with Matrix representation than the list representation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
 
import java.util.List;
import java.util.Map;
 
/**
 
* General Graph data structure based on Adjacency list. This structure will suffice for
* general Traversal algorithms on unweighted graphs.
*/
public class Graph {
 
// For some traversal applications, we need to maintain all the three graph states.
public enum GraphState {
Undiscovered, Discovered, Processed
}
 
// For simple cases this will do.
public enum BinomialGraphState {
Undiscovered, Processed
}
 
 
private final int nEdges;
private final int nVertices;
private final int degreeOfGraph;
private final Map<Integer, List<Integer>> edges;
private final boolean isDirected;
 
public Graph(int nEdges, int nVertices, int degreeOfGraph, Map<Integer, List<Integer>> edges, boolean directed) {
this.nEdges = nEdges;
this.nVertices = nVertices;
this.degreeOfGraph = degreeOfGraph;
this.edges = edges;
isDirected = directed;
}
 
public int getnEdges() {
return nEdges;
}
 
public int getnVertices() {
return nVertices;
}
 
public int getDegreeOfGraph() {
return degreeOfGraph;
}
 
public Map<Integer, List<Integer>> getEdges() {
return edges;
}
 
public boolean isDirected() {
return isDirected;
}
 
public boolean isEmpty() {
return (nVertices == 0);
}
}
view raw Graph This Gist brought to you by GitHub.

For  production applications, its sometimes better to use off-the-shelf data structures, with all the bells and whistles. For C++ developers, its worth looking at BOOST or LEDA. For Java developers,   JUNG looks like a viable option. I tried using it for a Semantic Web Application, but decided to use a custom one, since my requirements needed me to have a better control of the data structure.

If you own an Android phone, then chances are, you have heard the term “Rooting”. The following is a primer for a newbie android user, to help understand Rooting and other related terminologies.

Aren’t Androids supposed to be open already?

Yes, they are and that is the  primary reason, for me to choose an Android over Iphone.

A stock android phone is technically as open as a “Jail-broken” Iphone. Almost everything that you could do with a jail-broken iphone, could be done with an off the shelf android phone.

  • Install third party apps. (Apps not hosted in Android Market).
  • Replace core apps with replacement programs (For instance, the Soft Keyboard).
  • Perform some extensive UI Customization.(Like changing the Home program.)

So is there a compulsive reason to root your phone. In fact, there are many. Read on….

So what exactly is Rooting?

Rooting as a term, has its origin, from the term “Root Access” . Android is based on Linux.  You could consider Android, to be a wrapper around Linux OS. For those who are familiar with Linux, will know of a program called “Su”(Acronym for super user), that enables applications to run with this elevated permission.  So rooting is,  to install this “Su” program in your phone and manage the root access. With this power, you could choose to provide elevated permission to certain applications and perform actions that you would normally will not have access to. (like reading and modifying  files in system directory)

So why is not root access available by default?

It is for the same reason, that a sysadmin, will not give root access to all the users. With root access, a user can…

  • Do permanent irrevocable damage to the phone. (Appropriately named “Bricking” your phone.)
  • Disable some key functionalities; permanently.
  • Compromise his\her security and divulge personal information. (An app running with Root permission, has free reign to do anything to your phone, and hence could do some very naughty stuff.).
  • A heavily modded phone, will not be supported by your carrier’s tech support, who are trained to work, only on devices running stock android.

The carriers and device manufacturers have some ulterior motives of their own too.

  • To make sure that you cannot switch carriers.
  • To install apps in the read-only partition of the device. ( Bloatwares, that cannot be removed),

 

Is Rooting for me?

Rooting as a procedure is simplified immensely, thanks to the effort of some really talented developers. But still the process is not trivial and rooting is just the start of the journey. Usually that is followed up by flashing your rom and performing, some real cool customization and most of them, need the user to be fairly comfortable with computer. So if you have never worked in command prompt ( or terminal) in your life, and do not understand general permission management (or if you use IE for browsing… wink wink, nudge nudge), then rooting may not be the right thing for you.

 

So why do you want to Root?

  • Remove unwanted Bloatware: The carriers and manufacturers, install some apps in the read only partition of the device and hence they are un-removable, unless you have root access.
  • Increased Speed: The stock ROM is adequate, but to truly take advantage of your device’s hardware,  there are custom ROM’s developed, that could help you in extracting the best out of your android.(By means of over clocking and changing the vm size etc..)
  • Customization ability: Once you root your phone, you have better ability to customize the look and feel of your phone, since you have access to the theme files, residing in system directory.
  • Optimization: Most of the custom ROMs have minor optimizations that helps increase the battery life, responsiveness and more.
  • Better Signal and Call Quality: Rooted phone, provides you ability to update your phone’s baseband, which controls your device’s radio, which is responsible for your Phone’s signal and call quality.
  • Additional Features: Like tethering.( The user now has access to  whole array of applications, that only runs in rooted phone.)
  • To get OS Updates more frequently: If you want to get the latest and greatest OS in the Android Ecosystem, then rooting provides you access to hundreds of modded ROMs based on the latest version of android.

So why should you not Root your phone?

You might brick your phone, you will most definitely void your warranty and more importantly, you might expose your phone to security loopholes. An app with an root access has free reign to your phone file system. So only download apps, that are considered safe.

Is rooting different from Flashing?

Yes, they are two separate things.

More precisely flashing your rom, is the act of replacing the device’s android  OS, usually with a newer and more customized version. You can only do this, if you had previously rooted your phone. You cannot flash your device with any ROM; you need to find a ROM, that was either build for your device or has been ported to your device.

Terminologies:

Before rooting, we need to get certain terminologies out of the way.

Rooting: The process of installing the superuser app in your phone.(and in the process, unlocking some system dirs.)

ADB:  A command line tool, that comes packaged with Android SDK, that lets you communicate with your Android Device.

Flashing the ROM: Flashing is the operation of replacing  the phone’s Android operating system.(With a new one).

Recovery:  All android devices comes with a stock recovery console, that could be booted in to.It is not very dissimilar to Windows Recovery CD. You could perform factory reset or recover your operating system, using the recovery console.

Custom Recovery Programs: To flash your phone with a new Custom ROM, you need to be able to  ”Perform Backups and Restore”, “Wipe data”, “Clear Cache” , “Mount and Partition SD Card”. The stock recovery program, will not have all these options, so you would have to replace the stock recovery module with a custom recovery module. The two most famous recovery modules available at this point are “Clockworkmod recovery” and “Amon Ra”.

Nandroid: Nandroid is  a backup tool, that allows us to perform full system backups (not the data, but the ROM.), so that we can recover, if something goes really bad.

S-ON/S-OFF:   S-ON is  specific to HTC Devices.  Its a security measure implemented by HTC, to restrict access to system area (Nand Flash). So if you want to root those devices, first we have to switch off this flag.

 

General Tools used for Rooting and Flashing:

SuperOneClick: Superoneclick is a one click rooting tool, that will work for most of the phones.

ODIN: Odin is a windows software, used mostly in flashing Samsung devices.

RUU: Acronym for Rom Update Utility; its  a widows tool, used for flashing some android devices.

RomManager: Another very useful android App (downloadable from the App Market), that is used to download ROM, install Rom, install recovery, manage backups etc.

 

So what is the general procedure?

The general procedure of Rooting is different among different phones. In most cases the following are the general steps.

Taking stock:

  • Download Android SDK to your computer. Make sure that you have a computer with admin access and you can switch off “Antivirus program” if you have to.
  • Download the necessary software tools: Most of the time, you would have to download the USB drivers for your phone.
  • Understand your phone: Get the serial number of your phone, note down the android software versions..
  • Understand how to Reboot your phone to recovery: This procedure is different for different phones.

 

Perform Rooting: Check XDA developers for rooting procedure for your phone. Make sure that the rooting procedure is compatible to your Phone Model and OS Version. (Google “Xda Developers rooting <phone name>”).

The following sections are only appropriate, if you are also flashing a custom ROM.

Flash Custom Recovery: The rooting program, will install an app called Superuser in your phone. Flash custom recovery on to your phone. (Clockworkmod recovery or Amon Ra).

Note: In most cases, you could do this easily, by downloading  a program called RomManager (from Market) and then using Flash Clockworkmod recovery option within that app.


Get an compatible ROM: Not all modded ROM, will be compatible for your device. Make sure to get a ROM compatible with your device. (Google is your friend. Cyanogenmod ROM, is probably the most famous and have variants that works with most devices).

Mount your phones SD card and and copy over the downloaded ROM File (its a zip file).

Reboot in to recovery: This procedure varies with phone.(Learn it, as mentioned in the taking stock section above).

Perform Nandroid Backup: From your custom recovery console, you could perform Nandroid backup. (Just in case, if things does not work out, we can still have a restore point).

Clear Data: Still in recovery console, Wipe Data/Factory and Dalvik-Cache.

Flash the ROM: In the root of the recovery console menu and select ‘Flash Zip from SD Card’ the text may be different per Recovery. Locate the ROM .Zip file you wish to flash.

Follow the onscreen instruction and you are done.

For more detailed instruction on Flashing, check XDA Developer’s Flashing Guide.

 

Hopefully, I have provided a good starting point for android newbies, who are thinking about rooting their phone. Thanks to developers (like those in the XDA Developers forum), rooting is much more simple than it is. Head over there, to their forums for a much more detailed instructions, specific to your phone.

 

 

 

 

 

 

An Intelligent Assistant, that leverages the power and flexibility of Semantic Technology and Machine learning is very exciting from someone like me. The following is my take on Siri in particular and AI(Artificial Intelligence) personal assistants in general.

A brief History of Siri.

1- Siri was born out of a  “Defense advanced Research Project Agency” (DARPA) initiative,  a division under United States Department of Defense.

2- SRI International is the company, that DARPA, awarded a five year contract to develop an AI Personal assistant called CALO (Cognitive agent that learns and organizes); also called PAL (Perceptive assistant that learns). Sri stands for Stanford Research Institute and the company is perhaps best known for its invention of computer mouse.

3- CALO took about 5 years of development and about 200 million in funding, in what is called,  the largest artificial intelligence effort in U.S. history.

4- Apple bought SIRI and have spent about 2 years, to make it more polished and has released a beta version with IOS 5.

See resources section for more details.

The Key Idea behind an AI Personal Assistant.

The key idea behind an AI system is the Learning ability. For an entity to be deemed intelligent, it needs to display two main characteristics. Learning and generalization.  The system should learn from existing data; It should adopt as new data comes along. The system should generalize, in that, it should be able to predict the correct response to inputs, it has never seen before. To form an analogy, a pilot trained in  a two engine plane, should with some confidence be able to fly a single engine plane too.  We humans are provided with an extra-ordinary generalization  and pattern recognition skills. A baby would be able to classify people, based on sex, from just a very limited sample data. But this characteristic, is hard to imbibe in to an computer system.

The personal assistant should learn about the user, understand his\her accent, try to predict the intent and should be context aware. Is Siri, in its present incarnation, qualify as a true AI personal assistant?

My first Impression of Siri:

In the limited time, I had, to play with SIRI, I found it to be a conversational assistant, that integrates with all the system services (offered as part of the phone) and  some external services (Like Hotels, Businesses and search engines) to serve the user’s need.  It is best to classify Siri as a service delegation engine, that is voice activated. Siri will make sense of what the user is saying, formulate a request and call the appropriate service and finally present the result as actionable items to user, all in a seamless fashion.

Participating Components:

What follows from here on,is my speculation. I was never involved in the development of the application. I collated, all the information that were available to me (Google) and speculated on how the system like Siri, would have been implemented and what are the potential challenges in developing an application like Siri.

The following would be the participating components of an Intelligent Personal Assistant like Siri.

  • Voice Recognition Module ( that should learn the user’s accent),
  • a NLP analyzer to extract concepts from conversational texts (using techniques like Word Sense Disambiguation and Parts of Speech tagging.)
  • Machine learning module to map the user’s input to appropriate service.
  • Service Delegation Layer, that seamlessly integrates with various set of internal services (services offered within phone and cloud based services provided my apple) and external services (services provided by third party vendors.)

- Voice Recognition Module: This is fairly straightforward. SIRI uses technology from Nuance Communication (http://www.nuance.com/), for voice recognition.  The key point here, is learning. To enable learning, the system should have some way of training a neural network, to understand user’s accent.  There will never be enough training data, if the system tries to train solely from the user’s conversation with the system; The user would have to spend countless nights, talking with the phone ( and put his\her marriage and (or) social life in jeopardy). On the other hand, If the system collects  data from all users, in some centralized database and then clusters that data based on speech characteristics, then we can have a lot of training data to start with. So lets assume, that I am a user from South America, Based on my speech patterns, the system will assign me to the correct cluster (South American Cluster, if everything goes fine). So the system could be trained with that particular cluster’s data initially.  Chances are, my accent will share a lot of common features, with the data from my cluster.The system will gradually learn, some of my unique characteristics, as time goes on, but the total training time would be much less now. There should be some confidence scoring mechanism and probabilistic models that could help predict the Intent of the speaker (Something like an Hidden Markov Model.).

- The NLP Module: No matter, what you have been taught in hollywood, human language is far too complicated for Computers. For a rule based system, the constant variations and improvisation present in human speech pattern, is too hard to learn. There should be a module, that performs concept extraction from naturally spoken language. The extracted concept could be in the form of an triple (Subject -> Predictate -> Object). For instance, lets say that user says “Set up a meeting at 10.P.M with David”, then the extracted concepts would be “Meeting”, “time (10:00 pm)” and “David”.  So in software engineering talk, it needs to be translated as “Ask Calendar Program”-> “to Set Up Meeting” -> at 10:00 pm. Some of the more complex conversations, can be converted to multiple interconnected triples. For a demo of concept mining from text, visit the Alchemy API demo page.

-Machine Learning Module: Once the relevant concepts are extracted from the sentence, the system needs to identify the correct service to fulfill the user’s request. This could be done using a number of Machine Learning Algorithms, that performs supervised classification. Again with the magic of training (that are possible run through some clustering process), the system could be trained to classify the concept triples to actual service module. The key again is to learn from mistakes and to use the input from entire user base as training data.

-Service Access Layer: One of the best ways to integrate multiple services is by asking the service providers to implement a interface. The system could be made more dynamic, by creating a semantic model, to let each service providers, advertise the list of services, they are offering. Integrating internal services like Calendar service, Phone, Music Player are not very difficult. But for external services (Like booking a hotel or answering a rhetorical question), It could be slightly challenging, but as long as the all the participating service’s capabilities, are available to be  made sense of by a semantic reasoner, we can teach a AI system, to perform mapping between concepts mined from languages to concepts representing actual services.

- Making sense of the Result: One of the things, that sets apart Siri, is the fact that it provides seamless integration with services. For instance, using Android voice command, If I ask for “Best pub in town”, android will open up an “Browser window with google search results for ‘Best pub in town’”. But in Siri, the answer from the service (in this case a “search engine”), needs to be presented to the user, without having to leave the application.

 

My Personal Verdict:

I think it is too early to call Siri an artificial intelligence assistant. But its definitely a step in the right direction. I am sure that  limited hardware of a mobile platform, would have acted as a straightjacket, on the features that could be integrated in to the system. I certainly hope that, this is the first step, that will lead us to a truly intelligent assistant, that one day, will answer all our questions.

 

Resources:

What is Siri? http://www.sri.com/news/releases/020510.html

SRI’s AI Publication list.http://www.ai.sri.com/pub_list/

Alchemy Api Demo page:http://www.alchemyapi.com/api/demo.html

General SIRI usage: http://www.tuaw.com/2011/10/05/iphone-4s-what-can-you-say-to-siri/

Conspiracy http://cryptogon.com/?p=25289

 

 

 

 

 

In the first part of the series, we had seen how to setup quicksilver. In this blog, we will see, how to start using it.

Here’s a quick refresh of what we already discussed in the previous post…

- Quicksilver commands are split in to three components: Object, Action and Targets.

- A keyboard shortcut could be assigned to a command, as triggers.

General Terminologies used in this article:

  1. Each command is represented as triples in the form “<object> -> <Action> -> <Targets>”. Targets are optional.
  2. Items placed within angle brackets are placeholders. So when you see “<Application Name>”, it means, the name of any of the installed application.

General Shortcuts:

  • Activate Quicksilver: Hot-key ( Ctrl + Space by default).
  • Open Preferences: Cmd + ,
  • Open Catalog: Cmd + ;
  • Open Triggers: Cmd+ ‘
  • Open Plugins: Cmd + “
  • Switch between quicksilver panels: Tab

1.Finder Actions:

Prerequisites:

Proxy Objects should have been selected in Preferences -> Catalog -> Quicksilver.

General Navigation:

The common user folders are indexed by quicksilver and hence you could navigate to any of those folders using quicksilver. For instance to navigate to Applications folder, I could just fire up quicksilver and type “Applications” in object and “Open” in actions.

OpenAppFolder

Better yet, you could use triggers, to assign keyboard shortcuts to certain folders. For instance, lets say that you have a folder named “Tools”, that you navigate to, fairly frequently. Open triggers ( Activate quicksilver, then press cmd + ‘ ), Click the Plus button (+) at bottom left hand corner, choose HotKey, then choose “Tools” folder as Object and choose “Open” under Action. Assign a hotkey and now whenever you want to navigate to tools, you just need to press the assigned shortcut key.

ToolsTrigger

Move Finder Element:

This is usually a huge time saver. Lets say that you want to move a file from “Download” folder to “Application” folder; just highlight the item in Finder and then activate your quicksilver and use “Finder Selection” -> “Move to” -> “Application Folder”. (of course, you can set up a trigger for this, if you find yourself performing this move operation frequently).

Compress Finder Element:

Make sure that you have “File compression module” plugin and also have compress using action enabled in “preference -> Actions”. Then you could just highlight a finder element and then activate quicksilver and perform “Finder Selection -> Compress Using -> <Compression Type>”. By default, if you just want to compress to a .zip file, you could just use “Finder Selection -> Compress”. You can change this default option from .zip to something else, by using the drop down at “Preferences -> Compressions -> Create a file format in”.

 

Compress File using quicksilver

Compose and Send Mail:

Make sure that you have “Apple Address book plugin” and you have all your contacts addresses in your “Apple Address Book”.

The following are the options:

1- To just send an text email, Activate Quicksilver, press . (period key) to activate text mode, then press some text, lets say “Hello There” and then choose “Compose mail to” in action and choose the recipient.

Tip 1: Pressing . in any of the quicksilver panels, will switch to text mode, where you can type some free texts.

2- If you want to send a file as attachment, choose that file in the first panel. (You could navigate to that finder element using quicksilver or highlight that element in finder and choose “Finder selection”), choose “Compose email to” and choose the recipients.

3- If you want to compress the file first, then you could perform command linking, first choose the finder element -> “Compress” (or “Compress using”), press return. The compressed file will be autofilled in the first panel, then you can send mail, like mentioned in the previous line.

4- Finally you can send mail to multiple recipients by using the comma trick, fill in “Object” and “actions” panel as mentioned previously, then choose an recipient, instead of “Return” press “,”(comma) button. The recipient will be added to the list and you can now add another recipient.

Tip 2: You can add multiple items to any of the three panel in the command, using the , key. Try opening multiple applications using the comma key.

2.Use as General Launcher:

Quicksilver is primarily an application launcher.

Launching an application is simply: “<Application Name>” -> Open.

OpenApp

Once you have the application in “Object Panel” you could do multiple other things, use the right arrow key, to explore the list of other options. In Actions panel, click Right Arrow, you will be presented with a list of all possible options. Some of those actions, might have an sub-category, in that case, you can again, press the “Right arrow” on those items, to reveal the sub-categories. You can use the “left arrow” to navigate back to parent categories from sub-categories.

LaunchAppOtherOptions

To assign an Trigger for a specific application launch: Open triggers (Cmd + ‘), click on “+” at bottom left hand corner, choose HotKey, then….

LaunchMailTrigger

Once you save the trigger, you can assign a Hotkey to the trigger, by double clicking on the trigger.

3.The Shelf and Clipboard Module:

The shelf and clipboard module is deceptively simple and extremely useful. Clipboard plugin, helps you to maintain the clipboard history and provides shortcuts to put and retrieve items in your clipboard. Shelf is your quick access folder. You can put your commonly accessed items in your shelf. The items could be simple text elements, like your username or it could be entire application proxies or it could be actual files like commonly used images.

Prerequisites:

Make sure that the clipboard and shelf plugin is enabled in plug-ins. If any of the actions, explained below are not available, then make sure that, those items are available and checked in the Preferences -> Actions. Internal Objects should be checked under Preference -> Catalog -> Internal Objects.

Also make sure “Capture History” is enabled under Preferences -> Clipboard and also choose a default item number. Your clipboard and Shelf popups might behave badly ( Will become visible and invisible arbitrarily). If you find your shelf and clipboard popups behaving badly, do “Show Clipboard” -> “Run”. Once the clipboard is visible, drag it to a Edge of your screen. Now your clipboard will slide in and out of that edge of the screen. The same goes to shelf also.

I strongly suggest, assigning triggers to “Show Clipboard -> Run” and also to “Shelf -> Show”.

The shelf “module” may not be visible initially. Remember, you need to choose “Shelf” and not “Shelf and Clipboard catalog”. To activate Shelf, first you need to put some items in shelf. Activate quicksilver, press “.”(period) to activate text mode, enter some text and then press -> “Put in Shelf”. Once you have some items in shelf, then you should be able to see it. If it still does not work, choose “Shelf and Clipboard catalog -> Rescan catalog Entry”.

Using the Clipboard Module:

Using the clipboard module is very simple. It works in the background. Just perform successive copy operations. Invoke “Show Clipboard” -> “Run”. All the items you had copied will be stored in your clipboard screen (in the order in which it was copied). You can then drag items from Clipboard to your favorite text editor or any other program that could handle text inputs.

You can also explicitly copy items to clipboard by using, “<Any Text or Other Items>” -> “Copy to clipboard”. You could also pop the last element stored in clipboard by “Paste items from Clipboard” -> “Run”.

Using the Shelf Module:

You can have any Text or Application shortcuts or Actual finder items, in the object panel and choose “Put on Shelf” action. These items will be maintained in shelf, until explicitly removed. Then you could invoke show shelf, to access any of the items that you had previously pushed to shelf.

Do not store huge files in Shelf, this will slow down quicksilver.

4.Use it as your password manager:

Your Mac, stores your passwords and other security informations (like certificates) as keychains. By default every mac will have the “login.keychain” and “system.keychain”. Open Keychain Access, to see the keychains in your Mac.

The keychain module provides access to your Mac’s Keychain. You can quickly retrieve your password and paste it, in to your clipboard using quicksilver. Invoke quicksilver, Enter “login keychain” and then press on “right arrow key”. Choose the corresponding item from the displayed list, then choose “Copy to clipboard”(or just “Copy Password”) in actions panel. You might get a security warning. Its up to you to provide access or not.Essentially you are allowing a third party application(quicksilver, in this case), access to your keychain. Besides, you should never store sensitive information in your keychain. You are better off, using some password manager.

 

5.Web Search Module:

I use google heavily and wikipedia fairly frequently. So for me, it is sometime important to have an keyboard shortcut to invoke various searches. The quicksilver search plugin, is just for this purpose.

Prerequisites:

Add the web search module. Make sure “Web Searches” is checked in “Catalogs” -> “Modules”.

Once the module is installed, invoke quicksilver and check if “Google Search” is available at object panel. Now open triggers (activate, then press Cmd+ ‘ ), create a new trigger, choose “Google Search” under select an item and “Search For” under Actions(leave the target field empty.). Assign an hot-key to this trigger. (mine is CMD + CTRL + SHIFT + G). Test this trigger.

Google Search

6.Advanced Scripts: Freebies

You do not have to be an apple script guru to get the most out of your Mac. Most of the common problems are already solved for you. Just enable “Extra Scripts” in plugin. The following are the ones that I use frequently.

  • Shutdown
  • Sleep
  • Force Restart
  • Quit all Visible Apps.
  • Empty trash.
  • Lockscreen

I am sure that there are so much more, but these are the ones that I know.

There are various other modules in quicksilver. Image Manipulation, Text Manipulation, Developer Plugins etc. There are quicksilver plug-ins for third party programs like “Pathfinder” and “Transmit”. I am sure that you guys will find so much more, if you spend some time exploring quicksilver. I hope that I have provided enough information to help you start. Please let me know of any mistakes or have any general feedbacks.

 

Resources:

The definitive quicksilver manual: mysite.verizon.net/hmelman/Quicksilver.pdf

Quick Reference Guide: mysite.verizon.net/hmelman/QSRef.pdf

 

Mac For Developers

Author: Doc180

As a Java\Python\IOS Developer, who uses Mac as the primary development environment, I have learned  few tips and tricks along the way.This article is my attempt at sharing what I had learned in my brief journey.

The Initiation:

The first thing to do, while starting your development in Mac, is to get the Mac Development package installed. Register as an Apple Developer. Its free at  http://developer.apple.com/programs/register/. Now if you are planning to develop and distribute applications for OS X or IO S devices, then you need to enroll as Mac and (or) IPhone Developer respectively. Its a subscription service and starts at 99$ per month, for individual developer. More information here.

Once you have registered yourself as an Apple Developer (or Mac or Iphone developer), you need to install the latest version of Xcode (4 as of this writing). Xcode is an objective C\C\C++ IDE. More importantly, it comes bundled  with some nice developer tools like FileMerge, Make, Property List Editor etc. You will find these tools to be extremely useful.You can find Xcode here or you can download from the App Center (Installed in your Mac). If you only have Apple Developer Account, then you might have to shell some money to download Xcode, but its worth it. (Xcode is very useful for a Developer in Mac, even if you are not planning to develop apps for Iphone, you will still use it for general package compilation tasks  and writing apple scripts to automate  tasks).

Setting Up Environment Variable:

Setting up the  environment variables is more complicated that it needs be in Mac. Its one of the things that stumped me in the beginning. To summarize, I know of three ways.

Using your terminal.(Updating bash profile). The environment variable not be visible to GUI Applications.

  • How?: Fire up terminal and enter “export PATH=$PATH:/<your new path>”

Updating environment.plist properties. Some GUI Application (like IntelliJ IDEA) may still not see  variables set this way and hence this mechanism is not adequate.  Prior to Snow Leopard (10.6), GUI Applications launched using spotlight, will not read the environment variable set in environment.plist.

  • How?  If you had downloaded Xcode, then you would have Property List Editor installed in your machine. From Xcode 4, property list editor is integrated, as part of Xcode. Prior to Xcode 4, you could just fire up your Property List Editor ( Use spotlight, Cmd + Space and search for property list editor),then create an environment.plist file under ~/.MacOSX folder (~ stands for your home directory). From Xcode 4, onwards, you need to open up Xcode 4 and create a new File (Cmd + N) and choose Resource -> Property List (under Mac OS X) and create a environment.plist file under the same directory as above. Then you can add, properties as key value pairs.

By using Launchd. Probably the best solution, that will work universally across all kind of apps, that were invoked using any possible mechanism. But will need rebooting of system, for changes to take effect.

  • How?
    1. Open terminal.
    2. Enter “sudo emacs /etc/launchd.conf”  (You could use any of your preferred text
editor. This file may not exists, so create one if its not available).
    3. Edit this file and add the environmental variables.For example:

    setenv JAVA_VERSION 1.6
    setenv JAVA_HOME /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home
    setenv MAVEN_OPTS -Xmx1024M
    setenv M2_HOME /Applications/Dev/apache-maven

    Save the file and reboot your system.
    Like I mentioned, the last method will work universally. So I suggest that you use
it. (Please let me know if there are better ways).

Preparing your Mac for Java Development:

By default, Mac comes prebuilt with a list of JDK versions. Please note that, it takes time for Apple to release updated JDK Version.

Check the version of JDK: Using “javac -version” in terminal.

List and Switch JDK Versions: You can see the list of available JDKs using using a utility called “Java Preferences”(use spotlight).If you do have multiple versions installed, you could change your current version to an older version, by just dragging that version to the top of the list, in the
 General tab. The Java_Home environmental variable will be changed automatically for you.

Get the Java_Home directory: Its not easy to remember the Java_home, thankfully there is
 a command to find it for you. Fire up your terminal and enter the following command.

    “/usr/libexec/java_home

Download the Java Document and the source code: If you want to integrate Java API Docs
 with your IDE and have java source code available for debugging and reference, then you have to download the source and documents separately from Apple Developer Downloads. Search for “Java for Mac OS X Developer Package”.Download the correct package for your OS X Version and install it. We will see on how to incorporate this in Intellij in a future article.

Preparing Your Mac For Python Development:

Python comes pre installed with your Mac. It is highly recommended to update your python to a newer version.  You can find newer version of python here. http://www.python.org/download/releases/. For more usage instruction, see here.

Mac also comes installed with IDLE, a python IDE. But the best python IDE in my opinion is Pycharm ( From the Jetbrains Team). 

One of the added advantage of python in Mac is, it could be used for scripting Mac applications.(in place of Apple Script).

Changing a Program’s Initialization Parameter:

This is a question, that might occur to a new Mac convert. For instance if you want to change JVM arguments of Intellij IDEA, you will usually change the corresponding .ini file in windows.Mac’s Equivalent is “info.plist”. For example, to change the init params of application (Lets say IDEA.), Cmd + Click on the application’s Icon in the dock. You will be taken to the program’s installation directory. Context click on the application finder item and choose “Show Package Content” and search for “info.plist” file within this directory.(usually it will be under contents). You can edit the info.plist, using the property list editor. (Double click on the file and it will automatically open it up in property list editor, provided you installed Xcode package.).

General Development Tools Recommendation:

I am not the qualified enough to provide a comprehensive recommendation on the tools that you
 need to install in Mac. Check MacAppStorm for more detailed recommendations, So I am 
just going to list  the tools that I use…

  • For Version Management: Cornerstone for subversion and GitX for Github.(Although I stick to 
terminal for Git).
  • For Comparing and Merging Files: FileMerge comes prepackaged as part of Xcode developer
 bundle and it is very handy. Kaleidoscope is probably the best but its not free.
  • For FTP Transfer: Cyberduck (Free) and Transmit FTP (Paid).
  • Text Editor: BBEdit (Paid), Textwrangler (Free) and Emacs.( GNU Version and a more user
friendly version specifically for Mac called “Aquamacs”).

Finally one word of caution:

Sometimes Mac update will overwrite you default version of SDK or dev tools. For instance,
one Mac Update, removed all my previous version of Java and updated all my simlinks to the
 latest version (1.6). Another time, Mac decided to remove my Maven 2 and replaced it with
 Maven 3. So pay attention to what is being updated, when you get a software update alert.

Quicksilver from Blacktree is my favorite Mac Application. Its an absolutely delightful software. Mac OS X has always been a very script-able OS. Most of the applications in the Mac Ecosystem, supports scripting and automations. Applications like Quicksilver,  provides an abstraction layer, between the user and the applications, leveraging the scripting ability of the application. Quicksilver is not exactly under active development (although the Github project is active) and have not yet released a version for OS X Lion, but the snow leopard version works fine in Lion. There are a couple of comparable alternatives to quicksilver and I have heard good things about Alfred app. They also have a paid version of their app for real power user. Another app that might be considered comparable is Cockpit and I have never used it before. I will blog about it, when I try it out. But this article is primarily about quicksilver.

A Primer: I could not resist talking about some of the general terminologies used in quicksilver. The emphasis is on simplicity and hence some of the explanation may not be technically accurate, but I hope that it will make the rest of the articles simpler to understand.

The General Terminologies are:

1- Plugins: Quicksilver is a modularized application. New set of features are available as plugins and the plugins are usually categorized based on application.  So the user needs to pick the correct list of plugins needed, based on the  general usage pattern. Some plugins are more stable than others and hence only install plugins that are necessary. We can add more plugins as the need emerges.

2- Catalogs: Catalogs define the subset of items that Quicksilver can index.  You can install a plugin, lets say a search plugin and choose not to add any corresponding catalogs. That means the search plugin will have nothing to work with. The more items in catalog,  slower the quicksilver will be, since there are lot more items to index and monitor. We will learn more about catalog later.

3- Commands: Commands are how we make quicksilver do our bidding. A general command is made up of three portions. Object, Action and Argument. For instance, If I want to search google for a search term “Quicksilver”, this is how I will construct the command in quicksilver. First I will invoke quicksilver ( using the hotkey.. which is “ctrl + Space” by default). Once activated,…

NewImage

The three panels in the above screenshot represents a command and is made up of the Subject; “Google Search”, Action; “Search For” and the targets (arguments);”quicksilver”. You are essentially calling an method, on an object, with a parameter. Now you know, why I think quicksilver is just elegant.

Note: The targets are optional. Most commands do not need any arguments.

4- Triggers: Triggers are generally my three fingered salutes. You can consider triggers as keyboard shortcut  to commands. Instead of executing the entire command, I can  create a command and assign a keyboard shortcut to it. For instance, in the above example, I can save a lot of time, by assigning “Ctrl+ Cmd + G” to the Google search command.

5- Actions: Actions are the second part of a command. Objects are limited by the list of plugins and the list of enabled catalogs. Actions could also be limited by disabling some of them in the preference panel. Some actions are common to all objects ( things like Open). Some other actions could be unique to a module. For instance “Put in Shelf” is unique to the shelf module.

Enough with terminologies, lets get down to business.

Download: Download quicksilver from here. Its better to download the latest stable version. Its under open source development and hence some minor bugs might seep through. But quicksilver is   fairly bug free and maintains a very high bar in terms of quality and reliability.

Setup: The set up is fairly complex. Out of the box, quicksilver performs as a very good launcher, but we are going to use quicksilver for more than just launching applications.

General Setup Instructions: The following are the list of steps that I had undertaken to setup  quicksilver in my machine.

1. Change the Global Hotkey Activation:

This is an optional step.By default invoking quicksilver is by using “Ctrl + Space“. This is a fairly popular key combinations and in most cases, this combination will  already be taken up by some applications.( Ctrl + Space is auto complete, in almost all major java IDEs). So the first step is to change the Hotkey to something else. I have chosen, “Cmd + Return“.   You can change this while setup, when quicksilver installer asks you to choose the hotkey activation key.  After installation, we can still change it, by opening quicksilver preference (activate quicksilver and press (cmd + , )  to open the preference panel). Click on Command, under preferences and change the hotkey activation. To activate quicksilver, you just need to press the hotkey combination.

2. Carefully choose the Plugins:

Open Quicksilver preferences ( Activate quicksilver and them press Cmd + , ) and then go to plugins tab. The plug-ins are usually  organized based on applications and hence the plug-ins you need is determined which applications that you normally use.  Please be careful, while installing some plug-ins that are not in the recommended section;  some of them might make your quicksilver unstable. The following is the screenshot of my plug-ins folder. Among which, I generally recommend Extra Scripts, Shelf and Clipboard Module. The rest of the choices is up to you. (If you use Firefox a lot, it makes sense to download the firefox module and so on..)

For more recommendation on plug-ins visit this lifehacker article.

NewImage

3. Enable the correct Catalogs:

Once the plugins are installed, you still  need to choose the list of items that Quicksilver can act upon. Open Catalog tab in Preferences panel. You will see a list of items in the left navigation items, among which Modules, Quicksilver, Scripts, User and Custom are important.

NewImage

Modules: Modules are determined by the plug-ins that are enabled. Enable all modules that you need.

Quicksilver: Enable all the items in the quicksilver section. All of these items like “Proxy Objects” and “Shelf and Clipboard” help us perform certain advanced tricks.(Shelf and clipboard will be visible only when the Shelf plugin in installed).

Scripts: Enable Scripts(All Users). This item will be visible if you had installed the “Extra Scripts” plug-in.

User: The user section displays all the general user folder. Its better to enable all user folders.

Custom:  The folders added to User (the previous item) are generally  indexed for a limited depth (Lets say that you have a Image file under Documents\MyImage\Gallery1\Image.png, this image will not be indexed, since the image is at a depth of 3 and by default items added to User will have depth of 1). So if your need to scan files that are below a particular depth, then you need to add them to the custom folder. For instance, I need my music files to be indexed by quicksilver and most of my music files are under about a depth of 5, so I need to add the Music Folder to the Custom list. Highlight Custom, Click on the “+” at the bottom left hand corner, Choose “File and Folder” and browse to the folder of interest. A info panel will slide out, make sure that Include Contents is set to “Folder Contents” and also make sure to specify the intended depth. Click on the “Refresh” button on the bottom right hand corner, to update the item count.

NewImage

4. General Preferences:

In Preferences, click on Actions and make sure to check all the actions that you will normally use.  Under Clipboard make sure to enable Capture History and provide a depth of history to remember.

NewImage

We have done with setting up quicksilver, in the next posting, we will see how to start using quicksilver.

 

As a recent convert, I had some initial hiccups, while getting acclimatized to my Mac. My single most defining character as a programmer, is my laziness. I absolutely detest repeating my daily tasks. So I took my time to understand the various productivity features in OS X and have taken the time to document it.

Some of the few key things about your Mac:

1- Uniformity – Most Apps in Mac behave similarly. There is uniformity running across Mac. We will learn to take advantage of this later.

2- Self Organizing – Mac is extremely stable and as a user, you do not have to perform routine maintenance activities , that you were forced to do in windows.(defragmentation …).

3- Scripting ability – Most of the apps in Mac are script-able using a very user friendly scripting language “Applescript”. Even if you do not get comfortable with Applescript ( I highly recommend it), you can still leverage the power of scripting using Automator or using productivity apps like “Quicksilver”

4- OS X is extremely keyboard friendly – Hence a productivity treasure trove.

5- Limited yet well behaving apps – You have been warned, the amount of apps in for OS X, does not compare with Windows platform and most of the good ones are paid apps. But most of them behave well, thanks to the slightly closed nature of the platform.

Note: Most of the blog is aimed at Lion, but it is appropriate for Snow Leopard also.

Basic terminologies:

OS X is a very keyboard friendly environment. Although I do not hold against people who use mouse a lot, I personally believe that judicious usage of keyboard is a definite productivity boost. (Keyboard vs Mouse is a very serious argument and I am not going to go there, but for those who are interested this article in coding horror will be informative).

So the first thing to get out of the way are some of the key symbols in your Mac keyboard.

Command key icon (Command key) – On some Apple keyboards, this key also has an Apple logo (apple logo)
Control key icon (Control key)
Option or Alt key icon (Option key) – “Alt” may also appear on this key
Shift icon (Shift key)
Caps lock icon (Caps Lock) – Toggles Caps Lock on or off
fn (Function key)

Apart from these keys, the most important key that you should remember is the “fn” key. I have sprinkled some of my commonly used keyboard shortcuts,but it is in no way exhaustive enough and the chances are, each one of you will find your own set of most useful shortcuts. The following link provides a comprehensive list of shortcuts.

http://support.apple.com/kb/ht1343

For starters, you will do well to remember that the apple command key is almost equivalent to the control key in windows. Most of the common key sequence that you had used in windows, like ctrl + F and ctrl +c, could be used with the Command key.

Tip 1: One of the things that I like to do, is to make the function keys perform its standard functions. If you buy a Mac Book Pro, the chances are the function keys will be overloaded with more multimedia centric functionalities and to use your function keys for standard purpose, you need to press the “fn” key. I prefer to restore my function keys to its former glory. For that you need to click on the Mouse Preference and choose “Use all F1, F2 etc keys as standard function keys”.(pictured below).

NewImage

1. Stop Mousing Around:

Irrespective of whether it is productive or not, using the Mouse is the easiest way to get accustomed to an new environment. There are a few gotchas here…

The first among them is the right click, or context click option. By default OS X does not support right click in your mouse. Context menu is opened using “Command key icon + Left Click“. But if you want to use the right click, then you can set it up that way, using the Mouse Preference Panel and enabling secondary click and choosing click on right side.(Fig 1.b)

NewImage

Fig 1.b.

Tip 2: In case if you are wondering how to navigate to Mouse Preference, then it is under the system preference. Chances are that the system preferences is in your Dock.. But there is a quicker way to open these applications. Click on Cmd +Space, this will activate spotlight; Mac OS X pre-built search engine. Once activated start typing “Mouse Preferences” and you will get incremental search result and the top hit would be the one under system preference. Click it. You can save a lot of time if you leverage the power of spotlight.

Mouse Vs TrackPad: If you are getting your new Mac Computer, then I suggest that you get your wireless trackpad, instead of the Apple Magic Mouse. The magic mouse is an work of art , but its functionality is severely limited. Magic Mouse and trackpad, both support multi touch. What multi touch buys you is more options. But Magic mouse only supports two fingered multi touch, trackpad supports up to four fingers and starting from OS X Lion, they have introduced more complete gesture management, that could be key in getting the most out of your mac. For more advanced gestures supported by your Mac, click on gestures tab of your Mouse and Trackpad preference or you can find it here.

You will also learn that your Mouse have an important part to play in the effective navigation between various windows in the form of hot corners.

2. Finding your Mac:

One of the biggest surprises for a new Mac user is the limited functionality available in Finder. Finder is the Mac file Explorer. Of course if you are developer, then you will not mind this at all and fire up the terminal window instead, but for a normal user, it is important to get comfortable with Finder. Irrespective of how limited it feels, there are workarounds to make your finder feature rich and it comes pre-built with some hidden gems.

Note that there are lot of new enhancement to Finder in OS X Lion and some of the things discussed below may not be appropriate anymore.

So what are some of the limitations of Finder?

  1. It does not have a Visible Address Bar.
  2. There are no options to cut and paste finder items.
  3. There is no one step solution to copy file path.
  4. There is no option to a create New file in finder.

Workaround for your finder problems:

The simplest workaround is using a replacement finder program like “PathFinder”. PathFinder is a paid program that comes with all the bells and whistles that you would expect in a File Explorer and more. If you do not wish to shell the extra pennies, then there are simple enough workarounds.

Where is my Address bar?

The fact that there is no visible address bar, gives an impression that the Finder is limited in its use as a File Navigator. In fact Finder is very capable when it comes to Navigations, we just need to unlearn some of the things that we were taught by other operating systems.

Using File Navigation in Finder:

Lets say that you want to go to a folder location, You have the path of the folder in your clipboard. In finder press “CMD+ SHIFT +G” or Go To Folder. You will be shown an prompt, for you to paste your path information. You can use this trick, while navigating to a folder path even from within a program. I have seen people struggle a lot, while attaching files in mail. Even from within your external program like Mail, you can invoke Go To Folder, to navigate to a particular folder.

Finder also comes predefined with a pre-built set of Navigation shortcuts. The following are a selected few.

CMD + SHIFT + H -> Go to Home
CMD + SHIFT + A -> Go to Applications
CMD + SHIFT + D -> Go to Desktop

For a whole bunch of finder options click on “Go To” menu in your finder window.

Cut and Paste?

You can finally Cut and Paste finder items in Lion. To do that, you need to copy items like usual and while pasting to the destination folder, hold down “Options” and perform context click. You will see a “Move Items Here” option.

But if you have not migrated to Lion and do not wish to get pathfinder, then you still have some options.

The following are your options:

  1. Open terminal and execute an mv command.
  2. Drag and Drop, Dragging and dropping is technically a move. Just highlight the finder item using your mouse and drag to your destination folder. While dragging remember the following combinations.
    1. drag = move
    2. option+drag=copy
    3. option+command+drag=make alias(shortcut)
  3. Use quicksilver: More on this later.
  4. Leverage existing Applescripts. (Google “Applescript for cut and paste”. The script depends on the version of the OS X).

Create New File:

You might be wondering, why there is no New file creation option. In fact it makes sense to not having to create a new file. We hardly need to create a new file, outside of an program. But just in case, if you have an habit of creating lot of new files, then you can have it your way.

  1. NUFile: NewFile is an utility that adds a whole bunch of New Files options in the Finder Context Menu. I think it is versatile and it is free. ( May not work with Lion).
  2. Use Automator to create a new workflow.
  3. Use Quicksilver.( I know its becoming a repeated theme. Its intentional :) )

Copy File Path;

Copy file path looks like a simple enough requirement, but unfortunately there is no simple enough way to do it. There are a couple of not so complex way though.

  1. I have seen my Friends who use Mac, used to copy paste their folder to Terminal window and copy the path from the terminal window. I think you will agree, that this is a bad workaround.
  2. CMD + I, is a get info button. Click on CMD +I after highlighting an finder item. You can copy the folder path from this info panel.
  3. Write your own AppleScript.
  4. Use utilities like FileXaminer. Its a very versatile utility that provides many of the missing functions that we have discussed in this blog.

Other Useful Finder Features:

Customizing the Finder toolbar: The Finder toolbar is customizable, Context clicking the toolbar provides an customize option, Here we can decide on the items that are visible in the toolbar.

NewImage

Customizing the Sidebar: We can choose what items need to be displayed on the finder side bar. Invoke the preference panel (“cmd+ , “). You can also add custom sidebar items by dragging the finder items to the side bar.

NewImage

Rename: Finder items are renamed by pressing “Enter ( or Return)” button.

Get Info: To get info of finder item is by pressing “Cmd + I” (after highlighting the finder item).

Navigation: Move up a folder is “Cmd + Up Arrow“, move down a folder is “Cmd + Down Arrow“. “Cmd + [ " for going to previous folder and "Cmd + ] ” for next folder.

Quick Info: If you want to have a quick look in to a finder item, like pictures or text document, you can press “Space” button. This will open an modal window, with the quick preview of the file.

Open and Close: New Finder window is “Cmd + N“, Close a finder window is “Cmd + w ” . Close all finder window is “Cmd + Options + w“.

Change View Options: Finder provides a standard set of view options. Icons, List, Columns and Cover Flow. To switch between the views, you can press Cmd + <1..4>. Cmd + 1 stands for icon view and so on.

3. Launching your Application:

One of the primary function of the operating system is to provide seamless access to your programs and this is where OS X shines brightest. I have seen Mac with a cluttered desktop and I absolutely detest that. Being an minimalist, I think there are better ways to find and manage your programs.

1. The simplest way to launch application is using your dock. But its not the most productive way to launch an application. Besides Dock has some other interesting functions.(Dock is the application bar that typically floats around at the bottom of the screen. Although its position could be changed.)

2. Using LaunchPad: LauchPad is an new utility that is introduced in Lion. The launchPad is typically available in your Dock and the best possible way to invoke it is using the trackpad gesture.(one more reason why you should invest in a wireless trackpad). But without the ability to perform incremental search, you need to still rely on the Mouse based navigation to launch the application.

NewImage

Fig 3.0

3. Using Spotlight: Most often than not, spotlight is probably the best way to launch an application. “Cmd + Space” will activate the spotlight and you can type in the application’s name. Depending on how adept the user is at using the keyboard, this may or may not be the fastest way to launch applications.

4. The best possible way for launching application is using Quicksilver. Quicksilver is free and is one of the most important productive apps in Mac. More details in a future posting.

4. Customizing and using your Dock:

I have used an condescending tone while describing dock as an utility to launch application, but It does have some important productivity enhancing functionality. First, we will talk about customizing your dock. First open the dock preference.( remember what we already learned about launching applications).

Dock Preferences

1. First you can position your Dock. By default dock is at the bottom and you can position it to left or right.

2. I also like minimize window to application icon. If this option is not selected, then there would be one application icon and the open windows of the application will be minimized to a separate dock item.

3. Show Indicator light is a cool feature that helps us keep an visual registry of the open applications.

4. If you want to add more application to your Dock, open the application, an Dock Item corresponding to the application will be added to your dock. Right click (context click or Cmd + click) on the dock item and choose “Options”->”Keep in Dock” option.

Use your dock for…

1- Keeping a registry of all the running application: By default all the running application will have a small light indicator below it. I find it very useful to have a visual indicator of all the open apps.

2. Open the physical location of an application: More like the “Which” option in unix, we can navigate to the source folder of any dock item by, holding on the Cmd button while clicking on the dock item. (CMD + Click to open installation folder of Dock item).

3. Just maximize a particular Application: If you just want to keep an particular application maximized ( and all other open items minimized), then you could Option + Click on the dock item. Only that particular application will be visible in the desktop. Its like “Show Desktop” with only a particular application.

4- Assigning application to desktops; If you have multiple desktops (Spaces in older version), then you can use the Dock to assign applications to a particular desktop. Right click on the dock item and “Options”->”Assign to”.

5- To uninstall Application: You could drag the Dock Item to trash to uninstall the application.

Before we move on from Dock, there is one more useful tip concerned with Dock. Ctrl + F3 will move the focus to the first dock item. Then you could use the arrow keys to navigate to other dock items. This is an useful way to access the dock item, if you do not want to use the mouse.

5. Three Fingered Salute:

The famed three fingered salute Ctrl+Alt+Delete in windows is not present in Mac. But Mac does offer other comparable options.

If you were used to using the three fingered salute to recover from a frozen system, then there is good news for you. Mac rarely stops responding completely. In the rare case, if one (or few) of your applications are misbehaving, then you could use Option+Cmd+ Escape. This will open an dialog listing all the running apps. You can select one or many of the application and then press “Force Quit”.

How about just plain locking your computer. This could be accomplished best using hot corners. I have discussed about hot corners in the Mission control section, but to avoid switching context, here is how…

Open Mission Control Preferences and Click on Hot corners. (Expose for those who have not yet migrated to Lion), and choose one of the hot corners to start a screensaver.( or you could choose sleep)

hotcorners

We need to ensure that the system will prompt for password. Open the “Security and Privacy preferences”.We need to check the “Require password <?> after sleep or screen saver begins”. To avoid accidental screen saver invocation, I usually provide a small latency, instead of the immediately option.

Security

6. How to Uninstall Application?

The simple answer is, you just move the application to trash. You can move the dock item of the application to Trash or you can navigate to your application folder and move the entire folder to trash. (In fact, you could move the items from lauchpad, which probably is the fastest way to access application for uninstall).

For purists, this may not be the best possible solution, since there might be some lingering files that were left behind. In that case, the following are the options.

1- Use the vendor installation file: Most vendors will package an uninstaller with the installation .dmg file. So run the .dmg file to see if there is an uninstall option.

2- In case, if you do not have the .dmg file, then look for uninstaller scripts. Some vendors package an perl or python uninstaller scrips with the application files.(any file with unistaller.xx pattern).

3- Use third party uninstallers like AppZapper.

7. Shift Delete Options:

OS X is pretty defensive and hence there are few point of no returns. Shift + Delete definitely qualifies as one. Deleted files will always go to trash. But there is an simple enough shortcut. Once you deleted an (finder) item (Cmd +Delete), then you can click on Cmd + Options + Shift + Delete. This will empty the trash. (Note that a finder window must be active while performing this shortcut.)

8. Embrace the Uniformity:

I had already mentioned that the uniformity of the mac app is an very elegant feature. Once you are comfortable with an Mac app, the learning curve to understand other apps are considerably sharper. But the uniformity goes beyond the visual similarities and controls. The following are the common functionalities that I find very useful.

Open and Close: Not very unique to Mac, opening a new windows in any application is usually Cmd + N and closing is Cmd + W. In case of tabbed application, Cmd + W, will close the active tab.(in browser). Closing the entire application window is Cmd +Q. Cmd + T is new tab in tabbed applications.

Ask for Help: Help in a mac application is more interactive. Usually help is accompanied by a visual cue, indicating the item in the menu bar. To invoke help in almost all application is “Cmd + Shift + /“. For instances, lets say that you are using a blogging tool (like MarsEdit) and you need to know how to do a block quote. We can invoke the help (using Cmd + Shift + /) and type in block quote, you will be led to the menu item.

NewImage

Preferences Panel: For most applications, invoking the preference of the application is by using “Cmd + ,” ( command + comma) . In some applications, you can even use “Cmd + ; ” (command + semi colon) to invoke more localized properties. For instance in Intellij IDEA, you can use Cmd + ; and the project property panel will open.

Get Info: To get info on any item is usually “Cmd + I “. This works universally in all applications.

Scrolling with Joy: In most apps, primarily used for reading, (like browser, preview and adobe reader), scroll down is accomplished by “Space” button and scroll up is “Shift + Space”.( page down and page up correspondingly).

9. Mission Control or How to Organize your work space:

To organize your work space, OS X, provides you with Spaces and Expose. They are an ultimate productivity boosters. In Lion, they are presented under a single umbrella called Mission Control. Mission control is not all that different from the older Spaces, but there are subtle differences.

So if you are already used to Spaces and Expose in snow leopard, the following are the general differences:

1- Spaces and Expose are unified under a single umbrella.

2- Assigning applications to Desktops, option is removed from the preference panel and is now only available through the dock item of the application.

3- The individual desktops are more customizable, starting with having separate wallpapers for each one.

4- Adding more desktops is removed from the Preference panel and is available as part of the mission control tiled view.

5- Some application could be assigned across desktops using the “Assign to All Desktop” options in the context menu of the Dock item.

6- Enhanced gestures (multi touch) for accessing Mission control.

So enough with differences, how to leverage the power of Mission Control.

If you want to switch across application or navigate to different desktops, you will use mission control, if you just want to navigate to different windows belonging to same applications, you will use App Expose.

Mission Control:

Mission control will tile all the open application in the current desktop and also will tile all the available desktops. You can also add more desktops, by moving to the corner of the desktop tiles and you will see a “+” button (in the right edge) for adding more desktops.

NewImage

 

1. The best way to invoke mission control is using the Gestures. Open your trackpad preferences and switch to more gestures tab. You can choose the gesture for mission control. By default its swipe up with three fingers.( I have changed to four fingers, but its a personal preference.)

NewImage

3. Mission Control can also be invoked using Ctrl + Up Arrow.

4. Navigation between Desktops, is best accomplished using Ctrl + (left and Right) buttons. If you know the exact desktop number to navigate to, we can use Ctrl + <Desktop Number>. Lets say that I have four desktops. Ctrl + 3 will take me to the 3rd desktop.

App Expose:

App Expose is primarily used to navigate across two windows of the same applications. Its provides a snapshot of all the instances of an single applications.

1. You can invoke App Expose, using Gestures. By default its “Swipe Down with Three Fingers”, you can change that in trackpad preferences -> More Gestures.

2. You can use Ctrl + Down arrow.

Hot Corners:

You can assign behavior to mouse positions or more precisely the four corners of your desktop. Mission Control and App expose, could be assigned to top left and top right corners respectively.

NewImage

By creating multiple desktops and assigning each desktop a general theme, we can organize our work flow. For instance, I have five desktops and I use the First one for Dev Tools, second one for organizers, third one for Finders and terminals, Fourth one for readers (Kindle App, Preview, iPhoto etc) and finally the last one for internet. (browser, iChat etc.)

I find Ctrl + Arrow keys to be the fastest way to access Mission Control features. But depending on preferences, some may like gestures more.

Finally, I had liberally mentioned Quicksilver in this article. If you want to learn how to use quicksilver, then head to the “Getting started with Quicksilver” article.


 

So to our central question,  can we improve our happiness?. This is the third part of a three-part series on happiness.  I suggest reading the first and second part of the series before reading this.

In the first two parts of this series, I argued that happiness is a variable and we can change our general level of happiness and also analyzed the common pitfalls and reasons why we sometimes fail in our quest of happiness. Understanding all the reasons on why our pursuit is failing, is not enough to help improve happiness. We need to derive upon a simple set of action points that we could adhere to.

Need of Social Support Structure: It is widely accepted that we are social creatures, We need to have a healthy social support structure. People who we can talk to , rely upon and share our feelings with. It is very important to have strong social support structure, to buffer negative emotions and enhance positive emotions.

The quality of Company: Studying about the “Mirror Neurons” will only give credence to something that we already knew. We are limited by the company we keep. If we are surrounded by positive, happy people, there is a much better chance of us being happy. So it is important to choose our relationship wisely.

Look around : We have a tendency to objectify everything, our brain is not very good at finding values in non tangible things. Going out of your home and observing  nature could do so much more than staying at home and watching TV. Meeting new people, tree gazing or just simple star gazing could help us feel more alive and happy.

Convince yourself that habit matters: This probably is one of the key area, that we need to work upon to help improve our general well-being.  If we feel responsible for things that is happening to us (both positive and negative), we have better chance of making the changes, that will help improve our life. Or simply put, we need to convince our brain, that our behavior matters. Thinking on the contrary will give us the “Victim Mentality”.

We need to take advantage of the things that we learnt about Habits.
The following tips will help.

  • If you are trying to form a new habit, you need to have the conviction that the habit will bring about a positive change in your life and one way to convince yourself is to get acquainted with someone who has already benefited from the habit. It is like a sort of mentor-ship and it is important that this person is someone who you respect and have a personal relationship with.
  • Do it for 21 days: Research have shown that any habit that you continue to do for 21 days, will become part of your habit stream.  It creates strong neural pathways, so that the habit becomes part of your daily routine.
  • Reduce the activation energy: For anyone familiar with Chemistry, activation energy is the, energy that must be overcome in order for a chemical reaction to occur. Its the initial energy investment. The key idea is to increase activation energy for your bad habits and reduce the activation energy for your good habits. So if you are trying to avoid spending lot of time watching TV, just put the remote away from the couch. Lets say in your kitchen pantry. Lets say that you are trying to run every morning, just keep your running shoes next to your bed while going to sleep.

Once you have convinced your brain that your habit matters, you will have the necessary conviction to make the changes you want.

Look inside for happiness: Increased mindfulness is essential to be happy. Mindfulness creates more awareness in our mind, bridges the gap between the various layers of the brain, helps us take more rational decisions, stops us from fretting about simple things and more importantly, helps us to change the goggles with which we view the world. Meditation is absolutely essential if you have honest conviction about increasing your happiness.

Simplify:In a world filled with  options and complexity, we need to take  a deep breathe and simplify our life as much as we can. We need not  spend an entire day arguing with our-self on what jeans you should buy. Most of the decision we make, have limited impact in our life and we should be able to simplify those decisions.

Fall in to Routine:One way you could simplify your life is to establish a simple routine. Not everything in our life needs to be recorded  in our routine, but simple things that we do everyday, can be accomplished with much less effort if we follow a routine. Routine also allows a simple way to incorporate healthy, happiness inducing habits like Meditation and exercise in our daily life.

Engage in Compatible Jobs:Take some time in understanding your strong points. Then involve yourself in a job that leverages these strong points. Life is too short to engage in activities that are not suited for you and spending your weekends in binge drinking. Engaging in activities that you like is called the flow and could be key to happy life.

Apply your strength in  a meaningful way:After taking some time to understand your strong points and identifying activities that leverage those points, we can still increase our happiness, by using those skills to answer higher purposes than us. If you are good at developing websites, in your free time, you could help create websites for a good cause for free. Attaching meaning to life, provides us a intense sense of prevalent happiness.

Like Yourself:If you do not like yourself, what chances are there for others to like you. When you do not like yourself, it shows and it manifests itself in the way you advertise yourself to the society. I think it is important to be comfortable with who you are. One key way to achieve this is acceptance. If you accept you for who you are, then the brain starts synthesizing happiness for you.

Exercise:Exercise provides you an extra push for you to achieve happiness. The research on relationship between exercise and happiness is very conclusive and of course has the added benefit of looking and feeling good about yourself.

And above all be Altruistic:It is no coincidence that people who are really happy are not the ones who obsess about their own happiness. Be concerned for others happiness. Make conscious effort to make your friends and family happy. Be sympathetic to their problems and genuinely concerned for their well being. This idea is beautifully expressed in some Buddhist teaching. I am not repeating verbatim, but this is how it goes. The more you meditate, the more you see how you are very similar to others and more you start to lose the meaning of “I” and start embracing the idea of “US”.

To summarize:

  1. Choose your company wisely.
  2. Conviction that your habit matters.
  3. Increase mindfulness by the way of meditation.
  4. Simplify your life.
  5. Establish a routine.
  6. Find your strength.
  7. Apply your strength to a meaningful life.
  8. Accept yourself.
  9. Have love and compassion for others.

Our Quest for Happiness.

Author: Doc180

In the first part of the happiness series, I had discussed about Happiness in general. In this second part of the series, I will try to analyze how well we are doing, in our quest for happiness. There is no denying the fact that we all try to be happy.  The amount of books written on happiness and the amount of drugs in the market (albeit most books and drugs are on, how to evade misery, than how to be happy), is a testament to the effort we make to keep our-self happy. Still most of us seem to be failing in our goal.

Muddled Understanding: Our brain is not very good at understanding what makes us happy. Coupled with the fact, that our understanding of happiness in itself is very fuzzy, we end up pursuing dead ends. If you want to know more reasons on why we may not be as smart as we think we are, then checkout this website called YourAreNotSoSmart.

Vestigial Emotions: I believe that our evolution of brain is at an important juncture. We still carry around lot of those emotions that were instrumental in our ascent to being the dominant species in this planet, but have limited use in our present social environment. This leads to inappropriate applications of these emotions. Take for instance stress, the essential flight or fight reaction that kept our ancestors alive from being eaten by predators is now experienced while waiting at a traffic signal. Likewise we have learnt to apply emotions like Anger, Jealousy that had evolutionary significances, in inappropriate situations.

Skewed Perspective: We are loaded with negative information all around us. We live in the age of information and negative information travel much faster than positive ones. Our brain is fed with lot of negativity, and since our brain is inherently more concerned about avoiding misery, it justifies spending lot of its time in avoiding all the perceived misery, than trying to be happy. This evasive action makes us more and more private, introverted and paranoid. This image provides funny interpretations of the negative information overload.

Extreme Simulation: As already mentioned, our ability to simulate life-threatening situations, were one of the things that set us apart. Our brain could prepare us for eventualities like a predator chasing us and help us weigh up the options we have. So when we are actually chased by a predator, we would know what to do. This evolutionary improvement has created a problem in modern environment. We are not worried about being eaten alive when we sleep toady. Fed with all the negative emotions, our cerebral cortex goes on an overdrive, worrying about all eventualities that have very little chance of happening.

Increased Options: Imagine ordering a sandwich right now. About 20 years ago, it would be as simple as driving to your favorite restaurant and ordering from a predefined set of options. Now you need to know the details of eight different dressing, five different varieties of cheese and a myriad of vegetables you never knew existed. The same goes to shopping for trousers. It used to be as simple as knowing your waist size. You pick a color and you are done. Now Levis alone has about eight different options. Superficially this increased option looks like a good thing, but it causes two problems, first it freezes our brain with information overload and secondly and more importantly, the increased option provides our brain more reason to be unhappy. With a limited option, you get something and are happy with the decision you made (knowing that you took the best possible choice). Increased options mean we are giving our brain more reason to regret our decisions and in simple terms, we have managed to over complicate simple routine activities.

Cultural Significance: We are living in the age of achievement. The Economist should take the bulk of the blame for this state of society. Our life has become an exercise in satisfying our reward system. We set goals and are driven to achieve it, by stimulating our reward system. (If I do that, I will get this). We have lost touch with the journey, forgetting the fact that, we spend a major bulk of our life in Journeys and very few moments savoring our achievements. Engaging in activities that does not leverage your core ability will ensure a life of deep dissatisfaction.

Looking for external verifications:  Brought up in a reward driven society, our   every single achievement needs to be externally validated, we are programmed to become simple automatons, whose every belief needs to be externally validated. The external validation causes mental turmoil and increases our chances of leading a very unfulfilled life. The reason for doing something should come from within and not driven by external factors.

Failure to take responsibility:  We have an increased tendency to not take responsibility to our problems and attribute all problems to external factors.  On the other side of the spectrum, those who believed that their behavior matters are more probable to take the positive steps that will increase their level of happiness. This is the reason, why sometimes, we start creating a list of material prerequisites, when faced with a question of our happiness.

Looking for silver bullets. With increased emphasis on medication, we are trained to look for silver bullets. But unfortunately, not every problem has a simple solution. We need to be proactively involved in making the change, than hoping that some induced chemical or biological reaction in our system, will bring about the change. This phenomenon is again visible in increased reliance on concepts like Religion. Simply following a set of rules, that probably were never supposed to be taken literally, is not going to increase the meaning of life. There needs to be a continuous involvement in the process to make the change. (Increased belief that our behavior matters.)

Fear of change. Again coming back to our desire to avoid unhappy emotions, we are content with staying where we are, than taking some steps that can lead us to increase our happiness. Lack of conviction, external verification and muddle understanding has leaded us to stay static. So we continuously seek out local minima, a state with minimal negative feeling, that trying to pursue happiness. We are paralyzed by the probability of failure.

In the next and final section, we will discuss on how we can try to avoid some of this pitfalls.

Understanding Happiness.

Author: Doc180

Described as the “Goal of Goals” by Aristotle, happiness, as a concept, has been defined, analyzed and researched upon by some of the brightest minds to have inhabited this planet. Yet the idea of happiness has become muddled and amorphous and there is an increasing tendency to dismiss happiness as a doomed pursuit and an undertaking of the naïve. The world is far too problematic, riddled with multiple layers of complexity, for someone to have such a simplistic goal, they say. Yet, I believe happiness is the key to a meaningful and fulfilling life.

I honestly cannot claim to have understood happiness or even have a definitive set of action items to increase the level of general happiness. But I find it increasingly important to document everything I know so far.  The following is the first part, of a three-part series on happiness. In the second part, I try to analyze the common failings in our quest for happiness and in the third part, I try to derive upon a set of action points to increase our level of happiness.

Define Happiness:

Happiness is a state of mind, where it is free of concerns and is filled with mindfulness, contentment and joy. Happiness is more like substrata, which encourages manifestation of positive emotions in our brain and drives away negative ones.

Happiness should not be confused with ephemeral emotions like pleasure, which have a diminishing quality to it and is hard to sustain. Also happiness does not seem to share the same plane with misery. Depression for instance should not be confused with lack of happiness (it’s a disease and you need medical help) or lack of misery does not mean that one is filled with happiness.

The Critical Question:

It is fairly obvious for all to see, that being happy is a skill and just like every other ability, it’s a variable and varies from person to person. Some people are born happy and others are born miserable and most of us are somewhere in between.  So if it’s a variable, are there any definitive steps that we can undertake to increase our happiness?

So to answer, that question, first we need to, take stock of what we already know about happiness… (Obviously not a definitive list… a very small subset from my limited knowledge pool). Before we go to the list though, I wanted to discuss a bit about why research on happiness had stalled in the early part of 20th century and why it finds itself slightly removed from the public psyche even now.

The State of Research on Happiness:

Happiness research seems to have stalled in the early 20th Century. I attribute some of the blame to Sigmund Freud.  Psychology became a practice of restoring sanity or put simply, makes miserable people feel normal. Those people who are not miserable were categorized as optimal and people who are happy are completely ignored as an anomaly. This mentality could be attributed to the amount of information that was made available by science in the 20th century and our inability to process the complex set of information and its multiple dimensions.  Armed with our God Complex, we went ahead and made most simple ideas fuzzy and made simple targets intangible.

Thankfully in recent years, there is an increased focus on happiness, in the form of Positive Psychology and it has opened up new avenues for people striving to increase their happiness. People like Dr. Martin Seligman, has done a whole lot, to raise awareness on positive psychology. Dr Seligman’s homepage is a treasure trove for people interested in positive psychology.

Happiness Working Range: Our genes provide us the happiness baseline. We are all bestowed upon a working range, with lower and upper boundaries and we oscillate, but stay within these boundaries. Most of us will never step outside our working range, unless if we make a conscious effort.

Stability:  The working range remains fairly consistent and does not waver much.  Supposedly life-changing events (both positive and negative), only creates a temporary spike in this working range and we revert back to familiar territory, sooner rather than later. So events like winning a lottery or loosing all your money, does not have a lasting impact on your happiness.

Factors affecting happiness: The factors that affect our happiness other than our Genes are Behavioral and Environmental. Environment is what is provided to us, behavior is the goggle thro, which, we make sense of it. It’s fairly obvious to see on where we should focus our efforts on, to make an everlasting impact on our happiness levels.

Simulation of potential events: A highly evolved cerebral cortex enables us to learn from other’s mistakes and to simulate life-threatening situations.  Our ancestor’s ability to simulate what will happen, if a predator stalks them at night, should have played a very important role in their survival and subsequently our ascent to being the dominant species in this planet. But it has a negative side to it. We will see that in the second part of the series.

Plasticity:  The technical term is “Neuroplasticity”. Our brain has an inherent ability to change structurally and functionally, based on the environment and behavioral inputs.  So you can teach an old dog a new habit. (But there would be inertia while trying to rewire an established Neural Pathway).

Habit Formations: Habits are formed by creation of strong neural pathways.  A Neural Pathway is a series of neurons, whose polarization is permanently raised closer to the threshold potential making it easier to propagate action potentials down this path. Habits are formed by the repetition of a particular neural pathway leading to a reward.

In simple layman terms, if you learn some behavior, by associating rewards (dopamine) with a particular context, that habit gets ingrained in your habit stream and you will start doing it with little conscious effort.  Understanding neural pathways is both key to breaking out of old destructive habits and learning new constructive habits. I will discuss some tricks on habit formation later in actions steps.

Reward Pathway: Our brain is hardwired with reward pathways and this needs to be sufficiently simulated by serotonin, dopamine and other neurotransmitters. We need to keep these reward pathways simulated with positive constructive activities. If ignored, our brain will find a way. (by means of destructive habits like drug addictions).

The Company we keep:  Human beings are provided with enhanced ability to empathize. Also termed as Mirror Neurons, our mental state is influenced heavily by people near us.   For instance if someone smiles at us, we naturally smile back. Someone yawns in the room and automatically every one else yawns too.  Some agitated person in a ticket counter, will make the whole queue agitated.  So if we surround ourselves with positive happy people, we will be more inclined to be happy and it works the other way too.

Our Layered Brain: Common sense is not common action. Now why is that? We all want to be happy, but sometimes we make some very dump mistakes, that are sure to make us feel miserable.  At least one reason for this can be explained by how our brain is organized. Our brain is layered, a result of generations of evolution. Evolution did not alter our brain, but rather created new advanced layers over older layers to enhance the functionality. (As a developer, I cannot help analogize this to a Decorator pattern).

Reptilian system or R-complex: This is the most primitive portion of our brain and this is responsible for functions  related to instinct  and self preservation like   survival, digestion, reproduction, circulation, breathing, stress responses, territorial instincts, social dominance

Mammalian Brain: This is the second layer of the brain and is responsible for  functions in primal activities related to defense (‘fight or flight’ fear response), food and sex as well as activities related to the expression of emotions and feelings (fear and protection)  including emotions related to the attachment and care of offspring.

Cerebral Cortex: This is the layer that makes us Humans. The layer that is responsible for invention and abstract thoughts. The cerebral cortex is involved with most mental activity, including spatial and mathematical thinking, meditating, dreaming, remembering, processing and decoding of sensory information.

There is a kind of power struggle going on between the layers of our brain. This is why we sometime make some very questionable decisions in the heat of the moment or driven by primal needs, but regret it once we regained our composure. This is more like the rational brain wrestling control back from the more primitive layers of the brain.

Our Fear of Misery:

We are all naturally hardwired to pursue happiness, but more importantly we are more concerned with avoiding misery. Negative emotions in general are far more potent than positive ones (by an rough order of five). So our pursuit of happiness is outweighed heavily by our fear of misery.  Bad memories will linger on far longer than positive ones.

Happiness is Measurable (almost):

Knowing your present state of happiness will go a long way in helping you decide, your future course of actions. There are ways to do that. AuthenticHappiness has a series of questionnaires that could help evaluate where you stand in terms of positive psychology.

Continue reading the second part.