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));
Friday, March 28, 2014
SQLite: Getting an error message
Thursday, March 27, 2014
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;
}
Subscribe to:
Posts (Atom)