problem
stringlengths
26
131k
labels
class label
2 classes
how can i declare pointer to different data types but they will occupy the same amount of space in memory : this is my code int main() { char *pchar; short *pshort; int *pint; long *plong; float *pfloat; double *pdouble; pchar = pshort = pint = plong = pfloat = pdouble; printf("sizeof *pchar is = %u\n",sizeof(pchar)); printf("sizeof *pshort is = %u\n",sizeof(pshort)); printf("sizeof *pint is = %u\n",sizeof(pint)); printf("sizeof *plong is = %u\n",sizeof(plong)); printf("sizeof *pfloat is = %u\n",sizeof(pfloat)); printf("sizeof *pdouble is = %u\n",sizeof(pdouble)); return 0; } /// i want Each of these pointer variables will point to different data types, but they will occupy the same amount of space in memory. how can i do that ----------
0debug
static struct omap_prcm_s *omap_prcm_init(struct omap_target_agent_s *ta, qemu_irq mpu_int, qemu_irq dsp_int, qemu_irq iva_int, struct omap_mpu_state_s *mpu) { struct omap_prcm_s *s = (struct omap_prcm_s *) g_malloc0(sizeof(struct omap_prcm_s)); s->irq[0] = mpu_int; s->irq[1] = dsp_int; s->irq[2] = iva_int; s->mpu = mpu; omap_prcm_coldreset(s); memory_region_init_io(&s->iomem0, NULL, &omap_prcm_ops, s, "omap.pcrm0", omap_l4_region_size(ta, 0)); memory_region_init_io(&s->iomem1, NULL, &omap_prcm_ops, s, "omap.pcrm1", omap_l4_region_size(ta, 1)); omap_l4_attach(ta, 0, &s->iomem0); omap_l4_attach(ta, 1, &s->iomem1); return s; }
1threat
Insert a string on regex match in ruby : <pre><code>str = "This website is &lt;a href='www.google.com'&gt;Google&lt;/a&gt;, some other website is &lt;a href='www.facebook.com'&gt;Facebook&lt;/a&gt;" style_to_add = "style='text-decoration:none;'" </code></pre> <p>I want to add the <code>style_to_add</code> string to every hyperlink. So the result becomes</p> <pre><code>str = "This website is &lt;a href='www.google.com' style='text-decoration:none;&gt;Google&lt;/a&gt;, some other website is &lt;a href='www.facebook.com' style='text-decoration:none;&gt;Facebook&lt;/a&gt;" </code></pre>
0debug
static int copy_cell(Indeo3DecodeContext *ctx, Plane *plane, Cell *cell) { int h, w, mv_x, mv_y, offset, offset_dst; uint8_t *src, *dst; offset_dst = (cell->ypos << 2) * plane->pitch + (cell->xpos << 2); dst = plane->pixels[ctx->buf_sel] + offset_dst; mv_y = cell->mv_ptr[0]; mv_x = cell->mv_ptr[1]; if ((cell->ypos << 2) + mv_y < -1 || (cell->xpos << 2) + mv_x < 0 || ((cell->ypos + cell->height) << 2) + mv_y >= plane->height || ((cell->xpos + cell->width) << 2) + mv_x >= plane->width) { av_log(ctx->avctx, AV_LOG_ERROR, "Motion vectors point out of the frame.\n"); return AVERROR_INVALIDDATA; } offset = offset_dst + mv_y * plane->pitch + mv_x; src = plane->pixels[ctx->buf_sel ^ 1] + offset; h = cell->height << 2; for (w = cell->width; w > 0;) { if (!((cell->xpos << 2) & 15) && w >= 4) { for (; w >= 4; src += 16, dst += 16, w -= 4) ctx->hdsp.put_no_rnd_pixels_tab[0][0](dst, src, plane->pitch, h); } if (!((cell->xpos << 2) & 7) && w >= 2) { ctx->hdsp.put_no_rnd_pixels_tab[1][0](dst, src, plane->pitch, h); w -= 2; src += 8; dst += 8; } if (w >= 1) { ctx->hdsp.put_no_rnd_pixels_tab[2][0](dst, src, plane->pitch, h); w--; src += 4; dst += 4; } } return 0; }
1threat
static int vqf_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { VqfContext *c = s->priv_data; AVStream *st; int ret; int64_t pos; st = s->streams[stream_index]; pos = av_rescale_rnd(timestamp * st->codec->bit_rate, st->time_base.num, st->time_base.den * (int64_t)c->frame_bit_len, (flags & AVSEEK_FLAG_BACKWARD) ? AV_ROUND_DOWN : AV_ROUND_UP); pos *= c->frame_bit_len; st->cur_dts = av_rescale(pos, st->time_base.den, st->codec->bit_rate * (int64_t)st->time_base.num); if ((ret = avio_seek(s->pb, ((pos-7) >> 3) + s->internal->data_offset, SEEK_SET)) < 0) return ret; c->remaining_bits = -7 - ((pos-7)&7); return 0; }
1threat
Invoke function on each element of collection : <p>We have a list of cars - <code>List&lt;Car&gt;</code></p> <pre><code>Car{ String name; String year; String getName(){ return name;} String getYear(){ return year;} ... ...... } </code></pre> <p>For each car in the list,we would need to call function isVintage(String carName,.....).<br> All cars which return true for the above check need to be collected into a list.<br> Is this possible using Streams?</p>
0debug
static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque, uint64_t flags) { Error *local_err = NULL, **errp = &local_err; QEMUFileRDMA *rfile = opaque; RDMAContext *rdma = rfile->rdma; RDMAControlHeader head = { .len = 0, .repeat = 1 }; int ret = 0; CHECK_ERROR_STATE(); qemu_fflush(f); ret = qemu_rdma_drain_cq(f, rdma); if (ret < 0) { goto err; } if (flags == RAM_CONTROL_SETUP) { RDMAControlHeader resp = {.type = RDMA_CONTROL_RAM_BLOCKS_RESULT }; RDMALocalBlocks *local = &rdma->local_ram_blocks; int reg_result_idx, i, j, nb_remote_blocks; head.type = RDMA_CONTROL_RAM_BLOCKS_REQUEST; DPRINTF("Sending registration setup for ram blocks...\n"); ret = qemu_rdma_exchange_send(rdma, &head, NULL, &resp, &reg_result_idx, rdma->pin_all ? qemu_rdma_reg_whole_ram_blocks : NULL); if (ret < 0) { ERROR(errp, "receiving remote info!"); return ret; } qemu_rdma_move_header(rdma, reg_result_idx, &resp); memcpy(rdma->block, rdma->wr_data[reg_result_idx].control_curr, resp.len); nb_remote_blocks = resp.len / sizeof(RDMARemoteBlock); if (local->nb_blocks != nb_remote_blocks) { ERROR(errp, "ram blocks mismatch #1! " "Your QEMU command line parameters are probably " "not identical on both the source and destination."); return -EINVAL; } for (i = 0; i < nb_remote_blocks; i++) { network_to_remote_block(&rdma->block[i]); for (j = 0; j < local->nb_blocks; j++) { if (rdma->block[i].offset != local->block[j].offset) { continue; } if (rdma->block[i].length != local->block[j].length) { ERROR(errp, "ram blocks mismatch #2! " "Your QEMU command line parameters are probably " "not identical on both the source and destination."); return -EINVAL; } local->block[j].remote_host_addr = rdma->block[i].remote_host_addr; local->block[j].remote_rkey = rdma->block[i].remote_rkey; break; } if (j >= local->nb_blocks) { ERROR(errp, "ram blocks mismatch #3! " "Your QEMU command line parameters are probably " "not identical on both the source and destination."); return -EINVAL; } } } DDDPRINTF("Sending registration finish %" PRIu64 "...\n", flags); head.type = RDMA_CONTROL_REGISTER_FINISHED; ret = qemu_rdma_exchange_send(rdma, &head, NULL, NULL, NULL, NULL); if (ret < 0) { goto err; } return 0; err: rdma->error_state = ret; return ret; }
1threat
static int cmp_int(const void *p1, const void *p2) { int left = *(const int *)p1; int right = *(const int *)p2; return ((left > right) - (left < right)); }
1threat
void do_interrupt (CPUState *env) { #if !defined(CONFIG_USER_ONLY) target_ulong offset; int cause = -1; const char *name; if (qemu_log_enabled() && env->exception_index != EXCP_EXT_INTERRUPT) { if (env->exception_index < 0 || env->exception_index > EXCP_LAST) name = "unknown"; else name = excp_names[env->exception_index]; qemu_log("%s enter: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " %s exception\n", __func__, env->active_tc.PC, env->CP0_EPC, name); } if (env->exception_index == EXCP_EXT_INTERRUPT && (env->hflags & MIPS_HFLAG_DM)) env->exception_index = EXCP_DINT; offset = 0x180; switch (env->exception_index) { case EXCP_DSS: env->CP0_Debug |= 1 << CP0DB_DSS; env->CP0_DEPC = env->active_tc.PC | !!(env->hflags & MIPS_HFLAG_M16); goto enter_debug_mode; case EXCP_DINT: env->CP0_Debug |= 1 << CP0DB_DINT; goto set_DEPC; case EXCP_DIB: env->CP0_Debug |= 1 << CP0DB_DIB; goto set_DEPC; case EXCP_DBp: env->CP0_Debug |= 1 << CP0DB_DBp; goto set_DEPC; case EXCP_DDBS: env->CP0_Debug |= 1 << CP0DB_DDBS; goto set_DEPC; case EXCP_DDBL: env->CP0_Debug |= 1 << CP0DB_DDBL; set_DEPC: env->CP0_DEPC = exception_resume_pc(env); env->hflags &= ~MIPS_HFLAG_BMASK; enter_debug_mode: env->hflags |= MIPS_HFLAG_DM | MIPS_HFLAG_64 | MIPS_HFLAG_CP0; env->hflags &= ~(MIPS_HFLAG_KSU); if (!(env->CP0_Status & (1 << CP0St_EXL))) env->CP0_Cause &= ~(1 << CP0Ca_BD); env->active_tc.PC = (int32_t)0xBFC00480; set_hflags_for_handler(env); break; case EXCP_RESET: cpu_reset(env); break; case EXCP_SRESET: env->CP0_Status |= (1 << CP0St_SR); memset(env->CP0_WatchLo, 0, sizeof(*env->CP0_WatchLo)); goto set_error_EPC; case EXCP_NMI: env->CP0_Status |= (1 << CP0St_NMI); set_error_EPC: env->CP0_ErrorEPC = exception_resume_pc(env); env->hflags &= ~MIPS_HFLAG_BMASK; env->CP0_Status |= (1 << CP0St_ERL) | (1 << CP0St_BEV); env->hflags |= MIPS_HFLAG_64 | MIPS_HFLAG_CP0; env->hflags &= ~(MIPS_HFLAG_KSU); if (!(env->CP0_Status & (1 << CP0St_EXL))) env->CP0_Cause &= ~(1 << CP0Ca_BD); env->active_tc.PC = (int32_t)0xBFC00000; set_hflags_for_handler(env); break; case EXCP_EXT_INTERRUPT: cause = 0; if (env->CP0_Cause & (1 << CP0Ca_IV)) offset = 0x200; if (env->CP0_Config3 & ((1 << CP0C3_VInt) | (1 << CP0C3_VEIC))) { unsigned int spacing; unsigned int vector; unsigned int pending = (env->CP0_Cause & CP0Ca_IP_mask) >> 8; pending &= env->CP0_Status >> 8; spacing = (env->CP0_IntCtl >> CP0IntCtl_VS) & ((1 << 6) - 1); spacing <<= 5; if (env->CP0_Config3 & (1 << CP0C3_VInt)) { for (vector = 7; vector > 0; vector--) { if (pending & (1 << vector)) { break; } } } else { vector = pending; } offset = 0x200 + vector * spacing; } goto set_EPC; case EXCP_LTLBL: cause = 1; goto set_EPC; case EXCP_TLBL: cause = 2; if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL))) { #if defined(TARGET_MIPS64) int R = env->CP0_BadVAddr >> 62; int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0; int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0; int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0; if (((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX)) && (!(env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)))) offset = 0x080; else #endif offset = 0x000; } goto set_EPC; case EXCP_TLBS: cause = 3; if (env->error_code == 1 && !(env->CP0_Status & (1 << CP0St_EXL))) { #if defined(TARGET_MIPS64) int R = env->CP0_BadVAddr >> 62; int UX = (env->CP0_Status & (1 << CP0St_UX)) != 0; int SX = (env->CP0_Status & (1 << CP0St_SX)) != 0; int KX = (env->CP0_Status & (1 << CP0St_KX)) != 0; if (((R == 0 && UX) || (R == 1 && SX) || (R == 3 && KX)) && (!(env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)))) offset = 0x080; else #endif offset = 0x000; } goto set_EPC; case EXCP_AdEL: cause = 4; goto set_EPC; case EXCP_AdES: cause = 5; goto set_EPC; case EXCP_IBE: cause = 6; goto set_EPC; case EXCP_DBE: cause = 7; goto set_EPC; case EXCP_SYSCALL: cause = 8; goto set_EPC; case EXCP_BREAK: cause = 9; goto set_EPC; case EXCP_RI: cause = 10; goto set_EPC; case EXCP_CpU: cause = 11; env->CP0_Cause = (env->CP0_Cause & ~(0x3 << CP0Ca_CE)) | (env->error_code << CP0Ca_CE); goto set_EPC; case EXCP_OVERFLOW: cause = 12; goto set_EPC; case EXCP_TRAP: cause = 13; goto set_EPC; case EXCP_FPE: cause = 15; goto set_EPC; case EXCP_C2E: cause = 18; goto set_EPC; case EXCP_MDMX: cause = 22; goto set_EPC; case EXCP_DWATCH: cause = 23; goto set_EPC; case EXCP_MCHECK: cause = 24; goto set_EPC; case EXCP_THREAD: cause = 25; goto set_EPC; case EXCP_CACHE: cause = 30; if (env->CP0_Status & (1 << CP0St_BEV)) { offset = 0x100; } else { offset = 0x20000100; } set_EPC: if (!(env->CP0_Status & (1 << CP0St_EXL))) { env->CP0_EPC = exception_resume_pc(env); if (env->hflags & MIPS_HFLAG_BMASK) { env->CP0_Cause |= (1 << CP0Ca_BD); } else { env->CP0_Cause &= ~(1 << CP0Ca_BD); } env->CP0_Status |= (1 << CP0St_EXL); env->hflags |= MIPS_HFLAG_64 | MIPS_HFLAG_CP0; env->hflags &= ~(MIPS_HFLAG_KSU); } env->hflags &= ~MIPS_HFLAG_BMASK; if (env->CP0_Status & (1 << CP0St_BEV)) { env->active_tc.PC = (int32_t)0xBFC00200; } else { env->active_tc.PC = (int32_t)(env->CP0_EBase & ~0x3ff); } env->active_tc.PC += offset; set_hflags_for_handler(env); env->CP0_Cause = (env->CP0_Cause & ~(0x1f << CP0Ca_EC)) | (cause << CP0Ca_EC); break; default: qemu_log("Invalid MIPS exception %d. Exiting\n", env->exception_index); printf("Invalid MIPS exception %d. Exiting\n", env->exception_index); exit(1); } if (qemu_log_enabled() && env->exception_index != EXCP_EXT_INTERRUPT) { qemu_log("%s: PC " TARGET_FMT_lx " EPC " TARGET_FMT_lx " cause %d\n" " S %08x C %08x A " TARGET_FMT_lx " D " TARGET_FMT_lx "\n", __func__, env->active_tc.PC, env->CP0_EPC, cause, env->CP0_Status, env->CP0_Cause, env->CP0_BadVAddr, env->CP0_DEPC); } #endif env->exception_index = EXCP_NONE; }
1threat
document.write replace page content : <p>Whenever i tried using document.write it replaces the current html page content in example i have this <strong>HTML</strong></p> <pre><code> &lt;body&gt; &lt;div&gt; &lt;h1&gt;Hello&lt;/h1&gt; &lt;/div&gt; </code></pre> <p>and this <strong>jQuery</strong></p> <pre><code>var notif = document.write("&lt;div class = 'bg' style = 'height:250px; width:400px; z-index:10; background:red;'&gt;Good Morning!&lt;/div&gt;"); $('body').append(notif).delay(5000).fadeOut() </code></pre> <p>this replace the whole page big Hello will be gone the jQuery will work after a 5 seconds it disappears then displays nothing?</p>
0debug
on click to move on next variable : <p>How can I move from one variable called <code>trench1</code> to <code>trench2</code> with click I made this code but not working </p> <pre><code>var playthis = new Audio(); var trench1 = 'songs/example1.m4a'; var trench2 = 'songs/example2.m4a'; var trench3 = 'songs/example3.mp3'; i = 0; $('.next').click(function(){ playthis.src = trench + i++; }) </code></pre> <pre class="lang-html prettyprint-override"><code>&lt;button class="next"&gt;&lt;i class="fas fa-caret-right"&gt;&lt;/i&gt;&lt;/button&gt; </code></pre>
0debug
Communication between microservices - request data : <p>I am dealing with communication between microservices.</p> <p>For example (<em>fictive example, just for the illustration</em>):</p> <ul> <li><strong>Microservice A - Store Users (getUser, etc.)</strong></li> <li><strong>Microservice B - Store Orders (createOrder, etc.)</strong></li> </ul> <p>Now if I want to add new Order from the Client app, I need to know user address. So the request would be like this:</p> <p><strong>Client -> Microservice B (createOrder for userId 5) -> Microservice A (getUser with id 5)</strong></p> <p>The microservice B will create order with details (address) from the User Microservice.</p> <p><strong>PROBLEM TO SOLVE:</strong> How effectively deal with communication between microservice A and microservice B, as we have to wait until the response come back?</p> <p><strong>OPTIONS:</strong></p> <ul> <li>Use RestAPI,</li> <li>Use AMQP, like RabbitMQ and deal with this issue via RPC. (<a href="https://www.rabbitmq.com/tutorials/tutorial-six-dotnet.html" rel="noreferrer">https://www.rabbitmq.com/tutorials/tutorial-six-dotnet.html</a>)</li> </ul> <p>I don't know <strong>what will be better for the performance</strong>. Is call faster via RabbitMQ, or RestAPI? <strong>What is the best solution for microservice architecture</strong>?</p>
0debug
Unexpected '=>' (T_DOUBLE_ARROW) : <p>I am getting the following error and I just cant find the solution to the problem. Might be anyone be able to help me? </p> <pre><code> DB::table('videos')-&gt;insert( ['video_id' =&gt; $videos[$i]-&gt;title], ['url'] =&gt; $videos[$i]-&gt;url], ['default_thumb'] =&gt; $videos[$i]-&gt;default_thumb], ['thumb'] =&gt; $videos[$i]-&gt;thumb], ['publish_date'] =&gt; $videos[$i]-&gt;publish_date], ['tags'] =&gt; $videos[$i]-&gt;tags] ); </code></pre> <p>The error message is:</p> <pre><code>FatalErrorException in VideoController.php line 33: syntax error, unexpected '=&gt;' (T_DOUBLE_ARROW) </code></pre>
0debug
struct pxa2xx_mmci_s *pxa2xx_mmci_init(target_phys_addr_t base, qemu_irq irq, void *dma) { int iomemtype; struct pxa2xx_mmci_s *s; s = (struct pxa2xx_mmci_s *) qemu_mallocz(sizeof(struct pxa2xx_mmci_s)); s->base = base; s->irq = irq; s->dma = dma; iomemtype = cpu_register_io_memory(0, pxa2xx_mmci_readfn, pxa2xx_mmci_writefn, s); cpu_register_physical_memory(base, 0x000fffff, iomemtype); s->card = sd_init(sd_bdrv); register_savevm("pxa2xx_mmci", 0, 0, pxa2xx_mmci_save, pxa2xx_mmci_load, s); return s; }
1threat
dialog - The specified child already has a parent. You must call removeView() on the child's parent first : <p>After a check demanding the user to switch on internet services and I try to click on a button my app crashes with the error message</p> <pre><code>java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. </code></pre> <p>On this line it crashes, I have tried doing this but not resolved absolutely</p> <pre><code>if(alert.getContext() != null){ alert.show(); } </code></pre> <p>This is the complete code</p> <pre><code>else if (id == R.id.xyz) { //startActivity(borrowIntent); AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this); alert.setTitle("xyz"); input.setFilters(new InputFilter[] { // Maximum 2 characters. new InputFilter.LengthFilter(6), // Digits only. DigitsKeyListener.getInstance(), }); // Digits only &amp; use numeric soft-keyboard. input.setKeyListener(DigitsKeyListener.getInstance()); input.setHint("xyz"); alert.setView(input); alert.setPositiveButton("Borrow", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if(input.getText().length() == 0) { input.setError("xyz is required !"); } else { if(isNetworkAvailable()) { xyz( input.getText().toString()); }else{ //setContentView(R.layout.main); AlertDialog.Builder builder = new AlertDialog.Builder( MainActivity.this); builder.setCancelable(false); builder.setTitle("xyz"); builder.setMessage("Please enable wifi services"); builder.setInverseBackgroundForced(true); builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivityForResult(new Intent(android.provider.Settings.ACTION_SETTINGS), 0); dialog.dismiss(); } }); AlertDialog alerts = builder.create(); alerts.show(); }//end of block } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); if(alert.getContext() != null){ alert.show(); //crashes at this line } } </code></pre> <p>Please what am I missing?</p>
0debug
How do you find a maximum value in a Swift dictionary? : <p>So, say I have a dictionary that looks like this:</p> <pre><code>var data : [Float:Float] = [0:0,1:1,2:1.414,3:2.732,4:2,5:5.236,6:3.469,7:2.693,8:5.828,9:3.201] </code></pre> <p>How would I programmatically find the highest value in the dictionary? Is there a "data.max" command or something?</p>
0debug
Unable to create a constant value of type 'System.Char' : <p>I'm getting the following error trying to group and sum some values via LINQ in EF6:</p> <blockquote> <p>Unable to create a constant value of type 'System.Char'. Only primitive types or enumeration types are supported in this context.</p> </blockquote> <p>I've looked at half a dozen similar questions on StackOverflow and can't find my issue. Here's the query:</p> <pre><code>var q = from c in _context.HoursProviderCosts where c.PatientInsuranceCompanyName == insuranceName &amp;&amp; c.HoursDate &gt;= startDate &amp;&amp; c.HoursDate &lt;= endDate group c by new { c.ID, c.PatientFirstName, c.PatientLastName } into g select new Models.InsuranceCostListItem { PatientID = g.Key.ID, PatientName = g.Key.PatientFirstName + ' ' + g.Key.PatientLastName, Total = g.Sum(x =&gt; x.ProviderRate) }; return q.ToList(); </code></pre> <p>Is it something in my grouping (which I'm new to)? The underlying EF6 model is fine (I can expand the results view of <code>_context.HoursProviderCosts</code> and look at the data just fine).</p> <p>Thanks</p> <p>Edit: method signature:</p> <pre><code>public List&lt;Models.InsuranceCostListItem&gt; InsuranceCostsListItems(DateTime periodStart, string insuranceName) { </code></pre>
0debug
static int vmd_read_header(AVFormatContext *s) { VmdDemuxContext *vmd = s->priv_data; AVIOContext *pb = s->pb; AVStream *st = NULL, *vst; unsigned int toc_offset; unsigned char *raw_frame_table; int raw_frame_table_size; int64_t current_offset; int i, j; unsigned int total_frames; int64_t current_audio_pts = 0; unsigned char chunk[BYTES_PER_FRAME_RECORD]; int num, den; int sound_buffers; avio_seek(pb, 0, SEEK_SET); if (avio_read(pb, vmd->vmd_header, VMD_HEADER_SIZE) != VMD_HEADER_SIZE) return AVERROR(EIO); if(vmd->vmd_header[24] == 'i' && vmd->vmd_header[25] == 'v' && vmd->vmd_header[26] == '3') vmd->is_indeo3 = 1; else vmd->is_indeo3 = 0; vst = avformat_new_stream(s, NULL); if (!vst) return AVERROR(ENOMEM); avpriv_set_pts_info(vst, 33, 1, 10); vmd->video_stream_index = vst->index; vst->codec->codec_type = AVMEDIA_TYPE_VIDEO; vst->codec->codec_id = vmd->is_indeo3 ? AV_CODEC_ID_INDEO3 : AV_CODEC_ID_VMDVIDEO; vst->codec->codec_tag = 0; vst->codec->width = AV_RL16(&vmd->vmd_header[12]); vst->codec->height = AV_RL16(&vmd->vmd_header[14]); if(vmd->is_indeo3 && vst->codec->width > 320){ vst->codec->width >>= 1; vst->codec->height >>= 1; } vst->codec->extradata_size = VMD_HEADER_SIZE; vst->codec->extradata = av_mallocz(VMD_HEADER_SIZE + FF_INPUT_BUFFER_PADDING_SIZE); memcpy(vst->codec->extradata, vmd->vmd_header, VMD_HEADER_SIZE); vmd->sample_rate = AV_RL16(&vmd->vmd_header[804]); if (vmd->sample_rate) { st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); vmd->audio_stream_index = st->index; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = AV_CODEC_ID_VMDAUDIO; st->codec->codec_tag = 0; if (vmd->vmd_header[811] & 0x80) { st->codec->channels = 2; st->codec->channel_layout = AV_CH_LAYOUT_STEREO; } else { st->codec->channels = 1; st->codec->channel_layout = AV_CH_LAYOUT_MONO; } st->codec->sample_rate = vmd->sample_rate; st->codec->block_align = AV_RL16(&vmd->vmd_header[806]); if (st->codec->block_align & 0x8000) { st->codec->bits_per_coded_sample = 16; st->codec->block_align = -(st->codec->block_align - 0x10000); } else { st->codec->bits_per_coded_sample = 8; } st->codec->bit_rate = st->codec->sample_rate * st->codec->bits_per_coded_sample * st->codec->channels; num = st->codec->block_align; den = st->codec->sample_rate * st->codec->channels; av_reduce(&den, &num, den, num, (1UL<<31)-1); avpriv_set_pts_info(vst, 33, num, den); avpriv_set_pts_info(st, 33, num, den); } toc_offset = AV_RL32(&vmd->vmd_header[812]); vmd->frame_count = AV_RL16(&vmd->vmd_header[6]); vmd->frames_per_block = AV_RL16(&vmd->vmd_header[18]); avio_seek(pb, toc_offset, SEEK_SET); raw_frame_table = NULL; vmd->frame_table = NULL; sound_buffers = AV_RL16(&vmd->vmd_header[808]); raw_frame_table_size = vmd->frame_count * 6; if(vmd->frame_count * vmd->frames_per_block >= UINT_MAX / sizeof(vmd_frame) - sound_buffers){ av_log(s, AV_LOG_ERROR, "vmd->frame_count * vmd->frames_per_block too large\n"); return -1; } raw_frame_table = av_malloc(raw_frame_table_size); vmd->frame_table = av_malloc((vmd->frame_count * vmd->frames_per_block + sound_buffers) * sizeof(vmd_frame)); if (!raw_frame_table || !vmd->frame_table) { av_free(raw_frame_table); av_free(vmd->frame_table); return AVERROR(ENOMEM); } if (avio_read(pb, raw_frame_table, raw_frame_table_size) != raw_frame_table_size) { av_free(raw_frame_table); av_free(vmd->frame_table); return AVERROR(EIO); } total_frames = 0; for (i = 0; i < vmd->frame_count; i++) { current_offset = AV_RL32(&raw_frame_table[6 * i + 2]); for (j = 0; j < vmd->frames_per_block; j++) { int type; uint32_t size; avio_read(pb, chunk, BYTES_PER_FRAME_RECORD); type = chunk[0]; size = AV_RL32(&chunk[2]); if(!size && type != 1) continue; switch(type) { case 1: if (!st) break; vmd->frame_table[total_frames].frame_offset = current_offset; vmd->frame_table[total_frames].stream_index = vmd->audio_stream_index; vmd->frame_table[total_frames].frame_size = size; memcpy(vmd->frame_table[total_frames].frame_record, chunk, BYTES_PER_FRAME_RECORD); vmd->frame_table[total_frames].pts = current_audio_pts; total_frames++; if(!current_audio_pts) current_audio_pts += sound_buffers - 1; else current_audio_pts++; break; case 2: vmd->frame_table[total_frames].frame_offset = current_offset; vmd->frame_table[total_frames].stream_index = vmd->video_stream_index; vmd->frame_table[total_frames].frame_size = size; memcpy(vmd->frame_table[total_frames].frame_record, chunk, BYTES_PER_FRAME_RECORD); vmd->frame_table[total_frames].pts = i; total_frames++; break; } current_offset += size; } } av_free(raw_frame_table); vmd->current_frame = 0; vmd->frame_count = total_frames; return 0; }
1threat
Onclick Litener Gridview does not work in Fragment : i have 3 fragments with gridview but onclikitem event does not work what is problem ? I did my best and I tried all of them but not true I did my best and I tried all of them but not true I did my best and I tried all of them but not true I did my best and I tried all of them but not true I did my best and I tried all of them but not true I did my best and I tried all of them but not true public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.free_video_fragment, container, false); final GridView gridview = (GridView) view.findViewById(R.id.freevideogridview); List<ItemObject> allItems = getAllItemObject(); CustomAdapter customAdapter = new CustomAdapter(getActivity(), allItems); gridview.setAdapter(customAdapter); gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, final View view, final int position, long id) { Toast.makeText(getActivity(),"Position" , Toast.LENGTH_LONG).show(); } }); return view; Layout: <GridView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/freevideogridview" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:horizontalSpacing="4dp" android:numColumns="3" android:padding="4dp" android:scrollbars="none" android:stretchMode="columnWidth" android:verticalSpacing="4dp" /> Adapter: public class CustomAdapter extends BaseAdapter { private LayoutInflater layoutinflater; private List<ItemObject> listStorage; private Context context; public CustomAdapter(Context context, List<ItemObject> customizedListView) { this.context = context; layoutinflater =(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); listStorage = customizedListView; } @Override public int getCount() { return listStorage.size(); } @Override public Object getItem(int position) { return position; } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder listViewHolder; if(convertView == null){ listViewHolder = new ViewHolder(); convertView = layoutinflater.inflate(R.layout.pop_music_list, parent, false); listViewHolder.screenShot = (ImageView)convertView.findViewById(R.id.screen_shot); listViewHolder.musicName = (TextView)convertView.findViewById(R.id.music_name); listViewHolder.musicAuthor = (TextView)convertView.findViewById(R.id.music_author); convertView.setTag(listViewHolder); }else{ listViewHolder = (ViewHolder)convertView.getTag(); } listViewHolder.screenShot.setImageResource(listStorage.get(position).getScreenShot()); listViewHolder.musicName.setText(listStorage.get(position).getMusicName()); listViewHolder.musicAuthor.setText(listStorage.get(position).getMusicAuthor()); return convertView; } static class ViewHolder{ ImageView screenShot; TextView musicName; TextView musicAuthor; } }
0debug
How to leave a team on itunes connect? : <p>I'm in multiple teams in iTunes Connect and want to leave one of these teams. I can't connect with the administrator of that team. How to do that?<br> <strong>P.S.</strong> <a href="https://stackoverflow.com/questions/8825430/how-do-you-leave-a-team-when-a-member-of-multiple-teams-on-iphone-developer-prog">This</a> answer is for Developer site only.</p>
0debug
Creating objects in android studio : I am having issues with creating objects of a class on android studio. I have created a few classes called Fan, Light and Device. When i try to instantiate Fan and Light in MainActivity.java I get these errors: - Field 'myFan' is never used - Cannot resolve symbol 'breakDevice' The code is shown below . I'd appreciate any solution to this problem. Thanks >MainActivity.java ``` public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } public Light myLight = new Light(); Fan myFan = new Fan(); myFan.breakDevice(); myLight.breakDevice(); } ``` >Fan.java ``` package com.example.codealong3; import android.util.Log; public class Fan extends Device{ public Fan() { setDeviceName("FAN"); } @Override public void breakDevice() { Log.e(getDeviceName(), "BANG ! It's broken"); } } ``` >Light.java ``` package com.example.codealong3; import android.util.Log; public class Light extends Device { public Light() { setDeviceName("LIGHT"); } @Override public void breakDevice() { Log.e(getDeviceName(), "Glass Everywhere! .. I guess that's not bad"); } } ```
0debug
static int ogg_restore(AVFormatContext *s) { struct ogg *ogg = s->priv_data; AVIOContext *bc = s->pb; struct ogg_state *ost = ogg->state; int i, err; if (!ost) return 0; ogg->state = ost->next; for (i = 0; i < ogg->nstreams; i++) av_freep(&ogg->streams[i].buf); avio_seek(bc, ost->pos, SEEK_SET); ogg->page_pos = -1; ogg->curidx = ost->curidx; ogg->nstreams = ost->nstreams; if ((err = av_reallocp_array(&ogg->streams, ogg->nstreams, sizeof(*ogg->streams))) < 0) { ogg->nstreams = 0; return err; } else memcpy(ogg->streams, ost->streams, ost->nstreams * sizeof(*ogg->streams)); av_free(ost); return 0; }
1threat
How to programmatically open the Bluetooth settings in iOS 10 : <p>I'm trying to access the Bluetooth settings through my application using swift.how can access bluetooth setting?</p> <p>Xcode version - 8.0 swift - 2.3 iOS - 10</p>
0debug
how do i get my code to return the the answer without the extra '' and () : def analyze_text(text): #removes all of the non-al charaters new_string = "" for eachLetter in text: if eachLetter.isalpha(): new_string += eachLetter #count the number of e text_count_E = text.count("E") text_count_e = text.count("e") total_e = text_count_E + text_count_e #gets the percentage of e percentage = 100 * total_e / len(new_string) return "The text contains ",len(new_string),"alphabetic characters, of which",total_e,"(",percentage,")","are 'e'"
0debug
form not working properly? : So I'm trying to make a website with offers with php. I have a function that i use in a for loop with and the results from the database are passed in the function. The code is like this: <?php function table_values($row0,$row1,$row2,$row3,$row4,$row5){ $table_element = "<div id=\"$row0\" class='tab'> <div class='tab-header'>"; switch ($row1) { case "Tiscali": $img = "<img src='images/tiscali.png' alt='Tiscali' />"; break; case "Infostrada": $img = "<img src='images/infostrada.png' alt='Infostrada' />"; break; case "Fastweb": $img = "<img src='images/fastweb.png' alt='Fastweb' />"; break; case "TIM": $img = "<img src='images/telecom-italia.png' alt='TIM' />"; break; } $table_element = $table_element . " $img <span>$row2</span></div> <div class='block'> <div class='first-set-block'> <span class='s2'>Download</span><br /><span class='s3'>$row3 Mbps</span> </div> <div class='first-set-block'> <span class='s4'>ATTIVAZIONE</span><br /><span class='s5'>GRATUITA</span> </div> </div> <div class='block'> <div class='block-header'> Costo standard </div> <div class='block-describe-standard'> <span class='s6'>&#8364; $row4</span> </div> </div> <div class='block'> <div class='block-header'> Promozione </div> <div class='block-describe-promozione'> <span class='s7'>&#8364; $row5</span> </div> </div> <div class='block'> <div class='block-header-last'> Costo 1 anno </div> <div class='block-describe-costo'> <span class='desc1'>&#8364; 21</span> <span class='desc2'>.32<br />&#8364;/mese</span> <button class='ordina-offerta'>Ordina</button> </div> </div> </div> <div class='black'> </div> <div class='popup' id='pop".$row0."'> <form method='post' action='off.php'> <span class='close'>&times;</span> <table width='100%' style='text-align: center;'> <tr> <td>Nome: </td><td><input type='text' name='nome' /></td> </tr> <tr> <td>Cognome: </td><td><input type='text' name='cognome' /></td> </tr> <tr> <td>id: </td><td><input type='text' name='id' value=\"$row0\" /></td> </tr> <tr> <td colspan='2'><input type='submit' value='Carica' class='carica' /></td> </tr> </table> </form> </div>"; return $table_element; } ?> but for one reason i want that the div black and div popup to be child of the div class tab but when i change the code from that above to this the submit button doesn't work. <?php function table_values($row0,$row1,$row2,$row3,$row4,$row5){ $table_element = "<div id=\"$row0\" class='tab'> <div class='tab-header'>"; switch ($row1) { case "Tiscali": $img = "<img src='images/tiscali.png' alt='Tiscali' />"; break; case "Infostrada": $img = "<img src='images/infostrada.png' alt='Infostrada' />"; break; case "Fastweb": $img = "<img src='images/fastweb.png' alt='Fastweb' />"; break; case "TIM": $img = "<img src='images/telecom-italia.png' alt='TIM' />"; break; } $table_element = $table_element . " $img <span>$row2</span></div> <div class='block'> <div class='first-set-block'> <span class='s2'>Download</span><br /><span class='s3'>$row3 Mbps</span> </div> <div class='first-set-block'> <span class='s4'>ATTIVAZIONE</span><br /><span class='s5'>GRATUITA</span> </div> </div> <div class='block'> <div class='block-header'> Costo standard </div> <div class='block-describe-standard'> <span class='s6'>&#8364; $row4</span> </div> </div> <div class='block'> <div class='block-header'> Promozione </div> <div class='block-describe-promozione'> <span class='s7'>&#8364; $row5</span> </div> </div> <div class='block'> <div class='block-header-last'> Costo 1 anno </div> <div class='block-describe-costo'> <span class='desc1'>&#8364; 21</span> <span class='desc2'>.32<br />&#8364;/mese</span> <button class='ordina-offerta'>Ordina</button> </div> </div> <div class='black'> </div> <div class='popup' id='pop".$row0."'> <form method='post' action='off.php'> <span class='close'>&times;</span> <table width='100%' style='text-align: center;'> <tr> <td>Nome: </td><td><input type='text' name='nome' /></td> </tr> <tr> <td>Cognome: </td><td><input type='text' name='cognome' /></td> </tr> <tr> <td>id: </td><td><input type='text' name='id' value=\"$row0\" /></td> </tr> <tr> <td colspan='2'><input type='submit' value='Carica' class='carica' /></td> </tr> </table> </form> </div></div>"; return $table_element; } ?> does any body know why. I need to make them children of tab class for jquery reasons to use the parent() function.. Thanks in advanced, hope that i was clear.
0debug
static int flic_read_packet(AVFormatContext *s, AVPacket *pkt) { FlicDemuxContext *flic = (FlicDemuxContext *)s->priv_data; ByteIOContext *pb = &s->pb; int packet_read = 0; unsigned int size; int magic; int ret = 0; unsigned char preamble[FLIC_PREAMBLE_SIZE]; while (!packet_read) { if ((ret = get_buffer(pb, preamble, FLIC_PREAMBLE_SIZE)) != FLIC_PREAMBLE_SIZE) { ret = AVERROR_IO; break; } size = LE_32(&preamble[0]); magic = LE_16(&preamble[4]); if ((magic == FLIC_CHUNK_MAGIC_1) || (magic == FLIC_CHUNK_MAGIC_2)) { if (av_new_packet(pkt, size)) { ret = AVERROR_IO; break; } pkt->stream_index = flic->video_stream_index; pkt->pts = flic->pts; memcpy(pkt->data, preamble, FLIC_PREAMBLE_SIZE); ret = get_buffer(pb, pkt->data + FLIC_PREAMBLE_SIZE, size - FLIC_PREAMBLE_SIZE); if (ret != size - FLIC_PREAMBLE_SIZE) { av_free_packet(pkt); ret = AVERROR_IO; } flic->pts += flic->frame_pts_inc; packet_read = 1; } else { url_fseek(pb, size - 6, SEEK_CUR); } } return ret; }
1threat
static inline void gen_goto_tb(DisasContext *s, int n, uint64_t dest) { TranslationBlock *tb; tb = s->tb; if (use_goto_tb(s, n, dest)) { tcg_gen_goto_tb(n); gen_a64_set_pc_im(dest); tcg_gen_exit_tb((intptr_t)tb + n); s->is_jmp = DISAS_TB_JUMP; } else { gen_a64_set_pc_im(dest); if (s->singlestep_enabled) { gen_exception_internal(EXCP_DEBUG); } tcg_gen_exit_tb(0); s->is_jmp = DISAS_JUMP; } }
1threat
static inline int cris_abs(int n) { int r; asm ("abs\t%1, %0\n" : "=r" (r) : "r" (n)); return r; }
1threat
static int kvm_handle_internal_error(CPUState *env, struct kvm_run *run) { fprintf(stderr, "KVM internal error."); if (kvm_check_extension(kvm_state, KVM_CAP_INTERNAL_ERROR_DATA)) { int i; fprintf(stderr, " Suberror: %d\n", run->internal.suberror); for (i = 0; i < run->internal.ndata; ++i) { fprintf(stderr, "extra data[%d]: %"PRIx64"\n", i, (uint64_t)run->internal.data[i]); } } else { fprintf(stderr, "\n"); } if (run->internal.suberror == KVM_INTERNAL_ERROR_EMULATION) { fprintf(stderr, "emulation failure\n"); if (!kvm_arch_stop_on_emulation_error(env)) { cpu_dump_state(env, stderr, fprintf, CPU_DUMP_CODE); return 0; } } return -1; }
1threat
Xcode is running really slow : <p>I've recently tried to use Xcode 8 to make iOS apps and to test things in Swift however it is impossible to work on as doing a simple 'print("Hello World")' takes easily over a minute to process to print it to the console, I tried doing regular development as well by creating UI buttons etc. but when I try to compile it, it is too slow to work and that is with simple things. My computer is the Mid 2012 Macbook Pro Non-retina with 4GB of RAM, not a quick computer but I can program in Python without these problems. If anyone knows some solutions please tell me! Thanks.</p>
0debug
Swift function to duplicate images for thumbnail? : I'm making a photo gallery app. I'm compressing the images NSData *imageData = UIImageJPEGRepresentation(image,0.5) and then want to create a duplicate (for thumbnails) that I'll compress even further NSData *imageData = UIImageJPEGRepresentation(image,0.2) I'm a little stuck on the middle step of how to create a duplicate, anyone know if there is a swift function for this?
0debug
Drawing a doughnut chart with columns inside to represent hourly stats in chart.js : <p>This is a chart that represents a stat per hour. This was taken from last.fm website which shows the no. of "scrobbles" (songs played) per hour.</p> <p><a href="https://i.stack.imgur.com/pgskk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pgskk.png" alt="Stats by hour chart"></a></p> <p>Is this kind of chart possible with chart.js? I have been able to find a highcharts equivalent of what I am looking for: <a href="https://www.highcharts.com/demo/polar-wind-rose" rel="nofollow noreferrer">Highcharts Windrose Example</a></p> <p>I am already using chart.js within my application and don't want to use 2 libraries to do one job. The closest I have been able to find a chart.js equivalent is this <a href="http://www.chartjs.org/samples/latest/charts/polar-area.html" rel="nofollow noreferrer">polar chart</a></p> <p>Can anyone please guide me to a resource that will help me build something like this? Or if you know a better way to represent stat by hour, I am open to that as well.</p> <p>Thanks.</p>
0debug
Cannot find module 'webpack-cli' : <p>I want to make es6 into my project so I used this tutorial <a href="https://medium.com/netscape/firebase-cloud-functions-with-typescript-and-webpack-7781c882a05b" rel="noreferrer">this tutorial</a> and when i try to write 'webpack' in cmd I get the error</p> <pre><code> Done in 8.99s. { Error: Cannot find module 'webpack-cli' at Function.Module._resolveFilename (module.js:470:15) at Function.Module._load (module.js:418:25) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at runCommand.then.result (C:\Users\adirz\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:62:14) at process._tickCallback (internal/process/next_tick.js:109:7) code: 'MODULE_NOT_FOUND' } </code></pre> <p>package.json</p> <pre><code> { "name": "functions", "scripts": { "build": "tsc", "serve": "npm run build &amp;&amp; firebase serve --only functions", "shell": "npm run build &amp;&amp; firebase functions:shell", "start": "npm run shell", "deploy": "firebase deploy --only functions", "logs": "firebase functions:log" }, "main": "lib/index.js", "dependencies": { "firebase-admin": "~5.12.0", "firebase-functions": "^1.0.1" }, "devDependencies": { "ts-loader": "^4.2.0", "typescript": "^2.5.3", "webpack": "^4.5.0", "webpack-cli": "^2.0.14", "webpack-node-externals": "^1.7.2" }, "private": true } </code></pre> <p>my folder structure</p> <p><a href="https://i.stack.imgur.com/AECzu.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/AECzu.jpg" alt="enter image description here"></a></p>
0debug
Pattern match variable scope : <p>In the <a href="https://github.com/dotnet/roslyn/blob/features/patterns/docs/features/patterns.md#scope-of-pattern-variables" rel="noreferrer">Roslyn Pattern Matching spec</a> it states that:</p> <blockquote> <p>The scope of a pattern variable is as follows:</p> <p>If the pattern appears in the condition of an if statement, its scope is the condition and controlled statement of the if statement, but not its else clause.</p> </blockquote> <p>However the latest Microsoft "What's new" <a href="https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/" rel="noreferrer">posts</a> and <a href="https://channel9.msdn.com/Events/Connect/2016/105" rel="noreferrer">presentations</a> are showing this example:</p> <pre><code>public void PrintStars(object o) { if (o is null) return; // constant pattern "null" if (!(o is int i)) return; // type pattern "int i" WriteLine(new string('*', i)); } </code></pre> <p>Which shows the pattern match <code>i</code> variable used outside the if level scope of the pattern match.</p> <p>Is this an oversight, or has the scoping been changed from the spec?</p>
0debug
static int mimic_decode_update_thread_context(AVCodecContext *avctx, const AVCodecContext *avctx_from) { MimicContext *dst = avctx->priv_data, *src = avctx_from->priv_data; int i, ret; if (avctx == avctx_from) return 0; dst->cur_index = src->next_cur_index; dst->prev_index = src->next_prev_index; memcpy(dst->flipped_ptrs, src->flipped_ptrs, sizeof(src->flipped_ptrs)); for (i = 0; i < FF_ARRAY_ELEMS(dst->frames); i++) { ff_thread_release_buffer(avctx, &dst->frames[i]); if (src->frames[i].f->data[0]) { ret = ff_thread_ref_frame(&dst->frames[i], &src->frames[i]); if (ret < 0) return ret; } } return 0; }
1threat
Can we print inside a function with a return in python? : I wonder if I can print a message inside a #python function that already returns a value? would that print aprear when I call it from the main programme or I'll just get the value returned? for exemple : def test(x,y) if x>y : print('x is bigger then y') return x else: print('y is bigger then x') return y Thanx for helping in advence
0debug
Keeping the 91' error in VBA Excel : <p>I've a 91 error on my code, nothing seems to work.</p> <p>The next code is for identify each line wich contains LOW, MEDIUM, HIGH according to another table, the problem is that my data doesn't contain 'LOW' by the time, I guess I need to add an IF so the code can start searching MEDIUM value, but I don't know how to do it. </p> <hr> <pre><code>Private Sub CommandButton1_Click() Dim DataCalc_LOW As Integer Dim DataCalc_MEDIUM As Integer Dim DataCalc_HIGH As Integer DataToCalc_LOW = Worksheets("Random Generator").Range("AL16").Value DataToCalc_MEDIUM = Worksheets("Random Generator").Range("AL17").Value DataToCalc_HIGH = Worksheets("Random Generator").Range("AL18").Value Dim x As Integer Dim y As Integer Range("I14").Select Range(Selection, Selection.End(xlDown)).Select 'x = 0 Do x = x + 1 Selection.Find(What:="LOW", After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate With ActiveCell .Interior.ColorIndex = 44 End With ActiveCell.Select Selection.Offset(0, 0).Select Range(Selection, Selection.End(xlDown)).Select Loop Until x = DataToCalc_LOW Range("I14").Select Range(Selection, Selection.End(xlDown)).Select 'y = 0 Do y = y + 1 Selection.Find(What:="MEDIUM", After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate With ActiveCell .Interior.ColorIndex = 44 End With ActiveCell.Select Selection.Offset(0, 0).Select Range(Selection, Selection.End(xlDown)).Select Loop Until y = DataToCalc_MEDIUM Range("I14").Select Range(Selection, Selection.End(xlDown)).Select 'Z = 0 Do Z = Z + 1 Selection.Find(What:="HIGH", After:=ActiveCell, LookIn:=xlFormulas, LookAt _ :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Activate With ActiveCell .Interior.ColorIndex = 44 End With ActiveCell.Select Selection.Offset(0, 0).Select Range(Selection, Selection.End(xlDown)).Select Loop Until Z = DataToCalc_HIGH For i = 15 To 5000 cuenta = WorksheetFunction.CountIf(Range("F15:F500"), Cells(i, "F")) If cuenta = 1 Then Cells(i, "I").Interior.ColorIndex = 44 End If Next 'ActiveSheet.Protect Password:="QC" End Sub </code></pre>
0debug
Is there an easy way to get something like Keras model.summary in Tensorflow? : <p>I have been working with Keras and really liked the <code>model.summary()</code> It gives a good overview of the size of the different layers and especially an overview of the number of parameters the model has.</p> <p>Is there a similar function in Tensorflow? I could find nothing on Stackoverflow or the Tensorflow API documentation.</p>
0debug
Python Error str' object is not callable : My code is: I don't understand how I am getting this error please can someone help import time import os import xlwt from datetime import datetime num = 0 def default(): global num global model global partnum global serialnum global countryorigin time.sleep(1) print ("Model: ") model = input() print () print ("Part number: ") partnum = input() print() print ("Serial Number: ") serialnum = input() print () print ("Country of origin: ") countryorigin = input() print ("Thanks") num = num+1 xlwt() def xlwt(): print ("Do you want to write to excel?") excel = input() if excel == "y" or "yes": excel() else: print ("Bye") sys.exit() def excel(): print ("Enter a spreadsheet name") name = input() wb = xlwt.Workbook() ws = wb.add_sheet(name) ws.write(0,0,"Model") ws.write(0,1,"Part Number") ws.write(0,2,"Serial Number") ws.write(0,3,"Country Of Origin") ws.write(num,0,model) ws.write(num,1,partnum) ws.write(num,2,serialnum) ws.write(num,3,countryorigin) ws.save(name) def custom(): print() def main(): print ("Welcome") print () print ("The deafult catagories are: Model, Part Number, Serial Number," "country of origin") time.sleep(1) print() dorc() def dorc(): print ("Would you like to use the default or custom?") dorc = input () if dorc == "default": default() elif dorc == "custom": custom() else: print ("Invalid input") dorc() main()
0debug
Error running adb: Error running app. Error: Activity not started, unable to resolve Intent : <p>Hi I am trying to run 'yarn android' on my react-native project. And am running into the following error:</p> <pre><code>yarn android v0.27.5 $ react-native-scripts android 10:37:45 AM: Starting packager... 10:39:34 AM: Starting Android... 10:39:37 AM: Packager started! To view your app with live reloading, point the Expo app to this QR code. You'll find the QR scanner on the Projects tab of the app. &lt;QR CODE&gt; Or enter this address in the Expo app's search bar: exp://172.19.29.31:19000 Your phone will need to be on the same local network as this computer. For links to install the Expo app, please visit https://expo.io. Logs from serving your app will appear here. Press Ctrl+C at any time to stop. Error running adb: Error running app. Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=exp://172.19.29.31:19000 flg=0x10000000 } (node:28009) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'length' of null </code></pre> <p>I used the create-react-native-app generator to setup my app and here is my project structure:</p> <pre><code>&lt;username&gt;$ls App.js app.json gen package.json App.test.js assets my-app-key.keystore stylesheet.js README.md components node_modules yarn.lock </code></pre> <p>I also tried scanning the qr code with my expo app to run my app on my phone but it goes to 100% and then crashes out of the app, or it gives the dark blue screen in which the error is "Uncaught Error" Packager is not running at http::19003" (even if the port I scan is http:19000).</p> <p>I also just now tried running 'npm start' and then 'a' for the android option but am getting the message: 11:40:20 AM: Starting Android...</p> <pre><code>Error running adb: Error running app. Error: Activity not started, unable to resolve Intent { act=android.intent.action.VIEW dat=exp://172.19.29.31:19000 flg=0x10000000 } › Press a to open Android device or emulator, or i to open iOS emulator. › Press q to display QR code. › Press r to restart packager, or R to restart packager and clear cache. › Press d to toggle development mode. (current mode: development) (node:31496) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'length' of null 11:43:30 AM: Running app on SM-T560NU in development mode 11:44:01 AM: [sane] Warning: Lost connection to watchman, reconnecting.. </code></pre> <p>Can anyone help me with this issue?</p>
0debug
How can I hide/remove ScrollBar in ScrollView in SwiftUI? : <p>If the content of the ScrollView is bigger than the screen, while scrolling, the scrollbar on the side appears. I couldn't find anything to help me hide it.</p>
0debug
Calling Method from Separate Class to MainWindow.cs : <p>I guess doing this in VB is much easier, but how do I call a method that is another class? This is what I have inside of my Sql.cs:</p> <pre><code>public static MainWindow MainWindow; public void FlLoadMembers() { SetConnection(); SqlCon.Open(); SqlCmd = SqlCon.CreateCommand(); const string commandText = "select firstname, lastname from members"; SqlAdapter = new SQLiteDataAdapter(commandText, SqlCon); DsMembers.Reset(); SqlAdapter.Fill(DsMembers); DtMembers = DsMembers.Tables[0]; MainWindow.lstPanelMembers.Items.Add(DtMembers); SqlCon.Close(); } </code></pre> <p>Trying to call this in MainWindow.cs</p> <pre><code>private MainWindow() { InitializeComponent(); GetVersion(); FlLoadMembers(); //This doesn't work apparently in C# } </code></pre>
0debug
Why is there one `Atomic*` type for many primitive type instead of a generic `Atomic<T>`? : <p>Looking at <a href="https://doc.rust-lang.org/stable/std/sync/atomic/index.html" rel="noreferrer">the <code>std::sync::atomic</code> module</a>, one can see a bunch of different <code>Atomic*</code> types, like <code>AtomicU32</code>, <code>AtomicI16</code> and more. Why is that?</p> <p>Rust has generics and – as I see it – it would be possible to add a generic <code>Atomic&lt;T&gt;</code> where <code>T</code> is bounded by some trait defined in the module (in Java-ish naming: <code>Atomicable</code>). That trait would be implemented by the types that could be handled in an atomic fashion and users could just use <code>Atomic&lt;u32&gt;</code> instead of <code>AtomicU32</code>.</p> <p><strong>Why isn't there a generic <code>Atomic&lt;T&gt;</code>? Why have a bunch of different types instead?</strong></p>
0debug
Some of my text all over the website underline automatically : <p>I'm not quite sure what's going on, but I don't want any text underline on my website and for some reason, it just got added automatically... any of you know how to fix it?</p> <p>Is it because of the browser? The Stylesheet.css?</p> <p>I'm really confuse since some of them are fine and other aren't...</p> <p>Any help is really appreciated. Thanks</p> <p>This is the website: <a href="http://cliniquedukine.com" rel="nofollow">cliniquedukine.com</a></p>
0debug
what are these operator in c++ chrono : s 10s , ns 10ns , ms 10 ms , h 10h, min 10 min : I wonder what are these operators , I know that 10s means 10 seconds , ns means milliseconds and so on and can I use litters as operators or can I overload them ?
0debug
can't open tensorboard 0.0.0.0:6006 or localhost:6006 : <p>when i use tensorboard in cmd with win10</p> <p>D:\python document\tensorflow>tensorboard --logdir=D:\python document\tensorflow Starting TensorBoard b'47' at <a href="http://0.0.0.0:6006" rel="noreferrer">http://0.0.0.0:6006</a></p> <p>But when i open the webpage,it shows </p> <p>"dial tcp 0.0.0.0:6006: connectex: The requested address is not valid in its context."</p> <p>and i tried localhost:6006 then,and it shows</p> <p>"No scalar data was found."</p> <p>so what should i do now</p>
0debug
MS SQL QUERY To ms access query : I need following query to work with MS Access. select (left(x, Charindex('.', x, 1) - 1))As 'CRT', Cast(ROUND((ABS(x) - FLOOR(ABS(x)))* cf,1) as float) As 'PCs' from ( select 36 * 1.0 / 36 as x, 36 as cf ) t
0debug
How do I make an http request using cookies on flutter? : <p>I'd like to make an http request to a remote server while properly handling cookies (eg. storing cookies sent by the server, and sending those cookies when I make subsequent requests). It'd be nice to preserve any and all cookies</p> <p>for http request I am using</p> <pre><code>static Future&lt;Map&gt; postData(Map data) async { http.Response res = await http.post(url, body: data); // post api call Map data = JSON.decode(res.body); return data; } </code></pre>
0debug
xml parseing using Swift (IOS) Help me : <p>I have this XML By URL : </p> <pre><code>&lt;NewDataSet&gt; &lt;Table&gt; &lt;ID&gt;1&lt;/ID&gt; &lt;SongName&gt;AYA LIV LIVOKIM PEL?STANKTV&lt;/SongName&gt; &lt;SongPath&gt;http://jo.sms2tv.com/PelistankApp/Songs/song1.mp3&lt;/SongPath&gt; &lt;SongImagePath&gt;http:\\jo.sms2tv.com\PelistankApp\Images\logo1.png&lt;/SongImagePath&gt; &lt;/Table&gt; &lt;Table&gt; &lt;ID&gt;2&lt;/ID&gt; &lt;SongName&gt;DîLAN PPP PELISTANK&lt;/SongName&gt; &lt;SongPath&gt;http://jo.sms2tv.com/PelistankApp/Songs/song2.mp3&lt;/SongPath&gt; &lt;SongImagePath&gt;http:\\jo.sms2tv.com\PelistankApp\Images\logo2.png&lt;/SongImagePath&gt; &lt;/Table&gt; &lt;Table&gt; &lt;ID&gt;3&lt;/ID&gt; &lt;SongName&gt;KARIN BAL DAGRIM&lt;/SongName&gt; &lt;SongPath&gt;http://jo.sms2tv.com/PelistankApp/Songs/song3.mp3&lt;/SongPath&gt; &lt;SongImagePath&gt;http:\\jo.sms2tv.com\PelistankApp\Images\logo3.png&lt;/SongImagePath&gt; &lt;/Table&gt; &lt;Table&gt; &lt;ID&gt;4&lt;/ID&gt; &lt;SongName&gt;RUKEN WERE CANE&lt;/SongName&gt; &lt;SongPath&gt;http://jo.sms2tv.com/PelistankApp/Songs/song4.mp3&lt;/SongPath&gt; &lt;SongImagePath&gt;http:\\jo.sms2tv.com\PelistankApp\Images\logo4.png&lt;/SongImagePath&gt; &lt;/Table&gt; &lt;/NewDataSet&gt; </code></pre> <p>I want Show the Song Name in the table and i maked it no problem , now i want when i clicked in a cell on the Table Give me the Song Path And Put it in NSURL , because i want use it to PLAY Song . 1 - I Show the SongName in the Table no problem . 2 - I know how make AVPlayer To PLAY Song Just i want when clicked on the CELL Give me the SongPath and put it in NSURL </p> <p>And This is my Swift Code :</p> <pre><code>class ViewController: UIViewController, NSXMLParserDelegate, UITableViewDataSource, UITableViewDelegate { @IBOutlet var tbData : UITableView? var parser = NSXMLParser() var posts = NSMutableArray() var elements = NSMutableDictionary() var element = NSString() var title1 = NSMutableString() var date = NSMutableString() override func viewDidLoad() { // Do any additional setup after loading the view, typically from a nib. super.viewDidLoad() self.beginParsing() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func beginParsing() { posts = [] parser = NSXMLParser(contentsOfURL:(NSURL(string:"http://jo.sms2tv.com/PelistankApp2/getsongs.aspx"))!)! parser.delegate = self parser.parse() tbData?.reloadData() } //////////////////////////////////////XMLParser Methods func parser(parser: NSXMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String]) { element = elementName if (elementName as NSString).isEqualToString("Table") { elements = NSMutableDictionary() elements = [:] title1 = NSMutableString() title1 = "" date = NSMutableString() date = "" } } func parser(parser: NSXMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?) { if (elementName as NSString).isEqualToString("Table") { if !title1.isEqual(nil) { elements.setObject(title1, forKey: "title") } if !date.isEqual(nil) { elements.setObject(date, forKey: "date") } posts.addObject(elements) } } func parser(parser: NSXMLParser, foundCharacters string: String) { if element.isEqualToString("SongName") { title1.appendString(string) } else if element.isEqualToString("SongPath") { date.appendString(string) } } ///////////////////////////////////////////XMLParser Methods //////////////////////////////Tableview Methods func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int { return posts.count } func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -&gt; UITableViewCell { var cell : UITableViewCell = tableView.dequeueReusableCellWithIdentifier("Cell")! if(cell.isEqual(NSNull)) { cell = NSBundle.mainBundle().loadNibNamed("Cell", owner: self, options: nil) [0] as! UITableViewCell } cell.textLabel?.text = posts.objectAtIndex(indexPath.row).valueForKey("title") as! NSString as String cell.detailTextLabel?.text = posts.objectAtIndex(indexPath.row).valueForKey("date") as! NSString as String return cell as UITableViewCell } //////////////////////////////////////Tableview Methods /////// Table Action ( Cell clicked ) /////// func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { tableView.deselectRowAtIndexPath(indexPath, animated: true) let row = indexPath.row print("Row: \(row)") } /////// Table Action ( Cell clicked ) /////// @IBAction func Song(sender: UIButton) { let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("ViewSong") self.presentViewController(nextViewController, animated:true, completion:nil) } @IBAction func BackTableToHome(sender: UIBarButtonItem) { let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("Home") self.presentViewController(nextViewController, animated:true, completion:nil) } //////////Button SecandViewController //// @IBAction func SecondViewController(sender: AnyObject) { let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("ViewSong") self.presentViewController(nextViewController, animated:true, completion:nil) } } </code></pre> <p>And This is my Table </p> <p><a href="http://i.stack.imgur.com/CUEvL.png" rel="nofollow">enter image description here</a></p> <p>Any advice for this issue Thank's </p>
0debug
In JavaScript- Display a string multiplied by a variable : <p>I'd like to display a number of blank letter spaces = to the number of letters of a random word I pull from an array. </p> <p>This is for a hangman game for a class project. I have the randomly pulled word and the number of letters in that word but trying to use the variable that I've assigned that number too is proving a bit tricky. </p> <p>Any help appreciated!</p>
0debug
Protocol buffer3 and json : <p>Protocol buffer v3 claims, that library is json friendly (<a href="https://developers.google.com/protocol-buffers/docs/proto3#json" rel="noreferrer">https://developers.google.com/protocol-buffers/docs/proto3#json</a>), but I cannot find how to achieve get that mapping. Should I add some plugin, or some option into protoc, or call something special instead SerializeTo/ParseFrom?</p> <p>Is it someone who use that feature?</p>
0debug
Fatal error: Redefinition of parameter $request : <p>I have a strange error here. I am building a REST API with Slim framework.</p> <pre><code> $app-&gt;post('/createuser', function(Request $request, Response $request){ if(!haveEmptyParameters(array('email', 'password', 'name', 'school'), $response)){ $request_data = $request-&gt;getParseBody(); $email = $request_data['email']; $password = $request_data['password']; $name = $request_data['name']; $school = $request_data['school']; ... </code></pre> <p>The Error:</p> <pre><code>Fatal error: Redefinition of parameter $request in /Applications/XAMPP/xamppfiles/htdocs/RestAPIwithSLIM/public/index.php on line 17 </code></pre> <p>I DO NOT know which paramater is missing on this post function.</p> <p>Any thoughts?</p>
0debug
how to add target blank to an href.location hyperlink : <p>I'm trying to get a link in javascript to open a url in a new tab. I've found a number of posts for target="blank" using attribute and a couple other ways but can't seem to get it to work. Basically, if v_virt = "invoices" I just need the url to open in a new tab. Does anyone know the proper syntax? </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>if(v_virt=="invoices"){ location.href=('https://www.example.com/invoices/invoice?ProjectID=[@field:ProjectID]&amp;InvoiceID=[@field:InvoiceID]', '_blank'); }</code></pre> </div> </div> </p>
0debug
No provider for RouterOutletMap : <h1>Newest Angular 2.0.0 and via newest angular-cli 1.0.0-beta.14, node: 6.6.0, os: linux x64</h1> <h1>What I do:</h1> <p>1) Create new project</p> <pre><code>ng new angular-test ng g component projects ng g component typings </code></pre> <p>2) Add simple routing</p> <p>/src/app/app.component.html</p> <pre><code> &lt;router-outlet&gt;&lt;/router-outlet&gt; </code></pre> <p>/src/app/app.module.ts</p> <pre><code>export const ROUTES: Routes = [ { path: '', redirectTo: '/projects', pathMatch: 'full' }, { path: 'projects', component: ProjectsComponent, }, { path: '/typings', component: TypingsComponent }, { path: '**', redirectTo: '' } ]; @NgModule({ declarations: [ AppComponent, ProjectsComponent, TypingsComponent ], imports: [ BrowserModule, FormsModule, HttpModule, RouterModule.forChild(ROUTES) ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } </code></pre> <h1>What I get:</h1> <pre><code>EXCEPTION: Error in ./AppComponent class AppComponent - inline template:3:0 caused by: No provider for RouterOutletMap! ORIGINAL EXCEPTION: No provider for RouterOutletMap! </code></pre> <p><a href="https://i.stack.imgur.com/vRffx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vRffx.png" alt="enter image description here"></a></p> <h1>How I tried to fix this</h1> <p>I tried to add RouterOutletMap to providers in AppModule, exception don't throw, but app don't redirect to projects and don't show nesting components</p>
0debug
int ff_put_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int flags) { int bps, blkalign, bytespersec, frame_size; int hdrsize; int64_t hdrstart = avio_tell(pb); int waveformatextensible; uint8_t temp[256]; uint8_t *riff_extradata = temp; uint8_t *riff_extradata_start = temp; if (!par->codec_tag || par->codec_tag > 0xffff) return -1; frame_size = av_get_audio_frame_duration2(par, par->block_align); waveformatextensible = (par->channels > 2 && par->channel_layout) || par->sample_rate > 48000 || par->codec_id == AV_CODEC_ID_EAC3 || av_get_bits_per_sample(par->codec_id) > 16; if (waveformatextensible) avio_wl16(pb, 0xfffe); else avio_wl16(pb, par->codec_tag); avio_wl16(pb, par->channels); avio_wl32(pb, par->sample_rate); if (par->codec_id == AV_CODEC_ID_ATRAC3 || par->codec_id == AV_CODEC_ID_G723_1 || par->codec_id == AV_CODEC_ID_MP2 || par->codec_id == AV_CODEC_ID_MP3 || par->codec_id == AV_CODEC_ID_GSM_MS) { bps = 0; } else { if (!(bps = av_get_bits_per_sample(par->codec_id))) { if (par->bits_per_coded_sample) bps = par->bits_per_coded_sample; else bps = 16; } } if (bps != par->bits_per_coded_sample && par->bits_per_coded_sample) { av_log(s, AV_LOG_WARNING, "requested bits_per_coded_sample (%d) " "and actually stored (%d) differ\n", par->bits_per_coded_sample, bps); } if (par->codec_id == AV_CODEC_ID_MP2) { blkalign = (144 * par->bit_rate - 1)/par->sample_rate + 1; } else if (par->codec_id == AV_CODEC_ID_MP3) { blkalign = 576 * (par->sample_rate <= (24000 + 32000)/2 ? 1 : 2); } else if (par->codec_id == AV_CODEC_ID_AC3) { blkalign = 3840; } else if (par->codec_id == AV_CODEC_ID_AAC) { blkalign = 768 * par->channels; } else if (par->codec_id == AV_CODEC_ID_G723_1) { blkalign = 24; } else if (par->block_align != 0) { blkalign = par->block_align; } else blkalign = bps * par->channels / av_gcd(8, bps); if (par->codec_id == AV_CODEC_ID_PCM_U8 || par->codec_id == AV_CODEC_ID_PCM_S24LE || par->codec_id == AV_CODEC_ID_PCM_S32LE || par->codec_id == AV_CODEC_ID_PCM_F32LE || par->codec_id == AV_CODEC_ID_PCM_F64LE || par->codec_id == AV_CODEC_ID_PCM_S16LE) { bytespersec = par->sample_rate * blkalign; } else if (par->codec_id == AV_CODEC_ID_G723_1) { bytespersec = 800; } else { bytespersec = par->bit_rate / 8; } avio_wl32(pb, bytespersec); avio_wl16(pb, blkalign); avio_wl16(pb, bps); if (par->codec_id == AV_CODEC_ID_MP3) { bytestream_put_le16(&riff_extradata, 1); bytestream_put_le32(&riff_extradata, 2); bytestream_put_le16(&riff_extradata, 1152); bytestream_put_le16(&riff_extradata, 1); bytestream_put_le16(&riff_extradata, 1393); } else if (par->codec_id == AV_CODEC_ID_MP2) { bytestream_put_le16(&riff_extradata, 2); bytestream_put_le32(&riff_extradata, par->bit_rate); bytestream_put_le16(&riff_extradata, par->channels == 2 ? 1 : 8); bytestream_put_le16(&riff_extradata, 0); bytestream_put_le16(&riff_extradata, 1); bytestream_put_le16(&riff_extradata, 16); bytestream_put_le32(&riff_extradata, 0); bytestream_put_le32(&riff_extradata, 0); } else if (par->codec_id == AV_CODEC_ID_G723_1) { bytestream_put_le32(&riff_extradata, 0x9ace0002); bytestream_put_le32(&riff_extradata, 0xaea2f732); bytestream_put_le16(&riff_extradata, 0xacde); } else if (par->codec_id == AV_CODEC_ID_GSM_MS || par->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) { bytestream_put_le16(&riff_extradata, frame_size); } else if (par->extradata_size) { riff_extradata_start = par->extradata; riff_extradata = par->extradata + par->extradata_size; } if (waveformatextensible) { int write_channel_mask = !(flags & FF_PUT_WAV_HEADER_SKIP_CHANNELMASK) && (s->strict_std_compliance < FF_COMPLIANCE_NORMAL || par->channel_layout < 0x40000); avio_wl16(pb, riff_extradata - riff_extradata_start + 22); avio_wl16(pb, bps); avio_wl32(pb, write_channel_mask ? par->channel_layout : 0); if (par->codec_id == AV_CODEC_ID_EAC3) { ff_put_guid(pb, ff_get_codec_guid(par->codec_id, ff_codec_wav_guids)); } else { avio_wl32(pb, par->codec_tag); avio_wl32(pb, 0x00100000); avio_wl32(pb, 0xAA000080); avio_wl32(pb, 0x719B3800); } } else if ((flags & FF_PUT_WAV_HEADER_FORCE_WAVEFORMATEX) || par->codec_tag != 0x0001 || riff_extradata - riff_extradata_start) { avio_wl16(pb, riff_extradata - riff_extradata_start); } avio_write(pb, riff_extradata_start, riff_extradata - riff_extradata_start); hdrsize = avio_tell(pb) - hdrstart; if (hdrsize & 1) { hdrsize++; avio_w8(pb, 0); } return hdrsize; }
1threat
def check_element(list,element): check_element=all(v== element for v in list) return check_element
0debug
Is node js is middleware? : <p>When I have started learning nodeJs , I was consider this as a server side back end language . But then I came to know from a senior developer that NodeJs is not back end , it is middle ware . </p> <p>I don't find any specific article for this point .. can anyone clear this . Is it only middle ware , or can be use as middle ware language with a server side language ?</p>
0debug
av_cold int ff_mpv_encode_init(AVCodecContext *avctx) { MpegEncContext *s = avctx->priv_data; int i, ret, format_supported; mpv_encode_defaults(s); switch (avctx->codec_id) { case AV_CODEC_ID_MPEG2VIDEO: if (avctx->pix_fmt != AV_PIX_FMT_YUV420P && avctx->pix_fmt != AV_PIX_FMT_YUV422P) { av_log(avctx, AV_LOG_ERROR, "only YUV420 and YUV422 are supported\n"); return -1; } break; case AV_CODEC_ID_MJPEG: format_supported = 0; if (avctx->pix_fmt == AV_PIX_FMT_YUVJ420P || avctx->pix_fmt == AV_PIX_FMT_YUVJ422P || (avctx->color_range == AVCOL_RANGE_JPEG && (avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV422P))) format_supported = 1; else if (avctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL && (avctx->pix_fmt == AV_PIX_FMT_YUV420P || avctx->pix_fmt == AV_PIX_FMT_YUV422P)) format_supported = 1; if (!format_supported) { av_log(avctx, AV_LOG_ERROR, "colorspace not supported in jpeg\n"); return -1; } break; default: if (avctx->pix_fmt != AV_PIX_FMT_YUV420P) { av_log(avctx, AV_LOG_ERROR, "only YUV420 is supported\n"); return -1; } } switch (avctx->pix_fmt) { case AV_PIX_FMT_YUVJ422P: case AV_PIX_FMT_YUV422P: s->chroma_format = CHROMA_422; break; case AV_PIX_FMT_YUVJ420P: case AV_PIX_FMT_YUV420P: default: s->chroma_format = CHROMA_420; break; } s->bit_rate = avctx->bit_rate; s->width = avctx->width; s->height = avctx->height; if (avctx->gop_size > 600 && avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { av_log(avctx, AV_LOG_ERROR, "Warning keyframe interval too large! reducing it ...\n"); avctx->gop_size = 600; } s->gop_size = avctx->gop_size; s->avctx = avctx; if (avctx->max_b_frames > MAX_B_FRAMES) { av_log(avctx, AV_LOG_ERROR, "Too many B-frames requested, maximum " "is %d.\n", MAX_B_FRAMES); } s->max_b_frames = avctx->max_b_frames; s->codec_id = avctx->codec->id; s->strict_std_compliance = avctx->strict_std_compliance; s->quarter_sample = (avctx->flags & AV_CODEC_FLAG_QPEL) != 0; s->mpeg_quant = avctx->mpeg_quant; s->rtp_mode = !!avctx->rtp_payload_size; s->intra_dc_precision = avctx->intra_dc_precision; s->user_specified_pts = AV_NOPTS_VALUE; if (s->gop_size <= 1) { s->intra_only = 1; s->gop_size = 12; } else { s->intra_only = 0; } #if FF_API_MOTION_EST FF_DISABLE_DEPRECATION_WARNINGS s->me_method = avctx->me_method; FF_ENABLE_DEPRECATION_WARNINGS #endif s->fixed_qscale = !!(avctx->flags & AV_CODEC_FLAG_QSCALE); #if FF_API_MPV_OPT FF_DISABLE_DEPRECATION_WARNINGS if (avctx->border_masking != 0.0) s->border_masking = avctx->border_masking; FF_ENABLE_DEPRECATION_WARNINGS #endif s->adaptive_quant = (s->avctx->lumi_masking || s->avctx->dark_masking || s->avctx->temporal_cplx_masking || s->avctx->spatial_cplx_masking || s->avctx->p_masking || s->border_masking || (s->mpv_flags & FF_MPV_FLAG_QP_RD)) && !s->fixed_qscale; s->loop_filter = !!(s->avctx->flags & AV_CODEC_FLAG_LOOP_FILTER); if (avctx->rc_max_rate && !avctx->rc_buffer_size) { av_log(avctx, AV_LOG_ERROR, "a vbv buffer size is needed, " "for encoding with a maximum bitrate\n"); return -1; } if (avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate) { av_log(avctx, AV_LOG_INFO, "Warning min_rate > 0 but min_rate != max_rate isn't recommended!\n"); } if (avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate) { av_log(avctx, AV_LOG_ERROR, "bitrate below min bitrate\n"); return -1; } if (avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate) { av_log(avctx, AV_LOG_INFO, "bitrate above max bitrate\n"); return -1; } if (avctx->rc_max_rate && avctx->rc_max_rate == avctx->bit_rate && avctx->rc_max_rate != avctx->rc_min_rate) { av_log(avctx, AV_LOG_INFO, "impossible bitrate constraints, this will fail\n"); } if (avctx->rc_buffer_size && avctx->bit_rate * (int64_t)avctx->time_base.num > avctx->rc_buffer_size * (int64_t)avctx->time_base.den) { av_log(avctx, AV_LOG_ERROR, "VBV buffer too small for bitrate\n"); return -1; } if (!s->fixed_qscale && avctx->bit_rate * av_q2d(avctx->time_base) > avctx->bit_rate_tolerance) { av_log(avctx, AV_LOG_ERROR, "bitrate tolerance too small for bitrate\n"); return -1; } if (s->avctx->rc_max_rate && s->avctx->rc_min_rate == s->avctx->rc_max_rate && (s->codec_id == AV_CODEC_ID_MPEG1VIDEO || s->codec_id == AV_CODEC_ID_MPEG2VIDEO) && 90000LL * (avctx->rc_buffer_size - 1) > s->avctx->rc_max_rate * 0xFFFFLL) { av_log(avctx, AV_LOG_INFO, "Warning vbv_delay will be set to 0xFFFF (=VBR) as the " "specified vbv buffer is too large for the given bitrate!\n"); } if ((s->avctx->flags & AV_CODEC_FLAG_4MV) && s->codec_id != AV_CODEC_ID_MPEG4 && s->codec_id != AV_CODEC_ID_H263 && s->codec_id != AV_CODEC_ID_H263P && s->codec_id != AV_CODEC_ID_FLV1) { av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n"); return -1; } if (s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE) { av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with simple mb decision\n"); return -1; } if (s->quarter_sample && s->codec_id != AV_CODEC_ID_MPEG4) { av_log(avctx, AV_LOG_ERROR, "qpel not supported by codec\n"); return -1; } if (s->max_b_frames && s->codec_id != AV_CODEC_ID_MPEG4 && s->codec_id != AV_CODEC_ID_MPEG1VIDEO && s->codec_id != AV_CODEC_ID_MPEG2VIDEO) { av_log(avctx, AV_LOG_ERROR, "b frames not supported by codec\n"); return -1; } if ((s->codec_id == AV_CODEC_ID_MPEG4 || s->codec_id == AV_CODEC_ID_H263 || s->codec_id == AV_CODEC_ID_H263P) && (avctx->sample_aspect_ratio.num > 255 || avctx->sample_aspect_ratio.den > 255)) { av_log(avctx, AV_LOG_ERROR, "Invalid pixel aspect ratio %i/%i, limit is 255/255\n", avctx->sample_aspect_ratio.num, avctx->sample_aspect_ratio.den); return -1; } if ((s->avctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME)) && s->codec_id != AV_CODEC_ID_MPEG4 && s->codec_id != AV_CODEC_ID_MPEG2VIDEO) { av_log(avctx, AV_LOG_ERROR, "interlacing not supported by codec\n"); return -1; } if (s->mpeg_quant && s->codec_id != AV_CODEC_ID_MPEG4) { av_log(avctx, AV_LOG_ERROR, "mpeg2 style quantization not supported by codec\n"); return -1; } if ((s->mpv_flags & FF_MPV_FLAG_CBP_RD) && !avctx->trellis) { av_log(avctx, AV_LOG_ERROR, "CBP RD needs trellis quant\n"); return -1; } if ((s->mpv_flags & FF_MPV_FLAG_QP_RD) && s->avctx->mb_decision != FF_MB_DECISION_RD) { av_log(avctx, AV_LOG_ERROR, "QP RD needs mbd=2\n"); return -1; } if (s->avctx->scenechange_threshold < 1000000000 && (s->avctx->flags & AV_CODEC_FLAG_CLOSED_GOP)) { av_log(avctx, AV_LOG_ERROR, "closed gop with scene change detection are not supported yet, " "set threshold to 1000000000\n"); return -1; } if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) { if (s->codec_id != AV_CODEC_ID_MPEG2VIDEO) { av_log(avctx, AV_LOG_ERROR, "low delay forcing is only available for mpeg2\n"); return -1; } if (s->max_b_frames != 0) { av_log(avctx, AV_LOG_ERROR, "b frames cannot be used with low delay\n"); return -1; } } if (s->q_scale_type == 1) { if (avctx->qmax > 12) { av_log(avctx, AV_LOG_ERROR, "non linear quant only supports qmax <= 12 currently\n"); return -1; } } if (avctx->slices > 1 && (avctx->codec_id == AV_CODEC_ID_FLV1 || avctx->codec_id == AV_CODEC_ID_H261)) { av_log(avctx, AV_LOG_ERROR, "Multiple slices are not supported by this codec\n"); return AVERROR(EINVAL); } if (s->avctx->thread_count > 1 && s->codec_id != AV_CODEC_ID_MPEG4 && s->codec_id != AV_CODEC_ID_MPEG1VIDEO && s->codec_id != AV_CODEC_ID_MPEG2VIDEO && (s->codec_id != AV_CODEC_ID_H263P)) { av_log(avctx, AV_LOG_ERROR, "multi threaded encoding not supported by codec\n"); return -1; } if (s->avctx->thread_count < 1) { av_log(avctx, AV_LOG_ERROR, "automatic thread number detection not supported by codec," "patch welcome\n"); return -1; } if (s->avctx->thread_count > 1) s->rtp_mode = 1; if (!avctx->time_base.den || !avctx->time_base.num) { av_log(avctx, AV_LOG_ERROR, "framerate not set\n"); return -1; } if (avctx->b_frame_strategy && (avctx->flags & AV_CODEC_FLAG_PASS2)) { av_log(avctx, AV_LOG_INFO, "notice: b_frame_strategy only affects the first pass\n"); avctx->b_frame_strategy = 0; } i = av_gcd(avctx->time_base.den, avctx->time_base.num); if (i > 1) { av_log(avctx, AV_LOG_INFO, "removing common factors from framerate\n"); avctx->time_base.den /= i; avctx->time_base.num /= i; } if (s->mpeg_quant || s->codec_id == AV_CODEC_ID_MPEG1VIDEO || s->codec_id == AV_CODEC_ID_MPEG2VIDEO || s->codec_id == AV_CODEC_ID_MJPEG) { s->intra_quant_bias = 3 << (QUANT_BIAS_SHIFT - 3); s->inter_quant_bias = 0; } else { s->intra_quant_bias = 0; s->inter_quant_bias = -(1 << (QUANT_BIAS_SHIFT - 2)); } #if FF_API_QUANT_BIAS FF_DISABLE_DEPRECATION_WARNINGS if (avctx->intra_quant_bias != FF_DEFAULT_QUANT_BIAS) s->intra_quant_bias = avctx->intra_quant_bias; if (avctx->inter_quant_bias != FF_DEFAULT_QUANT_BIAS) s->inter_quant_bias = avctx->inter_quant_bias; FF_ENABLE_DEPRECATION_WARNINGS #endif if (avctx->codec_id == AV_CODEC_ID_MPEG4 && s->avctx->time_base.den > (1 << 16) - 1) { av_log(avctx, AV_LOG_ERROR, "timebase %d/%d not supported by MPEG 4 standard, " "the maximum admitted value for the timebase denominator " "is %d\n", s->avctx->time_base.num, s->avctx->time_base.den, (1 << 16) - 1); return -1; } s->time_increment_bits = av_log2(s->avctx->time_base.den - 1) + 1; switch (avctx->codec->id) { case AV_CODEC_ID_MPEG1VIDEO: s->out_format = FMT_MPEG1; s->low_delay = !!(s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY); avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1); break; case AV_CODEC_ID_MPEG2VIDEO: s->out_format = FMT_MPEG1; s->low_delay = !!(s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY); avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1); s->rtp_mode = 1; break; case AV_CODEC_ID_MJPEG: s->out_format = FMT_MJPEG; s->intra_only = 1; if (!CONFIG_MJPEG_ENCODER || ff_mjpeg_encode_init(s) < 0) return -1; avctx->delay = 0; s->low_delay = 1; break; case AV_CODEC_ID_H261: if (!CONFIG_H261_ENCODER) return -1; if (ff_h261_get_picture_format(s->width, s->height) < 0) { av_log(avctx, AV_LOG_ERROR, "The specified picture size of %dx%d is not valid for the " "H.261 codec.\nValid sizes are 176x144, 352x288\n", s->width, s->height); return -1; } s->out_format = FMT_H261; avctx->delay = 0; s->low_delay = 1; s->rtp_mode = 0; break; case AV_CODEC_ID_H263: if (!CONFIG_H263_ENCODER) return -1; if (ff_match_2uint16(ff_h263_format, FF_ARRAY_ELEMS(ff_h263_format), s->width, s->height) == 8) { av_log(avctx, AV_LOG_INFO, "The specified picture size of %dx%d is not valid for " "the H.263 codec.\nValid sizes are 128x96, 176x144, " "352x288, 704x576, and 1408x1152." "Try H.263+.\n", s->width, s->height); return -1; } s->out_format = FMT_H263; avctx->delay = 0; s->low_delay = 1; break; case AV_CODEC_ID_H263P: s->out_format = FMT_H263; s->h263_plus = 1; s->h263_aic = (avctx->flags & AV_CODEC_FLAG_AC_PRED) ? 1 : 0; s->modified_quant = s->h263_aic; s->loop_filter = (avctx->flags & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0; s->unrestricted_mv = s->obmc || s->loop_filter || s->umvplus; avctx->delay = 0; s->low_delay = 1; break; case AV_CODEC_ID_FLV1: s->out_format = FMT_H263; s->h263_flv = 2; s->unrestricted_mv = 1; s->rtp_mode = 0; avctx->delay = 0; s->low_delay = 1; break; case AV_CODEC_ID_RV10: s->out_format = FMT_H263; avctx->delay = 0; s->low_delay = 1; break; case AV_CODEC_ID_RV20: s->out_format = FMT_H263; avctx->delay = 0; s->low_delay = 1; s->modified_quant = 1; s->h263_aic = 1; s->h263_plus = 1; s->loop_filter = 1; s->unrestricted_mv = 0; break; case AV_CODEC_ID_MPEG4: s->out_format = FMT_H263; s->h263_pred = 1; s->unrestricted_mv = 1; s->low_delay = s->max_b_frames ? 0 : 1; avctx->delay = s->low_delay ? 0 : (s->max_b_frames + 1); break; case AV_CODEC_ID_MSMPEG4V2: s->out_format = FMT_H263; s->h263_pred = 1; s->unrestricted_mv = 1; s->msmpeg4_version = 2; avctx->delay = 0; s->low_delay = 1; break; case AV_CODEC_ID_MSMPEG4V3: s->out_format = FMT_H263; s->h263_pred = 1; s->unrestricted_mv = 1; s->msmpeg4_version = 3; s->flipflop_rounding = 1; avctx->delay = 0; s->low_delay = 1; break; case AV_CODEC_ID_WMV1: s->out_format = FMT_H263; s->h263_pred = 1; s->unrestricted_mv = 1; s->msmpeg4_version = 4; s->flipflop_rounding = 1; avctx->delay = 0; s->low_delay = 1; break; case AV_CODEC_ID_WMV2: s->out_format = FMT_H263; s->h263_pred = 1; s->unrestricted_mv = 1; s->msmpeg4_version = 5; s->flipflop_rounding = 1; avctx->delay = 0; s->low_delay = 1; break; default: return -1; } avctx->has_b_frames = !s->low_delay; s->encoding = 1; s->progressive_frame = s->progressive_sequence = !(avctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) || s->alternate_scan); ff_mpv_idct_init(s); if (ff_mpv_common_init(s) < 0) return -1; if (ARCH_X86) ff_mpv_encode_init_x86(s); ff_fdctdsp_init(&s->fdsp, avctx); ff_me_cmp_init(&s->mecc, avctx); ff_mpegvideoencdsp_init(&s->mpvencdsp, avctx); ff_pixblockdsp_init(&s->pdsp, avctx); ff_qpeldsp_init(&s->qdsp); if (s->msmpeg4_version) { FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_stats, 2 * 2 * (MAX_LEVEL + 1) * (MAX_RUN + 1) * 2 * sizeof(int), fail); } FF_ALLOCZ_OR_GOTO(s->avctx, s->avctx->stats_out, 256, fail); FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix, 64 * 32 * sizeof(int), fail); FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix, 64 * 32 * sizeof(int), fail); FF_ALLOCZ_OR_GOTO(s->avctx, s->q_intra_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail); FF_ALLOCZ_OR_GOTO(s->avctx, s->q_inter_matrix16, 64 * 32 * 2 * sizeof(uint16_t), fail); FF_ALLOCZ_OR_GOTO(s->avctx, s->input_picture, MAX_PICTURE_COUNT * sizeof(Picture *), fail); FF_ALLOCZ_OR_GOTO(s->avctx, s->reordered_input_picture, MAX_PICTURE_COUNT * sizeof(Picture *), fail); if (s->avctx->noise_reduction) { FF_ALLOCZ_OR_GOTO(s->avctx, s->dct_offset, 2 * 64 * sizeof(uint16_t), fail); } if (CONFIG_H263_ENCODER) ff_h263dsp_init(&s->h263dsp); if (!s->dct_quantize) s->dct_quantize = ff_dct_quantize_c; if (!s->denoise_dct) s->denoise_dct = denoise_dct_c; s->fast_dct_quantize = s->dct_quantize; if (avctx->trellis) s->dct_quantize = dct_quantize_trellis_c; if ((CONFIG_H263P_ENCODER || CONFIG_RV20_ENCODER) && s->modified_quant) s->chroma_qscale_table = ff_h263_chroma_qscale_table; s->quant_precision = 5; ff_set_cmp(&s->mecc, s->mecc.ildct_cmp, s->avctx->ildct_cmp); ff_set_cmp(&s->mecc, s->mecc.frame_skip_cmp, s->avctx->frame_skip_cmp); if (CONFIG_H261_ENCODER && s->out_format == FMT_H261) ff_h261_encode_init(s); if (CONFIG_H263_ENCODER && s->out_format == FMT_H263) ff_h263_encode_init(s); if (CONFIG_MSMPEG4_ENCODER && s->msmpeg4_version) if ((ret = ff_msmpeg4_encode_init(s)) < 0) return ret; if ((CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER) && s->out_format == FMT_MPEG1) ff_mpeg1_encode_init(s); for (i = 0; i < 64; i++) { int j = s->idsp.idct_permutation[i]; if (CONFIG_MPEG4_ENCODER && s->codec_id == AV_CODEC_ID_MPEG4 && s->mpeg_quant) { s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i]; s->inter_matrix[j] = ff_mpeg4_default_non_intra_matrix[i]; } else if (s->out_format == FMT_H263 || s->out_format == FMT_H261) { s->intra_matrix[j] = s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i]; } else { s->intra_matrix[j] = ff_mpeg1_default_intra_matrix[i]; s->inter_matrix[j] = ff_mpeg1_default_non_intra_matrix[i]; } if (s->avctx->intra_matrix) s->intra_matrix[j] = s->avctx->intra_matrix[i]; if (s->avctx->inter_matrix) s->inter_matrix[j] = s->avctx->inter_matrix[i]; } if (s->out_format != FMT_MJPEG) { ff_convert_matrix(s, s->q_intra_matrix, s->q_intra_matrix16, s->intra_matrix, s->intra_quant_bias, avctx->qmin, 31, 1); ff_convert_matrix(s, s->q_inter_matrix, s->q_inter_matrix16, s->inter_matrix, s->inter_quant_bias, avctx->qmin, 31, 0); } if (ff_rate_control_init(s) < 0) return -1; #if FF_API_ERROR_RATE FF_DISABLE_DEPRECATION_WARNINGS if (avctx->error_rate) s->error_rate = avctx->error_rate; FF_ENABLE_DEPRECATION_WARNINGS; #endif #if FF_API_NORMALIZE_AQP FF_DISABLE_DEPRECATION_WARNINGS if (avctx->flags & CODEC_FLAG_NORMALIZE_AQP) s->mpv_flags |= FF_MPV_FLAG_NAQ; FF_ENABLE_DEPRECATION_WARNINGS; #endif #if FF_API_MV0 FF_DISABLE_DEPRECATION_WARNINGS if (avctx->flags & CODEC_FLAG_MV0) s->mpv_flags |= FF_MPV_FLAG_MV0; FF_ENABLE_DEPRECATION_WARNINGS #endif #if FF_API_MPV_OPT FF_DISABLE_DEPRECATION_WARNINGS if (avctx->rc_qsquish != 0.0) s->rc_qsquish = avctx->rc_qsquish; if (avctx->rc_qmod_amp != 0.0) s->rc_qmod_amp = avctx->rc_qmod_amp; if (avctx->rc_qmod_freq) s->rc_qmod_freq = avctx->rc_qmod_freq; if (avctx->rc_buffer_aggressivity != 1.0) s->rc_buffer_aggressivity = avctx->rc_buffer_aggressivity; if (avctx->rc_initial_cplx != 0.0) s->rc_initial_cplx = avctx->rc_initial_cplx; if (avctx->lmin) s->lmin = avctx->lmin; if (avctx->lmax) s->lmax = avctx->lmax; if (avctx->rc_eq) { av_freep(&s->rc_eq); s->rc_eq = av_strdup(avctx->rc_eq); if (!s->rc_eq) return AVERROR(ENOMEM); } FF_ENABLE_DEPRECATION_WARNINGS #endif if (avctx->b_frame_strategy == 2) { for (i = 0; i < s->max_b_frames + 2; i++) { s->tmp_frames[i] = av_frame_alloc(); if (!s->tmp_frames[i]) return AVERROR(ENOMEM); s->tmp_frames[i]->format = AV_PIX_FMT_YUV420P; s->tmp_frames[i]->width = s->width >> avctx->brd_scale; s->tmp_frames[i]->height = s->height >> avctx->brd_scale; ret = av_frame_get_buffer(s->tmp_frames[i], 32); if (ret < 0) return ret; } } return 0; fail: ff_mpv_encode_end(avctx); return AVERROR_UNKNOWN; }
1threat
how to make nested list go down? : I have a list inside another and want to have the parent list of elements aligned horizontally and the child list of elements aligned vertically below the <li>. But what happens is that the child's father <li> list is at the top with the list below and the rest <li> of the parent list are below aligned with the end of the child list.[enter image description here][1] [1]: http://i.stack.imgur.com/9KtRV.png
0debug
Angular 1.5 component with ng-model : <p>Is it possible to use ng-model with a component? I would like to bind a scope variable to a component with ng-model. I have <a href="http://plnkr.co/edit/72XTUweimR2fzXg35xet?p=preview">plunkered my issue</a>. I would like the component my-input to be binded to the variable from the scope userData.name.</p> <p>I am using Angular JS 1.5.6 components, and want to avoid using directive.</p> <pre><code>&lt;body ng-controller="MyCtrl"&gt; &lt;div class="container"&gt; &lt;h2&gt;My form with component&lt;/h2&gt; &lt;form role="form"&gt; &lt;div class="form-group"&gt; &lt;label&gt;First name&lt;/label&gt; &lt;my-input placeholder="Enter first name" ng-model="userData.name"&gt;&lt;/my-input&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/body&gt; </code></pre>
0debug
int64_t object_property_get_int(Object *obj, const char *name, Error **errp) { QObject *ret = object_property_get_qobject(obj, name, errp); QInt *qint; int64_t retval; if (!ret) { return -1; } qint = qobject_to_qint(ret); if (!qint) { error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "int"); retval = -1; } else { retval = qint_get_int(qint); } QDECREF(qint); return retval; }
1threat
Joi validation of array : <p>trying to validate that an array has zero or more strings in one case and that it has zero or more objects in another , struggling with Joi docs :(</p> <pre><code>validate: { headers: Joi.object({ 'content-type': "application/vnd.api+json", accept: "application/vnd.api+json" }).options({ allowUnknown: true }), payload : Joi.object().keys({ data : Joi.object().keys({ type: Joi.any().allow('BY_TEMPLATE').required(), attributes: Joi.object({ to : Joi.string().email().required(), templateId : Joi.string().required(), categories : Joi.array().items( //trying to validate here that each element is a string), variables : Joi.array({ //also trying to validate here that each element is an Object with one key and value }) }) }).required() }) } </code></pre>
0debug
How can i change prinf("%.2f") in C++ : How can i change prinf("%.2f") in C++ so that it will also diplay upto two decimals Aslo for this to change in c++ Printf("-6c%14d%20.2f",'A',val1,val2); I have declared val1,val2 in double
0debug
Python, Py.Test, How can I prevent self from eating one of my test parameters? : I have in my test module: import pytest from src.model_code.central import AgentBasic class AgentBasicTestee(AgentBasic): pass @pytest.fixture() def agentBasic(): return AgentBasicTestee() @pytest.mark.parametrize('alpha, beta, delta, expected', [ (2, 1, 1, pytest.approx(0.5)), (2, 2, 2, pytest.approx(-0.9375 / 0.75)), ]) def test_b3(agentBasic, AgentCOne,alpha, beta, delta, expected): assert(agentBasic.b3(alpha, beta, delta) == expected) and in my import module from src.model_code.crra_utility import AgentCrra AgentCOne = AgentCrra class AgentBasic: @staticmethod def b3(alpha, beta, delta): """define matric element b3""" k = AgentCOne.k_bar(alpha, beta, delta) c = AgentCOne.c_bar(alpha, beta, delta) return -c/k The error message I get is: `> c = AgentCOne.c_bar(alpha, beta, delta) E TypeError: c_bar() missing 1 required positional argument: 'delta'` Note: def c_bar(self, alpha, beta, delta): """non-stochastic steady-state for consumption""" k = self.k_bar(alpha, beta, delta) return k ** alpha - delta * k So far, self takes one of my parameters s.t. delta stays empty... How can i prevent hat?
0debug
static void migrate_fd_cancel(MigrationState *s) { if (s->state != MIG_STATE_ACTIVE) return; DPRINTF("cancelling migration\n"); s->state = MIG_STATE_CANCELLED; notifier_list_notify(&migration_state_notifiers, s); migrate_fd_cleanup(s); }
1threat
Rolling Regression OLS Statsmodels : https://www.statsmodels.org/dev/examples/notebooks/generated/rolling_ls.html So running the from statsmodels.regression.rolling import RollingOLS command but says module ModuleNotFoundError: No module named 'statsmodels.regression.rolling' anyone else having this problem?
0debug
static int dmg_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVDMGState *s = bs->opaque; uint64_t info_begin, info_end, last_in_offset, last_out_offset; uint32_t count, tmp; uint32_t max_compressed_size = 1, max_sectors_per_chunk = 1, i; int64_t offset; int ret; bs->read_only = 1; s->n_chunks = 0; s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL; offset = bdrv_getlength(bs->file); if (offset < 0) { ret = offset; goto fail; } offset -= 0x1d8; ret = read_uint64(bs, offset, &info_begin); if (ret < 0) { goto fail; } else if (info_begin == 0) { ret = -EINVAL; goto fail; } ret = read_uint32(bs, info_begin, &tmp); if (ret < 0) { goto fail; } else if (tmp != 0x100) { ret = -EINVAL; goto fail; } ret = read_uint32(bs, info_begin + 4, &count); if (ret < 0) { goto fail; } else if (count == 0) { ret = -EINVAL; goto fail; } info_end = info_begin + count; offset = info_begin + 0x100; last_in_offset = last_out_offset = 0; while (offset < info_end) { uint32_t type; ret = read_uint32(bs, offset, &count); if (ret < 0) { goto fail; } else if (count == 0) { ret = -EINVAL; goto fail; } offset += 4; ret = read_uint32(bs, offset, &type); if (ret < 0) { goto fail; } if (type == 0x6d697368 && count >= 244) { size_t new_size; uint32_t chunk_count; offset += 4; offset += 200; chunk_count = (count - 204) / 40; new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count); s->types = g_realloc(s->types, new_size / 2); s->offsets = g_realloc(s->offsets, new_size); s->lengths = g_realloc(s->lengths, new_size); s->sectors = g_realloc(s->sectors, new_size); s->sectorcounts = g_realloc(s->sectorcounts, new_size); for (i = s->n_chunks; i < s->n_chunks + chunk_count; i++) { ret = read_uint32(bs, offset, &s->types[i]); if (ret < 0) { goto fail; } offset += 4; if (s->types[i] != 0x80000005 && s->types[i] != 1 && s->types[i] != 2) { if (s->types[i] == 0xffffffff && i > 0) { last_in_offset = s->offsets[i - 1] + s->lengths[i - 1]; last_out_offset = s->sectors[i - 1] + s->sectorcounts[i - 1]; } chunk_count--; i--; offset += 36; continue; } offset += 4; ret = read_uint64(bs, offset, &s->sectors[i]); if (ret < 0) { goto fail; } s->sectors[i] += last_out_offset; offset += 8; ret = read_uint64(bs, offset, &s->sectorcounts[i]); if (ret < 0) { goto fail; } offset += 8; if (s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) { error_report("sector count %" PRIu64 " for chunk %" PRIu32 " is larger than max (%u)", s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX); ret = -EINVAL; goto fail; } ret = read_uint64(bs, offset, &s->offsets[i]); if (ret < 0) { goto fail; } s->offsets[i] += last_in_offset; offset += 8; ret = read_uint64(bs, offset, &s->lengths[i]); if (ret < 0) { goto fail; } offset += 8; if (s->lengths[i] > DMG_LENGTHS_MAX) { error_report("length %" PRIu64 " for chunk %" PRIu32 " is larger than max (%u)", s->lengths[i], i, DMG_LENGTHS_MAX); ret = -EINVAL; goto fail; } update_max_chunk_size(s, i, &max_compressed_size, &max_sectors_per_chunk); } s->n_chunks += chunk_count; } } s->compressed_chunk = qemu_try_blockalign(bs->file, max_compressed_size + 1); s->uncompressed_chunk = qemu_try_blockalign(bs->file, 512 * max_sectors_per_chunk); if (s->compressed_chunk == NULL || s->uncompressed_chunk == NULL) { ret = -ENOMEM; goto fail; } if (inflateInit(&s->zstream) != Z_OK) { ret = -EINVAL; goto fail; } s->current_chunk = s->n_chunks; qemu_co_mutex_init(&s->lock); return 0; fail: g_free(s->types); g_free(s->offsets); g_free(s->lengths); g_free(s->sectors); g_free(s->sectorcounts); qemu_vfree(s->compressed_chunk); qemu_vfree(s->uncompressed_chunk); return ret; }
1threat
how do you take a string then organize the words in it with how many times the word occurs in c#? : <p>ok I have no idea on how to do this and i have tried looking up how to do this but nothing good came up so ill ask it here. So what i am trying to do is: </p> <pre><code>string input = TextEditor.text; &lt;-- this is in windows form application and The "TextEditor" is the textbox for input </code></pre> <p>i want to take the string (which is input from the texct box) then split it so each word is on every other line like so:</p> <p>if input = "hi my name is is" </p> <p>out put should be: </p> <pre><code>hi: 1 my: 1 name: 1 is: 2 &lt;-- if the word is said it shouldn't be repeated. </code></pre> <p>could someone please help me? I am a true newbie and i am completely lost. I don't have any code yet because I DONT KNOW HOW TO DO THIS!</p>
0debug
void netdev_del_completion(ReadLineState *rs, int nb_args, const char *str) { int len, count, i; NetClientState *ncs[MAX_QUEUE_NUM]; if (nb_args != 2) { return; } len = strlen(str); readline_set_completion_index(rs, len); count = qemu_find_net_clients_except(NULL, ncs, NET_CLIENT_OPTIONS_KIND_NIC, MAX_QUEUE_NUM); for (i = 0; i < count; i++) { QemuOpts *opts; const char *name = ncs[i]->name; if (strncmp(str, name, len)) { continue; } opts = qemu_opts_find(qemu_find_opts_err("netdev", NULL), name); if (opts) { readline_add_completion(rs, name); } } }
1threat
how to get that Id when the condition doesnot match : I have a table T. We have multiple records for a particular user_id with match type = "Red Card". I just wanted that user_Id and match_id which has never received a "Red Card" in a entire match. As per the table Image which is attached I would be getting output : match_id : 3036 and 3090 and user_id 4 and 6 respectively[![enter image description here][1]][1] [1]: https://i.stack.imgur.com/wm5Oy.png Kindly help with the query.
0debug
Javsacript. How to manipulate array of objects so it groups elements that have the same element? : <p>I have an array like the following, that I will fetch from MongoDB:</p> <pre><code>[ {date: '2019-10-05', score: 3}, {date: '2019-10-05', score: 5}, {date: '2019-10-06', score: 4}, {date: '2019-10-06', score: 1}, ] </code></pre> <p>I need to make a new array to look like the following:</p> <pre><code>[ {date: '2019-10-05', score: [3,5]}, {date: '2019-10-06', score: [4,1]} ] </code></pre> <p>Basically grouping the scores into the same arrays based on the date attribute. Any kinds of advice to achieve this is appreciated.</p>
0debug
bool qemu_peer_has_vnet_hdr(NetClientState *nc) { if (!nc->peer || !nc->peer->info->has_vnet_hdr) { return false; } return nc->peer->info->has_vnet_hdr(nc->peer); }
1threat
How pass objects from one page to another on ASP.Net Core with razor pages? : <p>I'm developing a web application using Asp.net core 2.0 with razor pages. I'm creating an object with some data and want to send that object to another page.</p> <p>Actually I'm doing this:</p> <pre><code>var customObject = new{ //some values }; return RedirectToPage("NewPage", customObject); </code></pre> <p>I see that the url has the values of the object I'm sending, but I can't find how to take that values (in the NewPage instance).</p> <p>Can anybody knows how to share objects between razor pages? Is this the correct way to achieve it? or Is there another better way?</p> <p>Thanks in advance</p>
0debug
Given a binary array return a count the number of consecutive 1's : <p>Write a function that accepts a binary array. This function should return the largest consecutive number of 1's in a row.</p>
0debug
Switch in C++ hits everything? : <p><strong>First of all, I know breaks fix this issue, but I just want to make sure I understand the default behavior of a switch in C++.</strong></p> <p>I have the following C++ code that isn't working the way I think it would coming from other languages:</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main(){ int n; cin &gt;&gt; n; switch(n) { case 1: cout &lt;&lt; "one" &lt;&lt; endl; case 2: cout &lt;&lt; "two" &lt;&lt; endl; case 3: cout &lt;&lt; "three" &lt;&lt; endl; case 4: cout &lt;&lt; "four" &lt;&lt; endl; case 5: cout &lt;&lt; "five" &lt;&lt; endl; case 6: cout &lt;&lt; "six" &lt;&lt; endl; case 7: cout &lt;&lt; "seven" &lt;&lt; endl; case 8: cout &lt;&lt; "eight" &lt;&lt; endl; case 9: cout &lt;&lt; "nine" &lt;&lt; endl; default: cout &lt;&lt; "Greater than 9" &lt;&lt; endl; } // your code goes here return 0; } </code></pre> <p>Which outputs:</p> <pre><code>$ ./a.out 1 one two three four five six seven eight nine Greater than 9 </code></pre> <p>Why are the other cases being hit?</p> <p>Why is the default behavior different from other languages?</p>
0debug
static void tile_codeblocks(Jpeg2000DecoderContext *s, Jpeg2000Tile *tile) { Jpeg2000T1Context t1; int compno, reslevelno, bandno; for (compno = 0; compno < s->ncomponents; compno++) { Jpeg2000Component *comp = tile->comp + compno; Jpeg2000CodingStyle *codsty = tile->codsty + compno; for (reslevelno = 0; reslevelno < codsty->nreslevels2decode; reslevelno++) { Jpeg2000ResLevel *rlevel = comp->reslevel + reslevelno; for (bandno = 0; bandno < rlevel->nbands; bandno++) { uint16_t nb_precincts, precno; Jpeg2000Band *band = rlevel->band + bandno; int cblkno = 0, bandpos; bandpos = bandno + (reslevelno > 0); if (band->coord[0][0] == band->coord[0][1] || band->coord[1][0] == band->coord[1][1]) continue; nb_precincts = rlevel->num_precincts_x * rlevel->num_precincts_y; for (precno = 0; precno < nb_precincts; precno++) { Jpeg2000Prec *prec = band->prec + precno; for (cblkno = 0; cblkno < prec->nb_codeblocks_width * prec->nb_codeblocks_height; cblkno++) { int x, y; Jpeg2000Cblk *cblk = prec->cblk + cblkno; decode_cblk(s, codsty, &t1, cblk, cblk->coord[0][1] - cblk->coord[0][0], cblk->coord[1][1] - cblk->coord[1][0], bandpos); x = cblk->coord[0][0]; y = cblk->coord[1][0]; if (codsty->transform == FF_DWT97) dequantization_float(x, y, cblk, comp, &t1, band); else dequantization_int(x, y, cblk, comp, &t1, band); } } } } ff_dwt_decode(&comp->dwt, codsty->transform == FF_DWT97 ? (void*)comp->f_data : (void*)comp->i_data); } }
1threat
CONNECTING TABLES WITH FOREIGN KEY SQL ORACLE : HERE IS MY QUESTION List the number of employees who work in each department. QUERY [enter image description here][1] IT WORKS FINE TILL HERE .BUT WHEN I TRY TO COMBINE WITH ANOTHER TABLE USING THE FOREIGN KEY IT THROWS AN ERROR.ANYONE COULD HELP ME TO FIND THE ERROR IN MY CODE? [enter image description here][2] [1]: https://i.stack.imgur.com/RwmYc.png [2]: https://i.stack.imgur.com/LK0aj.png
0debug
Hashmap Implementation : Here's a simple HashMap implementation `HashMap<String,String> hashMap=new HashMap<>(); hashMap.put(new String("ABC"), "Hello"); hashMap.put("ABC", "Hello"); System.out.println(hashMap.size());` How does the code return size as 1 with how internally this is evaluated? However if i use StringBuffer instead of String code returns value as 2. Is it because it internally compares the value using compareTo() method?
0debug
This code doesn't work in notpad++ when I copy and paste if from jsfiddle? : I was looking at this code from this page https://stackoverflow.com/questions/23262434/javascript-countdown-timer-pause-resume and I looked at the code `var CountDown = (function ($) { // Length ms var TimeOut = 10000; // Interval ms var TimeGap = 1000;` var CurrentTime = ( new Date() ).getTime(); var EndTime = ( new Date() ).getTime() + TimeOut; var GuiTimer = $('#countdown'); var GuiPause = $('#pause'); var GuiResume = $('#resume').hide(); var Running = true; var UpdateTimer = function() { // Run till timeout if( CurrentTime + TimeGap < EndTime ) { setTimeout( UpdateTimer, TimeGap ); } // Countdown if running if( Running ) { CurrentTime += TimeGap; if( CurrentTime >= EndTime ) { GuiTimer.css('color','red'); } } // Update Gui var Time = new Date(); Time.setTime( EndTime - CurrentTime ); var Minutes = Time.getMinutes(); var Seconds = Time.getSeconds(); GuiTimer.html( (Minutes < 10 ? '0' : '') + Minutes + ':' + (Seconds < 10 ? '0' : '') + Seconds ); }; var Pause = function() { Running = false; GuiPause.hide(); GuiResume.show(); }; var Resume = function() { Running = true; GuiPause.show(); GuiResume.hide(); }; var Start = function( Timeout ) { TimeOut = Timeout; CurrentTime = ( new Date() ).getTime(); EndTime = ( new Date() ).getTime() + TimeOut; UpdateTimer(); }; return { Pause: Pause, Resume: Resume, Start: Start }; `})(jQuery);` `jQuery('#pause').on('click',CountDown.Pause);` `jQuery('#resume').on('click',CountDown.Resume);` `CountDown.Start(120000);` http://jsfiddle.net/rnQ2W/2/ I copied and pasted the code into notpad++ but the code didn't work when I run it. Could anyone help please?
0debug
How can I replace the comma-separeted Id's with the names of services : I use in my sql report different tables. I want to display in one of the columns the names of services. I must have to take the names from an another table. How can I replace the comma-separeted Id's with the names of services. Table 1 IdPerson-----------Date----------Services ---------- 12345--------01-01-2019-----------1,5,15,17 Table 2 ---------- IdServices----------------------------- description ---------- 1--------------service 1 ---------- 2--------------service 2 ---------- 3--------------service 3 ---------- .-------------- ---------- .-------------- ---------- 17--------------service 17 ---------- The expected output is like this: ---------- ClientId--------------Date--------------Services ---------- 12345--------------01-01-2019--------------service 1,service 5, service 15, service 17
0debug
how to prevent threads from exist : i have 10 threads working together,after starting the threads 15s later all threads Exists only one thread remains, my code: procedure TForm1.Button2Click(Sender: TObject); begin AA; BB; CC; DD; EE; FF; GG; HH; II; JJ; end; procedure TForm1.AA; //same procedure for BB,CC,DD,EE.FF,JJ,HH,II,JJ var lHTTP: TIdHTTP; begin lHTTP := TIdHTTP.Create(nil); TTask.Create(Procedure //HTTP operations end).Start; end;
0debug
How to debounce async validator in Angular 4 with RxJS observable? : <p>I'm using custom async validator with Angular 4 reactive forms to check if E-Mail address is already taken by calling a backend.</p> <p>However, Angular calls the validator, which makes request to the server for every entered character. This creates an unnecessary stress on the server.</p> <p>Is it possible to elegantly debounce async calls using RxJS observable?</p> <pre class="lang-typescript prettyprint-override"><code>import {Observable} from 'rxjs/Observable'; import {AbstractControl, ValidationErrors} from '@angular/forms'; import {Injectable} from '@angular/core'; import {UsersRepository} from '../repositories/users.repository'; @Injectable() export class DuplicateEmailValidator { constructor (private usersRepository: UsersRepository) { } validate (control: AbstractControl): Observable&lt;ValidationErrors&gt; { const email = control.value; return this.usersRepository .emailExists(email) .map(result =&gt; (result ? { duplicateEmail: true } : null)) ; } } </code></pre>
0debug
from collections import Counter def most_common_elem(s,a): most_common_elem=Counter(s).most_common(a) return most_common_elem
0debug
Many Modules using the same component causes error - Angular 2 : <p>I have a shared component called GoComponent that I want to use in 2 modules: FindPageModule and AddPageModule.</p> <p>When I add it in the declarations of "FindPageModule" and in my "AddPageModule" I get an error:</p> <blockquote> <p>find:21 Error: (SystemJS) Type GoComponent is part of the declarations of 2 modules: FindPageModule and AddPageModule! Please consider moving GoComponent to a higher module that imports FindPageModule and AddPageModule. You can also create a new NgModule that exports and includes GoComponent then import that NgModule in FindPageModule and AddPageModule.</p> </blockquote> <p>So I take it out of them both and add it in AppModule declarations, which does import FindPageModule and AddPageModule, and I get an error in a component called "FindFormComponent" which is in the declarations of FindPageModule and uses "GoComponent":</p> <pre><code>zone.js:355 Unhandled Promise rejection: Template parse errors: 'go' is not a known element: 1. If 'go' is an Angular component, then verify that it is part of this module. 2. If 'go' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. (" style="height:64px;"&gt; &lt;div style="position: relative; display: inline-block; width: 100%;"&gt; [ERROR -&gt;]&lt;go&gt;&lt;/go&gt; &lt;/div&gt; &lt;/div&gt; "): FindFormComponent@101:4 ; Zone: &lt;root&gt; ; Task: Promise.then ; Value: Error: Template parse errors:(…) Error: Template parse errors: 'go' is not a known element: 1. If 'go' is an Angular component, then verify that it is part of this module. 2. If 'go' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. (" style="height:64px;"&gt; &lt;div style="position: relative; display: inline-block; width: 100%;"&gt; [ERROR -&gt;]&lt;go&gt;&lt;/go&gt; &lt;/div&gt; &lt;/div&gt; "): FindFormComponent@101:4 </code></pre> <p>How do I let components such as FindFormComponent that are declared in FindPageModule use GoComponent and also let components declared by AddPageModule use GoComponent?</p>
0debug
Maintaing order of dictionary when converting list to dictionary : <p>I have a list </p> <pre><code>List = [('The', 'DT'), ('study', 'NN'), ('guide', 'NN'), ('does', 'VBZ'), ('not', 'RB'), ('discuss', 'VB'), ('much', 'JJ'), ('of', 'IN'), ('the', 'DT'), ('basics', 'NNS'), ('of', 'IN'), ('ethics.', 'NN')] </code></pre> <p>I convert it to a dictionary using</p> <pre><code>dic=collections.OrderedDict() dic=dict(List) </code></pre> <p>when i print the dictionary the order isn't maintained in the way it is in the list.</p> <p>I tried using OrderedDict() but still the order isn't maintained</p>
0debug
void laio_attach_aio_context(LinuxAioState *s, AioContext *new_context) { s->aio_context = new_context; s->completion_bh = aio_bh_new(new_context, qemu_laio_completion_bh, s); aio_set_event_notifier(new_context, &s->e, false, qemu_laio_completion_cb, NULL); }
1threat
Angular2 - adding [_ngcontent-mav-x] to styles : <p>I'm setting up a basic angular app, and I'm trying to inject some css to my views. This is an example of one of my components:</p> <pre><code>import { Component } from 'angular2/core'; import { ROUTER_PROVIDERS, ROUTER_DIRECTIVES, RouteConfig } from 'angular2/router'; import { LandingComponent } from './landing.component'; import { PortfolioComponent } from './portfolio.component'; @Component({ selector: 'portfolio-app', templateUrl: '/app/views/template.html', styleUrls: ['../app/styles/template.css'], directives: [ROUTER_DIRECTIVES], providers: [ROUTER_PROVIDERS] }) @RouteConfig([ { path: '/landing', name: 'Landing', component: LandingComponent, useAsDefault: true }, { path: '/portfolio', name: 'Portfolio', component: PortfolioComponent } ]) export class AppComponent { } </code></pre> <p>Now the .css file is requested from my server, and when I inspect the page source, I can see it was added to the head. But something weird is happening: </p> <pre><code>&lt;style&gt;@media (min-width: 768px) { .outer[_ngcontent-mav-3] { display: table; position: absolute; height: 100%; width: 100%; } .mainContainer[_ngcontent-mav-3] { display: table-cell; vertical-align: middle; } .appContainer[_ngcontent-mav-3] { width: 95%; border-radius: 50%; } .heightElement[_ngcontent-mav-3] { height: 0; padding-bottom: 100%; } }&lt;/style&gt; </code></pre> <p>gets generated from this file:</p> <pre><code>/* Small devices (tablets, 768px and up) */ @media (min-width: 768px) { /* center the mainContainer */ .outer { display: table; position: absolute; height: 100%; width: 100%; } .mainContainer { display: table-cell; vertical-align: middle; } .appContainer { width: 95%; border-radius: 50%; } .heightElement { height: 0; padding-bottom: 100%; } } </code></pre> <p>Can somebody please explain where the _ngcontent-mav tag comes from, what does it stand for and how to get rid of it?</p> <p>I think this is the reason why my style is not getting applied to my templates.</p> <p>If you need more info about the app structure, please checkout my <a href="https://github.com/Shooshte/PortfolioV3">gitRepo</a>, or ask and I'll add the code to the question.</p> <p>Thanks for the help.</p>
0debug
How to make confirm dialog modal in angular2 : I want to confirm for delete row in table but not use confirm default in Angular2. Please help me.
0debug
Why is my code outputting 0000000000000 as an invalid ISBN number? : <p>0000000000000 is a valid ISBN number, but my code says it's invalid. My code takes a 13-digit number and checks if it's valid or not. </p> <p>Each of the first 12 digits of the ISBN is alternately multiplied by 1 and 3. Then, we sum them up and divide the sum by 10, and get the reminder. If 10 minus the reminder is equal to the 13th digit, then it's valid.</p> <pre><code>isbnNunmberCheck=input() n1=int(isbnNunmberCheck[0])*1 n2=int(isbnNunmberCheck[1])*3 n3=int(isbnNunmberCheck[2])*1 n4=int(isbnNunmberCheck[3])*3 n5=int(isbnNunmberCheck[4])*1 n6=int(isbnNunmberCheck[5])*3 n7=int(isbnNunmberCheck[6])*1 n8=int(isbnNunmberCheck[7])*3 n9=int(isbnNunmberCheck[8])*1 n10=int(isbnNunmberCheck[9])*3 n11=int(isbnNunmberCheck[10])*1 n12=int(isbnNunmberCheck[11])*3 k=10-(n1+n2+n3+n4+n5+n6+n7+n8+n9+n10+n11+n12)%10 if k==int(isbnNunmberCheck[-1]): print("Valid") else: print("Invalid") </code></pre>
0debug
android WRITE_EXTERNAL_STORAGE permission runtime : <p>I have an app that saves a file in pictures directory of the internal memory of the phone. I have this in my manifest:</p> <pre><code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt; </code></pre> <p>In android documentation it says that you must request for permission in execution (not installation) in devices with android 6 or later. But I have tested it in three devices:</p> <ul> <li>Moto E with android 7.0</li> <li>Moto E with android 7.1</li> <li>Huawei P8 Lite with android 6.0</li> </ul> <p>And it saves the file just with the permission in the manifest, without requesting it. I would like to test the new code I have to add to handle this in a device that requires the permission in runtime, why these 3 devices don't require it?</p>
0debug
How to use the split function on every row in a dataframe in Python? : <p>I want to count the number of times a word is being repeated in the review string</p> <p>I am reading the csv file and storing it in a python dataframe using the below line</p> <pre><code>reviews = pd.read_csv("amazon_baby.csv") </code></pre> <p>The code in the below lines work when I apply it to a single review. </p> <pre><code>print reviews["review"][1] a = reviews["review"][1].split("disappointed") print a b = len(a) print b </code></pre> <p>The output for the above lines were </p> <pre><code>it came early and was not disappointed. i love planet wise bags and now my wipe holder. it keps my osocozy wipes moist and does not leak. highly recommend it. ['it came early and was not ', '. i love planet wise bags and now my wipe holder. it keps my osocozy wipes moist and does not leak. highly recommend it.'] 2 </code></pre> <p>When I apply the same logic to the entire dataframe using the below line. I receive an error message</p> <pre><code>reviews['disappointed'] = len(reviews["review"].split("disappointed"))-1 </code></pre> <p>Error message: </p> <pre><code>Traceback (most recent call last): File "C:/Users/gouta/PycharmProjects/MLCourse1/Classifier.py", line 12, in &lt;module&gt; reviews['disappointed'] = len(reviews["review"].split("disappointed"))-1 File "C:\Users\gouta\Anaconda2\lib\site-packages\pandas\core\generic.py", line 2360, in __getattr__ (type(self).__name__, name)) AttributeError: 'Series' object has no attribute 'split' </code></pre>
0debug
static void netmap_update_fd_handler(NetmapState *s) { qemu_set_fd_handler2(s->me.fd, s->read_poll ? netmap_can_send : NULL, s->read_poll ? netmap_send : NULL, s->write_poll ? netmap_writable : NULL, s); }
1threat
How to loop python script over at end : <p>So I have the following test script I am playing with.</p> <pre><code>import time year = time.strftime('%Y') name = input('What is your name? ') dob = input('What is your DOB ') age = int(year) - int(dob) print(f'{name}, You are {age} years old.') </code></pre> <p>How do I start this script over after it prints out the last statement? Sorry for such a silly question, I have been looking everywhere but cannot find anything. Thanks in advance.</p>
0debug
static void apply_window_mp3(float *in, float *win, int *unused, float *out, int incr) { LOCAL_ALIGNED_16(float, suma, [17]); LOCAL_ALIGNED_16(float, sumb, [17]); LOCAL_ALIGNED_16(float, sumc, [17]); LOCAL_ALIGNED_16(float, sumd, [17]); float sum; memcpy(in + 512, in, 32 * sizeof(*in)); apply_window(in + 16, win , win + 512, suma, sumc, 16); apply_window(in + 32, win + 48, win + 640, sumb, sumd, 16); SUM8(MACS, suma[0], win + 32, in + 48); sumc[ 0] = 0; sumb[16] = 0; sumd[16] = 0; #define SUMS(suma, sumb, sumc, sumd, out1, out2) \ "movups " #sumd "(%4), %%xmm0 \n\t" \ "shufps $0x1b, %%xmm0, %%xmm0 \n\t" \ "subps " #suma "(%1), %%xmm0 \n\t" \ "movaps %%xmm0," #out1 "(%0) \n\t" \ \ "movups " #sumc "(%3), %%xmm0 \n\t" \ "shufps $0x1b, %%xmm0, %%xmm0 \n\t" \ "addps " #sumb "(%2), %%xmm0 \n\t" \ "movaps %%xmm0," #out2 "(%0) \n\t" if (incr == 1) { __asm__ volatile( SUMS( 0, 48, 4, 52, 0, 112) SUMS(16, 32, 20, 36, 16, 96) SUMS(32, 16, 36, 20, 32, 80) SUMS(48, 0, 52, 4, 48, 64) :"+&r"(out) :"r"(&suma[0]), "r"(&sumb[0]), "r"(&sumc[0]), "r"(&sumd[0]) :"memory" ); out += 16*incr; } else { int j; float *out2 = out + 32 * incr; out[0 ] = -suma[ 0]; out += incr; out2 -= incr; for(j=1;j<16;j++) { *out = -suma[ j] + sumd[16-j]; *out2 = sumb[16-j] + sumc[ j]; out += incr; out2 -= incr; } } sum = 0; SUM8(MLSS, sum, win + 16 + 32, in + 32); *out = sum; }
1threat
Spring use one application.properties for production and another for debug : <p>I have a Spring application and I would like to be able to switch between configurations depending if I'm debugging the server or if the server is running in production. (the difference in configurations being things like database location.)</p> <p>Ideally, I'd like to pass in a command line argument to my Spring application on boot-up and set the application configuration.</p> <p>I have two separate application.properties files, one with the production values, and another with the debug values. How can I switch between the two of them?</p>
0debug
how to separate number using javascript? : <p>I have a quetion please help me. I have number 21 or 22 or 23 etc. and I want to separate that number to be 20 and 1 or 20 and 2 or 20 and 3 etc. how to make it programmaticly in javascript. Sorry before cause I really confused and dont know the keyword to search on internet. Thanks guys hope U all can help me</p>
0debug
special characters in c string literals : <p>I'm writing some C code using the MySQL api to create databases, insert, update etc. I'm having a little trouble finding the cleanest/correct way to build the queries since the MySQL syntax can be tricky to put in a c string, for example, I'd like a query to look like this for readability:</p> <pre><code> strcpy(query, "CREATE TABLE Users ( userID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (userID), email VARCHAR(31) NOT NULL, timeEntered TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, address VARCHAR(31) NOT NULL, index (email)) "); </code></pre> <p>then of course I'd be running the query with something like </p> <pre><code> /* send SQL query */ if (mysql_query(conn, query)) { fprintf(stderr, "%s\n", mysql_error(conn)); exit(1); } else { printf("table created\n"); } </code></pre> <p>however the compiler complains about expected ‘)’ and missing terminating " etc. Whats the best solution?</p>
0debug
static void uhci_async_validate_end(UHCIState *s) { UHCIQueue *queue, *n; QTAILQ_FOREACH_SAFE(queue, &s->queues, next, n) { if (!queue->valid) { uhci_queue_free(queue); } } }
1threat
What is different between save(), create() function in laravel 5 : <p>I need to know what is the difference of <code>save()</code> and <code>create()</code> function in laravel 5. Where we can use <code>save()</code> and <code>create()</code> ?</p>
0debug
I have problem with the output of the js array sorting : I'm using js array sorting method on my webpage but it includes "," to the output. var locationTownInAshanti = new Array("<input type=\"radio\" value=\"Buokrom\" name=\"gender\">Buokrom", "<input type=\"radio\" value=\"Dote\" name=\"gender\">Dote", "<input type=\"radio\" value=\"Bantama\" name=\"gender\">Bantama") ; locationTownInAshanti.sort(); I expect the output to be only the item in the array without including ","[enter image description here][1] [1]: https://i.stack.imgur.com/79Bi3.png
0debug