Dec 6, 2009

Download counter and iWEB

Do you need to count downloads or something like that on your WEB page?
You don't want to write it yourself, right?
Do you use iWEB to maintain you web site?
If all answers are YES, than I think I have a solution for you.

Let's start from the download counter. Google Analytics is a great product of Google. It is a mandatory tool, I guess, for all who have web sites. Recently I found another great ability of the tool. It can track and log events! This ultimate ability we can use to count downloads, for example, on our sites or any other events. Chip and easy solution!

Now, if you use iWEB 08 or 09, than you would need a bit of voodoo here.
Let's say, you have a page and you want to have a download button, triggering which user gets a file to download.
Use "insert HTML Snippet" in iWEB to add a required code block. Important to have your analytics code inserted before the events tracking code. I used the same HTML snippets block for both analytics and events tracking code.

!!!IMPORTANT!!! You would need to modify a bit your analytics code. Namely, you need to add "pageTracker._initData();" after "pageTracker._trackPageview();", otherwise you get errors in the events tracking code.

Here we have a code snippets for that:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-XXXXX-XXX");
pageTracker._trackPageview();
pageTracker._initData();
} catch(err) {}
</script>


the following is the download button, which I want to be tracked and I do that by calling my tracking code on OnClick event:
<input type="button" name="Download" style="height: 1.5em; width: 14em"  value="source (22.8MB)" onClick="pageTracker._trackEvent( 'MyProject', 'Download', 'v1.1.2'); window.open('http://xxx.com/download.tar.gz', 'download', config='height=200,width=200' );">


Check the events tracking documentation for all details related to event tracking machinery of Google Analytics.

Nov 28, 2009

1password Pro app is for free

The extremely useful program 1password in Pro version for iPhone can be downloaded for free now, instead of 5 Euro pro copy. This is due to a celebration of a new release 1password 3 for Mac.

This gift will be there until December 1st. So, guys, I suggest to take off immediately!

Sep 2, 2009

iPhone 3Gs synchronization crashed iTunes

Today after a long trip to Geneva I finally arrived to a hotel and decided to sync and charge my iPhone (3Gs with OS v.3.0.1). What was a surprise when iTunes ( v.8.2.1(6) ) simply crashed as soon as a sync process has been started.
Well, bugs happen and unfortunately Apple isn't an exception here :(

BTW, this happened while syncing with an unibody MacBook Pro and Mac OS X 10.5.8.

  • I tried to restart iPhone/laptop.
  • I tried to reinstall iTunes - was a stupid idea I guess, but I was seeking for any help...
  • I tried to remove all podcasts - I read somewhere that it could be a problem for sync (google for that). Since today in the train I was watching/deleting some of my podcasts, I thought this could somehow make it happen, I mean the crash of iTunes :D
  • I also tried different USB ports and so on and so on... I tried many times and always result was the same...

At the end what actually did help is the following.
  1. I disconnected iPhone from the laptop,
  2. opened iTunes and in its settings I checked "Devices"->"Disable automatic syncing for iPhones and iPods",
  3. after that I connected the iPhone,
  4. and in the settings of sync I switched of a sync of podcasts (just in case),
  5. than it could successfully process the synchronization. After that I checked both changed settings to a previous states and it works now! In the automatic mode as well.
What the hell was that?
I don't know, but at least everything works now as expected!

Hope it helps some one...

Have fun!

Jul 22, 2009

How to merge two independent git repositories

I have two independent repositories (A and B) and would like to merge one repo. (B) into another one (A) with keeping the whole history of both. What do to?
With git it appeared to be a very easy task.

cd A
git remote add test ../B && git fetch test
git merge test/master
git push (if you use a remote repo.)

That's it.

You can also merge a subdir of one repo. into another. But to do so you need to use git filter-branch.

I love git! ;)

Jul 1, 2009

iPhone SDK 3.1 beta and iPhone OS 3.1 beta

Well, Apple seeded an iPhone SDK and OS v3.1 beta.
iPhone SDK 3.1 beta and iPhone OS 3.1 beta are now posted to the iPhone Dev Center. These versions are for development and testing only and should be installed on devices dedicated to iPhone OS 3.1 beta software development.

In terms of API there are a number of new methods added to AudioToolbox, OpenGLES, QuartzCore and UIKit (UIImagePickerController and UIVideoEditorController were updated).

Release Notes:

Known Issues and Fixes

Xcode/Developer Tools

  • Xcode only searches for codesigning certificate identities in the default keychain as selected in Keychain Access.

  • You may only use .png files for application icons for the device.

  • The iPhone SDK is designed for Intel-based Macs and is not supported on PPC-based Macs.

  • Xcode and the iPhone SDK only work in 32-bit mode; 64-bit mode is not supported.

  • When running and debugging on a device, be sure to turn off Passcode lock.

  • Trying to debug two applications at the same time on the same device fails with a broken pipe error in the debugger console.

Interface Builder

  • FIXED: If you use Interface Builder's UITabBarController inspector to add a UINavigationController to a tab bar controller, the navigation controller will be set up to show its toolbar. The toolbar won't be visible in Interface Builder, but will be visible at runtime, which is surprising. The workaround is to select the UINavigationController and uncheck "Shows Toolbar" in the inspector.

  • In some upgrade scenarios from beta SDK releases, Interface Builder may be left with duplicate files, which causes errors such as: "Two plug-ins both integrate a class description for the class X." Removing /Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Interface\ Builder and re-installing corrects the issue.

AddressBook

  • Image thumbnails are not displayed when ABPersonSetImageData() is called before [ABPersonViewController setDisplayedPerson:].

MessageUI

  • The Message UI framework exports class names without prefixes, which can cause namespace confusion. If you are using the Message UI framework, watch for compiler warnings about duplicate symbols. To avoid namespace issues, you can add prefixes to your own class names.

iPhone Simulator

  • iPhone Simulator does not support network home directories.

UIImage

  • You have to specify the image extension to -imageNamed: to get results.

UILabel

  • UILabel ignores its contentMode property.

UIPasteboard

  • UIPasteBoardNameFind is not populated automatically, nor is the value in the pasteboard used when displaying a search field.

UIScrollView

  • After zooming, content inset is ignored and content is left in the wrong position.

  • UIScrollView can be confused by overlapping touches in separate subviews.

UIStringDrawing

  • UILineBreakModeTruncateHead and UILineBreakModeMiddleTruncation do not work properly for multiline text.

UITableView

  • FIXED:UITableView can generate an exception when the data model changes during animation.

  • UITableView no longer ignores separatorColor. separatorStyle is still ignored.

  • A UITableView with sections cannot reorder a row to the bottom of the last section unless it started in that section.

  • Applications linked on iPhone OS 3.0 or later will get the new table view cell layout.

  • It is very, very expensive to customize row heights (via tableView:heightForRowAtIndexPath:).

  • Unable to resize table wider than the screen.

  • UITableViewCell’s accessoryAction property is deprecated. Instead, implement -tableView:accessoryButtonTappedForRowWithIndexPath in your table view delegate.

UITextField

  • No way to select all the text in a field if it exceeds the text field's visible area.

  • UITextField cannot be made to resign first responder once offscreen.

UITextView

  • Setting UITextView.editable to YES should not automatically show the keyboard.

UITouch

  • UITouch is not adjusted when a layer has a transform applied to it.

  • An application will not receive UITouchPhaseBegan if a swipe begins on or above the status bar.

UIView

  • Many UIKit controls cannot be resized properly if initialized with a CGRectZero frame.

  • animationDidEnd fires too soon and can cause animations to stutter if you do too much work in the callback.

  • If a view subclass implements -drawRect: then the background color for that view subclass cannot be animated.

UIViewController

  • A full-screen modal navigation controller doesn't display under the status bar in a non-full-screen window.

  • For applications linked prior to 2.2, view controllers within a navigation controller will only underlap a translucent navigation bar if their view is a scroll view. For applications linked to 2.2. or later, view controllers within a navigation controller will always have their view positioned to underlap a translucent navigation bar.

  • FIXED:If a UITabBarController has more items than can be displayed onscreen and the selected item on startup is within the More collection, changing the title of that item's view controller changes that view controller's title and the title of that item's TabBarItem. It also has the erroneous result that that item's TabBarItem is overlaid on the first TabBarItem.

  • FIXED:View controllers added to a tab bar controller don't behave correctly when hidesBottomBarWhenPushed is set to YES.

  • FIXED: When view controllers are pushed onto the stack, toolbars with their translucency changed now hide correctly.

  • FIXED: Navigation controllers now respond correctly when popping from landscape view to portrait view.

UIWebView

  • UIWebView does not make public its UIScrollView.

May 18, 2009

Swipe Delete From UITableView

You probably like to use swipe to delete elements from UITableView. Here you have a short example how to implement so in your iPhone applications.

On Swipe you receive the following message, you don't need to do anything in it:

-(void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
}

When a user hits DELETE you can process it:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
// If row is deleted, remove it from the list.
if (editingStyle == UITableViewCellEditingStyleDelete)
{
// delete your data item here
// Animate the deletion from the table.
[self.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}

May 12, 2009

Andrei Alexandrescu: "Iteratos Must Go"

Very interesting slides of Andrei Alexandrescu from BOOSTCon'09, where he talks about ranges. I wish to be there in Aspen at the time when BOOSTCon took place. So, here you get the slides.

Apr 15, 2009

Development under Mac OS X

Since long time already I have been not posting here... :( So, let's try to reload this blog...

With this post I am going to start a series of posts about development under Mac OS X. I will post about something I find interesting, difficult to implement, and some tricks I developed or just googled. :) Hope it helps to someone or at least it will help me to order my experience on that field.

Well, let's start from the environment.
I consider myself to be an experienced Windows and Linux developer. This stuff I do for many years already.
With Mac I met about five(!) moths ago. I mean, I knew it exists and I even worked briefly on it some years ago, but the truth is that, most of my projects were related to Windows or Linux.

I met Mac and that was love at first sight ;) As soon as I started to work on it I immediately suffered from the filling that I want to start an application development project under Mac and use it in my daily work... really!

As the hardware I use a new MacBook Pro, 15''



The only thing I can say is - WOW! It is a fucking amazing piece of hardware! Apple did a terrific job on this one.
I am just in love with the new trackpad device and the new keyboard of MacBook. No more words... Just get this laptop and enjoy!

BTW, I still do a lot of Linux development. In order to continue to do that on my Mac I use VMware Fusion. It works like a charm. One screen is a full screened Fedora 10 guest, another is a MS Windows XP guest and all under control of Mac OS X. ;)


The OS I am using is Mac OS X Leopard.
As the development environment I decided to use XCode (v. 3.1.2). Well, I am a bit disappointed with XCode and I tell you why. Mainly because of two thinks I see missing.
  1. A terrible SVN support. For example, I didn't find a way to set SVN properties on files. Also SVN plug-in sometimes living its own live and could be doing something, which blocks all version control operations on files in XCode. I didn't find a better way to just stop that plug-in by restarting XCode.
  2. No way to define custom formating rules. Formating preferences are very weak: a couple of checkboxes and that's it... If you do Objective-C development, then in a couple of weeks you will used to default formating and syntax coloring XCode does. But anyway, I would prefer to have a bit more flexible formating settings.
I think XCode is a very new and fresh product and Apple is developing it very fast (you can tell that from new thinks you get every new release). So I believe we will see soon a strong competitor to MS Visual Studio and to Eclipse. So far I would say MS VS is the best, at least for C++ development.

Anyway I would give a big plus to XCode and the best mark just for its very good integration with Objective-C and Cocoa. In combination with Interface Builder, which is by the way just the best GUI builder I have ever seen, XCode does all you need for application development.

James Bond will return... I mean, I will continue posting on that subject ;)