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>

Sunday, November 13, 2011

resolve undefined symbol: Perl_Gthr_key_ptr

When I upgrade my OS to Fedora16, such error occurs when I ran my perl program. use yum to reinstall perl dose not work.
The solution is as following
1 rm -rf /usr/local/lib64/perl5
2 reintall perl
This should work

Friday, July 29, 2011

status

The beta version of loading click stream has been released.
The DDL for database is designed.
next step
will wait the requirment and do some pre-computing.
Also, the time is still unsolved yet.

Tuesday, July 19, 2011

Click flow analysis

Currently, about 30G of click records are logged. About 80M rows of records. For the first version, We'll get the basic PV PU etc.
We use the perl script to do the job for now.

And we find a good module called module bigint
Unlike integer, this pragma creates integer constants that are only limited in their size by the available memory and CPU time.

Since we can use the database to do calculation. The script will only nomolize the records and then load into the database.

We can defined the format of to be loaded data now.

Monday, July 18, 2011

current status

For now. I'm working on the click flow staff. We have no privilege to code the script of logging. We can only make use of the log files. I have developped the scripts. Waiting for the measurements now. The model is quit useful though. Many of them can be imply, some of them cannot. Will need the data of the real data to test the performance with vast number of customber. And we have to analysis the customers seperatly.

Monday, May 30, 2011

Javascript study notes

There are 2 levels of event handler model.
For level 0, We can only set the event handler as an attribute of an element.
For level 2, We can register many handlers to the same element.

We use two function addEventListener( ) and removeEventListener( )
1. Event Propagation
First, during the capturing phase, events propagate from the Document object down through the document tree to the target node.
The next phase of event propagation occurs at the target node itself.
The third phase of event propagation is the bubbling phase, in which the event propagates or bubbles back up the document hierarchy from the target element up to the Document object.
2.If registerd many handler on same element for same event, We could never grantee the order of handler invoked.
3. if you register the same handler function more than once on the same element, all registrations after the first are ignored.

Wednesday, May 18, 2011

resolve "Nonce already used or out of range"

I've encountered this error. And after looking around on the internet, The most suggested cause is wrong date. However mine is caused by another reason.
Yesterday I've revoke 'others' 's write privilege from all the files under /app/tmp/. And the Cakephp Openid component will need to update the file store to work.

The resolve solution is chmod the privilege of tmp files to 777

Wednesday, May 11, 2011

Yes, It's Online

A new personalized public sharing search engine.

Tuesday, May 10, 2011

export and import ddl from mysql

export ddl for mysql database

mysqldbexport --server=username:passassword@hostname_or_ip --skip=GRANTS --export=DEFINITIONS schema_name > foo.sql


mysqldbimport --server=username:password@hostname_or_ip --skip=GRANTS --import=DEFINITIONS foo.sql

Sunday, May 08, 2011

无题

It has been a long time since the last post. All because of the great fire wall.
Recent tasks and plans.
First of all, is my website. Now. teches for beta1.0 is ready. Only the search bundle is required now.
After that, the personal affair is really bothering me. How nice would it be if I meet the perfect girl.
Of the financial aspect, Things are going on well.
I hate waiting for nothing.
是为记

Tuesday, September 14, 2010

yum error solution

if you encounter this error when using yum, try yum clean all, and then
rerun the job. It will be OK.

Downloading Packages:
Traceback (most recent call last):
File "/usr/bin/yum", line 29, in <module>
yummain.user_main(sys.argv[1:], exit_code=True)
File "/usr/share/yum-cli/yummain.py", line 258, in user_main
errcode = main(args)
File "/usr/share/yum-cli/yummain.py", line 196, in main
return_code = base.doTransaction()
File "/usr/share/yum-cli/cli.py", line 456, in doTransaction
problems = self.downloadPkgs(downloadpkgs,
callback_total=self.download_callback_total_cb)
File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 1756, in
downloadPkgs
self.plugins.run('predownload', pkglist=pkglist)
File "/usr/lib/python2.6/site-packages/yum/plugins.py", line 183, in run
func(conduitcls(self, self.base, conf, **kwargs))
File "/usr/lib/yum-plugins/axelget.py", line 280, in predownload_hook
downloaded_drpm_pkgs = download_drpm(conduit)
File "/usr/lib/yum-plugins/axelget.py", line 66, in download_drpm
presto_info[repo.id] = presto.PrestoParser(filename).getDeltas()
File "/usr/lib/yum-plugins/presto.py", line 509, in __init__
for event, elem in iterparse(fo):
File "<string>", line 61, in __iter__
File "/usr/lib64/python2.6/gzip.py", line 219, in read
self._read(readsize)
File "/usr/lib64/python2.6/gzip.py", line 271, in _read
uncompress = self.decompress.decompress(buf)
zlib.error: Error -3 while decompressing: invalid distance too far back

Monday, September 13, 2010

mysql security related sqls

show all users in mysql
select host, user, password from mysql.user;

grant all privilege to root from localhost
grant all on * to 'root'@'localhost';

grant all privilege to user_a from all hosts
grand all on * to 'user_a'@'%';

Tuesday, July 06, 2010

techspot IBM cares

Agile Development, Test Automation, Early Defect Removal Techniques, Secure Engineering, Cloud Computing and Engineering Practices & Tools & Techniques