Friday, March 28, 2014

SQLite: Getting an error message

   if(sqlite3_prepare_v2(yerocDB, sqlstmt, -1, &compiledstatement, NULL)==SQLITE_OK)
    {
        int result = sqlite3_step(compiledstatement);

        if(SQLITE_DONE != result)

            NSAssert1(0,@"Error while creating delete statement => %s",sqlite3_errmsg(yerocDB) );
    }else{
        NSLog(@"didn't delete error: %s", sqlite3_errmsg(yerocDB));

Tuesday, March 25, 2014

iOS Email, Phone, and Credit Card Number Regex

-(BOOL)checkCellFormatting:(NSString* )phoneNumber
{
    
    NSString *phoneRegex = @"[235689][0-9]{6}([0-9]{3})?";
    NSPredicate *test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", phoneRegex];
    BOOL matches = [test evaluateWithObject:phoneNumber];
    
    return matches;
}

-(BOOL)checkEmailFormatting:(NSString* )emailAddress
{
    
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    BOOL matches = [test evaluateWithObject:emailAddress];
    
    return matches;
}

-(BOOL) isCreditCardValid:(NSString*)creditCardNumber
{
    
    
    NSString *creditCardRegex = @"^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$";
    NSPredicate *test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", creditCardRegex];
    BOOL matches = [test evaluateWithObject:creditCardNumber];
        
    return matches;
        
}

-(BOOL) isCCVValid:(NSString*)ccvNumber
{
    

    
    NSString *ccvRegex = @"/^[0-9]{3,4}$/";
    NSPredicate *test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", ccvRegex];
    BOOL matches = [test evaluateWithObject:ccvNumber];
    
    return matches;
    
}


-(BOOL) isExpirationDateValid:(NSString*)expirationDate
{
    
    
    NSString *expirationDateRegex = @"(1[2-9]|[2-9][0-9])(0[1-9]|1[0-2])";
    NSPredicate *test = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", expirationDateRegex];
    BOOL matches = [test evaluateWithObject:expirationDate];
    
    return matches;

}

Sunday, March 23, 2014

Converting NSDate to Human Readable Date (iOS Dev)

    NSString* requestedOrderDateString = @"Delivery Date: ";
    

    requestedOrderDateString = [requestedOrderDateString stringByAppendingString:[self convertDateToMediumDateStyleString:order.dropOffDate]];

Currency Formatting to Double Digit (Dollars and Cents) (iOS Development)

    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init] ;
    [numberFormatter setNumberStyle: NSNumberFormatterCurrencyStyle];
    NSString *numberAsString = [numberFormatter stringFromNumber:order.orderAmount];


    totalPrice = [totalPrice stringByAppendingString:numberAsString];

Thursday, March 20, 2014

Getting Latitude and Longitude From Google API with Perl

    sub __getLatLngCoords
    {
        my ($self, $addy) = @_;
    
        my $geocoder = Geo::Coder::Google->new(apiver => 3, key => '<PLACE GOOGLE KEY HERE>', sensor => 'false');
    
        my $location = $geocoder->geocode(location => $addy);
    
        my $lat = '';
    
        my $lng = '';
    
        $lat = $location->{geometry}{location}{lat};
    
        $lng = $location->{geometry}{location}{lng};
    
        my @coords;
    
        if ($lat && $lng)
        {
        
            #print "$addy\n";
        
            push (@coords, $lat);
        
            push (@coords, $lng);
            #print "Addy: @coords\n";
        
        }
        else
        {
                push (@coords, "NA");
            
                push (@coords, "NA");
            
        }
            
        #print "Alt Addy: @coords\n";

        return @coords;
    
    

    }

Tuesday, March 11, 2014

Driven

I find myself these days driven to succeed.  I find doors being closed in my face, one after another, each saying I am unwanted.  Even though I am unwanted in the capacity I am wish to be wanted I find myself on the precipice of success nonetheless.  

I feel as though the door the universe is closing are doors of wanting, of longing, of preparation when the preparation has all ready been done.  I am on the verge of completing my first iPhone application.  I am in the final stage of debugging and while it is not yet done I can see the finish line.  Finally in this life of 36 years I will have done the thing I have tried to do, I will have succeeded, completing the build of a thing from the start to the finish and of this I am proud.

Soon my invention will be in the wild and I look forward to bringing it to it's rightful completion.  More important however is the fact that my hands know how to craft these things.  

Oh yes, there is more to learn.  My hands, my mind have much more to master but the basics have been crafted in terms of a mobile application.  My hands can build a minimally viable product.  Is it the best behind the veil of graphics, alas no.  But even Henry Ford took time to build his Model T.  Models A through S are a testament to that fact.  Oh, yes.  I can not hide the fact that I am pleased.  I feel as though a door that I have been looking to open for a very long time, a door to success, to recognition, but much more important than any of those trifles, is a door to improving the world for my fellow man, that I may use the gifts He has bestowed to me, the Great and Almighty God, to improve the lot of my fellow human being.  This is truly the calling of any being worthy of being called a son of God.  

Yet there are times ahead.  I will have to endure for a bit longer the sneers and jeers of my fellow co-workers.  They care for me not.  Even my manager cares not for me.  But everyone has their crosses to bear and I will not give them a second thought.  Rather I will stay the course and use my time to work and improve my craft of building.  As Westinghouse once said, ideas into products, products into companies, and companies into jobs.  I would add, and wealth into human dignity.

My calling is a blessed one, a sacred one, one that allows me to paint on the fabric of the future (which is a great enjoyment for me) while serving humanity which is any man's true calling.  I have no need for wealth in and of myself.  But improving the lot of humanity is my true reward.  And I intend to obtain it with humility and blessing toward He who gives and takes life.