Posts

ecmascript 6 - How to capture the json text inside fetch's then() -

this how call fetch fetchopts = {...} return fetch(url, fetchopts) .then(checkstatus) the url call return json data, in error condition: {error_message:"encountered issue update" status:"error", status_code:400} i hold of error_message field value , pass error constructor. inside checkstatus, handles exception way: function checkstatus(response) { let error = null; if (!response.headers.get('content-type').includes('application/json')) { error = new error(response.statustext); error.response = response; throw error; } if (response.status >= 200 && response.status < 300) { return response; } if (response.ok) { return response; } const jsondata = response.json() ; // <- `jsondata` promise error = new error(/* how extract error_message json data? */); error.response = response; throw error; } i have checked question not address need fetch: reject promise json error ob...

Turning string into executable python code, and holding that variable name -

i'm looping on following: a might equal task, wash_dishes or play_piano exec("%a = production(precondition({%s}),action({%s},{%s}))" %(a, precondition, stop, start)) list_a.append(a) expect: list_a = [wash_dishes, play_piano] (where wash_dishes production created above, not "wash_dishes") a holds string (parsed json), , want add value of a (as variable) list. thanks in advance! hope made sense! use dictionary. in exec() code, put quotes around place variable substituted, use value string. symboltable = {} exec("symboltable['%s'] = production(precondition({%s}),action({%s},{%s}))" %(a, precondition, stop, start)) list_a.append(symboltable[a])

How to resolve RecordTooLargeException in Kafka Producer? -

i using flinkkafkaproducer08 send records kafka . sometime getting following exception, though record printing in error message small in size 0.02 mb . java.lang.runtimeexception: not forward element next operator caused by: java.lang.runtimeexception: not forward element next operator caused by: java.lang.exception: failed send data kafka: message 1513657 bytes when serialized larger maximum request size have configured max.request.size configuration. caused by: org.apache.kafka.common.errors.recordtoolargeexception: message 1513657 bytes when serialized larger maximum request size have configured max.request.size configuration tried change max.request.size on producer , requires brokers changes , restart of broker . there broker setting max message size: message.max.bytes : 1,000,000 (default) so need restart brokers -- should not issue. kafka built in robust way regard broker bounces. cf. http://kafka.apache.org/082/documentation.html#producerconfigs

javascript - Overlay fixed on top of div and keep position page scrolled -

i've following example below. when click yellow box, overlay shown , works fine. when scroll down ofc stays because has position fixed. how can make sure overlay stay ontop of .div when scroll, aka "don't move"? $('.modal').css("top", $(".div").offset().top).css("left", $(".div").offset().left).css("width", $(".div").css("width")).css("height", $(".div").css("height")); $(".div").click(function() { $('.modal').addclass("loading"); }) .div { margin-top: 100px; margin-left: auto; margin-right: auto; height: 300px; width: 300px; background-color: yellow; content: ""; } body { height: 500px; background-color:black; } .modal { display: none; position: fixed; z-index: 1000; top: 0; left: 0; height: 100%; width: 100%; background: rgba( 255, 255, 255, ....

java - Activiti Process Updated Variable value is not getting persisted in DB -

i'm trying update process variable after starting process when starting activiti, pass random string value variable need update variable value afterwards. system.out.println(runtimeservice.getvariables(executionid)); runtimeservice.setvariable(executionid, varname, varvalue); system.out.println(runtimeservice.getvariables(executionid)); and output variableone : "randomvalue" variableone : "updatedvalue" but when documentation of task documentation the variable value ${variableone} i output the variable value randomvalue instead of the variable value updatedvalue the problem execution id not same process instance id. need update variable against process instance id rather execution id. cheers, greg

c - structure cast into unsigned char array without malloc/str methods -

i've read other questions response aren't helping me much. once again, i'm not developer wood worker trying make far complicated own brain. i work on pic alignment 4 bytes, structures define attribute ((packed)). i've found way uses malloc , str/mem-cpy, methods aren't safe interrupt, or malloc shouldn't using @ (cf. previous question) said structure contains 16 unsigned char, 1 s16 (2 bytes) et 3 s32 (4 bytes), 30 bytes long, 4bytes alignement making 32bytes long. (char coded on 8bits). 1) wrong until here? int len =sizeof(data_out.point[i]); unsigned char* raw; raw = malloc(len); memcpy(raw, &data_out.point[i], len); data_res[count].pdata = malloc(len); (int k = 0; k<len; k++) { data_res[count].pdata[k] = (uint8_t)(raw[k]); } data_res[count].datalen=len; count++; } data_out stucture (members not relevant except following one) point structure described before. data_res structure store uchar ...

javascript - Using nativescript converters -

im trying hooks nativescript javascript , have basic question: let costformatter= { toview(value){ console.log('got:' + value); return '$' + value; }, tomodel(value){ console.log('got:' + value); return '$' + value; } }; http.getjson("<my api call>").then(function (r){ page.bindingcontext = { deals: r, costformatter:costformatter }; }, function (e){ //// argument (e) error! //console.log(e); }); in above code, define cost formatter want $ added beside price on every sale price on listview labels. render list view im using: <listview id="steamitems" items="{{ deals }}"> <listview.itemtemplate> <gridlayout columns="*, *, 50, 50" rows="50, 50, auto, *"> ...