Posts

java - How should I send resourcebundle messages across controllers in spring mvc? -

most of spring tutorials , examples show how message resource file , how show in view (jsp), not how should handle messages in controller , between views. here example of how im doing have view/controller handles forgotten passwords. when password sent redirect login screen message "your password sent ..." @requestmapping(value="/forgottenpassword") public string forgottenpassword(@requestparam string email) { ....something if(email != null){ return "redirect:/login?forgottenpassword=ok"; } } @requestmapping(value="/login") public string login(httpservletrequest request) { if(request.getparameter("forgottenpassword") != null && request.getparameter("forgottenpassword").equals("ok")) { data.put("ok_forgottenpassword", "forgottenpassword.ok"); } return "login"; } finaly display message in view, in case freemarker template ...

php - Preg_replace multiple patterns -

i'm busy website , element use preg_replace replace spaces dash. preg_replace('/\\s/', '-', $item_replace_en[0]) and works great have new problem. user enterd following "music / film". output "music-/-film" , want "music-film". how can accomplish this? it looks you're trying generate string can used url. there numerous of scenarios can happen when user adds title want convert url safe string. instance use this: mess'd --text-- (to) stress /test/ ?our! `little` \\clean\\ url fun.ction!?-->"); should return: messd-up-text-just-to-stress-test-our-little-clean-url-function is code ready that? in case can use function: setlocale(lc_all, 'en_us.utf8'); function toascii($str, $replace=array(), $delimiter='-') { if( !empty($replace) ) { $str = str_replace((array)$replace, ' ', $str); } $clean = iconv('utf-8', 'ascii//translit', $str)...

Android Internal File Storage or SQLite? -

i developing android application. app deals contact information (name, number, photo), need store locally later processing. data needs modified frequently. what way achieve this? thinking of "file input stream internal file storage(achieved serialized)" , sqlite, confused both of them. can tell me difference between these 2 in terms of performance, speed, memory consumption etc.? (besides, sqlite3?) (my personal opinion) database slow compare file in getting data in arranging formats , can perform aggregate function on it. suggest use database in requirements. can store particular record in arranged format. sqlite software library implements self-contained, serverless, zero-configuration, transactional sql database engine.

c# - Using Timer In WCF Or ASMX based webservice? -

i have scenario, want monitor database(sql server) table, if record inserted in webservice should through message moblie phone. i have written function of throwing message mobile phone already, dont know how use timer hit database after few intervals monitor table using web service. any 1 me how resolve issue? thanks in advance. why want webservice, windows service or app running through windows scheduler better choice.

java - Why is it faster to process a sorted array than an unsorted array? -

Image
here piece of c++ code seems peculiar. strange reason, sorting data miraculously makes code 6 times faster. #include <algorithm> #include <ctime> #include <iostream> int main() { // generate data const unsigned arraysize = 32768; int data[arraysize]; (unsigned c = 0; c < arraysize; ++c) data[c] = std::rand() % 256; // !!! this, next loop runs faster std::sort(data, data + arraysize); // test clock_t start = clock(); long long sum = 0; (unsigned = 0; < 100000; ++i) { // primary loop (unsigned c = 0; c < arraysize; ++c) { if (data[c] >= 128) sum += data[c]; } } double elapsedtime = static_cast<double>(clock() - start) / clocks_per_sec; std::cout << elapsedtime << std::endl; std::cout << "sum = " << sum << std::endl; } without std::sort(data, data + arraysize); , code runs...

vba - Rule to save attachments on incoming emails not working on a fresh install of Outlook -

we're migrating 1 server , vba script save attachments working has given ghost on new server. this fresh install of outlook. script below: public sub saveattachmentall(itm outlook.mailitem) dim objatt outlook.attachment dim savefolder string savefolder = "d:\www\phones" each objatt in itm.attachments objatt.saveasfile savefolder & "\" & objatt.displayname set objatt = nothing next end sub i've tested outlook rule , outlook performing other actions on script isn't working! so turns out had disable macro security (which isn't best) , restart outlook. simple, scratching head while...!

How to specify to match more than one character inside regex sqaure brackets? -

given user input string, need find if end 1 of following - .com, .net , .edu., html etc. is there way regex square brackets? i tried $[.com|.net|.html] , $[(.com)(.net)(.html)] both don't work. you want use capture group. (\.com|\.net|\.html) this match either 1 of values. can add additional values appending pipe inside parenthesis , placing new value after pipe.