problem
stringlengths
26
131k
labels
class label
2 classes
static uint64_t icp_pit_read(void *opaque, hwaddr offset, unsigned size) { icp_pit_state *s = (icp_pit_state *)opaque; int n; n = offset >> 8; if (n > 2) { qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad timer %d\n", __func__, n); } return arm_timer_read(s->timer[n], offset & 0xff); }
1threat
static inline void FUNC(idctRowCondDC_extrashift)(int16_t *row, int extra_shift) #else static inline void FUNC(idctRowCondDC)(int16_t *row, int extra_shift) #endif { int a0, a1, a2, a3, b0, b1, b2, b3; #if HAVE_FAST_64BIT #define ROW0_MASK (0xffffLL << 48 * HAVE_BIGENDIAN) if (((((uint64_t *)row)[0] & ~ROW0_MASK) | ((uint64_t *)row)[1]) == 0) { uint64_t temp; if (DC_SHIFT - extra_shift >= 0) { temp = (row[0] * (1 << (DC_SHIFT - extra_shift))) & 0xffff; } else { temp = ((row[0] + (1<<(extra_shift - DC_SHIFT-1))) >> (extra_shift - DC_SHIFT)) & 0xffff; } temp += temp * (1 << 16); temp += temp * ((uint64_t) 1 << 32); ((uint64_t *)row)[0] = temp; ((uint64_t *)row)[1] = temp; return; } #else if (!(((uint32_t*)row)[1] | ((uint32_t*)row)[2] | ((uint32_t*)row)[3] | row[1])) { uint32_t temp; if (DC_SHIFT - extra_shift >= 0) { temp = (row[0] * (1 << (DC_SHIFT - extra_shift))) & 0xffff; } else { temp = ((row[0] + (1<<(extra_shift - DC_SHIFT-1))) >> (extra_shift - DC_SHIFT)) & 0xffff; } temp += temp * (1 << 16); ((uint32_t*)row)[0]=((uint32_t*)row)[1] = ((uint32_t*)row)[2]=((uint32_t*)row)[3] = temp; return; } #endif a0 = (W4 * row[0]) + (1 << (ROW_SHIFT + extra_shift - 1)); a1 = a0; a2 = a0; a3 = a0; a0 += W2 * row[2]; a1 += W6 * row[2]; a2 -= W6 * row[2]; a3 -= W2 * row[2]; b0 = MUL(W1, row[1]); MAC(b0, W3, row[3]); b1 = MUL(W3, row[1]); MAC(b1, -W7, row[3]); b2 = MUL(W5, row[1]); MAC(b2, -W1, row[3]); b3 = MUL(W7, row[1]); MAC(b3, -W5, row[3]); if (AV_RN64A(row + 4)) { a0 += W4*row[4] + W6*row[6]; a1 += - W4*row[4] - W2*row[6]; a2 += - W4*row[4] + W2*row[6]; a3 += W4*row[4] - W6*row[6]; MAC(b0, W5, row[5]); MAC(b0, W7, row[7]); MAC(b1, -W1, row[5]); MAC(b1, -W5, row[7]); MAC(b2, W7, row[5]); MAC(b2, W3, row[7]); MAC(b3, W3, row[5]); MAC(b3, -W1, row[7]); } row[0] = (a0 + b0) >> (ROW_SHIFT + extra_shift); row[7] = (a0 - b0) >> (ROW_SHIFT + extra_shift); row[1] = (a1 + b1) >> (ROW_SHIFT + extra_shift); row[6] = (a1 - b1) >> (ROW_SHIFT + extra_shift); row[2] = (a2 + b2) >> (ROW_SHIFT + extra_shift); row[5] = (a2 - b2) >> (ROW_SHIFT + extra_shift); row[3] = (a3 + b3) >> (ROW_SHIFT + extra_shift); row[4] = (a3 - b3) >> (ROW_SHIFT + extra_shift); }
1threat
How to get time from a variable having both date & time? : <p>I have a variable as:</p> <pre><code>$date_time = 2016-11-08T14:22:08.240Z </code></pre> <p>now how can i extract time in the format as <code>14:22</code> from the given variable.</p>
0debug
static int json_lexer_feed_char(JSONLexer *lexer, char ch, bool flush) { int char_consumed, new_state; lexer->x++; if (ch == '\n') { lexer->x = 0; lexer->y++; } do { new_state = json_lexer[lexer->state][(uint8_t)ch]; char_consumed = !TERMINAL_NEEDED_LOOKAHEAD(lexer->state, new_state); if (char_consumed) { qstring_append_chr(lexer->token, ch); } switch (new_state) { case JSON_OPERATOR: case JSON_ESCAPE: case JSON_INTEGER: case JSON_FLOAT: case JSON_KEYWORD: case JSON_STRING: lexer->emit(lexer, lexer->token, new_state, lexer->x, lexer->y); case JSON_SKIP: QDECREF(lexer->token); lexer->token = qstring_new(); new_state = IN_START; break; case IN_ERROR: QDECREF(lexer->token); lexer->token = qstring_new(); new_state = IN_START; return -EINVAL; default: break; } lexer->state = new_state; } while (!char_consumed && !flush); if (lexer->token->length > MAX_TOKEN_SIZE) { lexer->emit(lexer, lexer->token, lexer->state, lexer->x, lexer->y); QDECREF(lexer->token); lexer->token = qstring_new(); lexer->state = IN_START; } return 0; }
1threat
C(++) How is argv a string array when its a char array : Why doesnt argv[0] print the first character of the filename instead of the whole filename string? If argv is a pointer to an array of chars, then shouldnt accessing it with [n] result with a char? If its a string (as printf(argv[n]) suggests) then why doesnt argv[0][0] get me the first char of filename (compiles but crashes when started)?
0debug
while running the application on weblogic server getting this errors...can you please anyone help on this : org.eclipse.core.runtime.CoreException: Module named '_auto_generated_ear_' failed to deploy. See Error Log view for more detail. at oracle.eclipse.tools.weblogic.server.internal.WlsJ2EEDeploymentHelper.deployAutoGenerateEarApplication(WlsJ2EEDeploymentHelper.java:852) at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishWeblogicModules(WeblogicServerBehaviour.java:1452) at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishToServer(WeblogicServerBehaviour.java:944) at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishOnce(WeblogicServerBehaviour.java:735) at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publish(WeblogicServerBehaviour.java:584) at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:774) at org.eclipse.wst.server.core.internal.Server.publishImpl(Server.java:3182) at org.eclipse.wst.server.core.internal.Server$PublishJob.run(Server.java:355) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56) Contains: Module named '_auto_generated_ear_' failed to start. Contains: weblogic.application.ModuleException: javax.servlet.ServletException: MultipartFilter: No temporary upload directory found. Set a property named 'AVS.FILE_UPLOAD.TEMP_DIR' to a valid directory. java.lang.Exception: Exception received from deployment driver. See Error Log view for more detail. at oracle.eclipse.tools.weblogic.server.internal.DeploymentProgressListener.watch(DeploymentProgressListener.java:193) at oracle.eclipse.tools.weblogic.server.internal.WlsJ2EEDeploymentHelper.startModule(WlsJ2EEDeploymentHelper.java:1178) at oracle.eclipse.tools.weblogic.server.internal.WlsJ2EEDeploymentHelper.deployAutoGenerateEarApplication(WlsJ2EEDeploymentHelper.java:843) at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishWeblogicModules(WeblogicServerBehaviour.java:1452) at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishToServer(WeblogicServerBehaviour.java:944) at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publishOnce(WeblogicServerBehaviour.java:735) at oracle.eclipse.tools.weblogic.server.internal.WeblogicServerBehaviour.publish(WeblogicServerBehaviour.java:584) at org.eclipse.wst.server.core.model.ServerBehaviourDelegate.publish(ServerBehaviourDelegate.java:774) at org.eclipse.wst.server.core.internal.Server.publishImpl(Server.java:3182) at org.eclipse.wst.server.core.internal.Server$PublishJob.run(Server.java:355) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56) Caused by: weblogic.application.ModuleException: javax.servlet.ServletException: MultipartFilter: No temporary upload directory found. Set a property named 'AVS.FILE_UPLOAD.TEMP_DIR' to a valid directory. at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140) at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124) at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216) at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42) at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:73) at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:24) at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:729) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42) at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:258) at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:61) at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165) at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:587) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150) at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116) at weblogic.deploy.internal.targetserver.operations.StartOperation.doCommit(StartOperation.java:151) at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:339) at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:846) at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1275) at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:442) at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:176) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13) at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68) at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:548) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311) at weblogic.work.ExecuteThread.run(ExecuteThread.java:263) Caused by: javax.servlet.ServletException: MultipartFilter: No temporary upload directory found. Set a property named 'AVS.FILE_UPLOAD.TEMP_DIR' to a valid directory. at com.fritolay.avs.ui.MultipartFilter.init(MultipartFilter.java:31) at weblogic.servlet.internal.FilterManager$FilterInitAction.run(FilterManager.java:374) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57) at weblogic.servlet.internal.FilterManager.initFilter(FilterManager.java:125) at weblogic.servlet.internal.FilterManager.loadFilter(FilterManager.java:88) at weblogic.servlet.internal.FilterManager.preloadFilters(FilterManager.java:68) at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1844) at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2876) at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1661) at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:823) at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:360) at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:356) at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42) at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:138)
0debug
Variables to next activity : <p>I get 3 data string from editText (in 1 activity), and then go to next activity</p> <pre><code>button.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { a=editText.getText().toString(); b=editText2.getText().toString(); goToActivity2(); } }); </code></pre> <p>and in 2 activity, i want to set new variables user1, user2, like this</p> <pre><code>public String user1 = a(from 1 activity); public String user2 = b(from 1 activity); </code></pre> <p>Is it possible ? I cant found information about variables in my basics books java.</p>
0debug
Any Javascript Expert: Who can add multiple IDs in This Script to Check If CSS does not match redirect Page : Javascript expert, i have the below script $('#copyright, #credit, #doom a').each(function () { if ($(this).css('font-size') != '15px') { document.location.href = "http://www.example.com"; } }); It check all these IDs Css properties for font-size 15px if not equal then the page will be redirect to example.com Now here what i want, I want to know how can i add **multiple css property** in that script not only the font-size but i also want to include position:relative;height:auto;background:#000; to check it.. it may be look like this: (this is only example not the working script ) $('#copyright, #credit, #doom a').each(function () { if position:relative;height:auto;background:#000 { do nothing } else { document.location.href = "http://www.example.com"; } });
0debug
Why android ListView displays only one row? : I have custom adapter for ListView. No matter how many items are passed to it it displays only one row. I verified by debugging that overrided methods return correct result. For example getCount() returns: 3, getView(2, null, (ListView)rootView) returns expected view with TextView holding item name. Anyone can help?
0debug
static void iterative_me(SnowContext *s){ int pass, mb_x, mb_y; const int b_width = s->b_width << s->block_max_depth; const int b_height= s->b_height << s->block_max_depth; const int b_stride= b_width; int color[3]; for(pass=0; pass<50; pass++){ int change= 0; for(mb_y= 0; mb_y<b_height; mb_y++){ for(mb_x= 0; mb_x<b_width; mb_x++){ int dia_change, i, j; int best_rd= INT_MAX; BlockNode backup; const int index= mb_x + mb_y * b_stride; BlockNode *block= &s->block[index]; BlockNode *tb = mb_y ? &s->block[index-b_stride ] : &null_block; BlockNode *lb = mb_x ? &s->block[index -1] : &null_block; BlockNode *rb = mb_x<b_width ? &s->block[index +1] : &null_block; BlockNode *bb = mb_y<b_height ? &s->block[index+b_stride ] : &null_block; BlockNode *tlb= mb_x && mb_y ? &s->block[index-b_stride-1] : &null_block; BlockNode *trb= mb_x<b_width && mb_y ? &s->block[index-b_stride+1] : &null_block; BlockNode *blb= mb_x && mb_y<b_height ? &s->block[index+b_stride-1] : &null_block; BlockNode *brb= mb_x<b_width && mb_y<b_height ? &s->block[index+b_stride+1] : &null_block; if(pass && (block->type & BLOCK_OPT)) continue; block->type |= BLOCK_OPT; backup= *block; if(!s->me_cache_generation) memset(s->me_cache, 0, sizeof(s->me_cache)); s->me_cache_generation += 1<<22; check_block(s, mb_x, mb_y, (int[2]){block->mx, block->my}, 0, &best_rd); check_block(s, mb_x, mb_y, (int[2]){0, 0}, 0, &best_rd); check_block(s, mb_x, mb_y, (int[2]){tb->mx, tb->my}, 0, &best_rd); check_block(s, mb_x, mb_y, (int[2]){lb->mx, lb->my}, 0, &best_rd); check_block(s, mb_x, mb_y, (int[2]){rb->mx, rb->my}, 0, &best_rd); check_block(s, mb_x, mb_y, (int[2]){bb->mx, bb->my}, 0, &best_rd); do{ dia_change=0; for(i=0; i<FFMAX(s->avctx->dia_size, 1); i++){ for(j=0; j<i; j++){ dia_change |= check_block(s, mb_x, mb_y, (int[2]){block->mx+4*(i-j), block->my+(4*j)}, 0, &best_rd); dia_change |= check_block(s, mb_x, mb_y, (int[2]){block->mx-4*(i-j), block->my-(4*j)}, 0, &best_rd); dia_change |= check_block(s, mb_x, mb_y, (int[2]){block->mx+4*(i-j), block->my-(4*j)}, 0, &best_rd); dia_change |= check_block(s, mb_x, mb_y, (int[2]){block->mx-4*(i-j), block->my+(4*j)}, 0, &best_rd); } } }while(dia_change); do{ static const int square[8][2]= {{+1, 0},{-1, 0},{ 0,+1},{ 0,-1},{+1,+1},{-1,-1},{+1,-1},{-1,+1},}; dia_change=0; for(i=0; i<8; i++) dia_change |= check_block(s, mb_x, mb_y, (int[2]){block->mx+square[i][0], block->my+square[i][1]}, 0, &best_rd); }while(dia_change); for(i=0; i<3; i++){ color[i]= get_dc(s, mb_x, mb_y, i); } check_block(s, mb_x, mb_y, color, 1, &best_rd); if(!same_block(block, &backup)){ if(tb != &null_block) tb ->type &= ~BLOCK_OPT; if(lb != &null_block) lb ->type &= ~BLOCK_OPT; if(rb != &null_block) rb ->type &= ~BLOCK_OPT; if(bb != &null_block) bb ->type &= ~BLOCK_OPT; if(tlb!= &null_block) tlb->type &= ~BLOCK_OPT; if(trb!= &null_block) trb->type &= ~BLOCK_OPT; if(blb!= &null_block) blb->type &= ~BLOCK_OPT; if(brb!= &null_block) brb->type &= ~BLOCK_OPT; change ++; } } } av_log(NULL, AV_LOG_ERROR, "pass:%d changed:%d\n", pass, change); if(!change) break; } }
1threat
Reading response headers with Fetch API : <p>I'm in a Google Chrome extension with permissions for <code>"*://*/*"</code> and I'm trying to make the switch from XMLHttpRequest to the <a href="https://developers.google.com/web/updates/2015/03/introduction-to-fetch" rel="noreferrer">Fetch API</a>.</p> <p>The extension stores user-input login data that used to be put directly into the XHR's open() call for HTTP Auth, but under Fetch can no longer be used directly as a parameter. For HTTP Basic Auth, circumventing this limitation is trivial, as you can manually set an Authorization header:</p> <pre><code>fetch(url, { headers: new Headers({ 'Authorization': 'Basic ' + btoa(login + ':' + pass) }) } }); </code></pre> <p><a href="https://en.wikipedia.org/wiki/Digest_access_authentication#Example_with_explanation" rel="noreferrer">HTTP Digest Auth</a> however requires more interactivity; you need to read parameters that the server sends you with its 401 response to craft a valid authorization token. I've tried reading the <code>WWW-Authenticate</code> response header field with this snippet:</p> <pre><code>fetch(url).then(function(resp) { resp.headers.forEach(function(val, key) { console.log(key + ' -&gt; ' + val); }); } </code></pre> <p>But all I get is this output:</p> <pre><code>content-type -&gt; text/html; charset=iso-8859-1 </code></pre> <p>Which by itself is correct, but that's still missing around 6 more fields according to Chrome's Developer Tools. If I use <code>resp.headers.get("WWW-Authenticate")</code> (or any of the other fields for that matter), i get only <code>null</code>.</p> <p>Any chance of getting to those other fields using the Fetch API?</p>
0debug
static void vtd_realize(DeviceState *dev, Error **errp) { PCMachineState *pcms = PC_MACHINE(qdev_get_machine()); PCIBus *bus = pcms->bus; IntelIOMMUState *s = INTEL_IOMMU_DEVICE(dev); X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(dev); VTD_DPRINTF(GENERAL, ""); x86_iommu->type = TYPE_INTEL; if (!vtd_decide_config(s, errp)) { return; } QLIST_INIT(&s->notifiers_list); memset(s->vtd_as_by_bus_num, 0, sizeof(s->vtd_as_by_bus_num)); memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s, "intel_iommu", DMAR_REG_SIZE); sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->csrmem); s->iotlb = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal, g_free, g_free); s->vtd_as_by_busptr = g_hash_table_new_full(vtd_uint64_hash, vtd_uint64_equal, g_free, g_free); vtd_init(s); sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, Q35_HOST_BRIDGE_IOMMU_ADDR); pci_setup_iommu(bus, vtd_host_dma_iommu, dev); pcms->ioapic_as = vtd_host_dma_iommu(bus, s, Q35_PSEUDO_DEVFN_IOAPIC); }
1threat
static void test_qemu_strtoull_negative(void) { const char *str = " \t -321"; char f = 'X'; const char *endptr = &f; uint64_t res = 999; int err; err = qemu_strtoull(str, &endptr, 0, &res); g_assert_cmpint(err, ==, 0); g_assert_cmpint(res, ==, -321); g_assert(endptr == str + strlen(str)); }
1threat
Need help making while loops work : I've always struggled with while loops because they barely ever work for me. They always crash my programs but in this instance I really need it to work: void Update () { while (!gameOver) { if (!spawned) { //Do something } else if (timer >= 2.0f) { //Do something else } else { timer += Time.deltaTime; } } } Ideally, I want those if statements to run as the game runs. Right now it crashes the program and I know it's the while loop which is the problem because it crashes anytime I comment it out.
0debug
how to write a java 8 steam code for the following code : List<String> myList = Arrays.asList("a1", "a2", "b1", "c2", "c1"); List<Integer> addList=new ArrayList<Integer>(); for(String listobj:myList) { String appendedobj=listobj+"%"; List<Integer> intlist=myMethod(appendedobj,listobj); addList.addAll(intlist); } public list<String> mymethod(appendedobj,listobj) { do something and retrurn list of integers; } I want to covert this to java 8 stream code but how to call the myMethod with two arguments I am not able to get
0debug
why the output is not logic ? : <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> let vacationSpots = ['USA', 'UK', 'Colombia']; for (let vacationSpotIndex = vacationSpots.length - 1; vacationSpotIndex >= 0; vacationSpotIndex-- ) { console.log('I would love to visit ' + vacationSpots[vacationSpotIndex]); } <!-- end snippet --> i suppose the lenght is 3 and we substract 1 so it equals to 2; so the index start is 2 and we substract 1 on every loop the probleme in the condition vacationSpotIndex >= 0 i suppose logicly it is vacationSpotIndex <= 0
0debug
Softmax Implementation in C++ : <p>Folks,</p> <p>Are there any example of the implementation of a simple softmax function for N values? I've seem things like "softmax-based detectors" and so forth, but I just want to see a pure, straightforward C++ softmax implementation.</p> <p>Any examples you know of?</p> <p>Thanks,</p>
0debug
static void FUNC(put_hevc_qpel_bi_w_v)(uint8_t *_dst, ptrdiff_t _dststride, uint8_t *_src, ptrdiff_t _srcstride, int16_t *src2, int height, int denom, int wx0, int wx1, int ox0, int ox1, intptr_t mx, intptr_t my, int width) { int x, y; pixel *src = (pixel*)_src; ptrdiff_t srcstride = _srcstride / sizeof(pixel); pixel *dst = (pixel *)_dst; ptrdiff_t dststride = _dststride / sizeof(pixel); const int8_t *filter = ff_hevc_qpel_filters[my - 1]; int shift = 14 + 1 - BIT_DEPTH; int log2Wd = denom + shift - 1; ox0 = ox0 * (1 << (BIT_DEPTH - 8)); ox1 = ox1 * (1 << (BIT_DEPTH - 8)); for (y = 0; y < height; y++) { for (x = 0; x < width; x++) dst[x] = av_clip_pixel(((QPEL_FILTER(src, srcstride) >> (BIT_DEPTH - 8)) * wx1 + src2[x] * wx0 + ((ox0 + ox1 + 1) << log2Wd)) >> (log2Wd + 1)); src += srcstride; dst += dststride; src2 += MAX_PB_SIZE; } }
1threat
is there any one explain predicate logic to this sentence Some sleepy students do not answer any question : <p>Write a corresponding predicate logic sentences for the following 1. Some sleepy students do not answer any question</p>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
unsigned long virtio_load_direct(ulong rec_list1, ulong rec_list2, ulong subchan_id, void *load_addr) { u8 status; int sec = rec_list1; int sec_num = ((rec_list2 >> 32) & 0xffff) + 1; int sec_len = rec_list2 >> 48; ulong addr = (ulong)load_addr; if (sec_len != virtio_get_block_size()) { return -1; } sclp_print("."); status = virtio_read_many(sec, (void *)addr, sec_num); if (status) { virtio_panic("I/O Error"); } addr += sec_num * virtio_get_block_size(); return addr; }
1threat
parsing a nested dictionary : I would like to parse the following nested dictionary for all URL entries. They should be written into a list. How can I do this? {u'_id': ObjectId('56a22819ffd6f'), u'books': [{u'id': {u'id': u'4311'}, u'link': {u'name': u'Operating Business', u'url': u'http://ffff'}}, {u'id': {u'id': u'4310'}, u'link': {u'name': u'Operating Business', u'url': u'http://zzzzz'}}, {u'id': {u'id': u'7462'}, u'link': {u'name': u'European Credit Trading', u'url': u'http://xxxx'}}, {u'id': {u'id': u'3258'}, u'link': {u'name': u'Operating Business', u'url': u'http://dddddd'}}, {u'id': {u'id': u'7463'}, u'link': {u'name': u'US Credit Trading', u'url': u'http://aaaaa'}}], u'created': datetime.datetime(2016, 1, 2, 13, 1, 12, 744000), u'id': u'lingering-smoke', u'valuationDate': datetime.datetime(170, 1, 1, 0, 0, 16, 821000)}
0debug
How to get PHP variable from another php file : I have functions.php while ($row_posts = mysqli_fetch_array($run_news)) { $news_id = $row_posts['news_id']; $user_id = $row_posts['user_id']; $topic_id = $row_posts['topic_id']; $news_title = $row_posts['news_title']; $news_date = $row_posts['news_date']; // getting the user who has posted the thread $user = "select * from users where user_id ='$user_id' AND posts = 'yes'"; $run_user = mysqli_query($con, $user); $row_user = mysqli_fetch_array($run_user); $user_name = $row_user['user_name']; $user_image = $row_user['user_image']; And another file showmap.php where I want $string to be dynamically come from user $string = 'Massive fire underneath Metro-North tracks in MODEL TOWN disrupts train service.'; $lower_string= strtolower($string);
0debug
PDO SELECT from SLAVE and INSERT into MASTER : <p>is there any chance to set in PDO settings that SELECT's will be executed on SLAVE DB server and Insert &amp; Update &amp; DELETE will be executed on MASTER DB server, or I need to create PHP handler to do that? </p> <p>Situation: </p> <p>We have <strong>Master</strong> - <strong>Master</strong> replication for MySQL. We are going to add two new servers so it will be - <strong>Master</strong>/<strong>Slave</strong> - <strong>Master</strong>/<strong>Slave</strong>. </p> <p>I want to create some handling for <strong>SELECT</strong> queries. I want execute <strong>SELECT</strong> queries on <strong>SLAVE</strong> instead of <strong>MASTER</strong> and all <strong>UPADTE&amp;INSERT&amp;DELETE</strong> queries will be executed on <strong>MASTER</strong>. Is this possible with some setting? </p> <p>Thanks!</p>
0debug
Convert date to "dd.MM.yyyy" format date in swift : I work with an API, where one of parameters is of type Date in format "dd.MM.yyyy". I cant manage to convert it. I created an extension for Date, where I tried to implement it in next way: extension Date { var shortDate: Date { let formatter = DateFormatter() formatter.dateFormat = "dd.MM.yyyy" let strDate = formatter.string(from: self) let modifiedDate = formatter.date(from: strDate) return modifiedDate! } } and I call it like that: let day = Date().shortDate but unfortunately it doesn't work and it looks like that: 2017-06-18 21:00:00 +0000 Thanks a lot in advance for any help!
0debug
how to Mail script output in table format : I am very new to shell scripting. I need your help on below senario. I have the script output like below. Filename Destname rowcount bytesize file1 default 1488 2248 file2 default 123 657 file3 default 123 456 file4 default 567 124 Now I need to mail this ouput in table format with proper indentation. Please help me to write the script for the same.
0debug
Failed to refresh gradle project in IntelliJ IDEA 2016.1: Unknown method ScalaCompileOptions.getForce() : <p>I have a Gradle-based project primarily with Java code and a small subproject with Scala (a Gatling-based performance test).</p> <p>I recently upgraded Gradle wrapper to v2.12, which is currently the latest version. And today I just updated IntelliJ Idea from v15 to v2016.1.</p> <p>When I try to refresh the project from the Gradle files in Idea, I get this error.</p> <pre><code>Error:Cause: org.gradle.api.tasks.scala.ScalaCompileOptions.getForce()Ljava/lang/String; </code></pre> <p>I noticed when searching on Google, that the method getForce() (returning a String) apparently has been replaced by isForce() (returning a boolean).</p> <p>If i downgrade Gradle wrapper to v2.11 the problem disappears. Is there anything else I can do to fix the problem?</p>
0debug
Compare multiple lists inside a list Python : <p>Is it possible to compare a list containing an unknown number of lists with equal elements in a more terse (aka shorter) manner than what I have done? Preferably an one-liner!</p> <p>Here's an example if it's unclear what I want to do:</p> <pre><code>a = [1, 2, 3] b = [4, 2, 1] c = [7, 5, 1] d = [a, b, c] def multiCompList(lists): final = [i for i in lists[0] if i in lists[1]] for i in range(2, len(lists)): final = [i for i in final if i in lists[i]] return final print(multiCompList(d)) </code></pre> <p>What I've done is to first check if the first and second list contains any equal elements and put them in a list called final. Thereafter, checking if those elements can be found in the lists after and replacing the final-list with the remaining equal elements. The results in this case is: [1].</p>
0debug
How to extract interface from class in Visual Studio 2017 : <p>The functionality to extract an interface from a class (C#) seems to change in VS 2017. How can I do that in Visual Studio 2017.</p>
0debug
Hartl Rails Tutorial Ch9, "test_should_redirect_destroy_when_not_logged_in" : Working through Hartl's tutorial, in Chapter 9, Listing 9.56 produces the following error, showing 'admin?' as an undefined method. I've checked (and rechecked) the 2 sections of code that have been revised since the last green test. Stumped. ERROR["test_should_redirect_destroy_when_not_logged_in", UsersControllerTest, 2016-02-26 21:29:01 -0500] test_should_redirect_destroy_when_not_logged_in#UsersControllerTest (1456540141.41s) NoMethodError: NoMethodError: undefined method `admin?' for nil:NilClass app/controllers/users_controller.rb:73:in `admin_user' test/controllers/users_controller_test.rb:48:in `block (2 levels) in <class:UsersControllerTest>' test/controllers/users_controller_test.rb:47:in `block in <class:UsersControllerTest>' app/controllers/users_controller.rb:73:in `admin_user' test/controllers/users_controller_test.rb:48:in `block (2 levels) in <class:UsersControllerTest>' test/controllers/users_controller_test.rb:47:in `block in <class:UsersControllerTest>' 39/39: [==========================================================] 100% Time: 00:00:00, Time: 00:00:00 Finished in 0.97767s 39 tests, 152 assertions, 0 failures, 1 errors, 0 skips Note that the admin field was added to the database during a migration, which I understand *should* automatically produce a boolean admin? method class AddAdminToUsers < ActiveRecord::Migration def change add_column :users, :admin, :boolean, default: false end end users_controller_test.rb is where the problem apparently resides, specifically in the lines: test "should redirect destroy when not logged in" do assert_no_difference 'User.count' do delete :destroy, id: @user ...while the complete file looks like this: require 'test_helper' class UsersControllerTest < ActionController::TestCase def setup @user = users(:michael) @other_user = users(:archer) end test "should redirect index when not logged in" do get :index assert_redirected_to login_url end test "should get new" do get :new assert_response :success end test "should redirect edit when not logged in" do get :edit, id: @user assert_not flash.empty? assert_redirected_to login_url end test "should redirect to update when not logged in" do patch :update, id: @user, user: { name: @user.name, email: @user.email } assert_not flash.empty? assert_redirected_to login_url end test "should redirect edit when logged in as wrong user" do log_in_as(@other_user) get :edit, id: @user assert flash.empty? assert_redirected_to root_url end test "should redirect update when logged in as wrong user" do log_in_as(@other_user) patch :update, id: @user, user: {name: @user.name, email: @user.email } assert flash.empty? assert_redirected_to root_url end test "should redirect destroy when not logged in" do assert_no_difference 'User.count' do delete :destroy, id: @user end assert_redirected_to login_url end test "should redirect destroy when logged in as a non-admin" do log_in_as(@other_user) assert_no_difference 'User.count' do delete :destroy, id: @user end assert_redirected_to root_url end end and here's the contents of users.yaml # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html michael: name: Michael Example email: michael@example.com password_digest: <%= User.digest('password') %> admin: true archer: name: Sterling Archer email: duchess@example.gov password_digest: <%= User.digest('password') %> lana: name: Lana Kane email: hands@example.gov password_digest: <%= User.digest('password') %> mallory: name: Mallory Archer email: boss@example.gov password_digest: <%= User.digest('password') %> <% 30.times do |n| %> user_<%= n %>: name: <%= "User #{n}" %> email: <%= "user-#{n}@example.com" %> password_digest: <%= User.digest('password') %> <% end %>
0debug
static int armv7m_nvic_init(SysBusDevice *dev) { nvic_state *s = NVIC(dev); NVICClass *nc = NVIC_GET_CLASS(s); s->gic.num_cpu = 1; s->gic.revision = 0xffffffff; s->gic.num_irq = s->num_irq; nc->parent_init(dev); gic_init_irqs_and_distributor(&s->gic, s->num_irq); memory_region_init(&s->container, "nvic", 0x1000); memory_region_init_io(&s->sysregmem, &nvic_sysreg_ops, s, "nvic_sysregs", 0x1000); memory_region_add_subregion(&s->container, 0, &s->sysregmem); memory_region_init_alias(&s->gic_iomem_alias, "nvic-gic", &s->gic.iomem, 0x100, 0xc00); memory_region_add_subregion_overlap(&s->container, 0x100, &s->gic.iomem, 1); memory_region_add_subregion(get_system_memory(), 0xe000e000, &s->container); s->systick.timer = qemu_new_timer_ns(vm_clock, systick_timer_tick, s); return 0; }
1threat
How to install Angular2 beta with Bower? : <p>I'm trying to install Angular2 with Bower with command <code>bower install -S angular2</code> and have next messages in console:</p> <pre><code>$ bower install -S angular2 bower angular2#* cached git://github.com/angular/bower-angular.git#1.4.8 bower angular2#* validate 1.4.8 against git://github.com/angular/bower-angular.git#* bower angular#~1.4.8 install angular#1.4.8 angular#1.4.8 bower_components/angular </code></pre> <p>My <code>bower.json</code> file now contains next info in <code>dependencies</code> section:</p> <pre><code>"dependencies": { "angular": "angular2#~1.4.8" } </code></pre> <p>And I have Angular 1.4.8 after that in <code>bower_components</code> path.</p> <p>So, how to install Angular2 beta with Bower?</p>
0debug
Go channels only sending values : I am learning channels in GO and following this [tutorial][1] When I only send value to a channel it gives error. Here is the example code. package main import "fmt" func main() { ch := make(chan int) ch <- 1 fmt.Println("Does not work") } Here I am just sending value to the channel but not receiving anything. It give an error fatal error: all goroutines are asleep - deadlock! But when I run following code it doesn't give any error package main import "fmt" func sum(s []int, c chan int) { sum := 0 for _, v := range s { sum += v } c <- sum // send sum to c } func main() { s := []int{7, 2, 8, -9, 4, 0} c := make(chan int) go sum(s[:len(s)/2], c) go sum(s[len(s)/2:], c) fmt.Println("did not receive but still works") } and prints did not receive but still works I couldn't understand why it works in second case while it does not work in first case. Even though I have not received any value for the channel in both cases. Also what is causing the deadlock in first case and how it gets avoided in second case? [1]: https://tour.golang.org/concurrency
0debug
static void m5206_mbar_update(m5206_mbar_state *s) { int irq; int vector; int level; irq = m5206_find_pending_irq(s); if (irq) { int tmp; tmp = s->icr[irq]; level = (tmp >> 2) & 7; if (tmp & 0x80) { vector = 24 + level; } else { switch (irq) { case 8: vector = s->swivr; break; case 12: vector = s->uivr[0]; break; case 13: vector = s->uivr[1]; break; default: fprintf(stderr, "Unhandled vector for IRQ %d\n", irq); vector = 0xf; break; } } } else { level = 0; vector = 0; } m68k_set_irq_level(s->cpu, level, vector); }
1threat
static int decode_cell(Indeo3DecodeContext *ctx, AVCodecContext *avctx, Plane *plane, Cell *cell, const uint8_t *data_ptr, const uint8_t *last_ptr) { int x, mv_x, mv_y, mode, vq_index, prim_indx, second_indx; int zoom_fac; int offset, error = 0, swap_quads[2]; uint8_t code, *block, *ref_block = 0; const vqEntry *delta[2]; const uint8_t *data_start = data_ptr; code = *data_ptr++; mode = code >> 4; vq_index = code & 0xF; offset = (cell->ypos << 2) * plane->pitch + (cell->xpos << 2); block = plane->pixels[ctx->buf_sel] + offset; if (!cell->mv_ptr) { ref_block = block - plane->pitch; } else if (mode >= 10) { copy_cell(ctx, plane, cell); } else { mv_y = cell->mv_ptr[0]; mv_x = cell->mv_ptr[1]; offset += mv_y * plane->pitch + mv_x; ref_block = plane->pixels[ctx->buf_sel ^ 1] + offset; if (mode == 1 || mode == 4) { code = ctx->alt_quant[vq_index]; prim_indx = (code >> 4) + ctx->cb_offset; second_indx = (code & 0xF) + ctx->cb_offset; } else { vq_index += ctx->cb_offset; prim_indx = second_indx = vq_index; if (prim_indx >= 24 || second_indx >= 24) { av_log(avctx, AV_LOG_ERROR, "Invalid VQ table indexes! Primary: %d, secondary: %d!\n", prim_indx, second_indx); delta[0] = &vq_tab[second_indx]; delta[1] = &vq_tab[prim_indx]; swap_quads[0] = second_indx >= 16; swap_quads[1] = prim_indx >= 16; if (vq_index >= 8 && ref_block) { for (x = 0; x < cell->width << 2; x++) ref_block[x] = requant_tab[vq_index & 7][ref_block[x]]; error = IV3_NOERR; switch (mode) { case 0: case 1: case 3: case 4: if (mode >= 3 && cell->mv_ptr) { av_log(avctx, AV_LOG_ERROR, "Attempt to apply Mode 3/4 to an INTER cell!\n"); zoom_fac = mode >= 3; error = decode_cell_data(cell, block, ref_block, plane->pitch, 0, zoom_fac, mode, delta, swap_quads, &data_ptr, last_ptr); break; case 10: case 11: if (mode == 10 && !cell->mv_ptr) { error = decode_cell_data(cell, block, ref_block, plane->pitch, 1, 1, mode, delta, swap_quads, &data_ptr, last_ptr); } else { if (mode == 11 && !cell->mv_ptr) { av_log(avctx, AV_LOG_ERROR, "Attempt to use Mode 11 for an INTRA cell!\n"); zoom_fac = mode == 10; error = decode_cell_data(cell, block, ref_block, plane->pitch, zoom_fac, 1, mode, delta, swap_quads, &data_ptr, last_ptr); break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported coding mode: %d\n", mode); } switch (error) { case IV3_BAD_RLE: av_log(avctx, AV_LOG_ERROR, "Mode %d: RLE code %X is not allowed at the current line\n", mode, data_ptr[-1]); case IV3_BAD_DATA: av_log(avctx, AV_LOG_ERROR, "Mode %d: invalid VQ data\n", mode); case IV3_BAD_COUNTER: av_log(avctx, AV_LOG_ERROR, "Mode %d: RLE-FB invalid counter: %d\n", mode, code); case IV3_UNSUPPORTED: av_log(avctx, AV_LOG_ERROR, "Mode %d: unsupported RLE code: %X\n", mode, data_ptr[-1]); case IV3_OUT_OF_DATA: av_log(avctx, AV_LOG_ERROR, "Mode %d: attempt to read past end of buffer\n", mode); return data_ptr - data_start;
1threat
def fibonacci(n): if n == 1 or n == 2: return 1 else: return (fibonacci(n - 1) + (fibonacci(n - 2)))
0debug
This code takes forever to run but doesn't give an error : <p>I am trying to remove all instances of a particular character from a string by replacing the character with an empty string. Here is my code:</p> <pre><code>string1="BANANA" while string1.count("A") != 1: string1 = string1.replace("A","") </code></pre> <p>This code takes forever to run and doesn't give an error. What is the problem?</p>
0debug
static void video_refresh(void *opaque) { VideoState *is = opaque; VideoPicture *vp; double time; SubPicture *sp, *sp2; if (!is->paused && get_master_sync_type(is) == AV_SYNC_EXTERNAL_CLOCK && is->realtime) check_external_clock_speed(is); if (!display_disable && is->show_mode != SHOW_MODE_VIDEO && is->audio_st) video_display(is); if (is->video_st) { if (is->force_refresh) pictq_prev_picture(is); retry: if (is->pictq_size == 0) { SDL_LockMutex(is->pictq_mutex); if (is->frame_last_dropped_pts != AV_NOPTS_VALUE && is->frame_last_dropped_pts > is->frame_last_pts) { update_video_pts(is, is->frame_last_dropped_pts, is->frame_last_dropped_pos, 0); is->frame_last_dropped_pts = AV_NOPTS_VALUE; } SDL_UnlockMutex(is->pictq_mutex); } else { double last_duration, duration, delay; vp = &is->pictq[is->pictq_rindex]; if (vp->serial != is->videoq.serial) { pictq_next_picture(is); goto retry; } if (is->paused) goto display; last_duration = vp->pts - is->frame_last_pts; if (last_duration > 0 && last_duration < is->max_frame_duration) { is->frame_last_duration = last_duration; } delay = compute_target_delay(is->frame_last_duration, is); time= av_gettime()/1000000.0; if (time < is->frame_timer + delay) return; if (delay > 0) is->frame_timer += delay * FFMAX(1, floor((time-is->frame_timer) / delay)); SDL_LockMutex(is->pictq_mutex); update_video_pts(is, vp->pts, vp->pos, vp->serial); SDL_UnlockMutex(is->pictq_mutex); if (is->pictq_size > 1) { VideoPicture *nextvp = &is->pictq[(is->pictq_rindex + 1) % VIDEO_PICTURE_QUEUE_SIZE]; duration = nextvp->pts - vp->pts; if(!is->step && (framedrop>0 || (framedrop && get_master_sync_type(is) != AV_SYNC_VIDEO_MASTER)) && time > is->frame_timer + duration){ is->frame_drops_late++; pictq_next_picture(is); goto retry; } } if (is->subtitle_st) { if (is->subtitle_stream_changed) { SDL_LockMutex(is->subpq_mutex); while (is->subpq_size) { free_subpicture(&is->subpq[is->subpq_rindex]); if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE) is->subpq_rindex = 0; is->subpq_size--; } is->subtitle_stream_changed = 0; SDL_CondSignal(is->subpq_cond); SDL_UnlockMutex(is->subpq_mutex); } else { if (is->subpq_size > 0) { sp = &is->subpq[is->subpq_rindex]; if (is->subpq_size > 1) sp2 = &is->subpq[(is->subpq_rindex + 1) % SUBPICTURE_QUEUE_SIZE]; else sp2 = NULL; if ((is->video_current_pts > (sp->pts + ((float) sp->sub.end_display_time / 1000))) || (sp2 && is->video_current_pts > (sp2->pts + ((float) sp2->sub.start_display_time / 1000)))) { free_subpicture(sp); if (++is->subpq_rindex == SUBPICTURE_QUEUE_SIZE) is->subpq_rindex = 0; SDL_LockMutex(is->subpq_mutex); is->subpq_size--; SDL_CondSignal(is->subpq_cond); SDL_UnlockMutex(is->subpq_mutex); } } } } display: if (!display_disable && is->show_mode == SHOW_MODE_VIDEO) video_display(is); pictq_next_picture(is); if (is->step && !is->paused) stream_toggle_pause(is); } } is->force_refresh = 0; if (show_status) { static int64_t last_time; int64_t cur_time; int aqsize, vqsize, sqsize; double av_diff; cur_time = av_gettime(); if (!last_time || (cur_time - last_time) >= 30000) { aqsize = 0; vqsize = 0; sqsize = 0; if (is->audio_st) aqsize = is->audioq.size; if (is->video_st) vqsize = is->videoq.size; if (is->subtitle_st) sqsize = is->subtitleq.size; av_diff = 0; if (is->audio_st && is->video_st) av_diff = get_audio_clock(is) - get_video_clock(is); printf("%7.2f A-V:%7.3f fd=%4d aq=%5dKB vq=%5dKB sq=%5dB f=%"PRId64"/%"PRId64" \r", get_master_clock(is), av_diff, is->frame_drops_early + is->frame_drops_late, aqsize / 1024, vqsize / 1024, sqsize, is->video_st ? is->video_st->codec->pts_correction_num_faulty_dts : 0, is->video_st ? is->video_st->codec->pts_correction_num_faulty_pts : 0); fflush(stdout); last_time = cur_time; } } }
1threat
Go: Two return values to function with one argument : I want to do this: R, _ := strconv.Atoi(reader.ReadString(" ")) And the problem is, that strconv.Atoi expects one argument, but reader.ReadString() returns not only the string, but also the "err". Is there a way to solve this without creating variables or generally on just one line?
0debug
How to check if integer comes null/empty : I need to check if an input comes null/empty. If input <= 100 And input > 0 And Not input = "" Then subjectsInt.Add(subjects(i), input) check = True End If I know in that code I am checking it as String but I already did `Not input = Nothing` and `Not input = 0` and I am getting an error: >Run-time exception (line -1): Conversion from string "" to type 'Integer' is not valid. >Stack Trace: >[System.FormatException: Input string was not in a correct format.] >[System.InvalidCastException: Conversion from string "" to type 'Integer' is not valid.] Any suggestions?
0debug
type_init(parallel_register_types) static bool parallel_init(ISABus *bus, int index, CharDriverState *chr) { DeviceState *dev; ISADevice *isadev; isadev = isa_try_create(bus, "isa-parallel"); if (!isadev) { return false; } dev = DEVICE(isadev); qdev_prop_set_uint32(dev, "index", index); qdev_prop_set_chr(dev, "chardev", chr); if (qdev_init(dev) < 0) { return false; } return true; }
1threat
static int dvdsub_decode(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { DVDSubContext *ctx = avctx->priv_data; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AVSubtitle *sub = data; int is_menu; if (ctx->buf) { int ret = append_to_cached_buf(avctx, buf, buf_size); if (ret < 0) { *data_size = 0; return ret; } buf = ctx->buf; buf_size = ctx->buf_size; } is_menu = decode_dvd_subtitles(ctx, sub, buf, buf_size); if (is_menu == AVERROR(EAGAIN)) { *data_size = 0; return append_to_cached_buf(avctx, buf, buf_size); } if (is_menu < 0) { no_subtitle: reset_rects(sub); *data_size = 0; return buf_size; } if (!is_menu && find_smallest_bounding_rectangle(sub) == 0) goto no_subtitle; if (ctx->forced_subs_only && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED)) goto no_subtitle; #if defined(DEBUG) { char ppm_name[32]; snprintf(ppm_name, sizeof(ppm_name), "/tmp/%05d.ppm", ctx->sub_id++); av_dlog(NULL, "start=%d ms end =%d ms\n", sub->start_display_time, sub->end_display_time); ppm_save(ppm_name, sub->rects[0]->pict.data[0], sub->rects[0]->w, sub->rects[0]->h, (uint32_t*) sub->rects[0]->pict.data[1]); } #endif av_freep(&ctx->buf); ctx->buf_size = 0; *data_size = 1; return buf_size; }
1threat
how to share the data between the views in angualr : i am doing one angular project in which i am loading the new view by calling the function . up to this thing it is fine . now the my requirement is i want some data to transferred to the new view from the same same function . using the same controller . i am showing here the demo code. <!-- begin snippet: js hide: false --> <!-- language: lang-js --> $scope.passID = function(id){ console.log(id); $state.go("view", {id: $scope.id }); } <!-- end snippet -->
0debug
Software caused connection abort. Error returned in reply:Connection invalid : <p>My Xcode 9 gives the message to which I don't know how to respond. I want to run the app to my simulator, and I am getting this weird message. Attaching the snapshot for the same. <a href="https://i.stack.imgur.com/L1DSs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/L1DSs.png" alt="enter image description here"></a></p>
0debug
Cant get ASP.NET MVC 6 Controller to return JSON : <p>I have an MVC 6 project in which i am using Fiddler to test out Web API. If i take the following controller action which uses EntityFramework 7 to return a List. Then the html will render fine.</p> <pre><code>[HttpGet("/")] public IActionResult Index() { var model = orderRepository.GetAll(); return View(model); } </code></pre> <p>But when i try to return a Json response instead i get a 502 error.</p> <pre><code>[HttpGet("/")] public JsonResult Index() { var model = orderRepository.GetAll(); return Json(model); } </code></pre> <p>Any Idea on why the object isnt serialized into json correctly?</p>
0debug
static int virtio_ccw_set_vqs(SubchDev *sch, VqInfoBlock *info, VqInfoBlockLegacy *linfo) { VirtIODevice *vdev = virtio_ccw_get_vdev(sch); uint16_t index = info ? info->index : linfo->index; uint16_t num = info ? info->num : linfo->num; uint64_t desc = info ? info->desc : linfo->queue; if (index >= VIRTIO_CCW_QUEUE_MAX) { return -EINVAL; } if (linfo && desc && (linfo->align != 4096)) { return -EINVAL; } if (!vdev) { return -EINVAL; } if (info) { virtio_queue_set_rings(vdev, index, desc, info->avail, info->used); } else { virtio_queue_set_addr(vdev, index, desc); } if (!desc) { virtio_queue_set_vector(vdev, index, VIRTIO_NO_VECTOR); } else { if (info) { if (virtio_queue_get_max_num(vdev, index) < num) { return -EINVAL; } virtio_queue_set_num(vdev, index, num); } else if (virtio_queue_get_num(vdev, index) > num) { return -EINVAL; } virtio_queue_set_vector(vdev, index, index); } vdev->config_vector = VIRTIO_CCW_QUEUE_MAX; return 0; }
1threat
static inline TCGv load_cpu_offset(int offset) { TCGv tmp = new_tmp(); tcg_gen_ld_i32(tmp, cpu_env, offset); return tmp; }
1threat
Physics vector constructor, magnitude and unit vector functions not working c++ : <p>I am writing a class called Vector which represents a 3-dimensional vector. I need a constructor which can take a pre-existing Vector object and create a new one from it. This is the constructor:</p> <pre><code>Vector::Vector(const Vector &amp;v1){ for(int i = 0; i &lt; d; i++) components[i] = v1.components[i]; } </code></pre> <p>This is the note the compiler gives me:</p> <pre><code>candidate constructor not viable: no known conversion from 'Vector *' to 'const Vector &amp;' for 1st argument; dereference the argument with * Vector::Vector(const Vector &amp;v1){ </code></pre> <p>I also have a magnitude function:</p> <pre><code>double Vector::magnitude(){ return std::pow(dot(this, this), 0.5); } </code></pre> <p>I come from java so by the use of this I mean to say use this instance of the class and pass it in as a Vector to the dot function. I get the following error:</p> <pre><code>error: no viable conversion from 'Vector *' to 'Vector' return std::pow(dot(this, this), 0.5); </code></pre> <p>I also have a unit vector function where I try to use my constructor above to create a copy of the Vector object using <code>this</code>.</p> <pre><code>Vector Vector::getUnitVector(){ Vector unit(this); unit.scale(1/unit.magnitude()); return unit; } </code></pre> <p>I get the following error:</p> <pre><code>error: no matching constructor for initialization of 'Vector' Vector unit(this); </code></pre> <p>How can I fix these errors? Thank you.</p>
0debug
void tcg_set_frame(TCGContext *s, int reg, intptr_t start, intptr_t size) { s->frame_start = start; s->frame_end = start + size; s->frame_reg = reg; }
1threat
Android - transform Classes With Dex For Debug : <p>My project was working fine until I added the Facebook dependency. I've started getting this error. I've read many question, the problem seems to be related to <code>MultiDex</code>. But none of the solutions worked for me</p> <pre><code>Error:Execution failed for task ':app:transformClassesWithDexForDebug'. &gt; com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-openjdk-amd64/bin/java'' finished with non-zero exit value 1 </code></pre> <p>Even after I remove what I've added, it still show and also gradle seems to be taking a lot of time while building than usual </p> <p>Here is my build.gradle</p> <pre><code>apply plugin: 'com.android.application' android { compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "net.ciblo.spectrodraft" minSdkVersion 15 targetSdkVersion 23 versionCode 1 multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' repositories { mavenCentral() maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } } compile 'com.facebook.android:facebook-android-sdk:[4,5)' compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:appcompat-v7:23.2.1' compile 'com.android.support:cardview-v7:23.2.1' compile 'com.android.support:design:23.2.1' compile 'com.daimajia.easing:library:1.0.1@aar' compile 'com.daimajia.androidanimations:library:1.1.3@aar' compile 'com.google.android.gms:play-services:8.4.0' compile 'com.mcxiaoke.volley:library-aar:1.0.0' compile 'com.pnikosis:materialish-progress:1.5' compile 'com.nineoldandroids:library:2.4.+' compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT' compile 'com.android.support:support-v4:23.2.1' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' } </code></pre>
0debug
how to append <div> content in jquery : <!-- begin snippet: j s hide: false console: true babel: false --> <!-- language: lang-html --> // how to append this in j query to display dynamically. <div id="lol"> <tr data-userid="<%=iterator3.next()%>" data-mid="<%=iterator3.next()%>" > <td width="119">Practise Match</td> <%-- <td width="119"><%=iterator3.next()%><td> <td width="119"><%=iterator3.next()%> <td> --%> <td width="119"><%=iterator3.next()%>pts<td> <td width="119"><%=iterator3.next()%>rank<td> </tr></div> <!-- end snippet -->
0debug
Adding calculated column in Pandas : <p>I have a dataframe with 10 columns. I want to add a new column 'age_bmi' which should be a calculated column multiplying 'age' * 'bmi'. age is an INT, bmi is a FLOAT. </p> <p>That then creates the new dataframe with 11 columns.</p> <p>Something I am doing isn't quite right. I think it's a syntax issue. Any ideas?</p> <p>Thanks</p> <pre><code>df2['age_bmi'] = df(['age'] * ['bmi']) print(df2) </code></pre>
0debug
static void store_reg(DisasContext *s, int reg, TCGv var) { if (reg == 15) { tcg_gen_andi_i32(var, var, ~1); s->is_jmp = DISAS_JUMP; } tcg_gen_mov_i32(cpu_R[reg], var); dead_tmp(var); }
1threat
not able to run function in php : <p>I'am not able to run a function in php oops concept. My data gets inserted without checking the validation code in check_data(). My form directly points to insert_payment_cash() function.</p> <pre><code>function check_data() { $error =0; $balance = ($_POST["pay_amount"])-($_POST["cash_amount"]); $invoice_id = $_POST["id"]; if($_POST["cash_amount"]&gt;$_POST["pay_amount"]) { $_SESSION['message'] = "Amount cannot be greater than pay amount&lt;br&gt;"; $error=1; } else if($balance == 0 &amp;&amp; $_POST["penalty"] &gt; 0) { $_SESSION['message'] .= "If balance is zero(0), penalty will no be applied"; $error =1; } if($error == 1) { header("location:../payment_details.php?id=$invoice_id"); } } function insert_payment_cash() { $this-&gt;check_data(); #rest insertion code } </code></pre>
0debug
Send value or string from main.cpp to mainwindow.cpp (Qt Creator) : I'm a newbie in this world, but i need a help to send a value from main.cpp to mainwindow.cpp before opening the window. More or less, the process should be this: #include "mainwindow.h" #include <QApplication> int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; // some code here where I control parameters // Here I have some values and/or strings to send to MainWindow w.show(); return a.exec(); } Now how can I send them? I don't want to create a file where put these values. Thanks in advance for the help
0debug
Validating more than one field with Fool Proof : <p>Hello I'm using MVC <a href="http://foolproof.codeplex.com/" rel="nofollow noreferrer"><strong>Fool Proof Validation.</strong></a> to validate my model, and i need to use <code>RequiredIfNotEmpty</code> with two fields but i'm getting issues with it</p> <p><strong>Model</strong></p> <pre><code>public class Conexionado{ [DisplayName("Conexión")] [RequiredIfNotEmpty("Conex_BT2_Pos", ErrorMessage = "Error!")] [RequiredIfNotEmpty("Conex_BT2_N", ErrorMessage = "Conex_BT2 Cant be empty if Conex_BT2_N isnt!")] public string Conex_BT2 { get; set; } public string Conex_BT2_N { get; set; } [DisplayName("Ángulo BT")] [Range(0, 11, ErrorMessage = "Incorrect number")] public int? Conex_BT2_Pos { get; set; } } </code></pre> <p>I have tried some like </p> <pre><code>[RequiredIfNotEmpty("Conex_BT2_Pos , Conex_BT2_N", ErrorMessage = "Error!")] [RequiredIfNotEmpty("Conex_BT2_Pos || Conex_BT2_N", ErrorMessage = "Error!")] </code></pre> <p>But in this case, i can compile, but when i try to use <code>Conex_BT2</code> i get</p> <blockquote> <p>'System.NullReferenceException' en FoolproofValidation.dll</p> </blockquote> <p>Someone know how i must deal with it?</p> <p>Thanks!</p>
0debug
Command vue init requires a global addon : <p>When I tried to <code>vue init webpack test-app</code>, I got the following error: </p> <pre><code>Command vue init requires a global addon to be installed. Please run npm install -g @vue/cli-init and try again. </code></pre> <p>This is what I did to install <strong>vue cli</strong> v3 beta6<br> <code>npm install -g @vue/cli</code> </p> <p>This is the tutorial I followed<br> <a href="https://itnext.io/getting-started-vue-js-and-visual-studio-code-6990f92e918a" rel="noreferrer">https://itnext.io/getting-started-vue-js-and-visual-studio-code-6990f92e918a</a> </p> <p>Apparently, the tutorial does not need to install <code>@vue/cli-init</code>. I am wondering why and how to solve this issue.</p> <p>Side Notes: When I install like this <code>npm install -g vue-cli</code> it works as expected. I have found that vue-cli is a stable 2.9.x version.</p> <p>Thanks a ton!</p>
0debug
Add constant to few values in a vector - R : <p>I have a vector with 5 elements. I need to add a constant value 2nd, 3rd and 4th elements.</p> <pre><code>ar = c(0, 0, 0, 0, 0) ar = ar[2:3]+5 </code></pre> <p>Expected output:</p> <pre><code>0 5 5 5 0 </code></pre>
0debug
static int parse_pair(JSONParserContext *ctxt, QDict *dict, va_list *ap) { QObject *key = NULL, *token = NULL, *value, *peek; JSONParserContext saved_ctxt = parser_context_save(ctxt); peek = parser_context_peek_token(ctxt); if (peek == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } key = parse_value(ctxt, ap); if (!key || qobject_type(key) != QTYPE_QSTRING) { parse_error(ctxt, peek, "key is not a string in object"); goto out; } token = parser_context_pop_token(ctxt); if (token == NULL) { parse_error(ctxt, NULL, "premature EOI"); goto out; } if (!token_is_operator(token, ':')) { parse_error(ctxt, token, "missing : in object pair"); goto out; } value = parse_value(ctxt, ap); if (value == NULL) { parse_error(ctxt, token, "Missing value in dict"); goto out; } qdict_put_obj(dict, qstring_get_str(qobject_to_qstring(key)), value); qobject_decref(key); return 0; out: parser_context_restore(ctxt, saved_ctxt); qobject_decref(key); return -1; }
1threat
Connecting to SQL without freezing WPF : private async void Button_Click(object sender, RoutedEventArgs e) { var sampleMessageDialog = new SampleMessageDialog { Message = { Text = "Failed to connect" } }; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionS"].ConnectionString); try { con.Open(); // await DialogHost.Show(sampleMessageDialog, "RootDialog"); con.Close(); } catch (Exception ex) { await DialogHost.Show(sampleMessageDialog, "RootDialog"); } } Everything seem to run smoothly when the credentals are correct. However, when I put the wrong credentials for the SQL connection string, It seem to freez, the sec I click the button and the dialog only show after freez.
0debug
For Fitting in All Screen : <p>I Had Made a Website it is Complete But it does not fits all displays Like on Mobile Phones So is there any code for html or css that it should automatically fits all types of screen.</p>
0debug
How can i add inline style in JS code? : Is it possible to style inline the div ".trigger" on the following code and set its display to block ? $('.trigger').toggle(function(){ $('.greendiv').animate({'height': '300px', 'width': '400px'}, 200); }, function(){ $('.greendiv').animate({'height': '200px', 'width': '200px'}, 200); });
0debug
new icon when every click in jqery : I'm trying to do chance button icon when every click in jquery. maybe it was asked question. but i dont get why not work it. Can someone help? . my code -> html <li class="navbar-right"><a href="#"><i class="fa fa-2x fa-bars" aria-hidden="true"></i></a></li> jquery $(document).ready(function(){ var clicks; for (var clicks = 1; clicks++) { $('.fa').click(function() { if(clicks%2!==0){ $(".fa").removeClass("fa-bars"); $(".fa").addClass("fa-times"); } else{ $(".fa").removeClass("fa-times"); $(".fa").addClass("fa-bars"); } }); } });
0debug
Axios - Remove headers Authorization in 1 call only : <p>How can I remove the axios.defaults.headers.common.Authorization only in 1 call?</p> <p>I'm setting the default for all the calls to my domain but I have 1 call that I make on another domain and if the token is passed the call gives me an error, when there's no default Auth token saved everything works fine.</p> <p>So what I'm trying to do is not pass the Auth in that specific call</p> <p>I tried this but it doesn't work</p> <pre><code> loadApiCoins({ commit }) { Vue.axios({ method: 'get', url: 'https://api.coinmarketcap.com/v1/ticker/', headers: { 'Authorization': '', }, }).then(...) }, </code></pre> <p>I also tried auth: {...} but that doesn't work either. What's the solution? Thanks</p>
0debug
Creating an array of System.ValueTuple in c# 7 : <p>In my code I have:</p> <pre><code>private static readonly ValueTuple&lt;string, string&gt;[] test = {("foo", "bar"), ("baz", "foz")}; </code></pre> <p>But when I compile my code, I get:</p> <pre><code>TypoGenerator.cs(52,76): error CS1026: Unexpected symbol `,', expecting `)' TypoGenerator.cs(52,84): error CS1026: Unexpected symbol `)', expecting `)' TypoGenerator.cs(52,94): error CS1026: Unexpected symbol `,', expecting `)' TypoGenerator.cs(52,103): error CS1026: Unexpected symbol `)', expecting `)' TypoGenerator.cs(117,42): error CS1525: Unexpected symbol `(' TypoGenerator.cs(117,58): error CS1525: Unexpected symbol `[' </code></pre> <p>What is the correct way to create and initialize an array of ValueTuples?</p>
0debug
static int append_flv_data(RTMPContext *rt, RTMPPacket *pkt, int skip) { int old_flv_size, ret; PutByteContext pbc; const uint8_t *data = pkt->data + skip; const int size = pkt->size - skip; uint32_t ts = pkt->timestamp; if (pkt->type == RTMP_PT_AUDIO) { rt->has_audio = 1; } else if (pkt->type == RTMP_PT_VIDEO) { rt->has_video = 1; } old_flv_size = update_offset(rt, size + 15); if ((ret = av_reallocp(&rt->flv_data, rt->flv_size)) < 0) { rt->flv_size = rt->flv_off = 0; return ret; } bytestream2_init_writer(&pbc, rt->flv_data, rt->flv_size); bytestream2_skip_p(&pbc, old_flv_size); bytestream2_put_byte(&pbc, pkt->type); bytestream2_put_be24(&pbc, size); bytestream2_put_be24(&pbc, ts); bytestream2_put_byte(&pbc, ts >> 24); bytestream2_put_be24(&pbc, 0); bytestream2_put_buffer(&pbc, data, size); bytestream2_put_be32(&pbc, 0); return 0; }
1threat
static uint64_t cchip_read(void *opaque, hwaddr addr, unsigned size) { CPUState *cpu = current_cpu; TyphoonState *s = opaque; uint64_t ret = 0; if (addr & 4) { return s->latch_tmp; } switch (addr) { case 0x0000: break; case 0x0040: break; case 0x0080: ret = s->cchip.misc | (cpu->cpu_index & 3); break; case 0x00c0: break; case 0x0100: case 0x0140: case 0x0180: case 0x01c0: break; case 0x0200: ret = s->cchip.dim[0]; break; case 0x0240: ret = s->cchip.dim[1]; break; case 0x0280: ret = s->cchip.dim[0] & s->cchip.drir; break; case 0x02c0: ret = s->cchip.dim[1] & s->cchip.drir; break; case 0x0300: ret = s->cchip.drir; break; case 0x0340: break; case 0x0380: ret = s->cchip.iic[0]; break; case 0x03c0: ret = s->cchip.iic[1]; break; case 0x0400: case 0x0440: case 0x0480: case 0x04c0: break; case 0x0580: break; case 0x05c0: break; case 0x0600: ret = s->cchip.dim[2]; break; case 0x0640: ret = s->cchip.dim[3]; break; case 0x0680: ret = s->cchip.dim[2] & s->cchip.drir; break; case 0x06c0: ret = s->cchip.dim[3] & s->cchip.drir; break; case 0x0700: ret = s->cchip.iic[2]; break; case 0x0740: ret = s->cchip.iic[3]; break; case 0x0780: break; case 0x0c00: case 0x0c40: case 0x0c80: case 0x0cc0: break; default: cpu_unassigned_access(cpu, addr, false, false, 0, size); return -1; } s->latch_tmp = ret >> 32; return ret; }
1threat
How to demonstrate my SASS skill? : <p>I have just self taught SASS by studying the SASS documentation: <a href="http://sass-lang.com/documentation/file.SASS_REFERENCE.html" rel="nofollow noreferrer">http://sass-lang.com/documentation/file.SASS_REFERENCE.html</a>. What practical work can I do now that can best demonstrate my SASS skill and experience to employers?</p> <p>I am looking for a front-end or a web developer role around 70-80K. My current skill set is HTML5, CSS3, Bootstrap, JavaScript, jQuery, PHP, MySQL, WordPress, React, Angular, SVN and Photoshop. Thank you. :)</p>
0debug
static int32_t scalarproduct_and_madd_int32_c(int16_t *v1, const int32_t *v2, const int16_t *v3, int order, int mul) { int res = 0; while (order--) { res += *v1 * *v2++; *v1++ += mul * *v3++; } return res; }
1threat
Key Commands must all have a Title, Key and Selector : <p>I am receiving and error when trying to build, Xcode 8.0 Beta 4, and when I'm building it says "error: Illegal Configuration: Key Commands must all have a Title, Key, and Selector. Select each row in the table to check its configuration."</p> <p>It isn't on a TableView or anything, its a UIView with a Stack View inside it and some buttons, thats about it.</p> <p>And this is on a Storyboard file I'm getting the error</p> <p>I can't figure out what that might be?</p>
0debug
IntelliSense for Razor Pages routes : <p>I was toying with new Razor Pages in ASP .NET Core 2.0 and noticed some problems with IntelliSense.</p> <p>When using tag helper for MVC controller I get usual help:</p> <p><a href="https://i.stack.imgur.com/cH6j6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/cH6j6.png" alt="MVC with IntelliSense"></a></p> <p>However there is no such help for <code>asp-page</code> tag helper used in Razor Pages:</p> <p><a href="https://i.stack.imgur.com/k8Ooi.png" rel="noreferrer"><img src="https://i.stack.imgur.com/k8Ooi.png" alt="razor Pages with no help"></a></p> <p>Is this a problem with my Visual Studio or rather Razor Pages tags do not support it yet?</p> <p>I use ASP .NET Core 2.0 with framework 4.7 on VS 2017 15.5.5.</p>
0debug
static int nut_write_header(AVFormatContext *s) { NUTContext *nut = s->priv_data; AVIOContext *bc = s->pb; int i, j, ret; nut->avf = s; nut->version = FFMAX(NUT_STABLE_VERSION, 3 + !!nut->flags); if (nut->flags && s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { av_log(s, AV_LOG_ERROR, "The additional syncpoint modes require version %d, " "that is currently not finalized, " "please set -f_strict experimental in order to enable it.\n", nut->version); return AVERROR_EXPERIMENTAL; } nut->stream = av_calloc(s->nb_streams, sizeof(*nut->stream )); nut->chapter = av_calloc(s->nb_chapters, sizeof(*nut->chapter)); nut->time_base= av_calloc(s->nb_streams + s->nb_chapters, sizeof(*nut->time_base)); if (!nut->stream || !nut->chapter || !nut->time_base) { av_freep(&nut->stream); av_freep(&nut->chapter); av_freep(&nut->time_base); return AVERROR(ENOMEM); } for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; int ssize; AVRational time_base; ff_parse_specific_params(st->codec, &time_base.den, &ssize, &time_base.num); if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && st->codec->sample_rate) { time_base = (AVRational) {1, st->codec->sample_rate}; } else { time_base = ff_choose_timebase(s, st, 48000); } avpriv_set_pts_info(st, 64, time_base.num, time_base.den); for (j = 0; j < nut->time_base_count; j++) if (!memcmp(&time_base, &nut->time_base[j], sizeof(AVRational))) { break; } nut->time_base[j] = time_base; nut->stream[i].time_base = &nut->time_base[j]; if (j == nut->time_base_count) nut->time_base_count++; if (INT64_C(1000) * time_base.num >= time_base.den) nut->stream[i].msb_pts_shift = 7; else nut->stream[i].msb_pts_shift = 14; nut->stream[i].max_pts_distance = FFMAX(time_base.den, time_base.num) / time_base.num; } for (i = 0; i < s->nb_chapters; i++) { AVChapter *ch = s->chapters[i]; for (j = 0; j < nut->time_base_count; j++) if (!memcmp(&ch->time_base, &nut->time_base[j], sizeof(AVRational))) break; nut->time_base[j] = ch->time_base; nut->chapter[i].time_base = &nut->time_base[j]; if (j == nut->time_base_count) nut->time_base_count++; } nut->max_distance = MAX_DISTANCE; build_elision_headers(s); build_frame_code(s); av_assert0(nut->frame_code['N'].flags == FLAG_INVALID); avio_write(bc, ID_STRING, strlen(ID_STRING)); avio_w8(bc, 0); if ((ret = write_headers(s, bc)) < 0) return ret; if (s->avoid_negative_ts < 0) s->avoid_negative_ts = 1; avio_flush(bc); return 0; }
1threat
Java: check if value is 100 or 200 or 300 or x00 : <p>In java, I increase a value in a <code>while</code> statement and I would like to perform an action when this value has specific values (without hardcoding it because it can in theory go to infinite):</p> <p>100, 200, 300, x00, etc.</p> <p>I know this has a specific name, but I cannot remember it (Modulo ? But if so, how ?).</p>
0debug
jQuery - Cannot get index of an element : I want to get the index of d-flex that is inside "#Equipmentsfield_wrapper" but it doesnt working. I know that's wrong but i'm using this alert($(this).children('div').index()); <div id="Equipmentsfield_wrapper"> <div class="d-flex"> <input type="text" class="form-control" name="equipments[]" value="" required/> <a href="javascript:void(0);" id="Equipmentsadd_button" class="fieldAddDeleteIcon" title="Add field"><i class="fa fa-plus"></i></a></div> <div class="d-flex"> <input type="text" class="form-control" name="equipments[]" value="" required/> <a href="javascript:void(0);" id="Equipmentsadd_button" class="fieldAddDeleteIcon" title="Add field"><i class="fa fa-plus"></i></a></div> </div>
0debug
static void ehci_advance_async_state(EHCIState *ehci) { const int async = 1; switch(ehci_get_state(ehci, async)) { case EST_INACTIVE: if (!ehci_async_enabled(ehci)) { break; } ehci_set_state(ehci, async, EST_ACTIVE); case EST_ACTIVE: if (!ehci_async_enabled(ehci)) { ehci_queues_rip_all(ehci, async); ehci_set_state(ehci, async, EST_INACTIVE); break; } if (ehci->usbsts & USBSTS_IAA) { DPRINTF("IAA status bit still set.\n"); break; } if (ehci->asynclistaddr == 0) { break; } ehci_set_state(ehci, async, EST_WAITLISTHEAD); ehci_advance_state(ehci, async); if (ehci->usbcmd & USBCMD_IAAD) { ehci_queues_rip_unused(ehci, async, 1); DPRINTF("ASYNC: doorbell request acknowledged\n"); ehci->usbcmd &= ~USBCMD_IAAD; ehci_set_interrupt(ehci, USBSTS_IAA); } break; default: fprintf(stderr, "ehci: Bad asynchronous state %d. " "Resetting to active\n", ehci->astate); assert(0); } }
1threat
void qemu_ram_free(ram_addr_t addr) { RAMBlock *block; qemu_mutex_lock_ramlist(); QTAILQ_FOREACH(block, &ram_list.blocks, next) { if (addr == block->offset) { QTAILQ_REMOVE(&ram_list.blocks, block, next); ram_list.mru_block = NULL; ram_list.version++; if (block->flags & RAM_PREALLOC_MASK) { ; } else if (xen_enabled()) { xen_invalidate_map_cache_entry(block->host); } else if (mem_path) { #if defined (__linux__) && !defined(TARGET_S390X) if (block->fd) { munmap(block->host, block->length); close(block->fd); } else { qemu_anon_ram_free(block->host, block->length); } #else abort(); #endif } else { qemu_anon_ram_free(block->host, block->length); } g_free(block); break; } } qemu_mutex_unlock_ramlist(); }
1threat
void OPPROTO op_fdiv_ST0_FT0(void) { ST0 /= FT0; }
1threat
static void *source_return_path_thread(void *opaque) { MigrationState *ms = opaque; QEMUFile *rp = ms->rp_state.from_dst_file; uint16_t header_len, header_type; const int max_len = 512; uint8_t buf[max_len]; uint32_t tmp32, sibling_error; ram_addr_t start = 0; size_t len = 0, expected_len; int res; trace_source_return_path_thread_entry(); while (!ms->rp_state.error && !qemu_file_get_error(rp) && migration_is_setup_or_active(ms->state)) { trace_source_return_path_thread_loop_top(); header_type = qemu_get_be16(rp); header_len = qemu_get_be16(rp); if (header_type >= MIG_RP_MSG_MAX || header_type == MIG_RP_MSG_INVALID) { error_report("RP: Received invalid message 0x%04x length 0x%04x", header_type, header_len); mark_source_rp_bad(ms); goto out; } if ((rp_cmd_args[header_type].len != -1 && header_len != rp_cmd_args[header_type].len) || header_len > max_len) { error_report("RP: Received '%s' message (0x%04x) with" "incorrect length %d expecting %zu", rp_cmd_args[header_type].name, header_type, header_len, (size_t)rp_cmd_args[header_type].len); mark_source_rp_bad(ms); goto out; } res = qemu_get_buffer(rp, buf, header_len); if (res != header_len) { error_report("RP: Failed reading data for message 0x%04x" " read %d expected %d", header_type, res, header_len); mark_source_rp_bad(ms); goto out; } switch (header_type) { case MIG_RP_MSG_SHUT: sibling_error = be32_to_cpup((uint32_t *)buf); trace_source_return_path_thread_shut(sibling_error); if (sibling_error) { error_report("RP: Sibling indicated error %d", sibling_error); mark_source_rp_bad(ms); } goto out; case MIG_RP_MSG_PONG: tmp32 = be32_to_cpup((uint32_t *)buf); trace_source_return_path_thread_pong(tmp32); break; case MIG_RP_MSG_REQ_PAGES: start = be64_to_cpup((uint64_t *)buf); len = be32_to_cpup((uint32_t *)(buf + 8)); migrate_handle_rp_req_pages(ms, NULL, start, len); break; case MIG_RP_MSG_REQ_PAGES_ID: expected_len = 12 + 1; if (header_len >= expected_len) { start = be64_to_cpup((uint64_t *)buf); len = be32_to_cpup((uint32_t *)(buf + 8)); tmp32 = buf[12]; buf[13 + tmp32] = '\0'; expected_len += tmp32; } if (header_len != expected_len) { error_report("RP: Req_Page_id with length %d expecting %zd", header_len, expected_len); mark_source_rp_bad(ms); goto out; } migrate_handle_rp_req_pages(ms, (char *)&buf[13], start, len); break; default: break; } } if (rp && qemu_file_get_error(rp)) { trace_source_return_path_thread_bad_end(); mark_source_rp_bad(ms); } trace_source_return_path_thread_end(); out: ms->rp_state.from_dst_file = NULL; qemu_fclose(rp); return NULL; }
1threat
Difference between routing inside v-btn and using router-link : <p>I am learning Vue.js, and, following a tutorial, a is used to route the page to another. He used a button wrapped by this tag, and I found that using the routing directive inside the tag. I was wondering, what's the difference between this two ways of going from one page to another? Both of them seems to be producing the same behavior (and I am not sending or receiving any data when changing pages).</p> <p>Codes for comparison:</p> <p>Using <strong>v-btn</strong></p> <pre><code>&lt;v-btn :to="{name: 'songs-create'}" dark medium right bottom fab absolute class="pink" slot="action"&gt; &lt;v-icon&gt;add&lt;/v-icon&gt; &lt;/v-btn&gt; </code></pre> <p>Using <strong>router-link</strong></p> <pre><code>&lt;router-link :to="{name: 'Hello'}" tag="span" class="logo"&gt;Tab Tracker&lt;/router-link&gt; </code></pre> <p>Thanks in advance!</p>
0debug
How does this script work, when I can 1 function but 3 functions work at the same time? : <p>This code is copied from <a href="https://www.youtube.com/watch?v=XhXOsgdC9h0" rel="nofollow noreferrer">https://www.youtube.com/watch?v=XhXOsgdC9h0</a></p> <pre><code>import requests from bs4 import BeautifulSoup import operator #get all the words in the website def all_words(url,): word_list = [] source_code = requests.get(url).text #connect to url soup = BeautifulSoup(source_code, "html.parser") for before_text in soup.find_all("a", {"class": "result-title"}): content = before_text.string words = content.lower().split() #trun all words into lower case and split for each_word in words: word_list.append(each_word) clean_up_list(word_list) #remove all the symbols in each word def clean_up_list(word_list): clean_word_list = [] for word in word_list: symbols = "!@#$%^&amp;*()_+[]\"\-;',./&lt;&gt;?" for i in range(0, len(symbols)): word = word.replace(symbols[i], "") #replace all symbols with blank space if len(word) &gt; 0: #only word with length &gt; 0 can be added print(word) clean_word_list.append(word) create_dictionary(clean_word_list) #count the frequency of each word in the list def create_dictionary(clean_word_list): word_count = {} for word in clean_word_list: if word in word_count: word_count[word] += 1 else: word_count[word] = 1 for key, value in sorted(word_count.items(), key = operator.itemgetter(1)): #sort the item from the largest value print (key, value) all_words("https://cnj.craigslist.org/search/sys") </code></pre> <p>So the code just tries to count the frequency of each word in a website. I don't understand that I only call the function <code>all_words</code>, but it actually runs all the functions inside the code. How does it happen?</p> <p>Thank you!</p>
0debug
The ability to fight with Ad-Blocker : <p>I had searched by google and this forum-search and I didnt get any about this so I propose a new topic: WordPress with the ability to fight with Ad-Blocker.</p> <p>I am not an IT guy (subsea engineer) but I am having <a href="http://interresults2015.in/" rel="nofollow">website</a> with about 100 - 200 unique visitor/day now (according to adsense) as hobby (1%-4% using ad-blocker - I am lucky to have these ~97% my visitors).</p> <p>I just learn that ad-block users are about 300 mil and it is a huge problem to big publisher (they earn money from ads). Ad-blocker using bandwith, upload data to their server and some (one of them - I expect more of them) sell the data as anons.</p> <p>In accordance to the above idea, I have a question as a-non IT guys, is there a way to make WordPress to tackle ad-blocker (auto)?</p> <p>It may be a way to disarm ad-blocker. My website is like my home/house. You/Visitors can visit but please consider the owner.</p>
0debug
About statistical features of wavelet transfrom and how to find that : can anyone please help me what is mean by statistical features of wavelet transform and how to find that using the MATLAB
0debug
POWERPC_FAMILY(POWER7P)(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); dc->fw_name = "PowerPC,POWER7+"; dc->desc = "POWER7+"; dc->props = powerpc_servercpu_properties; pcc->pvr_match = ppc_pvr_match_power7; pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06; pcc->init_proc = init_proc_POWER7; pcc->check_pow = check_pow_nocheck; pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | PPC_FLOAT_FRSQRTES | PPC_FLOAT_STFIWX | PPC_FLOAT_EXT | PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | PPC_MEM_SYNC | PPC_MEM_EIEIO | PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_64B | PPC_ALTIVEC | PPC_SEGMENT_64B | PPC_SLBI | PPC_POPCNTB | PPC_POPCNTWD; pcc->insns_flags2 = PPC2_VSX | PPC2_DFP | PPC2_DBRX | PPC2_ISA205 | PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206; pcc->msr_mask = (1ull << MSR_SF) | (1ull << MSR_VR) | (1ull << MSR_VSX) | (1ull << MSR_EE) | (1ull << MSR_PR) | (1ull << MSR_FP) | (1ull << MSR_ME) | (1ull << MSR_FE0) | (1ull << MSR_SE) | (1ull << MSR_DE) | (1ull << MSR_FE1) | (1ull << MSR_IR) | (1ull << MSR_DR) | (1ull << MSR_PMM) | (1ull << MSR_RI) | (1ull << MSR_LE); pcc->mmu_model = POWERPC_MMU_2_06; #if defined(CONFIG_SOFTMMU) pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault; #endif pcc->excp_model = POWERPC_EXCP_POWER7; pcc->bus_model = PPC_FLAGS_INPUT_POWER7; pcc->bfd_mach = bfd_mach_ppc64; pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | POWERPC_FLAG_BE | POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | POWERPC_FLAG_VSX; pcc->l1_dcache_size = 0x8000; pcc->l1_icache_size = 0x8000; pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr; }
1threat
static void slavio_set_timer_irq_cpu(void *opaque, int cpu, int level) { SLAVIO_INTCTLState *s = opaque; DPRINTF("Set cpu %d local level %d\n", cpu, level); if (!s->cpu_envs[cpu]) return; if (level) { s->intreg_pending[cpu] |= s->cputimer_bit; } else { s->intreg_pending[cpu] &= ~s->cputimer_bit; } slavio_check_interrupts(s); }
1threat
Swift: How do I safe the value for variable? : so here is a brief explanation of my code: var myVar = 0 if(button image is equal to "mybutton image") { myVar = 1 print("It works") } else { myVar = 2 print("Not working") } ButtonPress { print(myVar) } The problem here is that when I run the application I see in the console that it prints "it works" but when I press the button myVar is equal to 0 again so how do I make sure when I press the button myVar will be equal to 1? Thank you!
0debug
Find most efficient groups of pairs : <h2>Problem</h2> <p>I have a group of people, and I want each person to have a 1:1 meeting with every other person in the group. A given person can only meet with one other person at a time, so I want to do the following:</p> <ol> <li>Find every possible pairing combination</li> <li>Group pairs together into "rounds" of meetings, where each person can only be in a round once, and where a round should contain as many pairs as possible to satisfy all possible pairing combinations in the smallest number of rounds.</li> </ol> <p>To demonstrate the problem in terms of desired input/output, let's say I have the following list:</p> <pre><code>&gt;&gt;&gt; people = ['Dave', 'Mary', 'Susan', 'John'] </code></pre> <p>I want to produce the following output:</p> <pre><code>&gt;&gt;&gt; for round in make_rounds(people): &gt;&gt;&gt; print(round) [('Dave', 'Mary'), ('Susan', 'John')] [('Dave', 'Susan'), ('Mary', 'John')] [('Dave', 'John'), ('Mary', 'Susan')] </code></pre> <p>If I had an odd number of people, then I would expect this result:</p> <pre><code>&gt;&gt;&gt; people = ['Dave', 'Mary', 'Susan'] &gt;&gt;&gt; for round in make_rounds(people): &gt;&gt;&gt; print(round) [('Dave', 'Mary')] [('Dave', 'Susan')] [('Mary', 'Susan')] </code></pre> <p>The key to this problem is that I need my solution to be performant (within reason). I've written code that <em>works</em>, but as the size of <code>people</code> grows it becomes exponentially slow. I don't know enough about writing performant algorithms to know whether my code is inefficient, or whether I'm simply bound by the parameters of the problem</p> <h2>What I've tried</h2> <p>Step 1 is easy: I can get all possible pairings using <code>itertools.combinations</code>:</p> <pre><code>&gt;&gt;&gt; from itertools import combinations &gt;&gt;&gt; people_pairs = set(combinations(people, 2)) &gt;&gt;&gt; print(people_pairs) {('Dave', 'Mary'), ('Dave', 'Susan'), ('Dave', 'John'), ('Mary', 'Susan'), ('Mary', 'John'), ('Susan', 'John')} </code></pre> <p>To work out the rounds themselves, I'm building a round like so:</p> <ol> <li>Create an empty <code>round</code> list</li> <li>Iterate over a copy of the <code>people_pairs</code> set calculated using the <code>combinations</code> method above</li> <li>For each person in the pair, check if there are any existing pairings inside the current <code>round</code> that already contain that individual</li> <li>If there's already a pair that contains one of the individuals, skip that pairing for this round. If not, add the pair to the round, and remove the pair from the <code>people_pairs</code> list.</li> <li>Once all the people pairs have been iterated over, append the round to a master <code>rounds</code> list</li> <li>Start again, since <code>people_pairs</code> now contains only the pairs that didn't make it into the first round</li> </ol> <p>Eventually this produces the desired result, and whittles down my people pairs until there are none left and all the rounds are calculated. I can already see that this is requiring a ridiculous number of iterations, but I don't know a better way of doing this.</p> <p>Here's my code:</p> <pre><code>from itertools import combinations # test if person already exists in any pairing inside a round of pairs def person_in_round(person, round): is_in_round = any(person in pair for pair in round) return is_in_round def make_rounds(people): people_pairs = set(combinations(people, 2)) # we will remove pairings from people_pairs whilst we build rounds, so loop as long as people_pairs is not empty while people_pairs: round = [] # make a copy of the current state of people_pairs to iterate over safely for pair in set(people_pairs): if not person_in_round(pair[0], round) and not person_in_round(pair[1], round): round.append(pair) people_pairs.remove(pair) yield round </code></pre> <p>Plotting out the performance of this method for list sizes of 100-300 using <a href="https://mycurvefit.com" rel="noreferrer">https://mycurvefit.com</a> shows that calculating rounds for a list of 1000 people would probably take around 100 minutes. Is there a more efficient way of doing this?</p> <p>Note: I'm not <em>actually</em> trying to organise a meeting of 1000 people :) this is just a simple example that represents the matching / combinatorics problem I'm trying to solve. </p>
0debug
Angular 6 - process is not defined when trying to serve application : <p>I am getting the following error when I try to serve my angular 6 application using cosmicjs:</p> <pre><code>Uncaught ReferenceError: process is not defined at Object../node_modules/cosmicjs/dist/index.js (index.js:6) at __webpack_require__ (bootstrap:81) at Object../src/app/app.component.ts (main.js:94) at __webpack_require__ (bootstrap:81) at Object../src/app/app.module.ts (app.component.ts:9) at __webpack_require__ (bootstrap:81) at Object../src/main.ts (environment.ts:18) at __webpack_require__ (bootstrap:81) at Object.0 (main.ts:12) at __webpack_require__ (bootstrap:81) </code></pre> <p>My latest theory is something to do with the process.env property being undefined.</p> <p>I'm following this tutorial <a href="https://hackernoon.com/how-to-build-an-angular-js-image-feed-ea6193fa0b75" rel="noreferrer">here</a></p> <p>and my exact code can be found <a href="https://github.com/DanielOram/gallery-app" rel="noreferrer">here</a></p> <p>The tutorial seems to be using an older version of angular that uses .angular-cli.json instead of the new angular.json and I think this is part of the issue in trying to specify the environment variables.</p>
0debug
void ff_init_vscale_pfn(SwsContext *c, yuv2planar1_fn yuv2plane1, yuv2planarX_fn yuv2planeX, yuv2interleavedX_fn yuv2nv12cX, yuv2packed1_fn yuv2packed1, yuv2packed2_fn yuv2packed2, yuv2packedX_fn yuv2packedX, yuv2anyX_fn yuv2anyX, int use_mmx) { VScalerContext *lumCtx = NULL; VScalerContext *chrCtx = NULL; int idx = c->numDesc - (c->is_internal_gamma ? 2 : 1); if (isPlanarYUV(c->dstFormat) || (isGray(c->dstFormat) && !isALPHA(c->dstFormat))) { if (!isGray(c->dstFormat)) { chrCtx = c->desc[idx].instance; chrCtx->filter[0] = use_mmx ? (int16_t*)c->chrMmxFilter : c->vChrFilter; chrCtx->filter_size = c->vChrFilterSize; chrCtx->filter_pos = c->vChrFilterPos; chrCtx->isMMX = use_mmx; --idx; if (yuv2nv12cX) chrCtx->pfn = yuv2nv12cX; else if (c->vChrFilterSize == 1) chrCtx->pfn = yuv2plane1; else chrCtx->pfn = yuv2planeX; } lumCtx = c->desc[idx].instance; lumCtx->filter[0] = use_mmx ? (int16_t*)c->lumMmxFilter : c->vLumFilter; lumCtx->filter[1] = use_mmx ? (int16_t*)c->alpMmxFilter : c->vLumFilter; lumCtx->filter_size = c->vLumFilterSize; lumCtx->filter_pos = c->vLumFilterPos; lumCtx->isMMX = use_mmx; if (c->vLumFilterSize == 1) lumCtx->pfn = yuv2plane1; else lumCtx->pfn = yuv2planeX; } else { lumCtx = c->desc[idx].instance; chrCtx = &lumCtx[1]; lumCtx->filter[0] = c->vLumFilter; lumCtx->filter_size = c->vLumFilterSize; lumCtx->filter_pos = c->vLumFilterPos; chrCtx->filter[0] = c->vChrFilter; chrCtx->filter_size = c->vChrFilterSize; chrCtx->filter_pos = c->vChrFilterPos; lumCtx->isMMX = use_mmx; chrCtx->isMMX = use_mmx; if (yuv2packedX) { if (c->yuv2packed1 && c->vLumFilterSize == 1 && c->vChrFilterSize <= 2) lumCtx->pfn = yuv2packed1; else if (c->yuv2packed2 && c->vLumFilterSize == 2 && c->vChrFilterSize == 2) lumCtx->pfn = yuv2packed2; else lumCtx->pfn = yuv2packedX; } else lumCtx->pfn = yuv2anyX; } }
1threat
MongoDB Print Pretty with PyMongo : <p>I've looked up print pretty for MongoDB, and i understand how to do it from the shell. What I can't find is how to do it with PyMongo, so that when I run it in eclipse, the output will print pretty instead of all in one line. Here's what I have right now:</p> <pre><code> cursor = collection.find({}) for document in cursor: print(document) </code></pre> <p>This prints everything in my collection, but each document in my collection just prints in one line. How can i change this to get it to print pretty?</p>
0debug
java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2 in android : I have a list of items and for some purpose, I have divided that list into two more ArrayList based on some criteria. When I have added all items of the combined list into 2 separate lists then I am not getting any error but If I add some items of the combined list into 1 and some items into 2 then I am getting an error. Tell me how to resolve "IndexOuOfBoundError." Code: Adding data from combined list to 2 lists if (modelRipeExpiryArrayList.size() > 0) { for (int i = 0; i < modelRipeExpiryArrayList.size(); i++) { if (!(modelRipeExpiryArrayList.get(i).getExpiryDate().equals("")) && modelRipeExpiryArrayList.get(i).getIsRipe() == 1) { explist.add(modelRipeExpiryArrayList.get(i).getItemName() + "@" + modelRipeExpiryArrayList.get(i).getExpiryDate()); ripeList.add(modelRipeExpiryArrayList.get(i).getItemName()); } else if ((modelRipeExpiryArrayList.get(i).getExpiryDate().equals("")) && modelRipeExpiryArrayList.get(i).getIsRipe() == 1) { ripeList.add(modelRipeExpiryArrayList.get(i).getItemName()); } else if (!(modelRipeExpiryArrayList.get(i).getExpiryDate().equals("")) && modelRipeExpiryArrayList.get(i).getIsRipe() == 0) { explist.add(modelRipeExpiryArrayList.get(i).getItemName() + "@" + modelRipeExpiryArrayList.get(i).getExpiryDate()); } } Log.e("TAG", "getInitialized: "+ripeList.size() +"((" +explist.size() ); AdapterExpHome adapterExpHome = new AdapterExpHome(getActivity(), modelRipeExpiryArrayList, explist, HomeFragment.this); RecyclerView.LayoutManager elayoutManager = new LinearLayoutManager(getActivity()); exp_list.setLayoutManager(elayoutManager); exp_list.setItemAnimator(new DefaultItemAnimator()); exp_list.setAdapter(adapterExpHome); adapterExpHome.notifyDataSetChanged(); AdapterHomeRipe adapterHomeRipe = new AdapterHomeRipe(getActivity(), modelRipeExpiryArrayList, ripeList, HomeFragment.this); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity()); ripe_list.setLayoutManager(layoutManager); ripe_list.setItemAnimator(new DefaultItemAnimator()); ripe_list.setAdapter(adapterHomeRipe); adapterHomeRipe.notifyDataSetChanged(); } Code for Adapter : public class AdapterHomeRipe extends RecyclerView.Adapter<AdapterHomeRipe.MyViewHolder> { Context context; FragmentRipe fragmentRipe; ArrayList<ModelRipeExpiry> modelRipeExpiryArrayList; ModelRipeExpiry modelRipeExpiry; ArrayList<String> ripeList; int qty; public AdapterHomeRipe(Context context, ArrayList<ModelRipeExpiry> modelRipeExpiryArrayList, ArrayList<String> ripeList, HomeFragment homeFragment) { this.context = context; this.modelRipeExpiryArrayList = modelRipeExpiryArrayList; this.ripeList = ripeList; this.fragmentRipe = fragmentRipe; } @NonNull @Override public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { final View itemView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.item_ripe_home, parent, false); return new MyViewHolder(itemView); } @Override public void onBindViewHolder(@NonNull final MyViewHolder holder, final int position) { modelRipeExpiry = modelRipeExpiryArrayList.get(position); Log.e("TAG", "adapterRipe: "+ ripeList.get(position)); // holder.txtRipeVeggie.setText(ripeList.get(position)); if (position % 2 == 0) { holder.layRipe.setBackgroundColor(context.getResources().getColor(R.color.lightGrey)); } else { holder.layRipe.setBackgroundColor(context.getResources().getColor(R.color.white)); } } @Override public long getItemId(int position) { return position; } @Override public int getItemViewType(int position) { return position; } @Override public int getItemCount() { return modelRipeExpiryArrayList.size(); } private static class ViewHolder { } public class MyViewHolder extends RecyclerView.ViewHolder { TextView txtRipeVeggie; RelativeLayout layRipe; LinearLayout layMain; public MyViewHolder(View itemView) { super(itemView); layRipe = (RelativeLayout) itemView.findViewById(R.id.layRipe); txtRipeVeggie = (TextView) itemView.findViewById(R.id.txtRipeVeggie) ; layMain = (LinearLayout) itemView.findViewById(R.id.layMain) ; } } }
0debug
I want my horizontal scroll bar enable all the time : <p>I want my horizontal scroll bar enable all the time. Actually when I scroll horizontally it comes up and when I move my pointer anywhere else then it gets hidden all the time, so I don't want it to be disabled. Please help...</p>
0debug
void arm_v7m_cpu_do_interrupt(CPUState *cs) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; uint32_t lr; arm_log_exception(cs->exception_index); switch (cs->exception_index) { case EXCP_UDEF: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_UNDEFINSTR_MASK; break; case EXCP_NOCP: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_NOCP_MASK; break; case EXCP_INVSTATE: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_USAGE, env->v7m.secure); env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_INVSTATE_MASK; break; case EXCP_SWI: armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_SVC, env->v7m.secure); break; case EXCP_PREFETCH_ABORT: case EXCP_DATA_ABORT: switch (env->exception.fsr & 0xf) { case 0x8: switch (cs->exception_index) { case EXCP_PREFETCH_ABORT: env->v7m.cfsr[M_REG_NS] |= R_V7M_CFSR_IBUSERR_MASK; qemu_log_mask(CPU_LOG_INT, "...with CFSR.IBUSERR\n"); break; case EXCP_DATA_ABORT: env->v7m.cfsr[M_REG_NS] |= (R_V7M_CFSR_PRECISERR_MASK | R_V7M_CFSR_BFARVALID_MASK); env->v7m.bfar = env->exception.vaddress; qemu_log_mask(CPU_LOG_INT, "...with CFSR.PRECISERR and BFAR 0x%x\n", env->v7m.bfar); break; } armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_BUS, false); break; default: switch (cs->exception_index) { case EXCP_PREFETCH_ABORT: env->v7m.cfsr[env->v7m.secure] |= R_V7M_CFSR_IACCVIOL_MASK; qemu_log_mask(CPU_LOG_INT, "...with CFSR.IACCVIOL\n"); break; case EXCP_DATA_ABORT: env->v7m.cfsr[env->v7m.secure] |= (R_V7M_CFSR_DACCVIOL_MASK | R_V7M_CFSR_MMARVALID_MASK); env->v7m.mmfar[env->v7m.secure] = env->exception.vaddress; qemu_log_mask(CPU_LOG_INT, "...with CFSR.DACCVIOL and MMFAR 0x%x\n", env->v7m.mmfar[env->v7m.secure]); break; } armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_MEM, env->v7m.secure); break; } break; case EXCP_BKPT: if (semihosting_enabled()) { int nr; nr = arm_lduw_code(env, env->regs[15], arm_sctlr_b(env)) & 0xff; if (nr == 0xab) { env->regs[15] += 2; qemu_log_mask(CPU_LOG_INT, "...handling as semihosting call 0x%x\n", env->regs[0]); env->regs[0] = do_arm_semihosting(env); return; } } armv7m_nvic_set_pending(env->nvic, ARMV7M_EXCP_DEBUG, false); break; case EXCP_IRQ: break; case EXCP_EXCEPTION_EXIT: do_v7m_exception_exit(cpu); return; default: cpu_abort(cs, "Unhandled exception 0x%x\n", cs->exception_index); return; } lr = R_V7M_EXCRET_RES1_MASK | R_V7M_EXCRET_S_MASK | R_V7M_EXCRET_DCRS_MASK | R_V7M_EXCRET_FTYPE_MASK | R_V7M_EXCRET_ES_MASK; if (env->v7m.control[env->v7m.secure] & R_V7M_CONTROL_SPSEL_MASK) { lr |= R_V7M_EXCRET_SPSEL_MASK; } if (!arm_v7m_is_handler_mode(env)) { lr |= R_V7M_EXCRET_MODE_MASK; } v7m_push_stack(cpu); v7m_exception_taken(cpu, lr); qemu_log_mask(CPU_LOG_INT, "... as %d\n", env->v7m.exception); }
1threat
static int bmds_aio_inflight(BlkMigDevState *bmds, int64_t sector) { int64_t chunk = sector / (int64_t)BDRV_SECTORS_PER_DIRTY_CHUNK; if (sector < bdrv_nb_sectors(bmds->bs)) { return !!(bmds->aio_bitmap[chunk / (sizeof(unsigned long) * 8)] & (1UL << (chunk % (sizeof(unsigned long) * 8)))); } else { return 0; } }
1threat
Navigator.mediaDevices.getUserMedia not working on iOS 12 Safari : <p>As of iOS 12, <code>navigator.mediaDevices.getUserMedia()</code> is returning an error in Safari.</p> <p>To recreate this, open <a href="https://developer.apple.com/library/archive/documentation/AppleApplications/Conceptual/Safari_Developer_Guide/GettingStarted/GettingStarted.html" rel="noreferrer">iPhone Web Inspector</a>, then run this snippet in the console:</p> <pre><code>var constraints = { audio: true, video: { width: 1280, height: 720 } }; navigator.mediaDevices.getUserMedia(constraints) .then(function() { console.log('getUserMedia completed successfully.'); }) .catch(function(error) { console.log(error.name + ": " + error.message); }); </code></pre> <p>You'll see that this runs successfully in desktop browsers, and in iOS 11 Safari, but fails in iOS 12 Safari.</p> <blockquote> <p>NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.</p> </blockquote> <p>Any idea why?</p> <p><em>note: This is happening prior to the user being asked if their camera can be accessed, ruling out the possibility of it being because the user denied permission.</em></p>
0debug
What is the purpose for the fallback option in ExtractTextPlugin.extract : <p>Using the example from <a href="https://github.com/webpack-contrib/extract-text-webpack-plugin" rel="noreferrer">webpack-contrib/extract-text-webpack-plugin</a>:</p> <pre><code>const ExtractTextPlugin = require('extract-text-webpack-plugin'); module.exports = { module: { rules: [ { test: /\.scss$/, use: ExtractTextPlugin.extract({ fallback: 'style-loader', //resolve-url-loader may be chained before sass-loader if necessary use: ['css-loader', 'sass-loader'] }) } ] }, plugins: [ new ExtractTextPlugin('style.css') //if you want to pass in options, you can do so: //new ExtractTextPlugin({ // filename: 'style.css' //}) ] } </code></pre> <p>What is the purpose of the fallback option?</p> <p>How I see this snippet to work is: </p> <p>I instruct webpack to use the <code>ExtractTextPlugin</code> on every <code>.scss</code> file it encounter. I am telling <code>ExtractTextPlugin</code> to use <code>['css-loader', 'sass-loader']</code> loaders to generate the css. Webpack will then emit extra <code>style.css</code> file containing the css.</p> <p>I can then reference this file in my index.html or if I am using html-webpack-plugin it will be added automatically to it.</p> <p>I can remove the <code>fallback: 'style-loader',</code> option and everything continues to work.</p> <p>What does it mean to fallback to <code>style-loader</code>?</p> <p>How/When the fallback gets triggered?</p> <p>I understand what <code>style-loader</code> is doing and how it is modifying the DOM with style tag if I am not using the <code>ExtractTextPlugin</code>. I just can't understand the fallback option when I am using <code>ExtractTextPlugin</code>.</p>
0debug
JavaScript Event Listeners inside methods : <p>I was hoping to be able to call object methods from an event listener, however, I am unable to access object properties on the called function:</p> <pre><code>import {action} from '../desktopIntegration/actions.js' class Object { constructor() { this.property = 2 } addListener() { action.on("keyup", this.printEvent) } printEvent() { console.log(this.property) } } </code></pre> <p>This code gives the error:</p> <pre><code> unable to access property of undefined </code></pre> <p>when addListener is called.</p> <p>Is there a way to make this work? I want to keep the callback as a method function so that I can delete the listener on each instance of Object. </p> <p>Thanks!</p>
0debug
Change many values with specific : <p>I have data like this:</p> <pre><code>data.frame(text1 = c("Amazon", "Google", "other")) </code></pre> <p>Add I would like to replace whatever is in the list with a specific value</p> <pre><code>mylist &lt;- c("Amazon", "Google") </code></pre> <p>replace what is in the mylist with stock value</p> <p>Expected output:</p> <pre><code>data.frame(text1 = c("stock", "stock", "other")) </code></pre>
0debug
What are the things hiding in abstraction? : <p>Most of the people says that abstraction is hiding something and showing only functionality to the user. Can anyone explain me what are all the things you are hiding and what are all the things you are showing?? please don't explain with the examples of animal, engine, vehicle.</p>
0debug
static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *insamples) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; ShowWavesContext *showwaves = ctx->priv; const int nb_samples = insamples->audio->nb_samples; AVFilterBufferRef *outpicref = showwaves->outpicref; int linesize = outpicref ? outpicref->linesize[0] : 0; int16_t *p = (int16_t *)insamples->data[0]; int nb_channels = av_get_channel_layout_nb_channels(insamples->audio->channel_layout); int i, j, h; const int n = showwaves->n; const int x = 255 / (nb_channels * n); for (i = 0; i < nb_samples; i++) { if (showwaves->buf_idx == 0 && showwaves->sample_count_mod == 0) { showwaves->outpicref = outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN, outlink->w, outlink->h); outpicref->video->w = outlink->w; outpicref->video->h = outlink->h; outpicref->pts = insamples->pts + av_rescale_q((p - (int16_t *)insamples->data[0]) / nb_channels, (AVRational){ 1, inlink->sample_rate }, outlink->time_base); linesize = outpicref->linesize[0]; memset(outpicref->data[0], 0, showwaves->h*linesize); } for (j = 0; j < nb_channels; j++) { h = showwaves->h/2 - av_rescale(*p++, showwaves->h/2, MAX_INT16); if (h >= 0 && h < outlink->h) *(outpicref->data[0] + showwaves->buf_idx + h * linesize) += x; } showwaves->sample_count_mod++; if (showwaves->sample_count_mod == n) { showwaves->sample_count_mod = 0; showwaves->buf_idx++; } if (showwaves->buf_idx == showwaves->w) push_frame(outlink); } avfilter_unref_buffer(insamples); return 0; }
1threat
Printing space between strings when using strcat() function : <p>How to print a space between two strings using strcat() function in c language?</p>
0debug