Monday, July 9, 2012

VMWare Player: cannot connect network by Bridged.

VMware player allow to connect to network with NAT, Host-only and Bridged. I can access internet with NAT configuration but cannot access LAN network so I switch to Bridged. But after switch to Bridged, I cannot access internet in virtual machine.

I found out the problem is: VMWare player using Hamachi interface network adapter in host OS when configurated with Bridge.
+ Hamachi was installed and then started when host OS starts up.
+ VmWare with Bidged: there is configurate parameter to automatically select network adapter in host OS, and it auto select Hamachi adapter.

Solution:
+ VmWare workstation: Edit > Virtual Network Editor. Select Bridged adapter and then change Bridged: Automatic ... to physical network adapter in host OS.

+ VmWare player: configure the interface bindings with utility.
In order to extract the utility manually, follow the steps below:
- Open an elevated command prompt (Run as Administrator).
- Browse to the directory that contains the installer file.
- Run the installer as follows
- VMware-player-3.0.0-203739.exe /e c:\vmware Your actual file name may be different, depending . Use the actual installer file name This command extracts the contents of the installer in to the c:\vmware folder.
- Browse to c:\vmware
- Open the file 'network.cab'. This is a compressed file that should open in most file compression software.
- Extract the contents of the cab file in to the VMWare Player directory. In my installation that is C:\Program Files\VMware\VMware Player.

Once the file is extracted, the setup is quite easy.
- Browse your VMware Player installation folder. (C:\Program Files\VMware Player).
- Find and run the file 'vmnetcfg.exe'.
- Highlight the VMnet0 interface (at the top of the page).
- In the VMnet information area ensure that 'Bridged (connect VMs directly to the external network)' is selected.
- On the 'Bridged to:' line, select the interface your Pico Base Stations will be connected to.
- Click 'OK'.

References:
http://support.tranzeo.com/knowledgebase/users/kb.php?id=10053&category_id=0&sid2= http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1018697

Monday, December 5, 2011

iPhone: prevent auto-lock screen.

[[UIApplication sharedApplication] setIdleTimerDisabled:YES];

iOS: hide keyboard when touch on background.

To close keyboard when user touch on background or touch outside a component: UITapGestureRecognizer
- (void)viewDidLoad
{
[super viewDidLoad];
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard)];
// For selecting cell.
gestureRecognizer.cancelsTouchesInView = NO;
[self.tableView addGestureRecognizer:gestureRecognizer];
[gestureRecognizer release];
}

- (void) hideKeyboard {
[self.view endEditing:YES];
}



If not using a table, replace self.tableView by self.view that will help to close keyboard when touch on background.

iPhone: easy to save a file.

To save a file in folder 'Documents':
NSData *dat = [[NSData alloc] init]; // init data.
UIImage *image = [[UIImage alloc] initWithData:dat];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [paths objectAtIndex: 0];
NSString * pathFile = [NSString stringWithFormat:@"image_%s.png", [[[NSDate date] descriptionWithCalendarFormat:@"%H_%M_%S" timeZone:nil locale: [NSUserDefaults standardUserDefaults] dictionaryRepresentation]] UTF8String]];
NSString *docFile = [docDir stringByAppendingPathComponent: pathFile];

NSLog(@"+++++++++++++++++++ %@", docFile);

NSData *imageData = UIImagePNGRepresentation(image);
[imageData writeToFile:docFile atomically:NO];

iOS: To find what is the first responder.

Notes: this is used for test only, do not use this codes in App because it is not allowed by Apple.
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; 
UIView   *firstResponder = [keyWindow performSelector:@selector(firstResponder)]; 

Hi there!

This is where to share my notes, :)