Bash (Born Again SHell) allows to convert hexadecimal number to decimal integers. For example, so:
echo $[0xFFFE]
Or this way:
let x=0xFFFE ; echo $x
or
((x=0xFFFE)) ; echo $x
Or so:
printf "%d\n" 0xFFFE
The last way, allows to convert the decimal values to the hexadecimal format. So I made two aliases for a test:
alias h2d='printf "%d\n" ${1}'
alias d2h='printf "0x%x\n" ${1}'
Now, I can write:
h2d 0x3B
and
d2x 12
Monday, May 31, 2010
Visual Studio for iPhone?
Absolutely unexpected:
AppleInsider. Microsoft's Steve Ballmer rumored to present at Apple's WWDC 2010
Think Different. Rumor: Will Steve Ballmer demonstrate Visual Studio for iPhone on WWDC?
Chowdhry says the new version of VS will allow developers to write native applications for the iPhone, iPad and Mac OS.Barron's. Apple: Will Steve Ballmer Show Up At The WWDC Keynote? Update: No, He Won’t
AppleInsider. Microsoft's Steve Ballmer rumored to present at Apple's WWDC 2010
Think Different. Rumor: Will Steve Ballmer demonstrate Visual Studio for iPhone on WWDC?
Saturday, May 29, 2010
Setstone + NeXT Computer = NextSTEP framework
Mac OS X Reference Library. Why Objective-C?
Historical note: As a language, Objective-C has a long history. It was created at the Stepstone company in the early 1980s by Brad Cox and Tom Love. It was licensed by NeXT Computer Inc. in the late 1980s to develop the NeXTStep frameworks that preceded Cocoa. NeXT extended the language in several ways, for example with the addition of protocols.
Historical note: As a language, Objective-C has a long history. It was created at the Stepstone company in the early 1980s by Brad Cox and Tom Love. It was licensed by NeXT Computer Inc. in the late 1980s to develop the NeXTStep frameworks that preceded Cocoa. NeXT extended the language in several ways, for example with the addition of protocols.
Monday, May 24, 2010
Snow Leopard. Setup Terminal
1. Launch Terminal.
2. In the menu choose Preferences
3. On page Startup select Pro in the combo box
4. On page Settings select "Pro Default"
5. Check "Antialias text"
6. On page "Shell" select "Close if the shell exited cleanly" in the "When the shell exits:" combo box
7. Close the Preferences.
8. Make the Terminal window bigger.
9. In the menu Shell press on "Use Settings As Default"
10. In the Terminal window type:
nano .profile
11. Add the following text:
export PATH=.:$PATH
export PS1="[\[\e[33m\]\u@\H \[\e[32m\]\w\[\e[0m\]]\n[\[\e[31m\]\!\[\e[0m\]]>"
export CLICOLOR=1
12. Press Ctrl+o. Press Enter.
13. Press Ctrl+x. It closes the editor.
14. In the Terminal type
exit.
Now you can launch Terminal again and type, for example:
ls -l
2. In the menu choose Preferences
3. On page Startup select Pro in the combo box
4. On page Settings select "Pro Default"
5. Check "Antialias text"
6. On page "Shell" select "Close if the shell exited cleanly" in the "When the shell exits:" combo box
7. Close the Preferences.
8. Make the Terminal window bigger.
9. In the menu Shell press on "Use Settings As Default"
10. In the Terminal window type:
nano .profile
11. Add the following text:
export PATH=.:$PATH
export PS1="[\[\e[33m\]\u@\H \[\e[32m\]\w\[\e[0m\]]\n[\[\e[31m\]\!\[\e[0m\]]>"
export CLICOLOR=1
12. Press Ctrl+o. Press Enter.
13. Press Ctrl+x. It closes the editor.
14. In the Terminal type
exit.
Now you can launch Terminal again and type, for example:
ls -l
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFtbniz96K6EMLwrnKzzsYLMd6m1s_7WTg-iSPl8Bhj4uEvKdPgh2Cc9VH0FyZTQnvWHlUH0Ft87gN64eoEdgGu4lNSZAeBFGKDzd89pRasIhiV9dI7U3DWYako0giRQuPMVVWpo4Eh1w/s320/Terminal+%E2%80%94+bash+%E2%80%94+113%C3%9734-3.jpg)
Saturday, May 22, 2010
GNU utilities for Win32
In case someone needs: GNU utilities for Win32.
Friday, May 21, 2010
Sun in Netanya. May 21.2010
It's not just a photo. It was very strange to see on the sky something like a circle rainbow around the sun in a sunny day.
Thursday, May 20, 2010
Determine memory on your Mac
Type (copy and paste) the following line in the Terminal:
system_profiler SPMemoryDataType | grep -e 'Size: [0-9]' | awk '{print $2}' | perl -e '$sum=0; while (<>) { $sum+=$_;} print "$sum\n";'
The output will be the amount of the memory on your Mac.
Funny? I found this exercise in a nice book "Beginning Mac OS X Snow Leopard Programming".
If you want to understand what's going on, you need to test sequemtially each part:
system_profiler SPMemoryDataType
system_profiler SPMemoryDataType | grep -e 'Size: [0-9]'
system_profiler SPMemoryDataType | grep -e 'Size: [0-9]' | awk '{print $2}'
system_profiler SPMemoryDataType | grep -e 'Size: [0-9]' | awk '{print $2}' | perl -e '$sum=0; while (<>) { $sum+=$
system_profiler SPMemoryDataType | grep -e 'Size: [0-9]' | awk '{print $2}' | perl -e '$sum=0; while (<>) { $sum+=$_;} print "$sum\n";'
The output will be the amount of the memory on your Mac.
Funny? I found this exercise in a nice book "Beginning Mac OS X Snow Leopard Programming".
If you want to understand what's going on, you need to test sequemtially each part:
system_profiler SPMemoryDataType
system_profiler SPMemoryDataType | grep -e 'Size: [0-9]'
system_profiler SPMemoryDataType | grep -e 'Size: [0-9]' | awk '{print $2}'
system_profiler SPMemoryDataType | grep -e 'Size: [0-9]' | awk '{print $2}' | perl -e '$sum=0; while (<>) { $sum+=$
Tuesday, May 18, 2010
Objective-C "explained".
The most boring program in the world is "Hello, World!". Here is the C-variant of this program:
Same program in Objective-C looks so:
The difference is not very big:
1. #import instead of #include. #include will work too. #import ensures that the header file is included only once. It is a replacement for our common
#ifdef _MY_HEADER_FILE_H_
#define _MY_HEADER_FILE_H_
#endif
2. Object instantiation:
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
I can replace this code with:
NSAutoreleasePool * pool = [NSAutoreleasePool new];
The program compiles and works with this replacement. Any C++ programmers understand what it does.
This trivial example explains the main principles of Objective-C:
1. The letter 'C' is the last in the name, but the the most important. Objective-C is a superset of C. Standard C functions can be called from the Objective-C code.
2. Objective-C is an extension of C. Strong and extremely portable procedural language C was updated by adding the message-send mechanism from SmallTalk, so we got [object message], instead of the common object->messaqe in C++. n C++ the program will crash if the object is NULL. In Objective-C it will not crash, if the object is nil.
#include <stdio.h>
int main (int argc, const char * argv[])
{
printf("Hello, World!\n");
return 0;
}
Same program in Objective-C looks so:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
printf("Hello, World!");
[pool drain];
return 0;
}
The difference is not very big:
1. #import instead of #include. #include will work too. #import ensures that the header file is included only once. It is a replacement for our common
#ifdef _MY_HEADER_FILE_H_
#define _MY_HEADER_FILE_H_
#endif
2. Object instantiation:
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
I can replace this code with:
NSAutoreleasePool * pool = [NSAutoreleasePool new];
The program compiles and works with this replacement. Any C++ programmers understand what it does.
This trivial example explains the main principles of Objective-C:
1. The letter 'C' is the last in the name, but the the most important. Objective-C is a superset of C. Standard C functions can be called from the Objective-C code.
2. Objective-C is an extension of C. Strong and extremely portable procedural language C was updated by adding the message-send mechanism from SmallTalk, so we got [object message], instead of the common object->messaqe in C++. n C++ the program will crash if the object is NULL. In Objective-C it will not crash, if the object is nil.
iPhone 4G
Apple iPhone 4G specifications revealed – plan to ship 24 million iPhone 4G in 2010
Foxconn to ship 24 million iPhone 4G in 2010, says Digitimes Research
iPhone 4G has Cortex A8 processor, PowerVR SGX 535 graphics processor allowing 1GHz, and 512 MB of memory. Now my iPhone 3GS has 256MB and Cortex A8 which is clocked at 600MHz.
Foxconn to ship 24 million iPhone 4G in 2010, says Digitimes Research
iPhone 4G has Cortex A8 processor, PowerVR SGX 535 graphics processor allowing 1GHz, and 512 MB of memory. Now my iPhone 3GS has 256MB and Cortex A8 which is clocked at 600MHz.
Friday, May 14, 2010
No C for students
I made my diploma projects (1993) were written in Borland Pascal 6.0. I loved this language, but then, when I had to switch to C and C++, it was not very easy to change my mind, to change the way I think when I program.
Now I see this article: Exam board deletes C and PHP from CompSci A-levels
I'm not a teacher and, I hope, they know what they do. They "strongly recommend Pascal/Delphi" - a conservative recommendation.
Now I see this article: Exam board deletes C and PHP from CompSci A-levels
I'm not a teacher and, I hope, they know what they do. They "strongly recommend Pascal/Delphi" - a conservative recommendation.
Xcode. Smart Groups
I'm not a very experienced Xcode user, so only today I found out that there is a nice feature - a possibility to group project files with the smart groups. By default any Xcode project has two smart groups: "Implementation Files" and "Interface Builder Files". Their folder icons are colored purple:
The smart groups filter the file names based on a set of rules. For example the Implementation Files smart group displays only the files with extensions c, cpp, m,.. - the implementation files. This rule is specified using the regular expression - a small sophisticated language for recognizing the patterns within the strings. If this Implementation Files group is selected (as it is shown on the screenshot above), click on the right mouse button will show the popup menu "Get Info" will show the pattern:
It is possible to own smart groups - in the Project menu choose New Smart Group.
I my test project I created two Smart Groups. The second group (shown on the screenshot below) show the files that have "math" in their names:
More info in the Mac OS X Reference Library: Project Organization
The smart groups filter the file names based on a set of rules. For example the Implementation Files smart group displays only the files with extensions c, cpp, m,.. - the implementation files. This rule is specified using the regular expression - a small sophisticated language for recognizing the patterns within the strings. If this Implementation Files group is selected (as it is shown on the screenshot above), click on the right mouse button will show the popup menu "Get Info" will show the pattern:
It is possible to own smart groups - in the Project menu choose New Smart Group.
I my test project I created two Smart Groups. The second group (shown on the screenshot below) show the files that have "math" in their names:
More info in the Mac OS X Reference Library: Project Organization
Tuesday, May 4, 2010
iPad
I think it is a kind of a very strange device. But Apple does not care what I think and sold 1,000,000 units in the first 28 days:
Apple Sells One Million iPads
And iPad users has downloaded 12 millions applications from the AppStore and 1.5 million ebooks.
Apple Sells One Million iPads
And iPad users has downloaded 12 millions applications from the AppStore and 1.5 million ebooks.
Sunday, May 2, 2010
iPhone OS 4
100+ new features and 1500 new API's in iPhone OS 4. Apple promises:
"What's New in iPhone OS4"
1. Multitasking
2. Video
3. Voice over IP
4. Mail
5 .In-App SMS
and many more. I'd expect new boom on AppStore.
It will work on iPhone 3G - it against all rumors saying that OS 4 will kill 3G - people expecting that 3GS is the minimal hardware for iPhone OS 4.
"What's New in iPhone OS4"
1. Multitasking
2. Video
3. Voice over IP
4. Mail
5 .In-App SMS
and many more. I'd expect new boom on AppStore.
It will work on iPhone 3G - it against all rumors saying that OS 4 will kill 3G - people expecting that 3GS is the minimal hardware for iPhone OS 4.
Saturday, May 1, 2010
Skitch
I do not want to advertise a 3rd party application, but in this case I may recommend for all Mac users:
Skitch: http://skitch.com/
Everybody knows about "Shift + Command + 4" on Mac OS X. In the minimal case Skitch does the same, but allows to modify the image, for example, add an arrow like on the screenshot above.
Skitch: http://skitch.com/
Everybody knows about "Shift + Command + 4" on Mac OS X. In the minimal case Skitch does the same, but allows to modify the image, for example, add an arrow like on the screenshot above.
Subscribe to:
Posts (Atom)