problem
stringlengths
26
131k
labels
class label
2 classes
mkdir immediatly after rmdir gives me access denied : <p>I have a folder (let's call it <code>F</code>). </p> <p>I wrote a batch file that does</p> <pre><code>rmdir F /S /Q mkdir F </code></pre> <p>When I call the mkdir <code>F</code>, it gives me access denied, probably because the system may be still deleting <code>F</code>. How can I do to deal with this problem?</p>
0debug
static int h264_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; H264Context *h = avctx->priv_data; AVFrame *pict = data; int buf_index = 0; H264Picture *out; int i, out_idx; int ret; h->flags = avctx->flags; h->setup_finished = 0; if (h->backup_width != -1) { avctx->width = h->backup_width; h->backup_width = -1; } if (h->backup_height != -1) { avctx->height = h->backup_height; h->backup_height = -1; } if (h->backup_pix_fmt != AV_PIX_FMT_NONE) { avctx->pix_fmt = h->backup_pix_fmt; h->backup_pix_fmt = AV_PIX_FMT_NONE; } ff_h264_unref_picture(h, &h->last_pic_for_ec); if (buf_size == 0) { out: h->cur_pic_ptr = NULL; h->first_field = 0; out = h->delayed_pic[0]; out_idx = 0; for (i = 1; h->delayed_pic[i] && !h->delayed_pic[i]->f->key_frame && !h->delayed_pic[i]->mmco_reset; i++) if (h->delayed_pic[i]->poc < out->poc) { out = h->delayed_pic[i]; out_idx = i; } for (i = out_idx; h->delayed_pic[i]; i++) h->delayed_pic[i] = h->delayed_pic[i + 1]; if (out) { out->reference &= ~DELAYED_PIC_REF; ret = output_frame(h, pict, out); if (ret < 0) return ret; *got_frame = 1; } return buf_index; } if (h->is_avc && av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) { int side_size; uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size); if (is_extra(side, side_size)) ff_h264_decode_extradata(h, side, side_size); } if(h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC && (buf[5]&0x1F) && buf[8]==0x67){ if (is_extra(buf, buf_size)) return ff_h264_decode_extradata(h, buf, buf_size); } buf_index = decode_nal_units(h, buf, buf_size, 0); if (buf_index < 0) return AVERROR_INVALIDDATA; if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) { av_assert0(buf_index <= buf_size); goto out; } if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) { if (avctx->skip_frame >= AVDISCARD_NONREF || buf_size >= 4 && !memcmp("Q264", buf, 4)) return buf_size; av_log(avctx, AV_LOG_ERROR, "no frame!\n"); return AVERROR_INVALIDDATA; } if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) || (h->mb_y >= h->mb_height && h->mb_height)) { if (avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) decode_postinit(h, 1); if ((ret = ff_h264_field_end(h, &h->slice_ctx[0], 0)) < 0) return ret; *got_frame = 0; if (h->next_output_pic && ( h->next_output_pic->recovered)) { if (!h->next_output_pic->recovered) h->next_output_pic->f->flags |= AV_FRAME_FLAG_CORRUPT; if (!h->avctx->hwaccel && (h->next_output_pic->field_poc[0] == INT_MAX || h->next_output_pic->field_poc[1] == INT_MAX) ) { int p; AVFrame *f = h->next_output_pic->f; int field = h->next_output_pic->field_poc[0] == INT_MAX; uint8_t *dst_data[4]; int linesizes[4]; const uint8_t *src_data[4]; av_log(h->avctx, AV_LOG_DEBUG, "Duplicating field %d to fill missing\n", field); for (p = 0; p<4; p++) { dst_data[p] = f->data[p] + (field^1)*f->linesize[p]; src_data[p] = f->data[p] + field *f->linesize[p]; linesizes[p] = 2*f->linesize[p]; } av_image_copy(dst_data, linesizes, src_data, linesizes, f->format, f->width, f->height>>1); } ret = output_frame(h, pict, h->next_output_pic); if (ret < 0) return ret; *got_frame = 1; if (CONFIG_MPEGVIDEO) { ff_print_debug_info2(h->avctx, pict, NULL, h->next_output_pic->mb_type, h->next_output_pic->qscale_table, h->next_output_pic->motion_val, &h->low_delay, h->mb_width, h->mb_height, h->mb_stride, 1); } } } av_assert0(pict->buf[0] || !*got_frame); ff_h264_unref_picture(h, &h->last_pic_for_ec); return get_consumed_bytes(buf_index, buf_size); }
1threat
Removing rows from a table if they have an email record from another table : <p>I have 2 tables, one with customers, containing their name, email, company, etc. I have another table that just contains the emails of the customers that need to be removed. I need to develop a query to delete all rows from the first table if they contain an email in the second. These tables are in a Microsoft SQL Server database.</p> <p>As I am in the process of learning SQL I have no idea how to do this, I've searched through questions and can't find a similar enough one.</p>
0debug
static int qemu_gluster_parse_uri(BlockdevOptionsGluster *gconf, const char *filename) { SocketAddress *gsconf; URI *uri; QueryParams *qp = NULL; bool is_unix = false; int ret = 0; uri = uri_parse(filename); if (!uri) { return -EINVAL; } gconf->server = g_new0(SocketAddressList, 1); gconf->server->value = gsconf = g_new0(SocketAddress, 1); if (!uri->scheme || !strcmp(uri->scheme, "gluster")) { gsconf->type = SOCKET_ADDRESS_TYPE_INET; } else if (!strcmp(uri->scheme, "gluster+tcp")) { gsconf->type = SOCKET_ADDRESS_TYPE_INET; } else if (!strcmp(uri->scheme, "gluster+unix")) { gsconf->type = SOCKET_ADDRESS_TYPE_UNIX; is_unix = true; } else if (!strcmp(uri->scheme, "gluster+rdma")) { gsconf->type = SOCKET_ADDRESS_TYPE_INET; error_report("Warning: rdma feature is not supported, falling " "back to tcp"); } else { ret = -EINVAL; goto out; } ret = parse_volume_options(gconf, uri->path); if (ret < 0) { goto out; } qp = query_params_parse(uri->query); if (qp->n > 1 || (is_unix && !qp->n) || (!is_unix && qp->n)) { ret = -EINVAL; goto out; } if (is_unix) { if (uri->server || uri->port) { ret = -EINVAL; goto out; } if (strcmp(qp->p[0].name, "socket")) { ret = -EINVAL; goto out; } gsconf->u.q_unix.path = g_strdup(qp->p[0].value); } else { gsconf->u.inet.host = g_strdup(uri->server ? uri->server : "localhost"); if (uri->port) { gsconf->u.inet.port = g_strdup_printf("%d", uri->port); } else { gsconf->u.inet.port = g_strdup_printf("%d", GLUSTER_DEFAULT_PORT); } } out: if (qp) { query_params_free(qp); } uri_free(uri); return ret; }
1threat
How to make selected tab in QTabBar to look same when hovered and not hovered : <p>I would like to make active tab (only) to look same when it is hovered and not. <br> Inactive(unselected) tabs should respond on hover as usual.</p>
0debug
PHP/MySQL: Count number of available tables : <p>I have a database $db_name that contains a slew of tables. Many of them contain the name 'puzzle' (for example: 'puzzle1', 'puzzle2', 'puzzle3', etc.). What command do I need to perform to count all of those tables and return an integer?</p>
0debug
Can you disable fullscreen editing in landscape in React Native Android? : <p>In an <code>EditText</code> Android element you can prevent the "fullscreen editing mode" from activating in landscape with <code>android:imeOptions="flagNoExtractUi"</code> (as detailed <a href="https://developer.android.com/guide/topics/ui/controls/text.html#Flags" rel="noreferrer">here</a>).</p> <p>Is there any way to replicate the same behavior with a React Native <code>TextInput</code> component? I've searched through the docs and StackOverflow and have not found a solution.</p>
0debug
static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap) { SWFContext *swf = 0; ByteIOContext *pb = &s->pb; int nbits, len, frame_rate, tag, v; offset_t firstTagOff; AVStream *ast = 0; AVStream *vst = 0; swf = av_malloc(sizeof(SWFContext)); if (!swf) return -1; s->priv_data = swf; tag = get_be32(pb) & 0xffffff00; if (tag == MKBETAG('C', 'W', 'S', 0)) { av_log(s, AV_LOG_ERROR, "Compressed SWF format not supported\n"); return AVERROR_IO; } if (tag != MKBETAG('F', 'W', 'S', 0)) return AVERROR_IO; get_le32(pb); nbits = get_byte(pb) >> 3; len = (4 * nbits - 3 + 7) / 8; url_fskip(pb, len); frame_rate = get_le16(pb); get_le16(pb); swf->ms_per_frame = ( 1000 * 256 ) / frame_rate; swf->samples_per_frame = 0; swf->ch_id = -1; firstTagOff = url_ftell(pb); for(;;) { tag = get_swf_tag(pb, &len); if (tag < 0) { if ( ast || vst ) { if ( vst && ast ) { vst->codec->time_base.den = ast->codec->sample_rate / swf->samples_per_frame; vst->codec->time_base.num = 1; } break; } av_log(s, AV_LOG_ERROR, "No media found in SWF\n"); return AVERROR_IO; } if ( tag == TAG_VIDEOSTREAM && !vst) { int codec_id; swf->ch_id = get_le16(pb); get_le16(pb); get_le16(pb); get_le16(pb); get_byte(pb); codec_id = codec_get_id(swf_codec_tags, get_byte(pb)); if ( codec_id ) { vst = av_new_stream(s, 0); av_set_pts_info(vst, 24, 1, 1000); vst->codec->codec_type = CODEC_TYPE_VIDEO; vst->codec->codec_id = codec_id; if ( swf->samples_per_frame ) { vst->codec->time_base.den = 1000. / swf->ms_per_frame; vst->codec->time_base.num = 1; } } } else if ( ( tag == TAG_STREAMHEAD || tag == TAG_STREAMHEAD2 ) && !ast) { get_byte(pb); v = get_byte(pb); swf->samples_per_frame = get_le16(pb); if (len!=4) url_fskip(pb,len-4); if ((v & 0x20) != 0) { if ( tag == TAG_STREAMHEAD2 ) { get_le16(pb); } ast = av_new_stream(s, 1); av_set_pts_info(ast, 24, 1, 1000); if (!ast) return -ENOMEM; if (v & 0x01) ast->codec->channels = 2; else ast->codec->channels = 1; switch((v>> 2) & 0x03) { case 1: ast->codec->sample_rate = 11025; break; case 2: ast->codec->sample_rate = 22050; break; case 3: ast->codec->sample_rate = 44100; break; default: av_free(ast); return AVERROR_IO; } ast->codec->codec_type = CODEC_TYPE_AUDIO; ast->codec->codec_id = CODEC_ID_MP3; } } else { url_fskip(pb, len); } } url_fseek(pb, firstTagOff, SEEK_SET); return 0; }
1threat
Testing a gRPC service : <p>I'd like to test a gRPC service written in Go. The example I'm using is the Hello World server example from the <a href="https://github.com/grpc/grpc-go/blob/master/examples/helloworld/greeter_server/main.go" rel="noreferrer">grpc-go repo</a>.</p> <p>The protobuf definition is as follows:</p> <pre><code>syntax = "proto3"; package helloworld; // The greeting service definition. service Greeter { // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) {} } // The request message containing the user's name. message HelloRequest { string name = 1; } // The response message containing the greetings message HelloReply { string message = 1; } </code></pre> <p>And the type in the <code>greeter_server</code> main is:</p> <pre><code>// server is used to implement helloworld.GreeterServer. type server struct{} // SayHello implements helloworld.GreeterServer func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloReply, error) { return &amp;pb.HelloReply{Message: "Hello " + in.Name}, nil } </code></pre> <p>I've looked for examples but I couldn't find any on how to implement tests for a gRPC service in Go.</p>
0debug
How to enable a virtualenv in a systemd service unit? : <p>I want to "activate" a virtualenv in a systemd service file.</p> <p>I would like avoid to have a shell process between the systemd process and the python interpreter.</p> <p>My current solution looks like this:</p> <pre><code>[Unit] Description=fooservice After=syslog.target network.target [Service] Type=simple User=fooservice WorkingDirectory={{ venv_home }} ExecStart={{ venv_home }}/fooservice --serve-in-foreground Restart=on-abort EnvironmentFile=/etc/sysconfig/fooservice.env [Install] WantedBy=multi-user.target </code></pre> <p>/etc/sysconfig/fooservice.env</p> <pre><code>PATH={{ venv_home }}/bin:/usr/local/bin:/usr/bin:/bin PYTHONIOENCODING=utf-8 PYTHONPATH={{ venv_home }}/... VIRTUAL_ENV={{ venv_home }} </code></pre> <p>But I am having trouble. I get ImportErrors since some enties in sys.path are missing.</p>
0debug
static int aio_read_f(int argc, char **argv) { int nr_iov, c; struct aio_ctx *ctx = calloc(1, sizeof(struct aio_ctx)); while ((c = getopt(argc, argv, "CP:qv")) != EOF) { switch (c) { case 'C': ctx->Cflag = 1; break; case 'P': ctx->Pflag = 1; ctx->pattern = parse_pattern(optarg); if (ctx->pattern < 0) { free(ctx); return 0; } break; case 'q': ctx->qflag = 1; break; case 'v': ctx->vflag = 1; break; default: free(ctx); return command_usage(&aio_read_cmd); } } if (optind > argc - 2) { free(ctx); return command_usage(&aio_read_cmd); } ctx->offset = cvtnum(argv[optind]); if (ctx->offset < 0) { printf("non-numeric length argument -- %s\n", argv[optind]); free(ctx); return 0; } optind++; if (ctx->offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned\n", ctx->offset); free(ctx); return 0; } nr_iov = argc - optind; ctx->buf = create_iovec(&ctx->qiov, &argv[optind], nr_iov, 0xab); if (ctx->buf == NULL) { free(ctx); return 0; } gettimeofday(&ctx->t1, NULL); bdrv_aio_readv(bs, ctx->offset >> 9, &ctx->qiov, ctx->qiov.size >> 9, aio_read_done, ctx); return 0; }
1threat
static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { int n, c, sample_size, v, ret; const short *samples; unsigned char *dst; const uint8_t *samples_uint8_t; const int16_t *samples_int16_t; const int32_t *samples_int32_t; const int64_t *samples_int64_t; const uint16_t *samples_uint16_t; const uint32_t *samples_uint32_t; sample_size = av_get_bits_per_sample(avctx->codec->id) / 8; n = frame->nb_samples * avctx->channels; samples = (const short *)frame->data[0]; if ((ret = ff_alloc_packet2(avctx, avpkt, n * sample_size))) return ret; dst = avpkt->data; switch (avctx->codec->id) { case AV_CODEC_ID_PCM_U32LE: ENCODE(uint32_t, le32, samples, dst, n, 0, 0x80000000) break; case AV_CODEC_ID_PCM_U32BE: ENCODE(uint32_t, be32, samples, dst, n, 0, 0x80000000) break; case AV_CODEC_ID_PCM_S24LE: ENCODE(int32_t, le24, samples, dst, n, 8, 0) break; case AV_CODEC_ID_PCM_S24LE_PLANAR: ENCODE_PLANAR(int32_t, le24, dst, n, 8, 0) break; case AV_CODEC_ID_PCM_S24BE: ENCODE(int32_t, be24, samples, dst, n, 8, 0) break; case AV_CODEC_ID_PCM_U24LE: ENCODE(uint32_t, le24, samples, dst, n, 8, 0x800000) break; case AV_CODEC_ID_PCM_U24BE: ENCODE(uint32_t, be24, samples, dst, n, 8, 0x800000) break; case AV_CODEC_ID_PCM_S24DAUD: for (; n > 0; n--) { uint32_t tmp = ff_reverse[(*samples >> 8) & 0xff] + (ff_reverse[*samples & 0xff] << 8); tmp <<= 4; bytestream_put_be24(&dst, tmp); samples++; } break; case AV_CODEC_ID_PCM_U16LE: ENCODE(uint16_t, le16, samples, dst, n, 0, 0x8000) break; case AV_CODEC_ID_PCM_U16BE: ENCODE(uint16_t, be16, samples, dst, n, 0, 0x8000) break; case AV_CODEC_ID_PCM_S8: ENCODE(uint8_t, byte, samples, dst, n, 0, -128) break; case AV_CODEC_ID_PCM_S8_PLANAR: ENCODE_PLANAR(uint8_t, byte, dst, n, 0, -128) break; #if HAVE_BIGENDIAN case AV_CODEC_ID_PCM_F64LE: ENCODE(int64_t, le64, samples, dst, n, 0, 0) break; case AV_CODEC_ID_PCM_S32LE: case AV_CODEC_ID_PCM_F32LE: ENCODE(int32_t, le32, samples, dst, n, 0, 0) break; case AV_CODEC_ID_PCM_S32LE_PLANAR: ENCODE_PLANAR(int32_t, le32, dst, n, 0, 0) break; case AV_CODEC_ID_PCM_S16LE: ENCODE(int16_t, le16, samples, dst, n, 0, 0) break; case AV_CODEC_ID_PCM_S16LE_PLANAR: ENCODE_PLANAR(int16_t, le16, dst, n, 0, 0) break; case AV_CODEC_ID_PCM_F64BE: case AV_CODEC_ID_PCM_F32BE: case AV_CODEC_ID_PCM_S32BE: case AV_CODEC_ID_PCM_S16BE: #else case AV_CODEC_ID_PCM_F64BE: ENCODE(int64_t, be64, samples, dst, n, 0, 0) break; case AV_CODEC_ID_PCM_F32BE: case AV_CODEC_ID_PCM_S32BE: ENCODE(int32_t, be32, samples, dst, n, 0, 0) break; case AV_CODEC_ID_PCM_S16BE: ENCODE(int16_t, be16, samples, dst, n, 0, 0) break; case AV_CODEC_ID_PCM_S16BE_PLANAR: ENCODE_PLANAR(int16_t, be16, dst, n, 0, 0) break; case AV_CODEC_ID_PCM_F64LE: case AV_CODEC_ID_PCM_F32LE: case AV_CODEC_ID_PCM_S32LE: case AV_CODEC_ID_PCM_S16LE: #endif case AV_CODEC_ID_PCM_U8: memcpy(dst, samples, n * sample_size); break; #if HAVE_BIGENDIAN case AV_CODEC_ID_PCM_S16BE_PLANAR: #else case AV_CODEC_ID_PCM_S16LE_PLANAR: case AV_CODEC_ID_PCM_S32LE_PLANAR: #endif n /= avctx->channels; for (c = 0; c < avctx->channels; c++) { const uint8_t *src = frame->extended_data[c]; bytestream_put_buffer(&dst, src, n * sample_size); } break; case AV_CODEC_ID_PCM_ALAW: for (; n > 0; n--) { v = *samples++; *dst++ = linear_to_alaw[(v + 32768) >> 2]; } break; case AV_CODEC_ID_PCM_MULAW: for (; n > 0; n--) { v = *samples++; *dst++ = linear_to_ulaw[(v + 32768) >> 2]; } break; default: return -1; } *got_packet_ptr = 1; return 0; }
1threat
static void iscsi_nop_timed_event(void *opaque) { IscsiLun *iscsilun = opaque; aio_context_acquire(iscsilun->aio_context); if (iscsi_get_nops_in_flight(iscsilun->iscsi) >= MAX_NOP_FAILURES) { error_report("iSCSI: NOP timeout. Reconnecting..."); iscsilun->request_timed_out = true; } else if (iscsi_nop_out_async(iscsilun->iscsi, NULL, NULL, 0, NULL) != 0) { error_report("iSCSI: failed to sent NOP-Out. Disabling NOP messages."); goto out; } timer_mod(iscsilun->nop_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + NOP_INTERVAL); iscsi_set_events(iscsilun); out: aio_context_release(iscsilun->aio_context); }
1threat
How to export an Angular Material Table into a pdf as well as csv, which should be downloaded on click of a button : <p>I am using Angular Material Table, to show data, which i am getting from an API call. The question now is, how can I export the Mat-Table data into a PDF and a CSV on click of a button, any Angular Modules which can help me serve my purpose.</p> <p>Thanks</p>
0debug
static void unterminated_sq_string(void) { QObject *obj = qobject_from_json("'abc", NULL); g_assert(obj == NULL); }
1threat
terminating applicaton through python script : I was using Python (Popen and subprocess modules) to open applications and automate some stuff. But, I do not know how to close using one line command/script. It should not take more than one line. e.g. I am using >>>import subprocess >>>subprocess.Popen(['c:\\windows\\system32\\notepad.exe','C:\\file1.txt']) I want to close this file. What is the process?
0debug
Not able to spy the menu item for web application : I want to spy on the menu items in blue prism for the web application but i am not able to do? when i tried to spy on the application i am getting error as "Error - Highlighting results - No elements match the supplied query terms" and i am trying to spy as normal web element can any one provide me the proper solutions for these kind of scenarios i tried all the option but still not able to spy the object Let me know the step by step procedure to work on these
0debug
const char *memory_region_name(const MemoryRegion *mr) { return object_get_canonical_path_component(OBJECT(mr)); }
1threat
Php Script to distrubate person working in a week : I made this Script to distrubate person working in a week but No one can work more than one time in a day and also must work 6 days/week But steel some problems cause some people work just 4 days some work more ... I tried doing it this way : <?php $input = array("Mohamed ET Sidi", "Ahmed ET ibrahim", "senoud","Hamed Et abdou"); $rand_keys = array_rand($input, 4); ?> <table border=1> <tr> <th> Samedi </th> <th> Dimanche </th> <th> Lundi </th> <th> Mardi </th> <th> Merecredi </th> <th> Jeudi </th> <th> Vendredi </th> </tr> <tr> <?php $counter_MS=0; $counter_AI=0; $counter_HA=0; $last_shift = $input[2]; for($i=0;$i<7;$i++){ echo "<td>\n"; shuffle($input); // controle no one Continu working while ($input[0] == $last_shift) { shuffle($input); } // no one work 7 days a week while ($counter_MS == 6 && $input[0]="Mohamed ET Sidi" || $counter_MS == 6 && $input[1]="Mohamed ET Sidi" || $counter_MS == 6 && $input[2]="Mohamed ET Sidi") { shuffle($input); } while ($counter_AI == 6 && $input[0]="Ahmed ET ibrahim" || $counter_MS == 6 && $input[1]="Ahmed ET ibrahim" || $counter_MS == 6 && $input[2]="Ahmed ET ibrahim") { shuffle($input); } while ($counter_HA == 6 && $input[0]="Hamed Et abdou" || $counter_MS == 6 && $input[1]="Hamed Et abdou" || $counter_MS == 6 && $input[2]="Hamed Et abdou") { shuffle($input); } if( $input[0] =="Mohamed ET Sidi" || $input[1]=="Mohamed ET Sidi" || $input[2]=="Mohamed ET Sidi") $counter_MS++; if( $input[0] =="Ahmed ET ibrahim" || $input[1]=="Ahmed ET ibrahim" || $input[2]=="Ahmed ET ibrahim") $counter_AI++; if( $input[0] =="Hamed Et abdou" || $input[1]=="Hamed Et abdou" || $input[2]=="Hamed Et abdou") $counter_HA++; echo $input[0] ." 7H-15H\n" ; echo $input[1] ." 15H-23H\n" ; echo $input[2] ." 23H-7H\n" ; $last_shift = $input[2]; echo "</td>\n"; } echo "Mohamed Et Sidi Worked =".$counter_MS." days"; echo "Ahmed ET ibrahim =".$counter_AI." days"; echo "Hamed Et abdou =".$counter_HA." days"; ?>
0debug
static int check_video_codec_tag(int codec_tag) { if (codec_tag <= 0 || codec_tag > 15) { return AVERROR(ENOSYS); } else return 0; }
1threat
Must constexpr expressions be captured by a lambda in C++? : <p>Here is a piece of code that won't compile in MSVC 2015 (ignore the uninitialized value access):</p> <pre><code>#include &lt;array&gt; int main() { constexpr int x = 5; auto func = []() { std::array&lt;int, x&gt; arr; return arr[0]; }; func(); } </code></pre> <p>It complains that:</p> <pre><code>'x' cannot be implicitly captured because no default capture mode has been specified </code></pre> <p>But <code>x</code> is a <code>constexpr</code>! <code>x</code> is known at compile time to be <code>5</code>. Why does MSVC kick up a fuss about this? (Is it <em>yet</em> another MSVC bug?) GCC will happily compile it.</p>
0debug
How to show content of a mysql table when the id is passed from one page to another? : I have a Table named table1 in Database named db1. Then, I have a fields named id, title & content in table1. When i Clicked submit button in the page 'add.php' The data in add.php page will be added to 'Title' & 'content' fields. Then, in the 'index.php' file, I want to show Title & Content. And i want to make the Title a URL links to 'view.php'. When the title url is clicked, It will load view.php, But how do i show the Content of the clicked Title in 'view.php' file? **add.php** mysql_query("insert into discussions(id, title, content)VALUES('', '$title', '$content')"); **index.php** echo '<tr><td><a href="????">' . $row["title"] . '</a></td><td>' . $row["dtime"] . '</td></tr>'; I am Asking what should i insert to the <a href=""> value &, **view.php** // What should be included on this page. Please Kindly Tell me before Downvoting this question if you don't understand what i asked. If you understand & See anything wrong in the question, Please edit this. Hope an answer soon. Thank you.
0debug
static void gif_put_bits_rev(PutBitContext *s, int n, unsigned int value) { unsigned int bit_buf; int bit_cnt; assert(n == 32 || value < (1U << n)); bit_buf = s->bit_buf; bit_cnt = 32 - s->bit_left; if (n < (32-bit_cnt)) { bit_buf |= value << (bit_cnt); bit_cnt+=n; } else { bit_buf |= value << (bit_cnt); *s->buf_ptr = bit_buf & 0xff; s->buf_ptr[1] = (bit_buf >> 8) & 0xff; s->buf_ptr[2] = (bit_buf >> 16) & 0xff; s->buf_ptr[3] = (bit_buf >> 24) & 0xff; s->buf_ptr+=4; if (s->buf_ptr >= s->buf_end) puts("bit buffer overflow !!"); bit_cnt=bit_cnt + n - 32; if (bit_cnt == 0) { bit_buf = 0; } else { bit_buf = value >> (n - bit_cnt); } } s->bit_buf = bit_buf; s->bit_left = 32 - bit_cnt; }
1threat
POST request with data in body with Alamofire 4 : <p>how is it possible to send a POST request with a data in the HTTP body with Alamofire 4? I used custom encoding at swift 2.3 it was working good. I converted my code swift 3 and I tried to paramater encoding but not working. This code :</p> <pre><code>public struct MyCustomEncoding : ParameterEncoding { private let data: Data init(data: Data) { self.data = data } public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -&gt; URLRequest { var urlRequest = try urlRequest.asURLRequest() do { urlRequest.httpBody = data urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") } catch { throw AFError.parameterEncodingFailed(reason: .jsonEncodingFailed(error: error)) } return urlRequest } </code></pre> <p>and Alamofire request :</p> <pre><code>let enco : ParameterEncoding = MyCustomEncoding(data: ajsonData) Alamofire.request(urlString, method: .post , parameters: [:], encoding: enco , headers: headers).validate() .responseJSON { response in switch response.result { case .success: print(response) break case .failure(let error): print(error) } } </code></pre>
0debug
Taking input again if not valid input : <p>I want to program it like that so while taking input of num1,num2 and operation if user doesn't give input in appropriate type it ask the user again for input.</p> <pre><code>operation=(input('1.add\n2.subtract\n3.multiply\n4.divide')) num1 =int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) if operation == "add" or operation == '1' : print(num1,"+",num2,"=", (num1+num2)) elif operation =="subtract" or operation == '2': print(num1,"-",num2,"=", (num1-num2)) elif operation =="multiply" or operation == '3': print(num1,"*",num2,"=", (num1*num2)) elif operation =="divide" or operation == '4': print(num1,"/",num2,"=", (num1/num2)) </code></pre>
0debug
Can Android Studio use OpenJDK or does it require Oracle JDK on Linux? : <p>Can Android Studio use OpenJDK 1.8 or does it require Oracle JDK on Linux? It would be easier to use OpenJDK because it comes installed on Fedora.</p> <p>I'm running 64 bit Fedora-23 linux with Android Studio 1.5.1.build AI-141.2456560 on an Intel Haswell i7 chip.</p> <pre><code>$ java -version openjdk version "1.8.0_72" OpenJDK Runtime Environment (build 1.8.0_72-b15) OpenJDK 64-Bit Server VM (build 25.72-b15, mixed mode) $ ./java -version java version "1.8.0_73" Java(TM) SE Runtime Environment (build 1.8.0_73-b02) Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode) $ uname -a Linux localhost.localdomain 4.3.5-300.fc23.x86_64 #1 SMP Mon Feb 1 03:18:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux $ more build.txt AI-141.2456560 </code></pre>
0debug
void ff_id3v2_read_dict(AVIOContext *pb, AVDictionary **metadata, const char *magic, ID3v2ExtraMeta **extra_meta) { id3v2_read_internal(pb, metadata, NULL, magic, extra_meta); }
1threat
Parse error: syntax error, unexpected '!' : <p>i am getting following error while running the code<br> any help</p> <pre><code>if(!$subcurpass){ $form-&gt;setError($field, "* Current Password not entered"); } else{ $subcurpass = stripslashes($subcurpass); if(strlen($subcurpass) &lt; 4 !eregi("^([0-9a-z])+$", ($subcurpass = trim($subcurpass)))){ $form-&gt;setError($field, "* Current Password incorrect"); </code></pre>
0debug
how to connect to database in C# using SqlConnection Object : How can I connect to a remote or local database using simple SqlConnection Object. I learned to do it this way: but my connection is failing. I read about creation of connection string from this page: https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx using System.Data.SqlClient; namespace SyncApp_BuiltInProviders { public partial class Form1 : Form { private void btnSynchronize_Click(object sender, EventArgs e) { SqlConnection source_conn = new SqlConnection(); source_conn.ConnectionString ="Server=localhost;Database = ptls; UID = root;Password = ODYSSEY99GRANITE;"; source_conn.Open(); } } }
0debug
How can I replace only plus sign (multiple occurrence) from a string without any text : <p>How can I replace multiple (++++++) signs with blank space?</p> <p>Example: <code>var string = "+++++++++++++++++";</code></p>
0debug
Sizing elements to percentage of screen width/height : <p>Is there a simple (non-LayoutBuilder) way to size an element relative to screen size (width/height)? For example: how do I set the width of a CardView to be 65% of the screen width.</p> <p>It can't be done inside the <code>build</code> method (obviously) so it would have to be deferred until post build. Is there a preferred place to put logic like this?</p>
0debug
def parabola_directrix(a, b, c): directrix=((int)(c - ((b * b) + 1) * 4 * a )) return directrix
0debug
Permission denied inside Docker container : <p>I have a started container <code>gigantic_booth</code> and I want to create the directory <code>/etc/test</code>:</p> <pre><code># docker exec -it gigantic_booth /bin/bash $ mkdir /etc/test $ mkdir: cannot create directory '/etc/test': Permission denied </code></pre> <p>And <code>sudo</code> command is not found. I don't want to create this directory in image-build-time but once is started.</p> <p>How can I do?</p> <p>Thanks :)</p>
0debug
What's Git.exe and do I need? (Newbie) : <p>I just installed Visual Studio Code. It gave a popup saying git.exe was missing.</p> <p>Do I need? What's it for? What am I missing if I don't get?</p> <p>Thanks.</p>
0debug
static void block_set_params(const MigrationParams *params, void *opaque) { block_mig_state.blk_enable = params->blk; block_mig_state.shared_base = params->shared; block_mig_state.blk_enable |= params->shared; }
1threat
I am finding it hard to understand inheritance in C# : <p>Am wondering of this case: Employee inherits from Person and Manager inherits from Employee, which statement will be correct?</p> <pre><code>Person alice = new Employee(); Employee bob = new Person(); Manager cindy = new Employee(); Manager dan = (Manager)(new Employee()); </code></pre>
0debug
Hey guys, can you help me and tell me how am i using wrongly the void expression? : I'm newbie in C and wanted to create a function that receives one integer n and one array V, and check if my array contains the values of 1 to n. This is my actual code: #include <stdio.h> void checkArray(int n, int* V); void checkArray(int n, int* V){ int remain = n; size_t length = sizeof V / sizeof V[0]; for(int i = 0; i<length;i++){ for(int j = 0; j<length;j++){ if(V[j] == remain){ remain--; } } } if(remain == 0) printf("It's Latin"); printf("Not Latin"); } int main(){ int n; scanf("%d", &n); int V[] = {1,2,3,4,5,6,7,8}; printf(checkArray(n, V)); } I'm getting the error at my printf, where it says invalid use of void expression.
0debug
how to solve this json error : iam new in json i dont know how to stringify the the data . below i write a code for alert the content but some error is shown how i solve that error <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> $('.savebutton').on('click', function (){ var myjson = {} var mainobject =[] myjson.push(mainobject); mainobject.main = {} mainobject.main.tittle = "'hai'"; mainobject.main.sub = []; var subobejct = {} mainobject.main.sub.push(subobejct); subobejct.tittle = "levler"; subobejct.tasks = [] var task = {}; subobejct.tasks.push(task); alert(JSON.stringify(myjson)); return myjson; }); <!-- end snippet -->
0debug
Dagger 2 - two provides method that provide same interface : <p>lets say I have:</p> <pre><code>public interface Shape {} public class Rectangle implements Shape { } public class Circle implements Shape { } </code></pre> <p>and I have a <strong>ApplicationModule</strong> which needs to provides instances for both <strong>Rec</strong> and <strong>Circle</strong>:</p> <pre><code>@Module public class ApplicationModule { private Shape rec; private Shape circle; public ApplicationModule() { rec = new Rectangle(); circle= new Circle (); } @Provides public Shape provideRectangle() { return rec ; } @Provides public Shape provideCircle() { return circle; } } </code></pre> <p>and <strong>ApplicationComponent</strong>:</p> <pre><code>@Component(modules = ApplicationModule.class) public interface ApplicationComponent { Shape provideRectangle(); } </code></pre> <p>with the code the way it is - it won't compile. error saying </p> <blockquote> <p>Error:(33, 20) error: Shape is bound multiple times.</p> </blockquote> <p>It makes sense to me that this can't be done, because the component is trying to find a <code>Shape</code> instance, and it finds two of them, so it doesn't know which one to return.</p> <p>My question is - how can I handle this issue?</p>
0debug
How can a move a sprite using the keyboard with pygame,livewires? : Hello: I have tried multiple different ways to make this work. I am making a remake of a video game to learn pygame and livewires. I am using livewires because it seems to be a good way to have the background graphics loaded with a sprite. I am trying to have a pre-loaded sprite move horizontally, while staying mobile on the correct location (in this case it is 50 pixels up). I can get the sprite move using pygame or I can have the background with the sprite loaded in the right position or I can have the sprite move, but both seems to not occur at the same time. For added bonus, I am also going to need the screen to scroll right when the character moves a different position. Here is my code: import pygame, sys from livewires import games from pygame.locals import * games.init(screen_width = 640, screen_height = 480, fps = 50) #setup up the window siz class Mario(games.Sprite): def update(self, pressed_keys): move = 50 #Setup the origianl position of the character if pressed_keys[K_RIGHT]: move += 1 #press right key to move forward if pressed_keys[K_LEFT]: move -= 1 #press left key to move back def main(): pygame.init() screen_image = games.load_image("World 1-1.bmp", transparent = False) #setup the background image games.screen.background = screen_image mario_image = games.load_image("Mario3.bmp") mario = games.Sprite(image = mario_image, x = move, y=370) #setup the position of the character sprites.add(mario) pygame.display.update() while True: for event in pygame.event.get(): if event.type == QUIT: return pygame.quit() #if the player quits keys_pressed = pygame.key.get_pressed() games.screen.mainloop() main()
0debug
Python program that rolls a fair die and counts the number of rolls before a 6 shows up : import random sample_size = int(input("Enter the number of times you want me to roll the die: ")) if (sample_size <=0): print("Please enter a positive number!") else: counter1 = 0 counter2 = 0 final = 0 while (counter1<= sample_size): dice_value = random.randint(1,6) if (dice_value) == 1: counter += 1 else: counter2 +=1 final = (counter2)/(sample_size) print("Estimation of the expected number of rolls before pigging out: " + str(expect)) Is the logic used here correct? Thanks
0debug
Is it possible to replace the %d : <pre><code>int main() { int M1[5][5], M2[10][3]; int i, j, k = 1, m, n; int x, y, z, l = 0; cout &lt;&lt; "Enter number of row "; cin &gt;&gt; m; cout &lt;&lt; "Enter number of columns"; cin &gt;&gt; n; printf("\nEnter the elements of the matrix :\n"); for (i = 0; i &lt; m; i++) { for (j = 0; j &lt; n; j++) { scanf ("%d", &amp;M1[i][j]); } } </code></pre> <p>I want to replace the 'scanf' with 'cin' but is it possible to replace the '%d' by something else and still keeping the data?</p>
0debug
Why my ping dont let me see the IP? maybe because im in job network? : <p>[CMD][<a href="https://i.stack.imgur.com/g8Mut.png]" rel="nofollow noreferrer">https://i.stack.imgur.com/g8Mut.png]</a></p> <p>I saw on youtube the others guys doesnt have it</p>
0debug
static void balloon_stats_get_all(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { Error *err = NULL; VirtIOBalloon *s = opaque; int i; visit_start_struct(v, name, NULL, 0, &err); if (err) { goto out; } visit_type_int(v, "last-update", &s->stats_last_update, &err); if (err) { goto out_end; } visit_start_struct(v, "stats", NULL, 0, &err); if (err) { goto out_end; } for (i = 0; i < VIRTIO_BALLOON_S_NR; i++) { visit_type_uint64(v, balloon_stat_names[i], &s->stats[i], &err); if (err) { break; } } error_propagate(errp, err); err = NULL; visit_end_struct(v, &err); out_end: error_propagate(errp, err); err = NULL; visit_end_struct(v, &err); out: error_propagate(errp, err); }
1threat
static void net_tx_pkt_do_sw_csum(struct NetTxPkt *pkt) { struct iovec *iov = &pkt->vec[NET_TX_PKT_L2HDR_FRAG]; uint32_t csum_cntr; uint16_t csum = 0; uint32_t cso; uint32_t iov_len = pkt->payload_frags + NET_TX_PKT_PL_START_FRAG - 1; uint16_t csl; struct ip_header *iphdr; size_t csum_offset = pkt->virt_hdr.csum_start + pkt->virt_hdr.csum_offset; iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum); csl = pkt->payload_len; iphdr = pkt->vec[NET_TX_PKT_L3HDR_FRAG].iov_base; csum_cntr = eth_calc_ip4_pseudo_hdr_csum(iphdr, csl, &cso); csum_cntr += net_checksum_add_iov(iov, iov_len, pkt->virt_hdr.csum_start, csl, cso); csum = cpu_to_be16(net_checksum_finish(csum_cntr)); iov_from_buf(iov, iov_len, csum_offset, &csum, sizeof csum); }
1threat
How to make a loop to count rows in datagridView c# : Hello guys I have a datagridView and DataTable. How to make a loop that add rows if it's not equal to 79rows? if it's equal to 79rows it will stop. Thankyou!
0debug
best tools for theme design? : <p>i am looking for bests and usable tools for creating wordpress themes.. and i Astounding in this process i want something like jQuery to do many things easily like fade, slide, selecting ... effects. id don't like to use frameworks that help to create faster like bootstrap or etc just want something that has powerful tools for theme design. like jquery or less.... i find many tools and i don't know exact usage of them react.js, mootools, ember.js, backbone.js, angular and .... what usage of them? is jquery UI useful? thanks...</p>
0debug
C++ socket error C1083: Cannot open include file: 'unistd.h': No such file or directory : <p>I'm following this tutorial <strong><a href="https://www.geeksforgeeks.org/socket-programming-cc/" rel="nofollow noreferrer">https://www.geeksforgeeks.org/socket-programming-cc/</a></strong>. I'm trying to practice Socket Programming in C/C++. Can someone tell me why I'm recieving this error and how to fix it? </p> <p><strong>error C1083: Cannot open include file: 'unistd.h': No such file or directory</strong></p> <p>thanks in advance</p> <pre><code>#include&lt;iostream&gt; #include&lt;string&gt; #include &lt;unistd.h&gt; #include &lt;stdio.h&gt; #include &lt;sys/socket.h&gt; #include &lt;stdlib.h&gt; #include &lt;netinet/in.h&gt; #include &lt;string.h&gt; #define PORT 8080 using namespace std; int main() { int server_fd, new_socket, valread; struct sockaddr_in address; int opt = 1; int addrlen = sizeof(address); char buffer[1024] = { 0 }; char *hello = "Hello from server"; // Creating socket file descriptor if ((server_fd = socket(AF_INET, SOCK_STREAM, 0)) == 0) { perror("socket failed"); exit(EXIT_FAILURE); } // Forcefully attaching socket to the port 8080 if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR | SO_REUSEPORT, &amp;opt, sizeof(opt))) { perror("setsockopt"); exit(EXIT_FAILURE); } address.sin_family = AF_INET; address.sin_addr.s_addr = INADDR_ANY; address.sin_port = htons(PORT); // Forcefully attaching socket to the port 8080 if (bind(server_fd, (struct sockaddr *)&amp;address, sizeof(address))&lt;0) { perror("bind failed"); exit(EXIT_FAILURE); } if (listen(server_fd, 3) &lt; 0) { perror("listen"); exit(EXIT_FAILURE); } if ((new_socket = accept(server_fd, (struct sockaddr *)&amp;address, (socklen_t*)&amp;addrlen))&lt;0) { perror("accept"); exit(EXIT_FAILURE); } valread = read(new_socket, buffer, 1024); printf("%s\n", buffer); send(new_socket, hello, strlen(hello), 0); printf("Hello message sent\n"); return 0; return 0; } </code></pre>
0debug
#c++ Copy constructors and Destructors;Copy constructors and Destructors : I am learning constructors and Destructors in c++; Help me grasp my mistakes even if they are silly... HERE is a code I have written to perform addition using classes in c++; This creates two summands of _datatype_ num and employs the constructor _sum()_ to perform sum of the two numbers; However when everything was goin' alright, I stumbled upon creating a copy constructor for num , (Although not necessary but still for practice)... without the dynamic object of the class _sum_ it is not possible to run the code anyway(without removing the copy constructor)... Help me improve my code and my mistakes in the code below; _Also I wanna know how to make use of the copy constructor in this program; the problem being that in the destructor the delete operation is being performed multiple times on the same piece of memory (I suppose)_ Here's my Code #include<iostream> #include<new> using namespace std; class num { public: int *a; num(int x) { try{ a=new int; }catch(bad_alloc xa) { cout<<"1"; exit(1); } *a=x; } num(){ } num(const num &ob) { try{ a=new int; }catch(bad_alloc xa) { cout<<"1''"; exit(2); } *a=*(ob.a); } ~num(){ cout<<"Destruct!!!"; delete a; } }; class sum:public num { public: int add; sum(num n1,num n2) { add=*(n1.a)+*(n2.a); } int getsum() { return add; } }; int main() { num x=58; num y=82; sum *s=new sum(x,y); cout<<s->getsum(); delete s; return 0; }
0debug
Please can someone help me training Random Forest regressor Model with Pyspark : I am working on a sentiment analysis project using data extracted in a json format extracted from stocktwits every tweet is assigned to a sentiment score wich is a float number between 0 and 1 .I want to train Random Forest using the pyspark Mllib
0debug
how make simpler expresion for showing multiple recyclerview in one activty : i try to make multiple recyclerview divided by textview in each recyclerview, thi code work for me but i want to make code simpler than before can anyone help me? here is my activity java public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ((MainActivity) getActivity()).setActionBarTitle("Tuntunan Toharoh"); // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_home, container, false); //============================================================= mRecyclerView = (RecyclerView) view.findViewById(R.id.recycler_view); mRecyclerView.setHasFixedSize(true); RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity()); mRecyclerView.setLayoutManager(layoutManager); mRecyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), LinearLayoutManager.VERTICAL)); RecyclerView.Adapter tadapter = new RecyclerViewAdapter(getActivity(), mRecyclerViewItems); mRecyclerView.setAdapter(tadapter); addMenuItemsFromJson(); mRecyclerView.setNestedScrollingEnabled(false); //========================================================= DzRecyclerView2 = (RecyclerView) view.findViewById(R.id.recycler_submenu); DzRecyclerView2.setHasFixedSize(true); RecyclerView.LayoutManager zlayoutManager = new LinearLayoutManager(getActivity()); DzRecyclerView2.setLayoutManager(zlayoutManager); RecyclerView.Adapter zadapter = new RecyclerViewAdapter(getActivity(), mRecyclerViewItems2); DzRecyclerView2.setAdapter(zadapter); addMenuItemsFromJson2(); DzRecyclerView2.setNestedScrollingEnabled(false); //========================================================= DzaRecyclerView3 = (RecyclerView) view.findViewById(R.id.recycler_mandi); DzaRecyclerView3.setHasFixedSize(true); RecyclerView.LayoutManager zzlayoutManager = new LinearLayoutManager(getActivity()); DzaRecyclerView3.setLayoutManager(zzlayoutManager); RecyclerView.Adapter ziadapter = new RecyclerViewAdapter(getActivity(), mRecyclerViewItems3); DzaRecyclerView3.setAdapter(ziadapter); addMenuItemsFromJson3(); DzaRecyclerView3.setNestedScrollingEnabled(false); //========================================================= return view; private void addMenuItemsFromJson() { try { String jsonDataString = readJsonDataFromFile(); JSONArray menuItemsJsonArray = new JSONArray(jsonDataString); for (int i = 0; i < menuItemsJsonArray.length(); ++i) { JSONObject menuItemObject = menuItemsJsonArray.getJSONObject(i); String menuItemtitle = menuItemObject.getString("title"); String menuItemContent = menuItemObject.getString("content"); DafAdapter dafa = new DafAdapter(menuItemtitle, menuItemContent); mRecyclerViewItems.add(dafa); } } catch (IOException | JSONException exception) { Log.e(MainActivity.class.getName(), "Unable to parse JSON file.", exception); } } private String readJsonDataFromFile() throws IOException { InputStream inputStream = null; StringBuilder builder = new StringBuilder(); try { String jsonDataString = null; inputStream = getResources().openRawResource(R.raw.tayamum); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream, "UTF-8")); while ((jsonDataString = bufferedReader.readLine()) != null) { builder.append(jsonDataString); } } finally { if (inputStream != null) { inputStream.close(); } } return new String(builder); } private void addMenuItemsFromJson2() { try { String jsonDataString = readJsonDataFromFile2(); JSONArray menuItemsJsonArray = new JSONArray(jsonDataString); for (int i = 0; i < menuItemsJsonArray.length(); ++i) { JSONObject menuItemObject = menuItemsJsonArray.getJSONObject(i); String menuItemtitle = menuItemObject.getString("title"); String menuItemContent = menuItemObject.getString("content"); DafAdapter dafa = new DafAdapter(menuItemtitle, menuItemContent); mRecyclerViewItems2.add(dafa); } } catch (IOException | JSONException exception) { Log.e(MainActivity.class.getName(), "Unable to parse JSON file.", exception); } } private String readJsonDataFromFile2() throws IOException { InputStream inputStream = null; StringBuilder builder = new StringBuilder(); try { String jsonDataString = null; inputStream = getResources().openRawResource(R.raw.wudhu); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream, "UTF-8")); while ((jsonDataString = bufferedReader.readLine()) != null) { builder.append(jsonDataString); } } finally { if (inputStream != null) { inputStream.close(); } } return new String(builder); } private void addMenuItemsFromJson3() { try { String jsonDataString = readJsonDataFromFile3(); JSONArray menuItemsJsonArray = new JSONArray(jsonDataString); for (int i = 0; i < menuItemsJsonArray.length(); ++i) { JSONObject menuItemObject = menuItemsJsonArray.getJSONObject(i); String menuItemtitle = menuItemObject.getString("title"); String menuItemContent = menuItemObject.getString("content"); DafAdapter dafa = new DafAdapter(menuItemtitle, menuItemContent); mRecyclerViewItems3.add(dafa); } } catch (IOException | JSONException exception) { Log.e(MainActivity.class.getName(), "Unable to parse JSON file.", exception); } } private String readJsonDataFromFile3() throws IOException { InputStream inputStream = null; StringBuilder builder = new StringBuilder(); try { String jsonDataString = null; inputStream = getResources().openRawResource(R.raw.mandi); BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(inputStream, "UTF-8")); while ((jsonDataString = bufferedReader.readLine()) != null) { builder.append(jsonDataString); } } finally { if (inputStream != null) { inputStream.close(); } } return new String(builder); } if i want to add one or more recyclerview it just make similar expression just change expression 1 to others. i think it can be change and more simpler than i use here. maybe using **switch or if** i have tried but no luck for code, thanks
0debug
av_cold static int auto_matrix(SwrContext *s) { int i, j, out_i; double matrix[64][64]={{0}}; int64_t unaccounted, in_ch_layout, out_ch_layout; double maxcoef=0; char buf[128]; const int matrix_encoding = s->matrix_encoding; float maxval; in_ch_layout = clean_layout(s, s->in_ch_layout); if(!sane_layout(in_ch_layout)){ av_get_channel_layout_string(buf, sizeof(buf), -1, s->in_ch_layout); av_log(s, AV_LOG_ERROR, "Input channel layout '%s' is not supported\n", buf); return AVERROR(EINVAL); } out_ch_layout = clean_layout(s, s->out_ch_layout); if(!sane_layout(out_ch_layout)){ av_get_channel_layout_string(buf, sizeof(buf), -1, s->out_ch_layout); av_log(s, AV_LOG_ERROR, "Output channel layout '%s' is not supported\n", buf); return AVERROR(EINVAL); } memset(s->matrix, 0, sizeof(s->matrix)); for(i=0; i<64; i++){ if(in_ch_layout & out_ch_layout & (1ULL<<i)) matrix[i][i]= 1.0; } unaccounted= in_ch_layout & ~out_ch_layout; if(unaccounted & AV_CH_FRONT_CENTER){ if((out_ch_layout & AV_CH_LAYOUT_STEREO) == AV_CH_LAYOUT_STEREO){ if(in_ch_layout & AV_CH_LAYOUT_STEREO) { matrix[ FRONT_LEFT][FRONT_CENTER]+= s->clev; matrix[FRONT_RIGHT][FRONT_CENTER]+= s->clev; } else { matrix[ FRONT_LEFT][FRONT_CENTER]+= M_SQRT1_2; matrix[FRONT_RIGHT][FRONT_CENTER]+= M_SQRT1_2; } }else av_assert0(0); } if(unaccounted & AV_CH_LAYOUT_STEREO){ if(out_ch_layout & AV_CH_FRONT_CENTER){ matrix[FRONT_CENTER][ FRONT_LEFT]+= M_SQRT1_2; matrix[FRONT_CENTER][FRONT_RIGHT]+= M_SQRT1_2; if(in_ch_layout & AV_CH_FRONT_CENTER) matrix[FRONT_CENTER][ FRONT_CENTER] = s->clev*sqrt(2); }else av_assert0(0); } if(unaccounted & AV_CH_BACK_CENTER){ if(out_ch_layout & AV_CH_BACK_LEFT){ matrix[ BACK_LEFT][BACK_CENTER]+= M_SQRT1_2; matrix[BACK_RIGHT][BACK_CENTER]+= M_SQRT1_2; }else if(out_ch_layout & AV_CH_SIDE_LEFT){ matrix[ SIDE_LEFT][BACK_CENTER]+= M_SQRT1_2; matrix[SIDE_RIGHT][BACK_CENTER]+= M_SQRT1_2; }else if(out_ch_layout & AV_CH_FRONT_LEFT){ if (matrix_encoding == AV_MATRIX_ENCODING_DOLBY || matrix_encoding == AV_MATRIX_ENCODING_DPLII) { if (unaccounted & (AV_CH_BACK_LEFT | AV_CH_SIDE_LEFT)) { matrix[FRONT_LEFT ][BACK_CENTER] -= s->slev * M_SQRT1_2; matrix[FRONT_RIGHT][BACK_CENTER] += s->slev * M_SQRT1_2; } else { matrix[FRONT_LEFT ][BACK_CENTER] -= s->slev; matrix[FRONT_RIGHT][BACK_CENTER] += s->slev; } } else { matrix[ FRONT_LEFT][BACK_CENTER]+= s->slev*M_SQRT1_2; matrix[FRONT_RIGHT][BACK_CENTER]+= s->slev*M_SQRT1_2; } }else if(out_ch_layout & AV_CH_FRONT_CENTER){ matrix[ FRONT_CENTER][BACK_CENTER]+= s->slev*M_SQRT1_2; }else av_assert0(0); } if(unaccounted & AV_CH_BACK_LEFT){ if(out_ch_layout & AV_CH_BACK_CENTER){ matrix[BACK_CENTER][ BACK_LEFT]+= M_SQRT1_2; matrix[BACK_CENTER][BACK_RIGHT]+= M_SQRT1_2; }else if(out_ch_layout & AV_CH_SIDE_LEFT){ if(in_ch_layout & AV_CH_SIDE_LEFT){ matrix[ SIDE_LEFT][ BACK_LEFT]+= M_SQRT1_2; matrix[SIDE_RIGHT][BACK_RIGHT]+= M_SQRT1_2; }else{ matrix[ SIDE_LEFT][ BACK_LEFT]+= 1.0; matrix[SIDE_RIGHT][BACK_RIGHT]+= 1.0; } }else if(out_ch_layout & AV_CH_FRONT_LEFT){ if (matrix_encoding == AV_MATRIX_ENCODING_DOLBY) { matrix[FRONT_LEFT ][BACK_LEFT ] -= s->slev * M_SQRT1_2; matrix[FRONT_LEFT ][BACK_RIGHT] -= s->slev * M_SQRT1_2; matrix[FRONT_RIGHT][BACK_LEFT ] += s->slev * M_SQRT1_2; matrix[FRONT_RIGHT][BACK_RIGHT] += s->slev * M_SQRT1_2; } else if (matrix_encoding == AV_MATRIX_ENCODING_DPLII) { matrix[FRONT_LEFT ][BACK_LEFT ] -= s->slev * SQRT3_2; matrix[FRONT_LEFT ][BACK_RIGHT] -= s->slev * M_SQRT1_2; matrix[FRONT_RIGHT][BACK_LEFT ] += s->slev * M_SQRT1_2; matrix[FRONT_RIGHT][BACK_RIGHT] += s->slev * SQRT3_2; } else { matrix[ FRONT_LEFT][ BACK_LEFT] += s->slev; matrix[FRONT_RIGHT][BACK_RIGHT] += s->slev; } }else if(out_ch_layout & AV_CH_FRONT_CENTER){ matrix[ FRONT_CENTER][BACK_LEFT ]+= s->slev*M_SQRT1_2; matrix[ FRONT_CENTER][BACK_RIGHT]+= s->slev*M_SQRT1_2; }else av_assert0(0); } if(unaccounted & AV_CH_SIDE_LEFT){ if(out_ch_layout & AV_CH_BACK_LEFT){ if (in_ch_layout & AV_CH_BACK_LEFT) { matrix[BACK_LEFT ][SIDE_LEFT ] += M_SQRT1_2; matrix[BACK_RIGHT][SIDE_RIGHT] += M_SQRT1_2; } else { matrix[BACK_LEFT ][SIDE_LEFT ] += 1.0; matrix[BACK_RIGHT][SIDE_RIGHT] += 1.0; } }else if(out_ch_layout & AV_CH_BACK_CENTER){ matrix[BACK_CENTER][ SIDE_LEFT]+= M_SQRT1_2; matrix[BACK_CENTER][SIDE_RIGHT]+= M_SQRT1_2; }else if(out_ch_layout & AV_CH_FRONT_LEFT){ if (matrix_encoding == AV_MATRIX_ENCODING_DOLBY) { matrix[FRONT_LEFT ][SIDE_LEFT ] -= s->slev * M_SQRT1_2; matrix[FRONT_LEFT ][SIDE_RIGHT] -= s->slev * M_SQRT1_2; matrix[FRONT_RIGHT][SIDE_LEFT ] += s->slev * M_SQRT1_2; matrix[FRONT_RIGHT][SIDE_RIGHT] += s->slev * M_SQRT1_2; } else if (matrix_encoding == AV_MATRIX_ENCODING_DPLII) { matrix[FRONT_LEFT ][SIDE_LEFT ] -= s->slev * SQRT3_2; matrix[FRONT_LEFT ][SIDE_RIGHT] -= s->slev * M_SQRT1_2; matrix[FRONT_RIGHT][SIDE_LEFT ] += s->slev * M_SQRT1_2; matrix[FRONT_RIGHT][SIDE_RIGHT] += s->slev * SQRT3_2; } else { matrix[ FRONT_LEFT][ SIDE_LEFT] += s->slev; matrix[FRONT_RIGHT][SIDE_RIGHT] += s->slev; } }else if(out_ch_layout & AV_CH_FRONT_CENTER){ matrix[ FRONT_CENTER][SIDE_LEFT ]+= s->slev*M_SQRT1_2; matrix[ FRONT_CENTER][SIDE_RIGHT]+= s->slev*M_SQRT1_2; }else av_assert0(0); } if(unaccounted & AV_CH_FRONT_LEFT_OF_CENTER){ if(out_ch_layout & AV_CH_FRONT_LEFT){ matrix[ FRONT_LEFT][ FRONT_LEFT_OF_CENTER]+= 1.0; matrix[FRONT_RIGHT][FRONT_RIGHT_OF_CENTER]+= 1.0; }else if(out_ch_layout & AV_CH_FRONT_CENTER){ matrix[ FRONT_CENTER][ FRONT_LEFT_OF_CENTER]+= M_SQRT1_2; matrix[ FRONT_CENTER][FRONT_RIGHT_OF_CENTER]+= M_SQRT1_2; }else av_assert0(0); } if (unaccounted & AV_CH_LOW_FREQUENCY) { if (out_ch_layout & AV_CH_FRONT_CENTER) { matrix[FRONT_CENTER][LOW_FREQUENCY] += s->lfe_mix_level; } else if (out_ch_layout & AV_CH_FRONT_LEFT) { matrix[FRONT_LEFT ][LOW_FREQUENCY] += s->lfe_mix_level * M_SQRT1_2; matrix[FRONT_RIGHT][LOW_FREQUENCY] += s->lfe_mix_level * M_SQRT1_2; } else av_assert0(0); } for(out_i=i=0; i<64; i++){ double sum=0; int in_i=0; for(j=0; j<64; j++){ s->matrix[out_i][in_i]= matrix[i][j]; if(matrix[i][j]){ sum += fabs(matrix[i][j]); } if(in_ch_layout & (1ULL<<j)) in_i++; } maxcoef= FFMAX(maxcoef, sum); if(out_ch_layout & (1ULL<<i)) out_i++; } if(s->rematrix_volume < 0) maxcoef = -s->rematrix_volume; if (s->rematrix_maxval > 0) { maxval = s->rematrix_maxval; } else if ( av_get_packed_sample_fmt(s->out_sample_fmt) < AV_SAMPLE_FMT_FLT || av_get_packed_sample_fmt(s->int_sample_fmt) < AV_SAMPLE_FMT_FLT) { maxval = 1.0; } else maxval = INT_MAX; if(maxcoef > maxval || s->rematrix_volume < 0){ maxcoef /= maxval; for(i=0; i<SWR_CH_MAX; i++) for(j=0; j<SWR_CH_MAX; j++){ s->matrix[i][j] /= maxcoef; } } if(s->rematrix_volume > 0){ for(i=0; i<SWR_CH_MAX; i++) for(j=0; j<SWR_CH_MAX; j++){ s->matrix[i][j] *= s->rematrix_volume; } } for(i=0; i<av_get_channel_layout_nb_channels(out_ch_layout); i++){ for(j=0; j<av_get_channel_layout_nb_channels(in_ch_layout); j++){ av_log(NULL, AV_LOG_DEBUG, "%f ", s->matrix[i][j]); } av_log(NULL, AV_LOG_DEBUG, "\n"); } return 0; }
1threat
F# .NET Framework Console application template missing : <p>I'm having trouble creating <code>F# Console App</code> using <code>.Net Framework</code> (<strong>not .Net Core</strong>). When I open: </p> <p><code>Visual Studio 2017 -&gt; New project -&gt; Visual F# -&gt; .Net Standard</code> </p> <p>the only template visible is <code>Class Library</code>.</p> <p>Using Visual Studio Installer I added following packages:</p> <ul> <li><code>F# Language Support</code> (I know this is a dependency for .Net Core, but it still might be important)</li> <li><code>F# Desktop Language Support</code> (the installer said it has only 147KB size, is that okay?)</li> </ul> <p>However, this didn't change anything - still there is no template for <code>Console Application</code>. I have also tried to see if target version of .NET Framework changes anything, but it doesn't - am I missing anything else?</p> <p><strong>Note</strong>: I can't use the <code>.Net Core</code> version, even though I would like to, because the use of the framework I'm going to use only supports .Net Standard framework - it requires System.Windows.Forms.</p>
0debug
R.java file is not generated : <p>I'm new to Android development. I listen Eclipse is better for beginners. So i downloaded and installed in my laptop, Setup also successfully done. My problem is that errors while run the project because R.java file is not generated. Please help me.</p>
0debug
JavaScript code not working with "toLowerCase" on equating it with value received from prompt : <pre><code>let browser = prompt('Enter browser name','Enter here..'); if (browser.toLowerCase=='edge') { alert('You got the Edge!'); } else if (browser.toLowerCase=='chrome' || browser.toLowerCase=='firefox' || browser.toLowerCase=='safari' || browser.toLowerCase=='opera') { alert('Okay we support these browsers too!') } else { alert('We hope this page looks okay!'); } </code></pre> <p>The above code is only executing the "Else" condition (last one). Removing "toLowerCase" makes it work perfectly, but why don't it works with "toLowerCase"?? </p>
0debug
Setter not working for boolean but work fine in string C# : <p><a href="https://i.stack.imgur.com/K5yV3.png" rel="nofollow noreferrer">Error description</a></p> <p>I don't know why setter is not working for bool variable but working fine with string variable. Is bool requires special setter for it?</p>
0debug
apt-get update' returned a non-zero code: 100 : <p>I am trying to create a docker image from my docker file which has following contains</p> <pre><code>FROM ubuntu:14.04.4 RUN echo 'deb http://private-repo-1.hortonworks.com/HDP/ubuntu14/2.x/updates/2.4.2.0 HDP main' &gt;&gt; /etc/apt/sources.list.d/HDP.list RUN echo 'deb http://private-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/ubuntu14 HDP-UTILS main' &gt;&gt; /etc/apt/sources.list.d/HDP.list RUN echo 'deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/azurecore/ trusty main' &gt;&gt; /etc/apt/sources.list.d/azure-public-trusty.list RUN gpg --keyserver pgp.mit.edu --recv-keys B9733A7A07513CAD RUN gpg -a --export 07513CAD | apt-key add - RUN gpg --keyserver pgp.mit.edu --recv-keys B02C46DF417A0893 RUN gpg -a --export 417A0893 | apt-key add - RUN apt-get update </code></pre> <p>Which failing with following error </p> <pre><code>root@sbd-docker:~/ubuntu# docker build -t hdinsight . Sending build context to Docker daemon 3.072 kB Step 1 : FROM ubuntu:14.04.4 ---&gt; 8f1bd21bd25c Step 2 : RUN echo 'deb http://private-repo-1.hortonworks.com/HDP/ubuntu14/2.x/updates/2.4.2.0 HDP main' &gt;&gt; /etc/apt/sources.list.d/HDP.list ---&gt; Using cache ---&gt; bc23070c0b18 Step 3 : RUN echo 'deb http://private-repo-1.hortonworks.com/HDP-UTILS-1.1.0.20/repos/ubuntu14 HDP-UTILS main' &gt;&gt; /etc/apt/sources.list.d/HDP.list ---&gt; Using cache ---&gt; e45c32975e28 Step 4 : RUN echo 'deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/azurecore/ trusty main' &gt;&gt; /etc/apt/sources.list.d/azure-public-trusty.list ---&gt; Using cache ---&gt; 1659cdcab06e Step 5 : RUN gpg --keyserver pgp.mit.edu --recv-keys B9733A7A07513CAD ---&gt; Using cache ---&gt; ca73b2bfcd21 Step 6 : RUN gpg -a --export 07513CAD | apt-key add - ---&gt; Using cache ---&gt; 95596ad10bc9 Step 7 : RUN gpg --keyserver pgp.mit.edu --recv-keys B02C46DF417A0893 ---&gt; Using cache ---&gt; f497deeef5b5 Step 8 : RUN gpg -a --export 417A0893 | apt-key add - ---&gt; Using cache ---&gt; d01dbe7fa02e Step 9 : RUN apt-get update ---&gt; Running in 89d75799982f E: The method driver /usr/lib/apt/methods/https could not be found. The command '/bin/sh -c apt-get update' returned a non-zero code: 100 root@sbd-docker:~/ubuntu# </code></pre> <p>I am running this on Ubuntu 14.04.4</p> <p>I tried restarting the docker, cleaning up all docker images, installing <code>apt-transport-https</code> but nothing worked.</p> <p>I dont know whats wrong here.</p>
0debug
dynamically How to convert rows to columns in sql server : I want to convert rows to columns dynamically, for sample data I have given below query. create table testtable( tableid int primary key identity(1,1), tableDatetime datetime, names varchar(50), tablevalue decimal(18,9) ) go insert into testtable select '2019-06-13 13:56:39.117', 'test1',23.45 union all select '2019-06-13 13:56:39.117', 'test2',33.45 union all select '2019-06-13 13:56:39.117', 'test3',10.45 union all select '2019-06-13 13:56:39.117', 'test4',90.45 union all select '2019-06-13 14:01:41.280', 'test1',33.45 union all select '2019-06-13 14:01:41.280', 'test2',53.45 union all select '2019-06-13 14:01:41.280', 'test3',41.45 union all select '2019-06-13 14:01:41.280', 'test4',93.45 union all select '2019-06-13 14:06:42.363', 'test1',30.45 union all select '2019-06-13 14:06:42.363', 'test2',13.45 union all select '2019-06-13 14:06:42.363', 'test3',23.45 union all select '2019-06-13 14:06:42.363', 'test4',73.45 go select * from testtable I want to convert data into below format Datetime test1 test2 test3 test4 2019-06-13 13:56:39 23.45 33.45 10.45 90.45 2019-06-13 14:01:41 33.45 53.45 41.45 93.45 2019-06-13 14:06:42 30.45 13.45 23.45 73.45
0debug
int ff_hevc_decode_short_term_rps(HEVCContext *s, ShortTermRPS *rps, const HEVCSPS *sps, int is_slice_header) { HEVCLocalContext *lc = s->HEVClc; uint8_t rps_predict = 0; int delta_poc; int k0 = 0; int k1 = 0; int k = 0; int i; GetBitContext *gb = &lc->gb; if (rps != sps->st_rps && sps->nb_st_rps) rps_predict = get_bits1(gb); if (rps_predict) { const ShortTermRPS *rps_ridx; int delta_rps, abs_delta_rps; uint8_t use_delta_flag = 0; uint8_t delta_rps_sign; if (is_slice_header) { unsigned int delta_idx = get_ue_golomb_long(gb) + 1; if (delta_idx > sps->nb_st_rps) { av_log(s->avctx, AV_LOG_ERROR, "Invalid value of delta_idx in slice header RPS: %d > %d.\n", delta_idx, sps->nb_st_rps); return AVERROR_INVALIDDATA; } rps_ridx = &sps->st_rps[sps->nb_st_rps - delta_idx]; } else rps_ridx = &sps->st_rps[rps - sps->st_rps - 1]; delta_rps_sign = get_bits1(gb); abs_delta_rps = get_ue_golomb_long(gb) + 1; delta_rps = (1 - (delta_rps_sign << 1)) * abs_delta_rps; for (i = 0; i <= rps_ridx->num_delta_pocs; i++) { int used = rps->used[k] = get_bits1(gb); if (!used) use_delta_flag = get_bits1(gb); if (used || use_delta_flag) { if (i < rps_ridx->num_delta_pocs) delta_poc = delta_rps + rps_ridx->delta_poc[i]; else delta_poc = delta_rps; rps->delta_poc[k] = delta_poc; if (delta_poc < 0) k0++; else k1++; k++; } } rps->num_delta_pocs = k; rps->num_negative_pics = k0; if (rps->num_delta_pocs != 0) { int used, tmp; for (i = 1; i < rps->num_delta_pocs; i++) { delta_poc = rps->delta_poc[i]; used = rps->used[i]; for (k = i - 1; k >= 0; k--) { tmp = rps->delta_poc[k]; if (delta_poc < tmp) { rps->delta_poc[k + 1] = tmp; rps->used[k + 1] = rps->used[k]; rps->delta_poc[k] = delta_poc; rps->used[k] = used; } } } } if ((rps->num_negative_pics >> 1) != 0) { int used; k = rps->num_negative_pics - 1; for (i = 0; i < rps->num_negative_pics >> 1; i++) { delta_poc = rps->delta_poc[i]; used = rps->used[i]; rps->delta_poc[i] = rps->delta_poc[k]; rps->used[i] = rps->used[k]; rps->delta_poc[k] = delta_poc; rps->used[k] = used; k--; } } } else { unsigned int prev, nb_positive_pics; rps->num_negative_pics = get_ue_golomb_long(gb); nb_positive_pics = get_ue_golomb_long(gb); if (rps->num_negative_pics >= MAX_REFS || nb_positive_pics >= MAX_REFS) { av_log(s->avctx, AV_LOG_ERROR, "Too many refs in a short term RPS.\n"); return AVERROR_INVALIDDATA; } rps->num_delta_pocs = rps->num_negative_pics + nb_positive_pics; if (rps->num_delta_pocs) { prev = 0; for (i = 0; i < rps->num_negative_pics; i++) { delta_poc = get_ue_golomb_long(gb) + 1; prev -= delta_poc; rps->delta_poc[i] = prev; rps->used[i] = get_bits1(gb); } prev = 0; for (i = 0; i < nb_positive_pics; i++) { delta_poc = get_ue_golomb_long(gb) + 1; prev += delta_poc; rps->delta_poc[rps->num_negative_pics + i] = prev; rps->used[rps->num_negative_pics + i] = get_bits1(gb); } } } return 0; }
1threat
Cannot execute code after the loop in c++ : <p>I'm facing a problem in c++ that I don't understand.</p> <p>this is my code:</p> <pre><code>auto DataArray = jvalue.at(U("data")).as_array(); std::cout &lt;&lt; "Outside the loop, first output" &lt;&lt; std::endl; for (int i = 0; i &lt;= 10; i++) { auto data = DataArray[i]; auto dataObj = data.as_object(); std::wcout &lt;&lt; "inside the loop" &lt;&lt; std::endl; } std::cout &lt;&lt; "Outside the loop, second output" &lt;&lt; std::endl; </code></pre> <p>Output:</p> <pre><code>Outside the loop, first output inside the loop inside the loop inside the loop inside the loop inside the loop inside the loop inside the loop inside the loop inside the loop inside the loop Press any key to continue . . . </code></pre> <p>It seems the code stops after the loop reach its end. But why?</p> <p>But if I commented out the </p> <pre><code>//auto data = DataArray[i]; //auto dataObj = data.as_object(); </code></pre> <p>it doesn't have a problem.</p> <p>By the way I'm working on cpprest and get json object data from api. The <code>jvalue</code> variable holds the result.</p> <p>And if I try and catch the code:</p> <pre><code>try { auto data = DataArray[i]; auto dataObj = data.as_object(); std::wcout &lt;&lt; "inside the loop" &lt;&lt; std::endl; } catch (const std::exception&amp; e) { std::wcout &lt;&lt; e.what() &lt;&lt; std::endl; } </code></pre> <p>the result is infinite loop with output: <code>not an object</code>.</p> <p>Please help. Thank you.</p>
0debug
Creating a regular polygon grid over a spatial extent, rotated by a given angle : <p> Hi all,</p> <p>I am struggling with this and hope someone could come out with a simple solution.</p> <p>My objective is to create a regular polygon grid over the extent of a polygon, but <strong>rotated by a user-defined angle</strong>.</p> <p>I know that I can easily create a North/South polygon grid in <code>sf</code> using for example:</p> <pre class="lang-r prettyprint-override"><code>library(sf) #&gt; Linking to GEOS 3.6.2, GDAL 2.2.3, proj.4 4.9.3 inpoly &lt;- st_read(system.file("shape/nc.shp", package="sf"))[1,] %&gt;% sf::st_transform(3857) %&gt;% sf::st_geometry() grd &lt;- sf::st_make_grid(inpoly, cellsize = 3000) plot(inpoly, col = "blue") plot(grd, add = TRUE) </code></pre> <p><img src="https://i.imgur.com/WUx6ssr.png" alt=""></p> <p>I also know that I can easily rotate it by a given angle using:</p> <pre class="lang-r prettyprint-override"><code>rotang = 20 rot = function(a) matrix(c(cos(a), sin(a), -sin(a), cos(a)), 2, 2) grd_rot &lt;- (grd - st_centroid(st_union(grd))) * rot(rotang * pi / 180) + st_centroid(st_union(grd)) plot(inpoly, col = "blue") plot(grd_rot, add = TRUE) </code></pre> <p><img src="https://i.imgur.com/lCtXWlB.png" alt=""></p> <p>My problem is that , depending on the rotation angle, the general “orientation” of the input polygon and the cell size, <strong>the rotated grid may not cover anymore the full extent of the polygon</strong>, as shown below:</p> <pre class="lang-r prettyprint-override"><code>rotang = 45 rot = function(a) matrix(c(cos(a), sin(a), -sin(a), cos(a)), 2, 2) grd_rot &lt;- (grd - st_centroid(st_union(grd))) * rot(rotang * pi / 180) + st_centroid(st_union(grd)) plot(inpoly, col = "blue") plot(grd_rot, add = TRUE) </code></pre> <p><img src="https://i.imgur.com/YYgk9pA.png" alt=""></p> <p>Any clever idea about how I could address this issue and <strong>create a rotated grid fully covering the polygon</strong> (besides by creating a larger grid to start with, which is quite inefficient for small cellsizes?)? </p> <p>Either <code>sf</code> or <code>sp</code> solutions would be welcome. “Bonus points” if it is possible to make the grid start at one of the extreme vertexes of the polygon (i.e., the first line of the grid “touches” the northern vertex of the polygon), but that is not "mandatory". </p> <p>Created on 2018-07-11 by the <a href="http://reprex.tidyverse.org" rel="noreferrer">reprex package</a> (v0.2.0).</p>
0debug
static unsigned int dec_move_rp(DisasContext *dc) { TCGv t[2]; DIS(fprintf (logfile, "move $r%u, $p%u\n", dc->op1, dc->op2)); cris_cc_mask(dc, 0); t[0] = tcg_temp_new(TCG_TYPE_TL); if (dc->op2 == PR_CCS) { cris_evaluate_flags(dc); t_gen_mov_TN_reg(t[0], dc->op1); if (dc->tb_flags & U_FLAG) { t[1] = tcg_temp_new(TCG_TYPE_TL); tcg_gen_andi_tl(t[0], t[0], 0x39f); tcg_gen_andi_tl(t[1], cpu_PR[PR_CCS], ~0x39f); tcg_gen_or_tl(t[0], t[1], t[0]); tcg_temp_free(t[1]); } } else t_gen_mov_TN_reg(t[0], dc->op1); t_gen_mov_preg_TN(dc, dc->op2, t[0]); if (dc->op2 == PR_CCS) { cris_update_cc_op(dc, CC_OP_FLAGS, 4); dc->flags_uptodate = 1; } tcg_temp_free(t[0]); return 2; }
1threat
static void spitz_common_init(MachineState *machine, enum spitz_model_e model, int arm_id) { PXA2xxState *mpu; DeviceState *scp0, *scp1 = NULL; MemoryRegion *address_space_mem = get_system_memory(); MemoryRegion *rom = g_new(MemoryRegion, 1); const char *cpu_model = machine->cpu_model; if (!cpu_model) cpu_model = (model == terrier) ? "pxa270-c5" : "pxa270-c0"; mpu = pxa270_init(address_space_mem, spitz_binfo.ram_size, cpu_model); sl_flash_register(mpu, (model == spitz) ? FLASH_128M : FLASH_1024M); memory_region_init_ram(rom, NULL, "spitz.rom", SPITZ_ROM, &error_abort); vmstate_register_ram_global(rom); memory_region_set_readonly(rom, true); memory_region_add_subregion(address_space_mem, 0, rom); spitz_keyboard_register(mpu); spitz_ssp_attach(mpu); scp0 = sysbus_create_simple("scoop", 0x10800000, NULL); if (model != akita) { scp1 = sysbus_create_simple("scoop", 0x08800040, NULL); } spitz_scoop_gpio_setup(mpu, scp0, scp1); spitz_gpio_setup(mpu, (model == akita) ? 1 : 2); spitz_i2c_setup(mpu); if (model == akita) spitz_akita_i2c_setup(mpu); if (model == terrier) spitz_microdrive_attach(mpu, 1); else if (model != akita) spitz_microdrive_attach(mpu, 0); spitz_binfo.kernel_filename = machine->kernel_filename; spitz_binfo.kernel_cmdline = machine->kernel_cmdline; spitz_binfo.initrd_filename = machine->initrd_filename; spitz_binfo.board_id = arm_id; arm_load_kernel(mpu->cpu, &spitz_binfo); sl_bootparam_write(SL_PXA_PARAM_BASE); }
1threat
SQL Remove substring results from result set : [Pls help with the query][1] Pls help with the T-sql query [1]: https://i.stack.imgur.com/pBKAX.jpg
0debug
SimpleDateFormat is giving wrong Date : <p><strong>I am inputting a specific date (dd/MM/yyyy) , while displaying it the Output is something else.</strong></p> <pre><code>import java.text.*; import java.io.*; import java.util.*; class InvalidUsernameException extends Exception //Class InvalidUsernameException { InvalidUsernameException(String s) { super(s); } } /////////////////////////////////////////////////////////////////////////////////////////// class InvalidPasswordException extends Exception //Class InvalidPasswordException { InvalidPasswordException(String s) { super(s); } } /////////////////////////////////////////////////////////////////////////////////////////// class InvalidDateException extends Exception //Class InvalidPasswordException { InvalidDateException(String s) { super(s); } } /////////////////////////////////////////////////////////////////////////////////////////// class EmailIdb1 //Class Email Id b1 { String username, password; int domainid; Date dt; EmailIdb1() { username = ""; domainid = 0; password = ""; dt = new Date(); } EmailIdb1(String u, String pwd, int did, int d, int m, int y) { username = u; domainid = did; password = pwd; dt = new Date(y,m,d); // I think There is a problem SimpleDateFormat formater = new SimpleDateFormat ("yyyy/MM/dd"); //Or there can be a problem try{ if((username.equals("User"))) { throw new InvalidUsernameException("Invalid Username"); } else if((password.equals("123"))) { throw new InvalidPasswordException("Invalid Password"); } else{ System.out.println("\nSuccesfully Login on Date : "+formater.format(dt)); } } catch(Exception e) { } } } /////////////////////////////////////////////////////////////////////////////////////////// class EmailId //Class Email Id { public static void main(String args[]) { int d,m,y,did; String usn,pwd; EmailIdb1 eml; try{ usn = args[0]; pwd = args[1]; did = Integer.parseInt(args[2]); d = Integer.parseInt(args[3]); m = Integer.parseInt(args[4]); y = Integer.parseInt(args[5]); switch(m) { case 2: if(d==29 &amp;&amp; y%4 == 0) { eml = new EmailIdb1(usn,pwd,did,d,m,y); } else if(d&lt;=28 &amp;&amp; d&gt;=1) { eml = new EmailIdb1(usn,pwd,did,d,m,y); } else{ throw new InvalidDateException("Wrong Date."); } break; case 1: case 3: case 5: case 7: case 8: case 10: case 12: if(d&gt;=1 &amp;&amp; d&lt;=31) { eml = new EmailIdb1(usn,pwd,did,d,m,y); } else { throw new InvalidDateException("Invalid Date"); } break; case 4: case 6: case 9: case 11: if(d&gt;=1 &amp;&amp; d&lt;=30) { eml = new EmailIdb1(usn,pwd,did,d,m,y); } else { throw new InvalidDateException("Invalid Date"); } break; default : throw new InvalidDateException("Invalid Date"); } } catch(InvalidDateException ed) { System.out.println(ed); } } } </code></pre> <p>Me and my two friends have similar kind of problem. Don't know why This is Happening. My teacher also couldn't find what's the problem</p> <p>The Output Should be</p> <pre><code>Successfully Login on Date : 1994/05/04 </code></pre> <p>As the Input Is</p> <pre><code>Successfully Login on Date : 3894/06/04 </code></pre>
0debug
static void write_long(unsigned char *p,uint32_t v) { p[0] = v>>24; p[1] = v>>16; p[2] = v>>8; p[3] = v; }
1threat
How to group array of objects by value : <p>I'm making a data set for one of my components, current data is</p> <pre><code> [ {name : "John" , id : "123"} , {name : "Josh" , id : "1234"}, {name : "Charlie" , id : "1234253"}, {name : "Charles" , id : "123345"} ] </code></pre> <p>want it to groupby like</p> <pre><code> { C : [{name:"Charlie",id:"1234253"},{name:"Charles",id:"123345"}], J : [{name:"John",id:"123"},{name:"Josh",id:"1234"}] } </code></pre>
0debug
Squash and merge master into same branch : <p>Is there a way to squash and merge master into the same branch? Effectively taking all the pending commits and putting them into 1 commit?</p> <p>My original idea is a script that takes <code>my-branch</code> and does a <code>git checkout master &amp;&amp; git pull &amp;&amp; git checkout my-branch-squashed</code> and then <code>git merge --squash my-branch</code> (deal with any merge conflicts) and then finally delete <code>my-branch</code> and rename <code>my-branch-squash</code> to <code>my-branch</code></p> <p>This seem very round-about and possibly bad, so I am trying to see if there is any other way. The intent I am trying to solve is that when I put branches on github and they are "squashed and merged" into master, the branch that exists on the local machine doesn't match the branch that was merged into master, so when using <code>git branch --merged ${1-master} | grep -v " ${1-master}$" | xargs -r git branch -d;</code> it doesnt correctly delete the branches that have already been merged into master. What I want is a way to auto-delete old branches that have been merged into master</p>
0debug
cant compile matrix multiplication ( C ) : Hey i got this error and i tried like 10 solutions and either works. I want to load 2 matrix, each one from its own txt file then to multiply them. I cant compile casue of LNK1120 and LNK2019 errors. Here is my code: int main(int argc, char *argv[]) { FILE *macierz1, *macierz2, *fw; char *line = malloc(1000); int count = 0; macierz1 = fopen("macierz1.txt", "r"); if (macierz1 == NULL) {`` printf("nie można otworzyć", argv[1]); exit(1); } macierz2 = fopen("macierz2.txt", "r"); if (macierz2 == NULL) { printf("nie można otworzyć", argv[2]); exit(1); } double *data = (double*)malloc(1000 * sizeof(double)); if (data == NULL) { printf("błąd lokowania pamięci"); return EXIT_FAILURE; } getline(&line, &count, macierz1); int read = -1, cur = 0, columCount1 = 0; while (sscanf(line + cur, "%lf%n", &data[columCount1], &read) == 1) { cur += read; columCount1++; } int rowCount1 = 1; while (getline(&line, &count, macierz1) != -1) { rowCount1++; } printf("%d\n", columCount1); printf("%d\n", rowCount1); getline(&line, &count, macierz2); read = -1, cur = 0; int columCount2 = 0; while (sscanf(line + cur, "%lf%n", &data[columCount2], &read) == 1) { cur += read; columCount2++; } int rowCount2 = 1; while (getline(&line, &count, macierz2) != -1) { rowCount2++; } printf("%d\n", columCount2); printf("%d\n", rowCount2); int i = 0; int j = 0; int **mat1 = (int **)malloc(rowCount1 * sizeof(int*)); for (i = 0; i < rowCount1; i++) mat1[i] = (int *)malloc(columCount1 * sizeof(int)); fseek(macierz1, 0, SEEK_SET); for (i = 0; i < rowCount1; i++) { for (j = 0; j < columCount1; j++) fscanf(macierz1, "%d", &mat1[i][j]); } i = 0; j = 0; printf("\n\n"); //print matrix 1 for (i = 0; i < rowCount1; i++) { for (j = 0; j < columCount1; j++) printf("%d", mat1[i][j]); printf("\n"); } i = 0; j = 0; int **mat2 = (int **)malloc(rowCount2 * sizeof(int*)); for (i = 0; i < rowCount2; i++) mat2[i] = (int *)malloc(columCount2 * sizeof(int)); fseek(macierz2, 0, SEEK_SET); for (i = 0; i < rowCount2; i++) { for (j = 0; j < columCount2; j++) fscanf(macierz2, "%d", &mat2[i][j]); } i = 0; j = 0; printf("\n\n"); //print matrix 2 for (i = 0; i < rowCount2; i++) { for (j = 0; j < columCount2; j++) printf("%d", mat2[i][j]); printf("\n"); } i = 0; int **mat3 = (int **)malloc(rowCount1 * sizeof(int*)); for (i = 0; i < rowCount1; i++) mat3[i] = (int *)malloc(columCount2 * sizeof(int)); i = 0; j = 0; int k = 0; int sum = 0; if (columCount1 != rowCount2) { puts("The number of columns in Matrix 1 is not same as the number of rows in Matrix 2"); exit(1); } //multiplication of two matrices for (i = 0; i<rowCount1; i++) { for (j = 0; j<columCount2; j++) { mat3[i][j] = 0; for (k = 0; k<columCount1; k++) { mat3[i][j] = mat3[i][j] + mat1[i][k] * mat2[k][j]; } } } //print multiplication result printf("\n\nResult = \n\n"); for (i = 0; i < rowCount1; i++) { for (j = 0; j < columCount2; j++) printf("%d", mat3[i][j]); printf("\n"); } for (i = 0; i< rowCount1; i++) free(mat1[i]); free(mat1); for (i = 0; i< rowCount2; i++) free(mat2[i]); free(mat2); for (i = 0; i< rowCount1; i++) free(mat3[i]); free(mat3); free(data); return 0; }
0debug
what are inheritAttrs:false and $attrs used for in vue? : <p>As the question suggests, I can't figure out their meaning and why I should use it. It's said that it can be used so that when we have many components and we want to pass data from parent to the child's child's child's component, we don't have to use props. Is this true?</p> <p>It'd be nice If you could provide an easier example. Vue.js docs don't mention much.</p>
0debug
how to add days using Date without using Calender : so i made a class called XDate which extends java.util.Date but do things little different, for example getMonth return a value from 1-12 and not 0-11, now , i want to make a function called addDays(int a), wich bassicly uses the current date (the date can be edited in the constructor) and add the number a to the days section, using Date.getTime() and the Date constructor that gets miliseconds .
0debug
static void qxl_log_image(PCIQXLDevice *qxl, QXLPHYSICAL addr, int group_id) { QXLImage *image; QXLImageDescriptor *desc; image = qxl_phys2virt(qxl, addr, group_id); desc = &image->descriptor; fprintf(stderr, " (id %" PRIx64 " type %d flags %d width %d height %d", desc->id, desc->type, desc->flags, desc->width, desc->height); switch (desc->type) { case SPICE_IMAGE_TYPE_BITMAP: fprintf(stderr, ", fmt %d flags %d x %d y %d stride %d" " palette %" PRIx64 " data %" PRIx64, image->bitmap.format, image->bitmap.flags, image->bitmap.x, image->bitmap.y, image->bitmap.stride, image->bitmap.palette, image->bitmap.data); break; } fprintf(stderr, ")"); }
1threat
Cant make listview it said array null on android studio : i want to display contacts that i get from api using listview. but when i want to run it, it forced close. when i try to look the log that i made, the usernamefriendprofile array is null outside the response. otherwise,the usernamefriendprofile array had a value inside the response. if i put the array adapter in response it get an error like > Cannot resolve constructor 'ArrayAdapter(anonymous com.androidnetworking.interfaces JSONObject RequestListener, int, int, java.util.ArrayList<java.lang.String>) public class MainActivity extends AppCompatActivity { private static final String TAG = "MainActivity"; private TextView username; public String tokenUser; public JSONObject namaTeman; public String namaUser; public JSONArray friends; private TextView usernameFriends; ArrayList<String> usernameFriendsProfile = new ArrayList<String>(); ListView teman; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tokenUser= getIntent().getStringExtra("token"); Log.d(TAG, "tokenmainactivity" + tokenUser); //untuk log pada onerror Log.d(TAG, "tokenhalamanselanjutnya " + tokenUser); username = (TextView) findViewById (R.id.user); usernameFriends = (TextView)findViewById(R.id.usernameTeman); teman=(ListView)findViewById(R.id.teman); initData(); ArrayAdapter<String> arrayAdapter=new ArrayAdapter<String>(this,R.layout.activity_listview,R.id.usernameTeman,usernameFriendsProfile); teman.setAdapter(arrayAdapter); Log.d(TAG, "usernametemendiluar : " + usernameFriendsProfile); } public void initData() { //get user AndroidNetworking.get("http://10.0.2.2:3000/users") .addHeaders("Authorization","Bearer "+tokenUser) .setPriority(Priority.MEDIUM) .build() .getAsJSONObject(new JSONObjectRequestListener() { @Override public void onResponse(JSONObject response) { Log.d(TAG, "onResponse: " + response); //untuk log pada onresponse try { JSONObject obj = new JSONObject(String.valueOf(response)); String usernameAkun = obj.getString("username"); username.setText(usernameAkun); Log.d(TAG, "namaprofil : " + username); JSONArray friends = obj.getJSONArray("friends"); for (int i=0;i<friends.length();i++) { JSONObject objek = friends.getJSONObject(i); usernameFriendsProfile.add(objek.getString("username")); } Log.d(TAG, "usernametemendidalem : " + usernameFriendsProfile); } catch (JSONException e) { e.printStackTrace(); } } @Override public void onError(ANError error) { Log.d(TAG, "onError: Failed" + error); //untuk log pada onerror } }); } } anyone know how to fix it ? thanks
0debug
Android Studio: Load a File into an Array : <p>I have made a class that can save an array to file, yet, I need it to load the file back into an array inside of an Activity named SampleGridViewAdapter.</p> <p>Text file format named gallerydump_img.txt:</p> <pre><code>https://mywebsite.com/path/samplefile.rtf https://anotherwebsite.com/ https://thirdwebsite.com/example/ </code></pre> <p>I have tried <code>strings = LIST[i]</code>, with <code>strings</code> being the output from the file, <code>i</code> being the loop, and <code>LIST</code> being the array to output the file data to, line by line. More code below:</p> <pre><code>@Override protected void onPostExecute(String[] strings) { for(int i = 0; i &lt; strings.length; i++) { Log.e("GalleryFileDump", strings[i]); ArrayToFile.writeArrayToFile(strings, Environment.getExternalStorageDirectory() + "/gallerydump_img.txt", "Eww, errors. Want a cookie? :: Unable to write to file gallerydump.bin. Check the report below for more information. :)"); strings = LIST[i] } } </code></pre> <p>Any help appreciated. Thanks!</p>
0debug
static int parse_section_header(GetByteContext *gbc, int *section_size, enum HapSectionType *section_type) { if (bytestream2_get_bytes_left(gbc) < 4) return AVERROR_INVALIDDATA; *section_size = bytestream2_get_le24(gbc); *section_type = bytestream2_get_byte(gbc); if (*section_size == 0) { if (bytestream2_get_bytes_left(gbc) < 4) return AVERROR_INVALIDDATA; *section_size = bytestream2_get_le32(gbc); } if (*section_size > bytestream2_get_bytes_left(gbc)) return AVERROR_INVALIDDATA; else return 0; }
1threat
static int v9fs_synth_chown(FsContext *fs_ctx, V9fsPath *path, FsCred *credp) { errno = EPERM; return -1; }
1threat
New to C++ and I'm having trouble calling my function : <pre><code>#include &lt;iostream&gt; #include &lt;math.h&gt; using namespace std; int Square(int num, int&amp; Answer); int Triangle(int num); int main(int argc, char **argv) { int num = -1; int Answer; //Prompts the user for the length of the sides and doesnt stop until they enter a valid input while(num &gt;= 6 || num &lt;= 1){ cout&lt;&lt;"Enter a number from 1 to 6: "; cin&gt;&gt;num; } Square(int num, int&amp; Answer); Triangle(int num, int&amp;Answer); } int Square(int num, int&amp; Answer){ Answer = num * num; cout&lt;&lt;Answer; } int Triangle(int num, int&amp; Answer){ Answer = .5 * (num * num); cout&lt;&lt;Answer; } </code></pre> <p>I'm not sure what I ma doing wrong but the error I keep getting is, expected primary-expression before 'int'</p> <p>This is where the error is and it shows up on each instance of int</p> <pre><code>Square(int num, int&amp; Answer); Triangle(int num, int&amp;Answer); </code></pre>
0debug
static uint32_t msix_mmio_readl(void *opaque, target_phys_addr_t addr) { PCIDevice *dev = opaque; unsigned int offset = addr & (MSIX_PAGE_SIZE - 1); void *page = dev->msix_table_page; uint32_t val = 0; memcpy(&val, (void *)((char *)page + offset), 4); return val; }
1threat
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
I need help create a function please look at details i have asked : I need a function created (EscapeAmpersand). The function should take 1 varchar(255) parameter. It should return a varchar(255) parameter. The purpose of the function is to take the input, replace ‘&’ with ‘&amp;’ and return the results. Examples: Input: ‘my dog & me’ return: ‘my dog &amp; me’ Input: ‘my dog and me’ return: ‘my dog and me’
0debug
Rendering a string as React component : <p>I want to render the react components with a string as the input which i am receiving dynamically from another page. BUt i will have the references for the react components. Here is the example</p> <pre><code>Page1: ----------------------------- loadPage('&lt;div&gt;&lt;Header value=signin&gt;&lt;/Header&gt;&lt;/div&gt;'); Page2: -------------------------------- var React =require('react'); var Header = require('./header'); var home = React.createClass({ loadPage:function(str){ this.setState({ content : str }); }, render : function(){ return {this.state.content} } }); </code></pre> <p>In this example i am receiving Header component as string , and i have the reference of Header component in my receiving page . How can i substitute the string with the actual react component</p>
0debug
static int flac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { FlacEncodeContext *s; const int16_t *samples; int frame_bytes, out_bytes, ret; s = avctx->priv_data; if (!frame) { s->max_framesize = s->max_encoded_framesize; av_md5_final(s->md5ctx, s->md5sum); write_streaminfo(s, avctx->extradata); return 0; } samples = (const int16_t *)frame->data[0]; if (frame->nb_samples < s->frame.blocksize) { s->max_framesize = ff_flac_get_max_frame_size(frame->nb_samples, s->channels, 16); } init_frame(s, frame->nb_samples); copy_samples(s, samples); channel_decorrelation(s); remove_wasted_bits(s); frame_bytes = encode_frame(s); if (frame_bytes > s->max_framesize) { s->frame.verbatim_only = 1; frame_bytes = encode_frame(s); } if ((ret = ff_alloc_packet(avpkt, frame_bytes))) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n"); return ret; } out_bytes = write_frame(s, avpkt); s->frame_count++; s->sample_count += frame->nb_samples; if ((ret = update_md5_sum(s, samples)) < 0) { av_log(avctx, AV_LOG_ERROR, "Error updating MD5 checksum\n"); return ret; } if (out_bytes > s->max_encoded_framesize) s->max_encoded_framesize = out_bytes; if (out_bytes < s->min_framesize) s->min_framesize = out_bytes; avpkt->pts = frame->pts; avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); avpkt->size = out_bytes; *got_packet_ptr = 1; return 0; }
1threat
How to compare a two files line by line and then word by word. Also we need to highlight the mismatched words in output : <p>How to compare a two files line by line and then word by word. Also we need to highlight the mismatched words in output.</p> <p>I need to write this in Java and create a HTML file.</p>
0debug
What is the difference between (++c) & (c++)? : <p>What is the difference between (++c) and (c++)?</p> <p>Lets say c = 4</p> <p>I know that for (++c) you would increment increment 4 by 1 so 5, but for (c++)?</p>
0debug
JAVASCRIPT ,html : $('#menuToggle, .menu-close').on('click', function(){ $('#menuToggle').toggleClass('active'); $('body').toggleClass('body-push-toleft'); $('#theMenu').toggleClass('menu-open'); $('#menuToggle').find($(".fa")).toggleClass('fa-rotate-180'); $("body").toggleClass("active"); }); this is my javascript code for navigation menu slide form right side.It is working properly but i want to close this menu when once it is open on click or close menu click anywhere on body and toggle button?
0debug
static void apply_window_and_mdct(AACEncContext *s, SingleChannelElement *sce, float *audio) { int i; float *output = sce->ret_buf; apply_window[sce->ics.window_sequence[0]](s->fdsp, sce, audio); if (sce->ics.window_sequence[0] != EIGHT_SHORT_SEQUENCE) s->mdct1024.mdct_calc(&s->mdct1024, sce->coeffs, output); else for (i = 0; i < 1024; i += 128) s->mdct128.mdct_calc(&s->mdct128, sce->coeffs + i, output + i*2); memcpy(audio, audio + 1024, sizeof(audio[0]) * 1024); memcpy(sce->pcoeffs, sce->coeffs, sizeof(sce->pcoeffs)); }
1threat
Need assist with my loop with a c++ dice program : how do I continue to keep the player rolling the dice till they roll the correct number or lose? Here are the directions. For this assignment, write a program that will simulate a single game of Craps. Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the die will determine whether the player (and anyone that has placed a bet) wins immediately, loses immediately, or if the game continues. If the sum of the first roll of the die is equal to 7 or 11, the player wins immediately. If the sum of the first roll of the die is equal to 2, 3, or 12, the player has rolled "craps" and loses immediately. If the sum of the first roll of the die is equal to 4, 5, 6, 8, 9, or 10, the game will continue with the sum becoming the "point." The object of the game is now for the player to continue rolling the die until they either roll a sum that equals the point or they roll a 7. If the player "makes their point," they win. If they roll a 7, they lose. Here is my program: #include <iostream> #include <ctime> #include <cstdlib> using namespace std; int main() { int dice_num1, dice_num2 = 0; int roll_dice; int dice_num3, dice_num4 = 0; int roll_dice2; char repeat = 'y'; while (repeat == 'y' || repeat == 'Y') { srand(time(0)); dice_num1 = rand() % 6 + 1; dice_num2 = rand() % 6 + 1; roll_dice = dice_num1 + dice_num2; cout <<"Player rolled: "<< dice_num1<<" + "<<dice_num2<<" = "<<roll_dice<<endl; cout <<"\nThe point is "<<roll_dice<<endl; dice_num3 = rand() % 6 + 1; dice_num4 = rand() % 6 + 1; roll_dice2 = dice_num3 + dice_num4; cout <<"\nPlayer rolled: "<< dice_num3<<" + "<<dice_num4<<" = "<<roll_dice2<<endl; if (roll_dice2 == 7 || roll_dice2 == 11) { cout << "Congrats you are a Winner!" << endl ; } else if (roll_dice2 == 2 || roll_dice2 == 3 || roll_dice2 == 12) { cout << "Sorry, you rolled craps, You lose!" << endl; } else if (roll_dice2 == 4 || roll_dice2 == 5 ||roll_dice2 == 6 ||roll_dice2 == 8 || roll_dice2 == 9 || roll_dice2 == 10) { dice_num3 = rand() % 6 + 1; dice_num4 = rand() % 6 + 1; int sum_num2 = dice_num3 + dice_num4; if( sum_num2 == roll_dice2 ) { cout << "Congrats you are a Winner!" << endl; break; } else if( sum_num2 == 7 ) { cout << "Sorry, You Lose!" << endl; break; } } cout <<"\nAnother game? Y(es) or N(o)" << endl; cin >> repeat; if (repeat == 'n' || repeat == 'N') { cout <<"Thank you for playing!"<< endl; return 0; } } } This is my output: Player rolled: 4 + 5 = 9 The point is 9 Player rolled: 5 + 3 = 9 Another game? Y(es) or N(o) This is what my output needs to be: Player rolled: 2 + 2 = 4 The point is 4 Player rolled: 4 + 5 = 9 Player rolled: 5 + 1 = 6 Player rolled: 1 + 2 = 3 Player rolled: 2 + 3 = 5 Player rolled: 1 + 2 = 3 Player rolled: 3 + 5 = 8 Player rolled: 2 + 4 = 6 Player rolled: 6 + 3 = 9 Player rolled: 6 + 2 = 8 Player rolled: 3 + 4 = 7 You rolled 7 and lost! How do i get this to continue rolling the dice in the loop, please tell me what i need to change. Thank you!
0debug
struct omap_sdrc_s *omap_sdrc_init(MemoryRegion *sysmem, hwaddr base) { struct omap_sdrc_s *s = (struct omap_sdrc_s *) g_malloc0(sizeof(struct omap_sdrc_s)); omap_sdrc_reset(s); memory_region_init_io(&s->iomem, NULL, &omap_sdrc_ops, s, "omap.sdrc", 0x1000); memory_region_add_subregion(sysmem, base, &s->iomem); return s; }
1threat
CSS table td color : <p>Am using this in Wordpress Tablepress plugin.</p> <p>I have these codes to highlight the table rows. Is there anyway I can merge them into single row to reduce the repeated codes?</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-css lang-css prettyprint-override"><code>.tablepress-id-1 .row-2 td { background-color: #000000; color: #ffffff; } .tablepress-id-1 .row-13 td { background-color: #000000; color: #ffffff; } .tablepress-id-1 .row-15 td { background-color: #000000; color: #ffffff; } .tablepress-id-1 .row-19 td { background-color: #000000; color: #ffffff; } .tablepress-id-1 .row-23 td { background-color: #000000; color: #ffffff; } .tablepress-id-1 .row-26 td { background-color: #000000; color: #ffffff; } .tablepress-id-1 .row-35 td { background-color: #000000; color: #ffffff; } .tablepress-id-1 .row-35 td { background-color: #000000; color: #ffffff; }</code></pre> </div> </div> </p>
0debug
I want to use stdin in a pytest test : <p>The PyTest documentation states that stdin is redirected to null as no-one will want to do interactive testing in a batch test context. This is true, but interactive is not the only use of stdin. I want to test code that uses stdin just as it would use any other file. I am happy with stdout and sterr being captured but how to actually have stdin connected to an io.StringIO object say in a PyTest conformant way?</p>
0debug
static uint64_t omap_mpu_timer_read(void *opaque, target_phys_addr_t addr, unsigned size) { struct omap_mpu_timer_s *s = (struct omap_mpu_timer_s *) opaque; if (size != 4) { return omap_badwidth_read32(opaque, addr); } switch (addr) { case 0x00: return (s->enable << 5) | (s->ptv << 2) | (s->ar << 1) | s->st; case 0x04: break; case 0x08: return omap_timer_read(s); } OMAP_BAD_REG(addr); return 0; }
1threat
Get number of comments within a forum : <p>I have 3 tables:</p> <p>forums, threads, comments</p> <p>I would like to write a query to get the number of comments within a forum.</p> <p>Every row in threads has a column "fid" which shows which forum the thread was posted in.</p> <p>Every row in comments has a column "tid" which shows which thread the comment was posted on.</p> <p>Do you have any idea?</p> <p>Thanks.</p>
0debug
Why do Node modules go into .staging folder? : <p>I have an Electron app that I'm trying to install node modules for. When I run <code>npm install</code>, it creates the <code>node_modules</code> folder but all the modules go into a subfolder called <code>.staging</code>. Each module also has <code>-xxxxx</code> appended to it, where the x's are some random alphanumerics.</p> <p>Other Electron apps I've created have never done this. All the node modules sit in the root of <code>node_modules</code> and don't have <code>-xxxxx</code> appended.</p> <p>Any idea why this is happening?</p>
0debug
Converting and integer to a list in python : Is there anyway to convert a string of integers into a list e.g. `1234` to `['1','2','3','4','5']`
0debug
Can't find an RSA key at my Amazon EC2 instance : <p>I have an Ubuntu instance on Amazon EC2. I can login to it via ssh. Also I have:</p> <pre><code>$ ls ~/.ssh/ authorized_keys </code></pre> <p>However, the rsa key itself doesn't exist. Where can I find it? So I'll be able to add it on my github account and pull a repo from it.</p>
0debug
Saving a certain motion in ios and comparing other motion to it : I want to know if this is possible in ios or no. I want to a calibrate a motion. For example If some one moves the iphone vertically from one point to another, I want the iphone to save that motion and if someone repeats the same motion the phone would be able to predict it. Is that possible using core motion ?
0debug
PHP to check if certain value exist in csv : I've a field in my database which has csv values, if I get the value in a variable it looks like > ` $data = "dell, dell7, jhon5, doe4"; ` //these are user id's I need to check if a certain id is already in this variable. I used `explode()` with `foreach()` and it worked well. But, I need to do this in several times and my code become messy. Is there any other way? I'm using Laravel(Lumen)
0debug
how can i display data from sql database to a textbox : I am currently searching, how can I put or display data from my database through a textbox that will be used to submit to a different table later on. $query=mysql_query("select * from subjects_main where Course='$c' && YearLevel='$d'"); if(!$query) { die("Error in Table"); }
0debug
How to create instances of same java class running in same process? : I am learning Java Process and I am trying to create two instances of same java class running in same process which is a requirement. Class Chat { public void getMessage() { *** some implementation } } class ProcessMain { public static void main(String args[]) { Chat c1 = new Chat(); Chat c2 = new Chat(); ProcessBuilder pb = new ProcessBuilder(c1); **** here is where I am stuck. Two instances of same class should run in same process } } Can anyone give me a lead?
0debug
Golang doc func parameters : <p>Reading the godoc <a href="https://blog.golang.org/godoc-documenting-go-code" rel="noreferrer">doc</a>. It does not specify how function parameters documented.</p> <p>What is the reason for omitting this?</p>
0debug