Sunday, December 29, 2013

Apple Products - The Making & What's inside

To all those who own an Apple Product, be it an iPod, iPhone, iPad, MacBooks, desktops etc., It's always a great feeling to own a Mac. Hope those who own it, agree with this. All we do and know is, go to a showroom or website and buy the apple product or upgrade. Ever wondered, how it is done. Thought of writing a blog on it.

Let me begin with this. Most of you may have noticed these lines, "Designed in California, Assembled in China." somewhere in your Apple Products.

Apple has contract with Foxconn. Foxconn is a Taiwanese  multinational  electronics contract manufacturing company headquartered in TuchengNew TaipeiTaiwan. It is the world's largest electronics contract manufacturer,and the fourth-largest information technology company by revenue. Read more.

PFB the video, which shows a tour inside Foxconn.




There are other talks that say about Samsung Processors inside Apple Products. Chipworks comments on it here. Apple is also working on with Pegatron recently. Read more on this.

To know more about the inside of each product, refer these teardowns from ifixit.
1. iPhone
2. iPad
3. iPod
4. MacBook
5. Desktop

Hope you would have got an insight into what's inside Apple product and how and where it's made.

Thursday, December 26, 2013

Running Scripts when USB inserted

Using USB Storage devices is very common nowadays. It has made data transfer so easy and fast. We are now able to carry upto 32GB of data in our palm.

Wouldn't it be nice, if the mounted i.e inserted USB triggers the action it's meant out to. Yes, it's possible in your system. For example,on insertion of a USB data card, the corresponding launch application or browser application can be opened or on insertion of a USB or pen-drive, or auto backup or copying/scanning files or playing music or video or photos can be done. 

There are three ways to do this in a Mac. They are
  •   Using Launch Agent
  •   Using Folder Actions
  •   Using Third Party Apps 
I will explain the first one and will share the links to the other two.

Launch Agent (launchd, launchctl) :
  Here are some useful links where you can know what it is.
   -> Apple Site
   -> Wiki

1. Open textedit and add the following code,
   #!/bin/bash
   if [ -d "/Volumes/<Your_USB>" ]; then
       say -v bell ding dong
       open /Applications/<YourAppName>.app
   fi
 Replace YourAppName with any applications installed in your mac,which you want to open when usb is inserted and save it as mount.sh(sh stands for shell script), Copy it to "/Users/<Your_User_Account>/Library/Scripts/

2. Open textedit and add the below code,
--------------------------------------------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<dict>
        <key>Label</key>
        <string>com.usb.mount</string>
        <key>LowPriorityIO</key>
        <true/>
        <key>Program</key>
        <string>/Users/<Your_User_Account>/Library/Scripts/mount.sh</string>
        <key>ProgramArguments</key>
        <array>
                <string>com.usb.mount</string>
        </array>
        <key>WatchPaths</key>
        <array>
        <string>/Volumes</string>
        </array>
</dict>
</plist>
 --------------------------------------------------------------------------------------------------------------
and save it as a plist file with name as the same value given for label in plist code, i.e. com.usb.mount.plist and place it in /Library/LaunchAgents

3. Now log out the current user and login again.

4. Open terminal and type the below command, to verify if your plist file is listed in there,
 launchctl list

Thats' it. done. Boom !! Now each time you insert the usb drive a bell sound rings and starts out your app..

Folder Actions :
 Please refer these links

Third Party Apps :
 There are tools like MarcoPolo, Do Something when etc.,


References :

Friday, December 20, 2013

Screen Lock

There are many Apps in AppStore that allows screen locking, however, if you are interested you can even write your own custom shell script to lock the screen when you are away.

Open TextEdit, and type the following code,
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend

Save it as "lock.sh" in a location easily accessible for you. Open terminal and give it execute permission using the following command,
 chmod 777 lock.sh

Right click the file and change the default application to open as terminal.

From next time onwards, a simple double click on the file, will open terminal and lock the screen.

References
http://osxdaily.com/2012/03/30/lock-mac-desktop-command-line/

Monday, December 16, 2013

Java & Path Variables in Mac OS

To know where Java is installed,

In terminal type the below

/usr/libexec/java_home -v 1.7   [or]
sudo find / -name java
To set any new path to the existing classpath in Mac,

Go to the .profile or .bash_profile found under Documents folder for each user and for example adding android path, type the below lines,
export PATH=${PATH}:<your-android-sdk-path>/platform-tools/
export PATH=${PATH}:<your-android-sdk-path>/tools
Save it. Close the file.

In terminal, type the below
echo $PATH
to confirm whether the path is listed there in environment variable.

Now close and restart the terminal and type the corresponding commands to check if it is working.

Reference:
http://stackoverflow.com/questions/5526470/trying-to-add-adb-to-path-variable-osx
http://stackoverflow.com/questions/15826202/where-is-java-7-installed-on-mac-os-x

Sunday, December 15, 2013

Intro

This blog was created to share my views, interest, learnings, and other tips and tricks about Mac.

To introduce, I have a MacBook Pro 13" Mid 2012. Bought it from eBay in Nov 2012.  As I am working with mobility, its always better to work in Mac as you can develop for any mobile platform. Ofcourse, I am a android developer and am writing a blog on android too. Now it's been a year, I am using it. Recently extended its warranty for another 2 years.

Before MacBook, I was working in a Windows Laptop. To compare both, Its like both has its standing merits and demerits. Getting accomodated to Mac was the only hurdle. Now after a year, I feel, Mac makes me feel at ease, comfortable, kind of richness to the work I am doing with my laptop. There were hardly things going wrong/crash in macbook which is more prevalent in Windows. I am not Apple evangelist as well am not against windows.

Few things which I like about Mac are as belows,
 1. Automator.
 2. Gestures in trackpad.
 3. Rare memory crashes.
 4. Magnetic charger pin.
 5. Nice Resolution while watching pictures/videos and in general.
 6. Inbuilt OS functionalities like video/audio cutter/recording and many more.
 7. Internet Sharing, especially via WiFi.
 8. Genie effect in minimise/maximise windows.
 9. Apple Logo Light behind monitor.
 10. Default Backlit keyboard.

I have Mountain Lion OS X 10.8.5. Waiting to upgrade to Mavericks, as I am yet to get portable hard-disk to backup my data.