Friday 13 February 2015

speaking ios iphone device ios8

#import 
-(void)speak:(NSString*)message {
    AVSpeechSynthesizer * synth = [[AVSpeechSynthesizer alloc] init];
    AVSpeechUtterance * utterance = [[AVSpeechUtterance alloc] initWithString:message];
    [utterance setRate:AVSpeechUtteranceMaximumSpeechRate *.3f];
    [utterance setVolume:1.0f];
    [utterance setPitchMultiplier:-3.0f];
    [utterance setVoice:[AVSpeechSynthesisVoice voiceWithLanguage:@"en-IE"]];
    [synth speakUtterance:utterance];
}

iOS8 / iOS 7 complete register for remote notifications

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
    if ([application respondsToSelector:@selector(registerUserNotificationSettings:)])
    {
        // use registerUserNotificationSettings
        ////---- push notification register
        [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
    }
    else
    {
        // use registerForRemoteNotifications
        ////---- push notification register
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
         (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
        
    }
#else
    // use registerForRemoteNotifications
    ////---- push notification register
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
    
#endif

Tuesday 10 February 2015

matching UINavigationBar color to your view controller object

[[UINavigationBar appearance] setBarTintColor: UIColorFromRGB(0x00a2ff)];

[searchBar setBackgroundImage:[UIImage imageFromColor:UIColorFromRGB(0x17aafe)]];

17aafe − 00a2ff = 1707ff



remove 1px line under uinavigationbar ios

@implementation UINavigationController(removeLine)

- (UIImageView *)findHairlineImageViewUnder:(UIView *)view
{
    if ([view isKindOfClass:UIImageView.class] && view.bounds.size.height <= 1.0)
    {
        return (UIImageView *)view;
    }
    
    for (UIView *subview in view.subviews)
    {
        UIImageView *imageView = [self findHairlineImageViewUnder:subview];
        
        if (imageView)
        {
            return imageView;
        }
    }
    
    return nil;
}

@end



// where you need to hide that line 
UIImageView *imgViewNav = [navController findHairlineImageViewUnder:navController.view];

// hide     
imgViewNav.hidden = YES;

// show
imgViewNav.hidden = NO;


Touch Id integration in iOS

#import <localauthentication ocalauthentication.h>

- (void)authenicateButtonTapped:(id)sender {
   LAContext *context = [[LAContext alloc] init];
 
   NSError *error = nil;
   if ([context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error]) {
       [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
               localizedReason:@"Are you the device owner?"
                         reply:^(BOOL success, NSError *error) {
 
           if (error) {
               UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                               message:@"There was a problem verifying your identity."
                                                              delegate:nil
                                                     cancelButtonTitle:@"Ok"
                                                     otherButtonTitles:nil];
               [alert show];
               return;
           }
 
           if (success) {
               UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Success"
                                                               message:@"You are the device owner!"
                                                              delegate:nil
                                                     cancelButtonTitle:@"Ok"
                                                     otherButtonTitles:nil];
               [alert show];
 
           } else {
               UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                               message:@"You are not the device owner."
                                                              delegate:nil
                                                     cancelButtonTitle:@"Ok"
                                                     otherButtonTitles:nil];
               [alert show];
           }
 
       }];
 
   } else {
 
       UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"
                                                       message:@"Your device cannot authenticate using TouchID."
                                                      delegate:nil
                                             cancelButtonTitle:@"Ok"
                                             otherButtonTitles:nil];
       [alert show];
 
   }
}

Monday 2 February 2015

Simple Neural Network training and testing in python

Other useful links

Good concept making
http://deeplearning.net/tutorial/

http://stackoverflow.com/questions/2276933/good-open-source-neural-network-python-library/3143318#3143318

https://code.google.com/p/neurolab/

http://stackoverflow.com/questions/13434854/how-to-create-basic-neural-network-in-python-pygame

http://pybrain.org/docs/

Lets make the world more beautiful. We are artist, lets code a new world. Hello world.
- Steve Jobs

We can use it to weather predication, forecasting models, stock market predictions etc.