Posts

multithreading - Algorithm to run code with no more than one concurrent thread per unique id -

i have go web application needs execute given section of code in 1 goroutine per unique id. scenario have requests coming various ids represent sort of transaction. subset of operations on these needs guaranteed run "one @ at time" given id (and other competing requests should block until prior 1 working on/for id done). i can think of few ways book keeping seems tricky - need keep global mutex lock access map of concurrent requests happening , use mutex or counter there, , make sure doesn't deadlock, , garbage collect (or reference count) old request entries. can this, sounds error prone. is there pattern or in standard library can used effect in case? didn't see obvious. edit: 1 thing think confusing in explanation above use of word "transaction". in case each of these not need explicit close - it's identifier associate multiple operations with. since don't have explicit "close" or "end" concept these, might rec...

javascript - Nested array is not returning deepest obj -

i working lodash , trying obtain object nested in array. need bettypes , put var needdeepestobj bettypes using _.filter var deepestobj = function(betslipdata) { var needdeepestobj = _.filter(betslipdata.customerbettypes, function(betindex) { return _.filter(betindex.bettypes, function(bettypes) { console.log('1', bettypes); //returns need return bettypes; }); }); console.log('2', needdeepestobj); //returns first _.filter param *betindex* }; so, how can reach scope contains bettypes ? this betindex param returns in browser console. { "header": { "name": "straights", "priority": "1" }, "bettypes": [ { "id": "1", "name": "straight", "buypoints": "y", "maxpoints": "3", "minpoints": "0", "isava...

html - Text Outside of Div -

for 1 reason or another, when attempt add text div, cleverly misses it. i'm trying text inside div, it's staying outside of it. here's jfiddle: http://jsfiddle.net/hspwtyag/1/ <div align="center"> <div id="box1"> <img src="https://upload.wikimedia.org/wikipedia/commons/c/cc/rectangle_.png" /> </div> <div id="box2"> <h2>proudly celebrating 10 years</h2> </div> </div> * { background-image: url("http://images.virtualworldsland.com/blog/2322/796.jpg"); background-attachment: fixed; } #box1 { border-radius: 1px solid black; width: 500px; background: white; border-radius: 15px 15px 15px 15px ; } #box2 { border-radius: 1px solid black; width: 500px; background: white; border-radius: 15px 15px 15px 15px ; height: 150px; } it is inside div - it's background image that's tricking you. see, if remove background image, , change div's ...

Excel VBA - Loop through column one at a time -

i trying loop through each row in sht1 (b2:b138) , , set "input" cell sht2 (a1) each item in loop, 1 @ time. then, value in "output" cell sht2 (n7) copied sht1 (c2:c138) . so example: sht2 (a1) = value in sht1 (b2) , sht1 (c2) = value in sht2 (n7) repeat sht2 (a1) = value in sht1 (b3) , sht1 (c3) = value in sht2 (n7) over , on until reaches bottom of list. may have expand list in sht1 colb , have been trying have evaluate number of iterations needed dynamically. the code i'm trying below gives me correct "outputs" not end in correct cell in sht2 colc . please see below. researched , found this q/a helpful , used influence code. appreciate in advance. my workbook in case need see it. sub fndesccalc() 'define objects dim wb workbook dim framework worksheet dim sumframework worksheet dim colb long dim colc long dim lastcolc integer dim lastcolb long 'set variables set wb = thisworkbook set framework = wb.sheets(...

android - How to use multithreading in LibGDX? -

i making game in libgdx. have gamescreen(screen) class main gameplay happens. want use use multithreading user can his/her own thing in screen , computer own thing in screen (changing output of screen @ same time). have knowledge of multithreading in java. graphics i'm confused. appereciated.thanks in advance. you can use threading per usual. thing have think of when working swing graphics thread can graphics operations if worker thread needs graphics use libgdx postrunnable command.

php - unlink($filename) : Permission denied Warning -

i getting permission denied waring when try use unlink(). i have created function delete image content directory : function del($fnam){ chmod('content/'.$fnam, 0777); chown('content/'.$fnam,465); unlink('content/'.$fnam); } i have used chmod() , chown() after reading forums , still getting warning , image not getting deleted. how ever runs charm when call different location. if($temp2==1){ //for delete $sql="delete blog b_id=$temp1"; $im=fetch('blog','b_img','b_id='.$temp1); //deleting image del($im); } code above not in function (running procedural fashion), , giving me positive response. how fix that? try changing permissions content directory function del($fnam){ chmod('content/, 0777); unlink('content/'.$fnam); }

What is the correct way of writing typeof(Xml) for C# .NET? -

i'm making dictionary maps .net types sql server types. using msdn's "sql server data type mappings" page show me correct conversions are. @ bottom of table says .net framework type xml, , wrote: {typeof (xml), "xml"} as key-value pair of dictionary. resharper has xml in red , says cannot resolve symbol. what's correct statement typeof(xml)? rest of dictionary looks , doesn't have problems: private static readonly dictionary<type, string> sqlservermap = new dictionary<type, string> { {typeof (int64), "bigint"}, {typeof (boolean), "bit"}, {typeof (byte[]), "binary"}, {typeof (double), "float"}, {typeof (int32), "int"}, {typeof (decimal), "decimal"}, {typeof (single), "real"}, {typeof (int16), "smallint"}, {typeof (datetime), "date"}, {typeof (timespan), "time"}, {typeof (string), "n...