Thursday, April 25, 2013

iPage PERL Module List

Tuesday, April 23, 2013

iOS Scrap Book


Setting the title of a ViewController:

self.title = @"Clock In Time";

Setting the field placeholder:

signOutTimeField.placeholder = @"Time to Clock Out of Work";

Bending the corners of  a button

cancelJobButton.layer.cornerRadius = 8;
cancelJobButton.layer.borderWidth = 1;
cancelJobButton.layer.borderColor = [UIColor grayColor].CGColor;
cancelJobButton.clipsToBounds = YES;

Adding a Return Key to the Keyboard and Calling a method ("hideKeyBoard:") after the Keyboard Retracts

emailAddressField.returnKeyType=UIReturnKeyDone;
[emailAddressField addTarget:self action:@selector(hideKeyBoard:)
forControlEvents:UIControlEventEditingDidEndOnExit];

Defining a Method for Keyboard Retraction

-(void)hideKeyBoard: (id) sender
{
//Hiding the Keyboard
if ([sender tag] == 0) {
[emailAddressField resignFirstResponder];
}
else if ([sender tag] == 1) {
[passwordField resignFirstResponder];
}

[UIView beginAnimations:nil context:NULL];

//Setting the animation duration
[UIView setAnimationDuration:1];
CGRect rect = self.view.frame;

//Resetting the origin to 0
rect.origin.y = 0;
self.view.frame = rect;
[UIView commitAnimations];
}

Getting the ViewController to 'Roll' up and down when the Keyboard Retracts:

- (void)textFieldBegin:(NSNotification *)notif
{
UITextField *obj= [notif object];NSNumber *offsetValue=[[NSNumber alloc]
initWithFloat:obj.frame.origin.y];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
//Get a reference to the frame
CGRect rect = self.view.frame;
//Set the origin to a new value
rect.origin.y = 60.0-[offsetValue floatValue];
//Adjust the views height
rect.size.height += [offsetValue floatValue]-60.0;
//Commit the changes to the current frame
self.view.frame = rect;
//Commit the animations
[UIView commitAnimations];
}

Adding an Observer and Removing an Observer when the view Appears and a View Disappears

- (void)viewWillDisappear:(BOOL)animated
{
// unregister for textfield notifications while not visible.
[[NSNotificationCenter defaultCenter] removeObserver:self
name:UITextFieldTextDidBeginEditingNotification object:nil];
}

-(void) viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector
(textFieldBegin:) name:UITextFieldTextDidBeginEditingNotification object:self.view.window];
[super viewWillAppear:animated];
}

Building an Alert


alert = [[UIAlertView alloc]
initWithTitle:@"Unverified" 
message:@"Please enter a new name and password." 
delegate:nil cancelButtonTitle:@"OK" 
otherButtonTitles:nil];
 
[alert show];
[alert release];

Trimming the Whitespace from a NSString


cellPhoneNumberString = [cellPhoneNumberTextField.text stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceCharacterSet]];

Accessing a Restful Service:

    NSString *urlString = @"http://www.samplesite.com/dtdOrdersExist.pl?";
    NSString *queryString = @"";
    queryString = [queryString stringByAppendingString:@"parameter1="];
    queryString = [queryString stringByAppendingString:p1];
    queryString = [queryString stringByAppendingString:@"parameter2="];
    queryString = [queryString stringByAppendingString:p2];
    
    // Step 5:  Make the RESTful call.
    
    urlString = [urlString stringByAppendingString:queryString];
    
    urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
    
    
    NSLog(@"ConfirmationCodeViewController URL String: %@", urlString);
    
    // {cellPhoneNumberConfirmed => $cellPhoneNumberConfirmed, cellPhoneNumber => $cellPhoneNumber, customerID => $customerID};
    
    
    // RESTFUL CODE BLOCK A
    
    
    NSURL *url = [NSURL URLWithString:urlString];
    NSData *dataURL = [NSData dataWithContentsOfURL:url];
    NSDictionary *myDict = [NSJSONSerialization JSONObjectWithData:dataURL options:0 error:nil];
    
    // Step 6:  Retrieve the data from the RESTful call
    
    NSString* numberOfOrders = [myDict objectForKey:@"numberOfOrders"];
    
    NSLog(@"Post JSON: Verified jsonCustomerID: %@", numberOfOrders);


    return numberOfOrders;


Pushing a New ViewController:


CourierViewController *cvc = [[CourierViewController alloc
  initWithNibName:@"CourierViewController" 
  bundle:nil];

[self.navigationController pushViewController:cvc animated:YES];
[cvc release];

Trimming Leading and trailing Whitespaces  off NSString:


NSString *trimmedString = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]

Deleting all objects from Core Data:


-(NSManagedObjectContext *)deleteCustomerObject: (NSManagedObjectContext *) context
{
    
    NSLog(@"deleteCustomerObject");
// self.navigationController = [[UINavigationController alloc] initWithNibName:@"Go_For_MeViewController" bundle:nil];
// NSManagedObjectContext* context = [fetchedResultsController managedObjectContext];
if (context == nil)
    {
context = [(Go_For_MeAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
NSLog(@"After managedObjectContext: %@",   context);
}
NSLog(@"GFMVC: Test Point 1");
    
// INPUT THE ENTITY NAME SLATED FOR DELETION HERE
    
    NSEntityDescription *entityDesc = [NSEntityDescription entityForName:@"CustomerInformation"
  inManagedObjectContext:context];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entityDesc];
// NSPredicate *pred = [NSPredicate predicateWithFormat:@"(loggedIn == 1)"];
// [request setPredicate:pred];
NSError *error = nil;
NSArray *results = [context executeFetchRequest:request error:&error];
    /*
    entityDesc =  [NSEntityDescription entityForName:@"jobData"
  inManagedObjectContext:context];
[request setEntity:entityDesc];
pred = [NSPredicate predicateWithFormat:@"(jobCompleted == NO)"];
[request setPredicate:pred];
    
NSError *jobsError = nil;
NSArray *jobsResults = [context executeFetchRequest:request error:&jobsError];
    */
    
    if (results != nil && [results count] >= 0)
    {
NSLog(@"GFMVC:  Valid Request Results");
int size = [results count];
NSLog(@"GFMVC: Number of Results: %d", size);
        
        // DELETING THE OBJECTS IN THE MANAGED OBJECT CONTEXT.
for (NSManagedObject *newManagedObject in results)
        {
// [self printContext:newManagedObject];
[context deleteObject:newManagedObject];
}
        [self saveContext:context];
        return context;
        
}
else if (results == nil)
{
        
        [self saveContext:context];
        return context;
}

    [self saveContext:context];
    return context;
    
}



How to Save an object with a relationship.  BOOYAH!
        
[customerManagedObject setValue:ordersManagedObject forKey:@"customerToOrders"];

-- customerManagedObject -- the object that is the parent

-- ordersManagedObject -- the object that is the child object

-- customerToOrders -- the name of the relationship object


Setting up UIPickerView:

UIPickerView Set Up

Making UIPickerView Appear When UITextField is Selected

Printing a Date and a Time:


      timeLoggedIn = [NSDateFormatter localizedStringFromDate:[managedObj valueForKey:@"timeLoggedIn"]
      dateStyle:NSDateFormatterShortStyle
      timeStyle:NSDateFormatterFullStyle];

Changing ViewControllers with Storyboard Programatically:


If you're in a Navigation Controller:
ViewController *viewController = [[ViewController alloc] init];
[self.navigationController pushViewController:viewController animated:YES];
or if you just want to present a new view:
ViewController *viewController = [[ViewController alloc] init];    
[self presentViewController:viewController animated:YES completion:nil];

MySQL:

Alter a column:  Dropping the NOT NULL provision:


ALTER TABLE tbl_name MODIFY columnA varchar(6) NULL DEFAULT NULL;





Where I'm at Now

Spiritually

Spiritually I am in a reasonable place.  I guess that originally comes from a revelation.  A while back my body felt strong and healthy, my mind is always being fed (the joy of being an intellectual) but my soul felt thin and weak, frail.  It shook often and would quake at negative energy.  I realized it was because while I fed my body daily and my mind was well nourished my soul was starving.  I never fed it.  I took very poor care of it.  That's why it was weak and emaciated.  I changed that by reading the Bible daily.  That changed my life.  Slowly my soul began to heal and get bigger.  Bit-by-bit my confidence returned.  My mind became stronger and negativity cleared away slowly.  I no longer shook but rather knew I could rely on my internal strength quite a bit.  Slowly power came back to me.  

When I was little I said that children were so happy because they had just come from God.  But as they got older and farther away from him that happiness waned.  I began to return to Him and my happiness and internal strength returned to me. 

It led me to a conclusion.  The internal strength of a person is in direct correlation to their relationship with God.  And everything else springs from that spiritual strength. 

I used to clamor for a girlfriend.  Now I'm like, it'll come to me when I'm ready and God sees fit.  And even if it doesn't, I'm happy so it doesn't really matter.

I used to say, look tough.  Now I rest on my internal strength, my rock, and just allow life to happen.  I just allow the universe to work.  

I used to ask, who am I?  Now I say I am in my right mind, my body is strong, and my spirit is getting stronger.  I don't know exactly where I'm going but I trust my Navigator.  I know that I am going to get there.  Everything is okay.

Faith is letting go, knowing you'll be able to fly.  I'm much happier.  But that is because of my balance and my God.

Career-wise

I just want to be a part of creating the future.  The future is being created right now.  I just want to be a part of that more than anything else.  I'm in such a rush to be a part of creating the future.  The future is being created faster and faster and I want to be one of the people that architects it, a member of the team that actually creates it.  

Because of that I can't just go and do whatever makes me happy, political science or whatever.  I have to be a part of what's going on.  It's like the Fat Boy Slim album, Right Here, Right Now.  I really must be a part of creating the future.  I just don't know another way.

I'm in the midst of building this App and then I'll demo it for someone at a Meetup.  But that's where I'm at.  I have to be a part of what Elon Musk and other great entrepreneurs inside and outside of digital tech are doing.  I just have to.  I can't just sit idly by and watch. I'd never be able to live with myself.  The dye is set in this regard.