Saturday, December 25, 2021

2021 MacBook M1 monterey mariadb slow

When run Django test, I found the migration test step is rather slow, which is is about 20X more time it spend vs on my PC。 

solved by install mysql instead of mariadb

Friday, May 15, 2015

two things you need to do when using corelocation on 8.0+

firstly.
add NSLocationWhenInUseUsageDescription to info.plst.


secondly.
use this code to get authorization

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0){
        [self.locationManager requestWhenInUseAuthorization];

    }

Wednesday, May 13, 2015

make tableview cell unselectable

- (NSIndexPath *)tableView:(UITableView *)tv willSelectRowAtIndexPath:(NSIndexPath *)path
{
   // NSLog(@"here");
    return nil;

}

Saturday, May 02, 2015

IOS email validation



-(BOOL) NSStringIsValidEmail:(NSString *)checkString
{
   BOOL stricterFilter = NO; // Discussion http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/
   NSString *stricterFilterString = @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}";
   NSString *laxString = @".+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2}[A-Za-z]*";
   NSString *emailRegex = stricterFilter ? stricterFilterString : laxString;
   NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
   return [emailTest evaluateWithObject:checkString];
}

IOS programatically jump to another view

1st, create a segue between your current view and the view you want to jump to. e.g, ViewMe and ViewLogin. Set the set identity of the segue to like 'Me2LoginSegue'.

2nd,  Ctrl+drag the button to the .h file,  create an action name like 'onClickLoginSubmit'.

3rd, put this code into the method you created in the .m file.  like this
- (IBAction)onClickLoginSubmit:(id)sender {
    [self performSegueWithIdentifier: @"Me2LoginSegue" sender: self];
}

@end

Done

Friday, May 01, 2015

programatic set uitableview row height

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if([Utils IsUserLoggedIn] && indexPath.section == 0 && indexPath.row == 0)
    {
        
        self.LoginView.frame = CGRectMake(0, 0, self.LoginView.frame.size.width, 800);
        self.LoginButton.frame = CGRectMake(self.LoginButton.frame.origin.x, self.LoginButton.frame.origin.x, self.LoginView.frame.size.width, 34);
        return 800;
    }
    else{
        return UITableViewAutomaticDimension;
    }

}

Saturday, November 19, 2011

simple way to enable mod_deflate in httpd server

http://httpd.apache.org/docs/2.0/mod/mod_deflate.html
Compress everything except images

<Location />
# Insert filter
SetOutputFilter DEFLATE

# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary

# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>