Posts

php - Dynamically change database connection in cakephp 3 -

i'm trying change database connection used in cakephp 3 on fly. every answer question found refers cakephp 2 ( these three for instance). this guy found solution cakephp 3 having finite number of databases, , defining database used table file. the thing want create new database every new user, , change database when logs in. can't know in advance databases exist, write in config/app.php file. and can't set default database in each /src/model/table file, because tables same in every database. use connectionmanager::config() function create connections on fly , connnectionmanager::alias() method make table classes use default. there article describing process here: http://mark-story.com/posts/view/using-cakephp-and-a-horizontally-sharded-database the difference can create connection config on fly instead of declaring shards manually shown in article.

java regex escape sequences -

i wondering regex in java , stumbled upon use of backslashes. instance, if wanted occurences of words "this regex" in text, this: pattern.compile("this regex"); nonetheless, this: pattern.compile("this\\sregex"); my question is: difference between 2 of them? , why have type backslash twice, mean, why isn't \s escape sequence in java? in advance! \s means whitespace character, including tab, line feed , carriage return. java string literals use \ escape special characters. put character \ in string literal, need write "\\" . regex patterns use \ escape character, , way put string literal use two, because goes through 2 separate escaping processes. if read regex pattern plain text file example, won't need double escaping.

swift - iOS: Download .TXT file give strange result -

Image
i'm trying download .txt file has 5mb size in 1 website i tried download file directly , give correct size i tried download via android downloadmanager.request , give correct size except , in ios, while tried download via nsurlconnection, without 1 second, show successful download 5mb size however, when check in network receiving show used 25kb? ps. if change download same domain .zip file, download properly problem link: http://www.bluewindsolution.com/speed_test/downloads/download_file.txt working link: http://www.bluewindsolution.com/speed_test/downloads/download_file.zip here code @ibaction func buttonclick(sender: anyobject) { let timestamp = nsstring(format: "%.0f", nsdate().timeintervalsince1970) let url:nsurl = nsurl(string: "http://www.bluewindsolution.com/speed_test/downloads/download_file.txt?time=\(timestamp)")! var request:nsurlrequest = nsurlrequest(url: url, cachepolicy: nsurlrequestcachepolicy.reloadignoringlocalca...

aggregation framework - MongoDB Sorting on GeoNear Results -

i'm trying sort values in collection "vehicle" text field "condition", although seems sorting having no effect on result set. believe syntax correct, cause of problem? db.vehicle.aggregate([ { $geonear: { near:[26.243640,-80.265397], maxdistance: 2500/111.12, query: { isactive: true, condition: {$in: ['new','used']} }, distancefield: "distance", limit: 10 } }, { $project: {condition: 1, distance: 1} }, { $sort: {condition: -1} } ])

What profiler could I use to generate a "timeline" for my c++ openMP program? -

i want profile openmp program , think timeline threads good, have tried several tools, however. valgrind doesn't give timeline, gives callmap vtune not free, , can't afford it. i need root install zoom. to use scalasca, have install score-p, however, there errors qt. so, there profiler free, generate timeline , installed non-root user?

regex - Python: Formatting a string with a variable that must be inside curly braces {} -

my task make function regex returns matches count word characters long or longer. here's tried: import re # example: # >>> find_words(4, "dog, cat, baby, balloon, me") # ['baby', 'balloon'] def find_words(count, a_string): pattern = r'\w{{{},}}'.format(count) return re.findall(pattern, a_string) the reason mess of curly braces attempting escape them . the final search string ( pattern ) want \w{ count ,} edit: forgot return statement in original post. i'll leave here because answers coming in valuable. why don't use % operator? in [1]: def find_words(count, a_string): ...: pattern = r'\w{%s,}' % count ...: return re.findall(pattern, a_string) in [2]: find_words(4, "dog, cat, baby, balloon, me") out[2]: ['baby', 'balloon']

android - Google play services freezes Eclipse -

i have 2 problems eclipse. want add advertisements android project. creating new android application project following settings: minimum required sdk: api 13 target sdk: api 19 compile with: api 22 my first problem eclipse java problem shown below: the type actionbaractivity deprecated mainactivity.java /hjjhg/src/com/example/hjjhg line 3 my main problem when add google play services sdk\extras\google\google_play_services\libproject\google-play-services_lib , run application. eclipse working in no-load operation. after while, eclipse gives error: gc overhead limit exceeded what wrong?