Posts

c++ - When embed one application into Qt application, hwo to get the mouseMoveEvent and embed windows size -

i use qx11embedcontainer embed application: spicec(it based on x11). follows: qx11embedcontainer spicec; spicec.embedclient(winid); spicec.setmousetracking(true); spicec.show(); i have unresolved questions: i reimplemented mousemoveevent, not work (the parent widget set setmousetracking(true) too); how can mouse move event qx11embedcontainer? or there way can mouse move event, mouse not in qt windows (global mouse move event)? since embeded windows have own size, there way original size of the embeded windows? because want adjust qt application show full content. the environment ubuntu 14.04 , qt 4.8.

How to create a git patch from the differences between 2 repos but keep the history? -

the code in our repo copy of download of source rather git clone (the repo wasn't available @ time) when doing git blame, lot of files author downloaded code. we have since made lot of changes code. but have access original repo, i'd add git history original repo. wondered if possible? if do cd originalrepo git checkout taggedversionineed git log copy last commit hash cd ../ourcode git remote add upstream ../originalrepo git fetch upstream git checkout develop git diff taggedversionhash it happily shows differences between 2 without history. if try git format-patch taggedversionhash --stdout > ../mypatch.patch it seems add commits, not code differences. when do git checkout -b feature_updatehistory taggedversionhash git < ../mypatch.patch i lots , lots of applying: commitmessage error: patch failed: filename:387 error: filename: patch not apply patch failed @ 0001 commitmessage copy of patch failed found in: /home/username/www/mycode/.git/...

Updating row on mysql php -

i want update row on table , not updating. html , php code : <?php if ($_get) { if (isset($_get['id'])) { $id = preg_replace('#[^0-9]#', '', $_get['id']); echo $id; $query = "select * posts id='{$id}'"; $result = mysqli_query($connect, $query); $rows = mysqli_fetch_assoc($result); } elseif (empty($_get['id'])) { header("location: manage_posts.php"); } } ?> <form action="modify_post.php?id=<?php echo $id; ?>" method="post"> <h3>post title <?php //echo $id; ?></h3> <input name="title" value="<?php echo $rows['title'];?>" type="text" placeholder="title here ..." id="title" required> <h3>post content</h3> <textarea name="content" required placeholder="title here ..." style="resi...

algorithm - Solving a TSP-related task -

i have problem similar basic tsp not quite same. i have starting position player character, , has pick n objects in shortest time possible. doesn't need return original position , order in picks objects not matter. in other words, problem find minimum-weight (distance) hamiltonian path given (fixed) start vertex. what have currently, algorithm this: best_total_weight_so_far = inf foreach possible end vertex: add vertex 0-weight edges start , end vertices current_solution = solve tsp graph remove 0 vertex total_weight = weight (current_solution) if total_weight < best_total_weight_so_far best_solution = current_solution best_total_weight_so_far = total_weight however algorithm seems time-consuming, since has solve tsp n-1 times. there better approach solving original problem? it rather minor variation of tsp , np-hard. heuristic algorithm (and shouldn't try better heuristic game imho) tsp should modifiable situation...

c++ - ctypes passing C string to Python, ValueError: invalid string pointer -

i'm trying pass const char * c code python via ctypes. here code: .h file: extern "c" { _declspec(dllexport) const char * return_string(); } .cpp file: const char * return_string() { const char* test = "test"; return test; } python code: a = lib.return_string(); print("a =",a) b = c_char_p(a).value print(b) result: > = -1781171860 traceback (most recent call last): file > "c:\users\krzys\desktop\test\pythontest.py", > line 23, in <module> > b = c_char_p(a).value valueerror: invalid string pointer 0xffffffff95d5796c [finished in 0.1s] what causes problem? is related memory management or wrong approach of getting c string?

c++ - Rendering to a CCRenderTexture not working -

i'm trying use ccrendertexture create heightmap use terrain class. don't know if best way it, i'm newb both opengl , cocos2d-x, please bear me. auto* rendertexheightmap = ccrendertexture::create(width, height); rendertexheightmap->begin(); glrasterpos2i(0, 0); gldrawpixels(width, height, gl_rgb, gl_float, pixelbuffer); rendertexheightmap->end(); rendertexheightmap->savetofile("heightmap.jpg", false); i know pixelbuffer contains data want (greyscale pixel data), whenever call ccrendertexture::savetofile black picture. missing? rendertexture delay 1 frame render ,so need savetofile @ next frame,my english not ,do anderstand? can use delaytime or way way: code type lua local function save() rendertexture:savetofile("heightmap.jpg",false) end local callfunc = cc.callfunc:create(save) local dela = cc.delaytime:create(0.01) local seq = cc.sequence:create(dela,callfunc) node:runaction(seq)

go - Redis Pub/Sub Ack/Nack -

is there concept of acknowledgements in redis pub/sub? for example, when using rabbitmq, can have 2 workers running on separate machines , when publish message queue, 1 of workers ack/nack , process message. however have discovered redis pub/sub, both workers process message. consider simple example, have go routine running on 2 different machines/clients: go func() { { switch n := pubsubclient.receive().(type) { case redis.message: process(n.data) case redis.subscription: if n.count == 0 { return } case error: log.print(n) } } }() when publish message: conn.do("publish", "tasks", "task a") both go routines receive , run process function. is there way of achieving similar behaviour rabbitmq? e.g. first worker ack message 1 receive , process it. redis pubsub more broadcast mechanism. if want queues, can use blpop al...