Saturday, September 8, 2007

OS-X is 64-bit Unix

Just to prove that my Macbook is a 64-bit machine, I build the following simple program:

#include

int main()
{
printf("sizeof(long) = %d\n", sizeof(long));
printf("sizeof(double) = %d\n", sizeof(double));
}


Compile it with:

gcc -mtune=nocona -m64 -mfpmath=sse -msse3 -O3 test.c -o test

and execute test. If the size of long is 8 bytes, it's 64-bit!

Sunday, September 2, 2007

Making ipod video files from DVD

Search google for "handbrake", and install it.

Edit/create a new shell script, and paste one of the following:

For low resolution:
HandBrakeCLI -f mp4 -w 320 -l 176 -s 1 -N eng -e x264 -b 700 -2 -d -E ac3 -B 160 -R 48 -T -x "--threads 2" -i /dev/dvd -o $1

For high resolution:

HandBrakeCLI -f mp4 -w 640 -l 368 -s 1 -N eng -e x264 -b 1500 -2 -d -E ac3 -B 160 -R 48 -T -x "--threads 2" -i /dev/dvd -o $1


The /dev/dvd is where the DVD device is located (might be different that this one). While the output file is the only parameter in that script.

Say the script file is named "dvd2ipod". To make a m4v file, we just type:

dvd2ipod , where is replaced with the output file we want to make into. For example, the following is the result after I typed something.

linux-dell:/> dvd2ipod evil_cult.m4v
HandBrake 0.9.1 (2007090200) - http://handbrake.m0k.org/
2 CPUs detected
Opening /dev/dvd...
Scanning title 1...
Scanning title 1...
Scanning title 1...
Scanning title 1...
Scanning title 1...
Scanning title 1...
Scanning title 1...
Scanning title 1...
Scanning title 1...
Scanning title 1...
Scanning title 1...
Scanning title 1...
+ title 1:
+ vts 1, ttn 1, cells 0->6 (2015335 blocks)
+ duration: 01:43:07
+ size: 720x480, aspect: 1.33, 29.970 fps
+ autocrop: 62/72/8/10
+ chapters:
+ 1: cells 0->0, 14566 blocks, duration 00:00:44
+ 2: cells 1->1, 270120 blocks, duration 00:13:49
+ 3: cells 2->2, 274760 blocks, duration 00:14:03
+ 4: cells 3->3, 330130 blocks, duration 00:16:53
+ 5: cells 4->4, 377811 blocks, duration 00:19:20
+ 6: cells 5->5, 345073 blocks, duration 00:17:39
+ 7: cells 6->6, 402875 blocks, duration 00:20:37
+ audio tracks:
+ 1, Unknown (AC3) (2.0 ch), 48000Hz, 224000bps
+ subtitle tracks:
Applying the following x264 options: --threads 2
Modified x264 options for pass 1 to append turbo options: --threads 2:ref=1:subme=1:me=dia:analyse=none:trellis=0:no-fast-pskip=0:8x8dct=0
x264 [info]: using cpu capabilities: MMX MMXEXT SSE


The HandBrake is an open-source application and supports Mac, Linux and Windows platform and is downloadable at http://handbrake.m0k.org/

Saturday, September 1, 2007

Internet everywhere with MacBook

This is how to connect to the Internet on the road via GSM phone provided by Cingular/AT&T Wireless (gotta have unlimited data plan though).

First, enable bluetooth on the Cellphone (mine is Cingular 8125) and check the "Discoverable" box. Do the same on Macbook. On the cellphone, add incoming port to this newly discovered device (Macbook). in my case, I use COM6.

From MacBook, click Apple -> System preference -> Bluetooth. Select the newly discovered device (cellphone), check both "Access the Internet with your phone's data connection" and "Use device as handset for this computer". It will auto-configure it. Ensure when we click "Edit Serial Port", it shows a virtual port (RS-232 compatible).

Now, to setup the dial-in configuration, from Apple -> system preference -> Network, add this under "PPP":

Telephone number: *99#
Account name: wap@cingulargprs.com
passwordl: CINGULAR1

Now, if you try to dial in, it will use the bluetooth to your cellphone (acting as a wireless modem), and badaboom...you're connected!

Wednesday, August 29, 2007

Xcode now is installed!

I now successfuly installed Xcode. The reason it couldn't be installed before was because the folder /Developer was there. After deleting this folder and redo the installation, it went thru successfuly.

Friday, August 24, 2007

I am a Mac Convert!

Since the very early stage of my computer learning (which might be more than 20 years ago), I never used or even learned to use Apple products (Macintosh etc.). I have been a devoted PC user wholeheartedly.

I had been thinking to get another laptop which is light, easy to carry, beauty in the look, robust, quite fast and surely is in the trend. I looked at HP, Sony, Lenovo, or Toshiba laptop, even Acer tablet PC but nothing to interest me. All of them run Micro$oft Vista (which I hate, mostly because of its resource hungry). Besides, I wanted to explore to other sides of the "dark side". Linux is another one, but then it has been my toy for years now.

Last week (Aug 14), I was curious about Apple's product and went to its site. I saw they were having a deal: buy one MacBook get one iPod nano for free (or with additional $50 to upgrade to iPod Video). Not bad, I said. The deal was especially for students.

One interesting pricing scheme is that the black color is about $70 more expensive. I don't know exactly what reason for the difference, but I didn't care because I like the white color better (it's so unique and slick, no PCs made with this color and style).

I opted to add an extra 1 GB of RAM (the standard one came with 1 GB). I also chose the 120 GB HD version, plus I ordered mini-DVI to DVI (to be able to hook it up to standard LCD screen). It came with apple remote (looks so cool), 2 MacOS+iLife Installation DVD. I also bought iWork '08 (Supposedly the Office competitor in Mac world). The Micro$oft Word 2004 was installed but it was actually a trial and I didn't want to waste couple hundreds of dollars for M$ product.

When the package came (the macBook was shipped from Shanghai, but took only 4 days to deliver), I saw the box was relatively thinner than average PC boxes (I took some pictures of it, but did not have a chance to uload them here yet). The manual is just a small booklet, but the rest of information is in the HD (PDF file). No big deal to me. Oh.., I love the power supply. It's soo cool and small, yet it can provide juice about 60 W. The connector to macBook is also a smart masterpiece made by Apple. Instead of snapping with lock, it uses magnetic and can be connected in both sides (no need to know the polarity). What a design!

After opening the box, I tried to weight the laptop. It's weight it is about average like other subnotebook (13' screen laptops). No caddy or tray to put CD/DVD. They just need to be inserted to the hole on the side. Keys on the keyboard is slightly different than PC keyboards. Most noticeable one is the apple key. It also has "FN", "CTRL", "ALT/OPTION" and CD-eject keys. There are two different ENTER keys (not sure what is the function for the extra one). There is only one button below the touchpad. The keys are made quite shallow but yet are comfortable to press. Barely hear the 'click' sound there.

One tiny web camera is on the top of the screen along with a tiny LED and microphone. There are two USB2 ports and 1 FireWire 400 Mbps port. The Audio in/out are very good as they are combos with optical audio in/out. 1 Gigabit Ethernet is also there. All these ports are located on the left side of the laptop (the right side is for CD only).

The Wireless network supports A/B/G/N standards, so it can go up to 100 Mbps (theoretically). The DVD is capable of reading/writing dual-layer +/-R and onto WR as well. There are two tiny speakers hidden close to the LCD hinge (guess they don't have enough power to make 'boom' sound).

One thing I am really not used to is the font. Unlike Windows fonts which are very sharp, Mac OS's fonts are kind of blurry. I read some article about it and it says that is because Apple has been following different path of how to draw fonts (font rendering). The main difference is fonts on Mac are more closer to what they suppose to be drawn on screen and printer.

Software sides, this is what Mac away excels than Micro$soft. From widgets, animated windows, zoomed toolbar, high DPI icons, etc. Mac Is undoubtedly the winner here. It also does not eat that much resources compared to Windows, especially Vista. I barely notice any slowdown on performance, while my office laptop (Dell Latitude D620 with 2 GB and Nvidia's dedicated graphic card) has been somewhat slower than when the first time I used it due to many softwares installed. No wonder, Apple is based on Unix (FreeBSD) which is known for its efficieny, stability and robustness. I also noticed the used space is comparably less than on NTFS, although MacOS uses Journaled HFS+ (see, they have been using journaling system long before Windows. Even current Vista doesn't have this journaling as they originally promised to include into WinFS). Imagine, my 120 GB (about 112 GB for the actual usable space) still has about 94 GB left, eventhough I'd installed many softwares (MS Office trial, iWork '08, Mac's Xcode IDE, many bells and whistle gadgets and tools I downloaded from the Internet).

Other softwares are so integrated and work flawlessly and smoothly. Most notable are iTune and iPhotos. GarageBand is also a very good one to try. It has virtual instruments that playable thru keyboard (and are polyphonic!) I did download some freewares there too, including Google Earth, Skype and Adium (for chatting. It recognizes most protocols including GoogleTak, Y!M, AOL, Gadu-gadu etc.)

The sleep mode is very stable and fast. We either just need to close the lid, press the power button for short time or go to Apple->Sleep. To wake it up, just open the lid or press the power button. Also the lid doesn't have mechanical latch. It uses magnetic and snap to the body. Full standing ovation to Apple for this.

Pricewise, this is not an expensive laptop as some people might think. $1099 is the standard price. But it comes with many extra and elegant stuff which can only be found on a few high-end laptops (such Sony VAIO, Toshiba or Lenovo).

I am, though, still unable to install Xcode + development tools to this one. I don't know why. But I will explore and google more to find out the reason.

The bottom line is, I am falling in love with my new MacBook. Probably I won't go back to Windows (unless I are forced to use because of some software or for work-related stuff). For other hacking stuff, I still use my SUSE Linux (installed both on my dual-processor desktop home-server and old Toshiba laptop).

Here I list the hardware data of my macBook (for security reason, I removed some of the condifential data):

Model Name: Mac
Model Identifier: MacBook2,1
Processor Name: Intel Core 2 Duo
Processor Speed: 2.16 GHz
Number Of Processors: 1
Total Number Of Cores: 2
L2 Cache (per processor): 4 MB
Memory: 2 GB
Bus Speed: 667 MHz
Boot ROM Version: MB21.00A5.B06
SMC Version: 1.17f0
Sudden Motion Sensor: State: Enabled

ATA Bus:

MATSHITADVD-R UJ-857E:

Capacity: 516.57 MB
Model: MATSHITADVD-R UJ-857E
Revision: ZB0E
Serial Number:
Removable Media: Yes
Detachable Drive: No
BSD Name: disk1
Protocol: ATAPI
Unit Number: 0
Socket Type: Internal
Low Power Polling: Yes
OS9 Drivers: No
S.M.A.R.T. status: Not Supported

Intel High Definition Audio:

Available Devices:
Headphone:
Connection: Combo
Microphone:
Connection: Internal
Speaker:
Connection: Internal
Line In:
Connection: Combo
S/P-DIF Out:
Connection: Combo
S/P-DIF In:
Connection: Combo

Apple Bluetooth Software Version: 1.9.0f8
Hardware Settings:
Muhammad Lutfi’s Computer:
Address: 00-1b-63-5d-5b-ae
Manufacturer: Cambridge Silicon Radio
Firmware Version: 3.1965 (3.1965)
Bluetooth Power: On
Discoverable: Yes
HCI Version: 3 ($3)
HCI Revision: 1965 ($7ad)
LMP Version: 3 ($3)
LMP Subversion: 1965 ($7ad)
Device Type (Major): Computer
Device Type (Complete): Laptop Computer
Composite Class Of Device: 1057036 ($10210c)
Device Class (Major): 1 ($1)
Device Class (Minor): 3 ($3)
Service Class: 129 ($81)
Requires Authentication: No
Services:
Bluetooth File Transfer:
Folder other devices can browse: ~/Public
Requires Authentication: Yes
State: Disabled
Bluetooth File Exchange:
Folder for accepted items: ~/Documents
Requires Authentication: No
When other items are accepted: Ask
When PIM items are accepted: Ask
When receiving items: Prompt for each file
State: Enabled
Devices (Paired, Favorites, etc):
M.Lutfi:
Name: M.Lutfi
Address: 00-12-37-fa-60-85
Type: Palm Sized PDA
Services: Service Discovery, OBEX Object Push, Voice Gateway, Dial-up Networking, Audio Video Remote Control Profile, Voice Gateway
Paired: Yes
Favorite: Yes
Connected: No
Incoming Serial Ports:
Serial Port 1:
Name: Bluetooth-PDA-Sync
RFCOMM Channel: 3
Requires Authentication: No
Outgoing Serial Ports:
Serial Port 1:
Address: 00-12-37-xx-xx-xx
Name: M-1
RFCOMM Channel: 4
Requires Authentication: No
Serial Port 2:
Address: 00-12-37-xx-xx-xx
Name: Bluetooth-Modem
RFCOMM Channel: 4
Requires Authentication: No

MATSHITA DVD-R UJ-857E:

Firmware Revision: ZB0E
Interconnect: ATAPI
Burn Support: Yes (Apple Shipped/Supported)
Cache: 2048 KB
Reads DVD: Yes
CD-Write: -R, -RW
DVD-Write: -R, -R DL, -RW, +R, +RW, +R DL
Burn Underrun Protection CD: Yes
Burn Underrun Protection DVD: Yes
Write Strategies: CD-TAO, CD-SAO, DVD-DAO
Media:
Media Type: CD-ROM
Blank: No
Erasable: No
Overwritable: No
Appendable: No

FireWire Bus:

Maximum Speed: Up to 400 Mb/sec

Intel GMA 950:

Chipset Model: GMA 950
Type: Display
Bus: Built-In
VRAM (Total): 64 MB of shared system memory
Vendor: Intel (0x8086)
Device ID: 0x27a2
Revision ID: 0x0003
Displays:
Color LCD:
Display Type: LCD
Resolution: 1280 x 800
Depth: 32-bit Color
Built-In: Yes
Core Image: Supported
Main Display: Yes
Mirror: Off
Online: Yes
Quartz Extreme: Supported
Display:
Status: No display connected

BANK 0/DIMM0:

Size: 1 GB
Type: DDR2 SDRAM
Speed: 667 MHz
Status: OK

System Power Settings:

AC Power:
System Sleep Timer (Minutes): 10
Disk Sleep Timer (Minutes): 10
Display Sleep Timer (Minutes): 10
Automatic Restart On Power Loss: No
Wake On AC Change: No
Wake On Clamshell Open: Yes
Wake On LAN: Yes
Display Sleep Uses Dim: Yes
Battery Power:
System Sleep Timer (Minutes): 5
Disk Sleep Timer (Minutes): 10
Display Sleep Timer (Minutes): 1
Wake On AC Change: No
Wake On Clamshell Open: Yes
Display Sleep Uses Dim: Yes
Reduce Brightness: Yes

Battery Information:

Battery Installed: Yes
First low level warning: No
Full Charge Capacity (mAh): 5002
Remaining Capacity (mAh): 5002
Amperage (mA): 263
Voltage (mV): 12632
Cycle Count: 2

AC Charger Information:

Connected: Yes
Charging: Yes

Hardware Configuration:

UPS Installed: No

Intel ICH7-M AHCI:

Vendor: Intel
Product: ICH7-M AHCI
Speed: 1.5 Gigabit
Description: AHCI Version 1.10 Supported

ST9120822AS:

Capacity: 111.79 GB
Model: ST9120822AS
Revision: 3.CAE
Serial Number: 5RM09N7A
Native Command Queuing: Yes
Queue Depth: 32
Removable Media: No
Detachable Drive: No
BSD Name: disk0
OS9 Drivers: No
S.M.A.R.T. status: Verified
Volumes:
Macintosh HD:
Capacity: 111.47 GB
Available: 94.33 GB
Writable: Yes
File System: Journaled HFS+
BSD Name: disk0s2
Mount Point: /

USB Bus:

Host Controller Location: Built In USB
Host Controller Driver: AppleUSBUHCI
PCI Device ID: 0x27c9
PCI Revision ID: 0x0002
PCI Vendor ID: 0x8086
Bus Number: 0x3d

AirPort Card Information:

Wireless Card Type: AirPort Extreme (0x168C, 0x87)
Wireless Card Locale: USA
Wireless Card Firmware Version: 1.1.9.3
Current Wireless Network: XXXXXXX
Wireless Channel: 6


Software
--------
AirPort Card Information:

Wireless Card Type: AirPort Extreme (0x168C, 0x87)
Wireless Card Locale: USA
Wireless Card Firmware Version: 1.1.9.3
Current Wireless Network: XXXXXXX
Wireless Channel: 6

I will post more for the progress and tricks/info I'll have learnt.

Wednesday, July 25, 2007