Posts

routing - Creating actor per domain object -

i have been trying use router consistenthashingpool create actors on fly consume messages on basis of object id, in simple case unique string. i want actor per domain aggregate , seemed simple way of doing it. but hashing seems doing odd things , sending messages actors have been spawned different hash mapping value. actorsystem.actorof( props.create(() => new myaggergateactor()).withrouter( new consistenthashingpool(10) .withhashmapping(o => (o myevent)?.myaggregateuniqueid ?? string.empty) .withresizer(new defaultresizer(1, int.maxvalue))), "myaggregaterouter"); also tweaking values nrofinstances seems break things well, meaning hash maybe works across set of initial instances , no new actors being spawned? thought resizer supposed me here? please forgive naivety, have started using akka. the key here understand routers do. consistent hashing means, given range of possible consistent hash values, each of actors...

java - How to split element in an ArrayList in multidimensional arrayList -

i have following: [[statistics (ph)], [ upright normal recumbent normal total]] i want split first element of second element on whitespace end with: [[statistics (ph)], [upright,normal,recumbent,normal,total]] my code far: for (arraylist<list<string>> row2 : statsph) { row2.get(1).get(0).split("\\s"); } but nothing happens java strings are immutable , need store return value of split("\\s") in correct list . i recommend like for (arraylist<list<string>> row2 : statsph) { list<string> stats = row2.get(1); // remove() returns object removed string allstats = stats.remove(0); collections.addall(stats, allstats.split("\\s")); } note we're removing original string first, adding of 'split' values.

c# - How to create a List<int> basead on two properties from another list? -

problem i need create list<int> basead on 2 properties list. example i have class has 2 fields need. public class myclass { //other fields int? valueid int? valuetwoid } above code it's example, not focus there. i want retrieve properties like: myclasslist.elementat(0).valueid = 1; myclasslist.elementat(0).valuetwoid = 2; myclasslist.elementat(1).valueid = 3; myclasslist.elementat(1).valuetwoid = 4; list<int> resultlist = myclasslist.where(x => x.valueid != null && x.valuetwoid != null).select(x => ??).tolist()); desired output resultlist.elementat(0) == 1 resultlist.elementat(1) == 2 resultlist.elementat(2) == 3 resultlist.elementat(3) == 4 there's way achieve using .select(x => ).tolist() , without using code like: list<int> resultlist = new list<int>(); foreach(var item in myclasslist) { resultlist.add(item.valueid); resultlist.add(item.valuetwoid); } thanks in advance, sorry poor engli...

javascript - can not get json from php to html (sometimes works and sometimes not..) -

i need help... i have 2 files: form.html contains html form register.php- gets post request form, registers user in database , returns json contains registered users (i want display them in form.html right after successful registration). my problem: i catched submit event , made post request register.php. register file works fine , regiters users db. problem json registers users register.php form.html. can see tried alert json alert(json) in callback function check if came ok. when run code surprised see line alert(json) works , somtimes not no rational reason... want clear: line alert("inserting") , actual user registration db works fine. problem in callback function... perhaps problem related end of register file (the creation of json). thanks advance! form.html $( "#myform" ).submit(function( event ) { if(!validateform()) //there error { event.preventdefaul...

c++ - boost::asio::async_read get end of file error -

i've written program uses boost:asio library, transfers data between 2 tcp servers. 1 server uses following code send data: std::shared_ptr<std::string> s = std::make_shared<std::string>(message); boost::asio::async_write(socket_, boost::asio::buffer(*s), std::bind(&tcpserver::handlewrite, shared_from_this(), s, _1, _2)); in tcpserver, when use async_read_until data, works fine, if replace async_read_until async_read, gives end of file error: boost::asio::streambuf input_buffer; boost::asio::async_read_until(socket_, input_buffer, match_condition(), std::bind(&tcpserver::handleread, shared_from_this(), _1)); //boost::asio::async_read(socket_, input_buffer, boost::asio::transfer_all(), // std::bind(&tcpserver::handleread, shared_from_this(), _1)); if use boost::asio::transfer_at_least(1) in async_read, can expected result. why did happen? an eof error indicates writer side closed connection. data sent before should still availa...

python - implementation of an orientation map for fingerprint enhancement -

i'm implementing function orientation map of fingerprint image using opencv , python wrong don't know code def compute_real_orientation(array_i, w=17, h=17, low_pass_filter=cv2.blur,filter_size=(5,5),blur_size=(5,5),**kwargs): row, col = array_i.shape array_i = array_i.astype(np.float) ox = array_i[0:row-h+1:h,0:col-w+1:w].copy() ox[:] = 0.0 vx = ox.copy() vy = vx.copy() oy = ox.copy() angle = vx.copy()#array contain 17*17 blocks's orientatons c = r = -1 in xrange(0, row-h+1, h): r+=1 j in xrange(0, col-w+1, w): c+=1 dx = cv2.sobel(array_i[i:i+h,j:j+w],-1,1,0)#gradient component x 17*17block dy = cv2.sobel(array_i[i:i+h,j:j+w],-1,0,1)#gradient component y 17*17 block k in range(0,h): l in range(0,w): vy[r][c] += ((dx[k][l])*(dy[k][l]))**2 vx[r][c] += 2*(dx[k][l])*(dy[k][l]) angle[r][c] = 0.5*(math.atan...

javascript - Angular - Making String Safe for URL - Is Route this correct? -

to make app seo friendly/easier users read urls i'm appending title of page clicked on each url. so example if user clicks on story 'asia stocks climb' sent url: mysite.com/story/34324/asia-stocks-climb in routes.js specify url containing text @ end exist ignore it: .when("/story/:id/:pagetitle", { templateurl: "views/story.html", controller: 'story' , controlleras: 'story' } ) so questions: 1 - ok (for seo) append end of urls when clicked? 2 - text story 'asia stocks climb' become url friendly 'asia-stocks-url' i'm using own code: textcontent.trim().tolowercase().replace(/ /g,'-').replace(/[^\w-]+/g,'') i've tested , seems ok there angular method this? thanks. that's 100% correct, use this: $scope.slugify = function (text) { if (text == null || text == 'undefined') return ""; return text .tolowerca...