problem
stringlengths
26
131k
labels
class label
2 classes
Why does my UITableView "jump" when inserting or removing a row? : <p>(Happy to accept an answer in Swift or Objective-C)</p> <p>My table view has a few sections, and when a button is pressed, I want to insert a row at the end of section 0. Pressing the button again, I want delete that same row. My almost working code looks like this:</p> <pre><code>// model is an array of mutable arrays, one for each section - (void)pressedAddRemove:(id)sender { self.adding = !self.adding; // this is a BOOL property self.navigationItem.rightBarButtonItem.title = (self.adding)? @"Remove" : @"Add"; // if adding, add an object to the end of section 0 // tell the table view to insert at that index path [self.tableView beginUpdates]; NSMutableArray *sectionArray = self.model[0]; if (self.adding) { NSIndexPath *insertionPath = [NSIndexPath indexPathForRow:sectionArray.count inSection:0]; [sectionArray addObject:@{}]; [self.tableView insertRowsAtIndexPaths:@[insertionPath] withRowAnimation:UITableViewRowAnimationAutomatic]; // if removing, remove the object from the end of section 0 // tell the table view to remove at that index path } else { NSIndexPath *removalPath = [NSIndexPath indexPathForRow:sectionArray.count-1 inSection:0]; [sectionArray removeObject:[sectionArray lastObject]]; [self.tableView deleteRowsAtIndexPaths:@[removalPath] withRowAnimation:UITableViewRowAnimationAutomatic]; } [self.tableView endUpdates]; } </code></pre> <p>This behaves properly sometimes, but sometimes not, depending on where the table view is scrolled:</p> <ul> <li>Section 0 at the very top, contentOffset.y == 0: Works great, the row is inserted and the stuff below section 0 animates downward</li> <li>Section 0 invisible, because the table is scrolled past it: Works great, the visible content below the new row animates downward as if a row was inserted above it.</li> <li>BUT: if the table view is scrolled a little, so that part of section 0 is visible: it works wrong. In a single frame, all of the content in the table view jumps up (content offset increases) Then, with animation, the new row gets inserted and the table view content scrolls back down (content offset decreases). Everything ends up where it should be, but the process looks super bad with that single frame "jump" at the start.</li> </ul> <p>I can see this happen in slow-motion the simulator with "Debug->Toggle Slow Animations". The same problem occurs in reverse on the deletion.</p> <p>I've found that the size of the jump in offset is related to the how far into section 0 the table is scrolled: the jump tiny when the offset is tiny. The jump gets bigger as the scrolling approaches <em>half</em> of section 0 total height (the problem is at it's worst here, jump == half the section height). Scrolling further, the jump gets smaller. When the table is scrolled so that only a tiny amount of section 0 is still visible, the jump is tiny.</p> <p><strong>Can you help me understand why this is and how to fix?</strong></p>
0debug
opts_check_list(Visitor *v, Error **errp) { }
1threat
Huge files in Docker containers : <p>I need to create a Docker image (and consequently containers from that image) that use large files (containing genomic data, thus reaching ~10GB in size).</p> <p>How am I supposed to optimize their usage? Am I supposed to include them in the container (such as <code>COPY large_folder large_folder_in_container</code>)? Is there a better way of referencing such files? The point is that it sounds strange to me to push such container (which would be >10GB) in my private repository. I wonder if there is a way of attaching a sort of volume to the container, without packing all those GBs together.</p> <p>Thank you.</p>
0debug
Facebook graph API python wrapper? : Does anyone know how to get the following values from Facebook graph API using python? Lifetime Post Total Reach Lifetime Post organic reach Lifetime Post Paid Reach Lifetime Post Total Impressions Lifetime Post Organic Impressions Lifetime Post Paid Impressions Lifetime Engaged Users Lifetime Post Consumers Lifetime Post Consumptions Lifetime Negative feedback Lifetime Negative Feedback from Users Lifetime Post Impressions by people who have liked your Page Lifetime Post reach by people who like your Page Lifetime Post Paid Impressions by people who have liked your Page Lifetime Paid reach of a post by people who like your Page Lifetime People who have liked your Page and engaged with your post Lifetime Organic watches at 95% Lifetime Organic watches at 95% Lifetime Paid watches at 95% Lifetime Paid watches at 95% Lifetime Organic Video Views Lifetime Paid Video Views Lifetime Average time video viewed Lifetime Video length
0debug
Django Bootstrap App differences with the normal Bootstrap : <p>I read in books and see in tutorials that is better to use a Django Bootstrap example:</p> <p><a href="https://github.com/dyve/django-bootstrap-toolkit" rel="nofollow">https://github.com/dyve/django-bootstrap-toolkit</a></p> <p><a href="https://github.com/dyve/django-bootstrap3" rel="nofollow">https://github.com/dyve/django-bootstrap3</a></p> <p>Over using a base template with the Original boostrap?</p> <p>But what is the difference? Which one is better?</p>
0debug
void socket_listen_cleanup(int fd, Error **errp) { SocketAddress *addr; addr = socket_local_address(fd, errp); if (addr->type == SOCKET_ADDRESS_KIND_UNIX && addr->u.q_unix.data->path) { if (unlink(addr->u.q_unix.data->path) < 0 && errno != ENOENT) { error_setg_errno(errp, errno, "Failed to unlink socket %s", addr->u.q_unix.data->path); } } qapi_free_SocketAddress(addr); }
1threat
What does the "EXDEV: cross-device link not permitted" error mean? : <p>What does this error actually mean? What is a "cross-device link"?</p> <p>It is mentioned on <a href="http://docs.libuv.org/en/v1.x/errors.html" rel="noreferrer">this libuv page</a> but it doesn't give any details beyond "cross-device link not permitted".</p>
0debug
Anyone help me on this. I try to make a simple java system. How can i make a system to create this output? : (1 - 250) START = 870136 END = 870385 (251 - 500) START = 870386 END = 870635 (501 - 750) START = 870636 END = 870885 (751 - 1000) START = 870886 END = 871135 (1001 - 1250) START = 871136 END = 871385 (1251 - 1500) START = 871386 END = 871635 (1501 - 1750) START = 871636 END = 871885 (1751 - 2000) START = 871886 END = 872135
0debug
Does an 8-bit timer take same time as a 16-bit timer to overflow in microcontroller? : <p>I want to call a function after certain time, irrespective of the other code, so which timer should I select</p>
0debug
How can i have a java interface return an object of a non primitive type? : <p>Can java interface methods can only return primitive types (int,string,etc?)</p> <p>I want to have a method return a type "BitMap". But my IDE is complaining with Cannot resolve symbol "BitMap":</p> <pre><code>public interface MyContract { public BitMap getBitMap(); .... </code></pre> <p>I suspect I'm misunderstanding something inherent to interfaces that is preventing me from doing this?</p>
0debug
static int sd_open(BlockDriverState *bs, const char *filename, int flags) { int ret, fd; uint32_t vid = 0; BDRVSheepdogState *s = bs->opaque; char vdi[SD_MAX_VDI_LEN], tag[SD_MAX_VDI_TAG_LEN]; uint32_t snapid; char *buf = NULL; strstart(filename, "sheepdog:", (const char **)&filename); QLIST_INIT(&s->inflight_aio_head); QLIST_INIT(&s->pending_aio_head); s->fd = -1; memset(vdi, 0, sizeof(vdi)); memset(tag, 0, sizeof(tag)); if (parse_vdiname(s, filename, vdi, &snapid, tag) < 0) { ret = -EINVAL; goto out; } s->fd = get_sheep_fd(s); if (s->fd < 0) { ret = s->fd; goto out; } ret = find_vdi_name(s, vdi, snapid, tag, &vid, 0); if (ret) { goto out; } s->cache_flags = SD_FLAG_CMD_CACHE; if (flags & BDRV_O_NOCACHE) { s->cache_flags = SD_FLAG_CMD_DIRECT; } if (s->cache_flags == SD_FLAG_CMD_CACHE) { s->flush_fd = connect_to_sdog(s->addr, s->port); if (s->flush_fd < 0) { error_report("failed to connect"); ret = s->flush_fd; goto out; } } if (snapid || tag[0] != '\0') { dprintf("%" PRIx32 " snapshot inode was open.\n", vid); s->is_snapshot = true; } fd = connect_to_sdog(s->addr, s->port); if (fd < 0) { error_report("failed to connect"); ret = fd; goto out; } buf = g_malloc(SD_INODE_SIZE); ret = read_object(fd, buf, vid_to_vdi_oid(vid), 0, SD_INODE_SIZE, 0, s->cache_flags); closesocket(fd); if (ret) { goto out; } memcpy(&s->inode, buf, sizeof(s->inode)); s->min_dirty_data_idx = UINT32_MAX; s->max_dirty_data_idx = 0; bs->total_sectors = s->inode.vdi_size / SECTOR_SIZE; pstrcpy(s->name, sizeof(s->name), vdi); qemu_co_mutex_init(&s->lock); g_free(buf); return 0; out: qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL, NULL); if (s->fd >= 0) { closesocket(s->fd); } g_free(buf); return ret; }
1threat
no [query] registered for [filtered] : <p>I have a query which I need to filter out results.</p> <p>This is my query</p> <pre><code>{ "query": { "filtered": { "query": { "multi_match": { "default_operator": "AND", "fields": [ "author", "title", "publisher", "year" ], "query": "George Orwell" } }, "filter": { "terms": { "year": [ 1980, 1981 ] } } } } } </code></pre> <p>I get an error saying <code>no [query] registered for [filtered]</code>. I clearly have a query for the filtered field. I am following the format given in the filtered query documentation on the elasticsearch page. <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-filtered-query.html</a></p>
0debug
creating unique ID to assign to duplicate addresses in file : <p>I am working to create a household ID when people in my file have the same address but assigned to different people. I need it to be the same ID for each person with the same address not a sequential ID and I am using a program called Alpine so I need to use Sql or version of pig syntax. </p>
0debug
How to find out the number of arguments (using variable arguments) if the first argument just indicates and enum value? : <p>So I am given an list of enum values. This function will return integer value. It takes in an enum value and the rest is followed by integer values. I am supposed to get the total of the following integer values if the enum type is called total and return the total. </p>
0debug
static void mp3_update_xing(AVFormatContext *s) { MP3Context *mp3 = s->priv_data; int i; if (!mp3->has_variable_bitrate) { avio_seek(s->pb, mp3->xing_offset, SEEK_SET); ffio_wfourcc(s->pb, "Info"); } avio_seek(s->pb, mp3->xing_offset + 8, SEEK_SET); avio_wb32(s->pb, mp3->frames); avio_wb32(s->pb, mp3->size); avio_w8(s->pb, 0); for (i = 1; i < XING_TOC_SIZE; ++i) { int j = i * mp3->pos / XING_TOC_SIZE; int seek_point = 256LL * mp3->bag[j] / mp3->size; avio_w8(s->pb, FFMIN(seek_point, 255)); } avio_seek(s->pb, 0, SEEK_END); }
1threat
Password Verification in Ruby : I've been tasked with a very simple password verification, but for the life of me, I cannot seem to get this right. Here is the task: > The user sends a numeric password of 6 characters through a form. In > order to force secure passwords create a validation that the numbers > cannot consecutively go up or down. Here is what I have: password = '246879' new_password = password.split('').map { |s| s.to_i } new_password.each_with_index do |val, index| next_element = new_password[index + 1] prev_element = new_password[index - 1] if new_password[index] + 1 == next_element puts 'next bad' break elsif new_password[index] - 1 == prev_element puts 'prev bad' break end end The password should fail on the 87 because 7 is one less than 8. Thank you for any help.
0debug
static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { CFHDContext *s = avctx->priv_data; GetByteContext gb; ThreadFrame frame = { .f = data }; AVFrame *pic = data; int ret = 0, i, j, planes, plane, got_buffer = 0; int16_t *coeff_data; s->coded_format = AV_PIX_FMT_YUV422P10; init_frame_defaults(s); planes = av_pix_fmt_count_planes(s->coded_format); bytestream2_init(&gb, avpkt->data, avpkt->size); while (bytestream2_get_bytes_left(&gb) > 4) { uint16_t tagu = bytestream2_get_be16(&gb); int16_t tag = (int16_t)tagu; int8_t tag8 = (int8_t)(tagu >> 8); uint16_t abstag = abs(tag); int8_t abs_tag8 = abs(tag8); uint16_t data = bytestream2_get_be16(&gb); if (abs_tag8 >= 0x60 && abs_tag8 <= 0x6f) { av_log(avctx, AV_LOG_DEBUG, "large len %x\n", ((tagu & 0xff) << 16) | data); } else if (tag == 20) { av_log(avctx, AV_LOG_DEBUG, "Width %"PRIu16"\n", data); s->coded_width = data; } else if (tag == 21) { av_log(avctx, AV_LOG_DEBUG, "Height %"PRIu16"\n", data); s->coded_height = data; } else if (tag == 101) { av_log(avctx, AV_LOG_DEBUG, "Bits per component: %"PRIu16"\n", data); if (data < 1 || data > 31) { av_log(avctx, AV_LOG_ERROR, "Bits per component %d is invalid\n", data); ret = AVERROR(EINVAL); break; } s->bpc = data; } else if (tag == 12) { av_log(avctx, AV_LOG_DEBUG, "Channel Count: %"PRIu16"\n", data); s->channel_cnt = data; if (data > 4) { av_log(avctx, AV_LOG_ERROR, "Channel Count of %"PRIu16" is unsupported\n", data); ret = AVERROR_PATCHWELCOME; break; } } else if (tag == 14) { av_log(avctx, AV_LOG_DEBUG, "Subband Count: %"PRIu16"\n", data); if (data != SUBBAND_COUNT) { av_log(avctx, AV_LOG_ERROR, "Subband Count of %"PRIu16" is unsupported\n", data); ret = AVERROR_PATCHWELCOME; break; } } else if (tag == 62) { s->channel_num = data; av_log(avctx, AV_LOG_DEBUG, "Channel number %"PRIu16"\n", data); if (s->channel_num >= planes) { av_log(avctx, AV_LOG_ERROR, "Invalid channel number\n"); ret = AVERROR(EINVAL); break; } init_plane_defaults(s); } else if (tag == 48) { if (s->subband_num != 0 && data == 1) s->level++; av_log(avctx, AV_LOG_DEBUG, "Subband number %"PRIu16"\n", data); s->subband_num = data; if (s->level >= DWT_LEVELS) { av_log(avctx, AV_LOG_ERROR, "Invalid level\n"); ret = AVERROR(EINVAL); break; } if (s->subband_num > 3) { av_log(avctx, AV_LOG_ERROR, "Invalid subband number\n"); ret = AVERROR(EINVAL); break; } } else if (tag == 51) { av_log(avctx, AV_LOG_DEBUG, "Subband number actual %"PRIu16"\n", data); s->subband_num_actual = data; if (s->subband_num_actual >= 10) { av_log(avctx, AV_LOG_ERROR, "Invalid subband number actual\n"); ret = AVERROR(EINVAL); break; } } else if (tag == 35) av_log(avctx, AV_LOG_DEBUG, "Lowpass precision bits: %"PRIu16"\n", data); else if (tag == 53) { s->quantisation = data; av_log(avctx, AV_LOG_DEBUG, "Quantisation: %"PRIu16"\n", data); } else if (tag == 109) { s->prescale_shift[0] = (data >> 0) & 0x7; s->prescale_shift[1] = (data >> 3) & 0x7; s->prescale_shift[2] = (data >> 6) & 0x7; av_log(avctx, AV_LOG_DEBUG, "Prescale shift (VC-5): %x\n", data); } else if (tag == 27) { av_log(avctx, AV_LOG_DEBUG, "Lowpass width %"PRIu16"\n", data); if (data < 3 || data > s->plane[s->channel_num].band[0][0].a_width) { av_log(avctx, AV_LOG_ERROR, "Invalid lowpass width\n"); ret = AVERROR(EINVAL); break; } s->plane[s->channel_num].band[0][0].width = data; s->plane[s->channel_num].band[0][0].stride = data; } else if (tag == 28) { av_log(avctx, AV_LOG_DEBUG, "Lowpass height %"PRIu16"\n", data); if (data < 3 || data > s->plane[s->channel_num].band[0][0].height) { av_log(avctx, AV_LOG_ERROR, "Invalid lowpass height\n"); ret = AVERROR(EINVAL); break; } s->plane[s->channel_num].band[0][0].height = data; } else if (tag == 1) av_log(avctx, AV_LOG_DEBUG, "Sample type? %"PRIu16"\n", data); else if (tag == 10) { if (data != 0) { avpriv_report_missing_feature(avctx, "Transform type of %"PRIu16, data); ret = AVERROR_PATCHWELCOME; break; } av_log(avctx, AV_LOG_DEBUG, "Transform-type? %"PRIu16"\n", data); } else if (abstag >= 0x4000 && abstag <= 0x40ff) { av_log(avctx, AV_LOG_DEBUG, "Small chunk length %d %s\n", data * 4, tag < 0 ? "optional" : "required"); bytestream2_skipu(&gb, data * 4); } else if (tag == 23) { av_log(avctx, AV_LOG_DEBUG, "Skip frame\n"); avpriv_report_missing_feature(avctx, "Skip frame"); ret = AVERROR_PATCHWELCOME; break; } else if (tag == 2) { av_log(avctx, AV_LOG_DEBUG, "tag=2 header - skipping %i tag/value pairs\n", data); if (data > bytestream2_get_bytes_left(&gb) / 4) { av_log(avctx, AV_LOG_ERROR, "too many tag/value pairs (%d)\n", data); ret = AVERROR_INVALIDDATA; break; } for (i = 0; i < data; i++) { uint16_t tag2 = bytestream2_get_be16(&gb); uint16_t val2 = bytestream2_get_be16(&gb); av_log(avctx, AV_LOG_DEBUG, "Tag/Value = %x %x\n", tag2, val2); } } else if (tag == 41) { av_log(avctx, AV_LOG_DEBUG, "Highpass width %i channel %i level %i subband %i\n", data, s->channel_num, s->level, s->subband_num); if (data < 3) { av_log(avctx, AV_LOG_ERROR, "Invalid highpass width\n"); ret = AVERROR(EINVAL); break; } s->plane[s->channel_num].band[s->level][s->subband_num].width = data; s->plane[s->channel_num].band[s->level][s->subband_num].stride = FFALIGN(data, 8); } else if (tag == 42) { av_log(avctx, AV_LOG_DEBUG, "Highpass height %i\n", data); if (data < 3) { av_log(avctx, AV_LOG_ERROR, "Invalid highpass height\n"); ret = AVERROR(EINVAL); break; } s->plane[s->channel_num].band[s->level][s->subband_num].height = data; } else if (tag == 49) { av_log(avctx, AV_LOG_DEBUG, "Highpass width2 %i\n", data); if (data < 3) { av_log(avctx, AV_LOG_ERROR, "Invalid highpass width2\n"); ret = AVERROR(EINVAL); break; } s->plane[s->channel_num].band[s->level][s->subband_num].width = data; s->plane[s->channel_num].band[s->level][s->subband_num].stride = FFALIGN(data, 8); } else if (tag == 50) { av_log(avctx, AV_LOG_DEBUG, "Highpass height2 %i\n", data); if (data < 3) { av_log(avctx, AV_LOG_ERROR, "Invalid highpass height2\n"); ret = AVERROR(EINVAL); break; } s->plane[s->channel_num].band[s->level][s->subband_num].height = data; } else if (tag == 71) { s->codebook = data; av_log(avctx, AV_LOG_DEBUG, "Codebook %i\n", s->codebook); } else if (tag == 72) { s->codebook = data; av_log(avctx, AV_LOG_DEBUG, "Other codebook? %i\n", s->codebook); } else if (tag == 70) { av_log(avctx, AV_LOG_DEBUG, "Subsampling or bit-depth flag? %i\n", data); if (!(data == 10 || data == 12)) { av_log(avctx, AV_LOG_ERROR, "Invalid bits per channel\n"); ret = AVERROR(EINVAL); break; } s->bpc = data; } else if (tag == 84) { av_log(avctx, AV_LOG_DEBUG, "Sample format? %i\n", data); if (data == 1) s->coded_format = AV_PIX_FMT_YUV422P10; else if (data == 3) s->coded_format = AV_PIX_FMT_GBRP12; else if (data == 4) s->coded_format = AV_PIX_FMT_GBRAP12; else { avpriv_report_missing_feature(avctx, "Sample format of %"PRIu16, data); ret = AVERROR_PATCHWELCOME; break; } planes = av_pix_fmt_count_planes(s->coded_format); } else av_log(avctx, AV_LOG_DEBUG, "Unknown tag %i data %x\n", tag, data); if (tag == 4 && data == 0x1a4a && s->coded_width && s->coded_height && s->coded_format != AV_PIX_FMT_NONE) { if (s->a_width != s->coded_width || s->a_height != s->coded_height || s->a_format != s->coded_format) { free_buffers(avctx); if ((ret = alloc_buffers(avctx)) < 0) { free_buffers(avctx); return ret; } } ret = ff_set_dimensions(avctx, s->coded_width, s->coded_height); if (ret < 0) return ret; frame.f->width = frame.f->height = 0; if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0) return ret; s->coded_width = 0; s->coded_height = 0; s->coded_format = AV_PIX_FMT_NONE; got_buffer = 1; } coeff_data = s->plane[s->channel_num].subband[s->subband_num_actual]; if (tag == 4 && data == 0xf0f && s->a_width && s->a_height) { int lowpass_height = s->plane[s->channel_num].band[0][0].height; int lowpass_width = s->plane[s->channel_num].band[0][0].width; int lowpass_a_height = s->plane[s->channel_num].band[0][0].a_height; int lowpass_a_width = s->plane[s->channel_num].band[0][0].a_width; if (!got_buffer) { av_log(avctx, AV_LOG_ERROR, "No end of header tag found\n"); ret = AVERROR(EINVAL); goto end; } if (lowpass_height > lowpass_a_height || lowpass_width > lowpass_a_width || lowpass_a_width * lowpass_a_height * sizeof(int16_t) > bytestream2_get_bytes_left(&gb)) { av_log(avctx, AV_LOG_ERROR, "Too many lowpass coefficients\n"); ret = AVERROR(EINVAL); goto end; } av_log(avctx, AV_LOG_DEBUG, "Start of lowpass coeffs component %d height:%d, width:%d\n", s->channel_num, lowpass_height, lowpass_width); for (i = 0; i < lowpass_height; i++) { for (j = 0; j < lowpass_width; j++) coeff_data[j] = bytestream2_get_be16u(&gb); coeff_data += lowpass_width; } bytestream2_seek(&gb, bytestream2_tell(&gb) & 3, SEEK_CUR); if (lowpass_height & 1) { memcpy(&coeff_data[lowpass_height * lowpass_width], &coeff_data[(lowpass_height - 1) * lowpass_width], lowpass_width * sizeof(*coeff_data)); } av_log(avctx, AV_LOG_DEBUG, "Lowpass coefficients %d\n", lowpass_width * lowpass_height); } if (tag == 55 && s->subband_num_actual != 255 && s->a_width && s->a_height) { int highpass_height = s->plane[s->channel_num].band[s->level][s->subband_num].height; int highpass_width = s->plane[s->channel_num].band[s->level][s->subband_num].width; int highpass_a_width = s->plane[s->channel_num].band[s->level][s->subband_num].a_width; int highpass_a_height = s->plane[s->channel_num].band[s->level][s->subband_num].a_height; int highpass_stride = s->plane[s->channel_num].band[s->level][s->subband_num].stride; int expected; int a_expected = highpass_a_height * highpass_a_width; int level, run, coeff; int count = 0, bytes; if (!got_buffer) { av_log(avctx, AV_LOG_ERROR, "No end of header tag found\n"); ret = AVERROR(EINVAL); goto end; } if (highpass_height > highpass_a_height || highpass_width > highpass_a_width || a_expected < highpass_height * (uint64_t)highpass_stride) { av_log(avctx, AV_LOG_ERROR, "Too many highpass coefficients\n"); ret = AVERROR(EINVAL); goto end; } expected = highpass_height * highpass_stride; av_log(avctx, AV_LOG_DEBUG, "Start subband coeffs plane %i level %i codebook %i expected %i\n", s->channel_num, s->level, s->codebook, expected); init_get_bits(&s->gb, gb.buffer, bytestream2_get_bytes_left(&gb) * 8); { OPEN_READER(re, &s->gb); if (!s->codebook) { while (1) { UPDATE_CACHE(re, &s->gb); GET_RL_VLC(level, run, re, &s->gb, s->table_9_rl_vlc, VLC_BITS, 3, 1); if (level == 64) break; count += run; if (count > expected) break; coeff = dequant_and_decompand(level, s->quantisation); for (i = 0; i < run; i++) *coeff_data++ = coeff; } } else { while (1) { UPDATE_CACHE(re, &s->gb); GET_RL_VLC(level, run, re, &s->gb, s->table_18_rl_vlc, VLC_BITS, 3, 1); if (level == 255 && run == 2) break; count += run; if (count > expected) break; coeff = dequant_and_decompand(level, s->quantisation); for (i = 0; i < run; i++) *coeff_data++ = coeff; } } CLOSE_READER(re, &s->gb); } if (count > expected) { av_log(avctx, AV_LOG_ERROR, "Escape codeword not found, probably corrupt data\n"); ret = AVERROR(EINVAL); goto end; } bytes = FFALIGN(FF_CEIL_RSHIFT(get_bits_count(&s->gb), 3), 4); if (bytes > bytestream2_get_bytes_left(&gb)) { av_log(avctx, AV_LOG_ERROR, "Bitstream overread error\n"); ret = AVERROR(EINVAL); goto end; } else bytestream2_seek(&gb, bytes, SEEK_CUR); av_log(avctx, AV_LOG_DEBUG, "End subband coeffs %i extra %i\n", count, count - expected); s->codebook = 0; if (highpass_height & 1) { memcpy(&coeff_data[highpass_height * highpass_stride], &coeff_data[(highpass_height - 1) * highpass_stride], highpass_stride * sizeof(*coeff_data)); } } } if (!s->a_width || !s->a_height || s->a_format == AV_PIX_FMT_NONE || s->coded_width || s->coded_height || s->coded_format != AV_PIX_FMT_NONE) { av_log(avctx, AV_LOG_ERROR, "Invalid dimensions\n"); ret = AVERROR(EINVAL); goto end; } if (!got_buffer) { av_log(avctx, AV_LOG_ERROR, "No end of header tag found\n"); ret = AVERROR(EINVAL); goto end; } planes = av_pix_fmt_count_planes(avctx->pix_fmt); for (plane = 0; plane < planes && !ret; plane++) { int lowpass_height = s->plane[plane].band[0][0].height; int lowpass_width = s->plane[plane].band[0][0].width; int highpass_stride = s->plane[plane].band[0][1].stride; int act_plane = plane == 1 ? 2 : plane == 2 ? 1 : plane; int16_t *low, *high, *output, *dst; if (lowpass_height > s->plane[plane].band[0][0].a_height || lowpass_width > s->plane[plane].band[0][0].a_width || !highpass_stride || s->plane[plane].band[0][1].width > s->plane[plane].band[0][1].a_width) { av_log(avctx, AV_LOG_ERROR, "Invalid plane dimensions\n"); ret = AVERROR(EINVAL); goto end; } av_log(avctx, AV_LOG_DEBUG, "Decoding level 1 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride); low = s->plane[plane].subband[0]; high = s->plane[plane].subband[2]; output = s->plane[plane].l_h[0]; for (i = 0; i < lowpass_width; i++) { vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height); low++; high++; output++; } low = s->plane[plane].subband[1]; high = s->plane[plane].subband[3]; output = s->plane[plane].l_h[1]; for (i = 0; i < lowpass_width; i++) { vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height); low++; high++; output++; } low = s->plane[plane].l_h[0]; high = s->plane[plane].l_h[1]; output = s->plane[plane].subband[0]; for (i = 0; i < lowpass_height * 2; i++) { horiz_filter(output, low, high, lowpass_width); low += lowpass_width; high += lowpass_width; output += lowpass_width * 2; } if (s->bpc == 12) { output = s->plane[plane].subband[0]; for (i = 0; i < lowpass_height * 2; i++) { for (j = 0; j < lowpass_width * 2; j++) output[j] *= 4; output += lowpass_width * 2; } } lowpass_height = s->plane[plane].band[1][1].height; lowpass_width = s->plane[plane].band[1][1].width; highpass_stride = s->plane[plane].band[1][1].stride; if (lowpass_height > s->plane[plane].band[1][1].a_height || lowpass_width > s->plane[plane].band[1][1].a_width || !highpass_stride || s->plane[plane].band[1][1].width > s->plane[plane].band[1][1].a_width) { av_log(avctx, AV_LOG_ERROR, "Invalid plane dimensions\n"); ret = AVERROR(EINVAL); goto end; } av_log(avctx, AV_LOG_DEBUG, "Level 2 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride); low = s->plane[plane].subband[0]; high = s->plane[plane].subband[5]; output = s->plane[plane].l_h[3]; for (i = 0; i < lowpass_width; i++) { vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height); low++; high++; output++; } low = s->plane[plane].subband[4]; high = s->plane[plane].subband[6]; output = s->plane[plane].l_h[4]; for (i = 0; i < lowpass_width; i++) { vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height); low++; high++; output++; } low = s->plane[plane].l_h[3]; high = s->plane[plane].l_h[4]; output = s->plane[plane].subband[0]; for (i = 0; i < lowpass_height * 2; i++) { horiz_filter(output, low, high, lowpass_width); low += lowpass_width; high += lowpass_width; output += lowpass_width * 2; } output = s->plane[plane].subband[0]; for (i = 0; i < lowpass_height * 2; i++) { for (j = 0; j < lowpass_width * 2; j++) output[j] *= 4; output += lowpass_width * 2; } lowpass_height = s->plane[plane].band[2][1].height; lowpass_width = s->plane[plane].band[2][1].width; highpass_stride = s->plane[plane].band[2][1].stride; if (lowpass_height > s->plane[plane].band[2][1].a_height || lowpass_width > s->plane[plane].band[2][1].a_width || !highpass_stride || s->plane[plane].band[2][1].width > s->plane[plane].band[2][1].a_width) { av_log(avctx, AV_LOG_ERROR, "Invalid plane dimensions\n"); ret = AVERROR(EINVAL); goto end; } av_log(avctx, AV_LOG_DEBUG, "Level 3 plane %i %i %i %i\n", plane, lowpass_height, lowpass_width, highpass_stride); low = s->plane[plane].subband[0]; high = s->plane[plane].subband[8]; output = s->plane[plane].l_h[6]; for (i = 0; i < lowpass_width; i++) { vert_filter(output, lowpass_width, low, lowpass_width, high, highpass_stride, lowpass_height); low++; high++; output++; } low = s->plane[plane].subband[7]; high = s->plane[plane].subband[9]; output = s->plane[plane].l_h[7]; for (i = 0; i < lowpass_width; i++) { vert_filter(output, lowpass_width, low, highpass_stride, high, highpass_stride, lowpass_height); low++; high++; output++; } dst = (int16_t *)pic->data[act_plane]; low = s->plane[plane].l_h[6]; high = s->plane[plane].l_h[7]; for (i = 0; i < lowpass_height * 2; i++) { horiz_filter_clip(dst, low, high, lowpass_width, s->bpc); low += lowpass_width; high += lowpass_width; dst += pic->linesize[act_plane] / 2; } } end: if (ret < 0) return ret; *got_frame = 1; return avpkt->size; }
1threat
How to make data on chart not duplicate ? PHP : Excuse me please help me master... im beginner I've made bar chart use "highchart" (cuz the tutorial a lot) its work but.... part of my data on the chart has been duplicated *sorry for my bad english* For more details see this picture [duplicate data graph][1] my script like this [script][2] Hope u can help me make chart [1]: https://i.stack.imgur.com/Ft2Tm.png [2]: https://i.stack.imgur.com/hLWbl.png
0debug
static void idcin_decode_vlcs(IdcinContext *s) { hnode_t *hnodes; long x, y; int prev; unsigned char v = 0; int bit_pos, node_num, dat_pos; prev = bit_pos = dat_pos = 0; for (y = 0; y < (s->frame.linesize[0] * s->avctx->height); y += s->frame.linesize[0]) { for (x = y; x < y + s->avctx->width; x++) { node_num = s->num_huff_nodes[prev]; hnodes = s->huff_nodes[prev]; while(node_num >= HUF_TOKENS) { if(!bit_pos) { if(dat_pos > s->size) { av_log(s->avctx, AV_LOG_ERROR, "Huffman decode error.\n"); return; } bit_pos = 8; v = s->buf[dat_pos++]; } node_num = hnodes[node_num].children[v & 0x01]; v = v >> 1; bit_pos--; } s->frame.data[0][x] = node_num; prev = node_num; } } }
1threat
Read bytes of loaded executable from memory : I am trying to make an executable which can read itself from memory using **ReadProcessMemory** api of windows. Then, I will use this to calculate the checksum of executable. This is my code : #define PSAPI_VERSION 1 #include <string> #include <windows.h> #include <tchar.h> #include <stdio.h> #include <psapi.h> #include <Wincrypt.h> #define BUFSIZE 1024 #define MD5LEN 16 // To ensure correct resolution of symbols, add Psapi.lib to TARGETLIBS #pragma comment(lib, "psapi.lib") int main(void) { HWND hMyProcess = (HWND)(GetCurrentProcess()); HMODULE hModule = (HMODULE)GetModuleHandle(NULL); TCHAR szProcessName[MAX_PATH] = TEXT("<unknown>"); MODULEINFO moduleInfo; if(hModule != NULL && hMyProcess != NULL){ // if (GetModuleInformation()) GetModuleBaseName(hMyProcess, hModule, szProcessName, MAX_PATH); printf("%s\n", szProcessName); if (GetModuleInformation(hMyProcess, hModule, &moduleInfo, sizeof(moduleInfo))){ printf("lpBaseOfDLL : %x\n", moduleInfo.lpBaseOfDll); printf("Entry Point : %x\n", moduleInfo.EntryPoint); printf("SizeOfImage : %x\n", moduleInfo.SizeOfImage); } } // Till here working fine, problem lies below // read process memory TCHAR *hexEXE; SIZE_T *lpNumberOfBytesRead; if(ReadProcessMemory(hMyProcess, moduleInfo.lpBaseOfDll, &hexEXE, moduleInfo.SizeOfImage, 0)){ //printf("%s\n", hexEXE); printf("Read memory\n"); printf("%d \n",strlen(hexEXE)); } // will be implemented later, taken from --> https://msdn.microsoft.com/en-us/library/aa382380(VS.85).aspx DWORD dwStatus = 0; BOOL bResult = FALSE; HCRYPTPROV hProv = 0; HCRYPTHASH hHash = 0; /*if (!CryptAcquireContext(&hProv,NULL,NULL,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT)){ dwStatus = GetLastError(); printf("CryptAcquireContext failed: %d\n", dwStatus); //CloseHandle(hFile); return dwStatus; } if (!CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash)){ dwStatus = GetLastError(); printf("CryptAcquireContext failed: %d\n", dwStatus); //CloseHandle(hFile); CryptReleaseContext(hProv, 0); return dwStatus; }*/ return 0; } ## Problem : I am not able to read the my own process's memory, it's the first time I'm using **WinAPI**, so perhaps I am using the function in some wrong way. The program just hangs and it shows "Windows has encountered some problem..." Thanks.
0debug
static void gen_cop1_ldst(DisasContext *ctx, uint32_t op, int rt, int rs, int16_t imm) { if (ctx->CP0_Config1 & (1 << CP0C1_FP)) { check_cp1_enabled(ctx); gen_flt_ldst(ctx, op, rt, rs, imm); } else { generate_exception_err(ctx, EXCP_CpU, 1); } }
1threat
Most suitable BLAS package for matrix operations : <p>I need the fastest BLAS package for heavy matrix multiplication. I'm currently using the armadillo library included blas.</p> <p>I've done some research and it pointed to OpenBLAS. </p> <p>After some testing it didn't show any improvement. Any thoughts?</p>
0debug
Android Studio: Text cursor disappears/gone after open some other class or pasting text in different classes : <p><strong>Android Studio:</strong> Text cursor disappears/gone after open some other class or pasting text in different classes. Cursor is randomly disappear while coding in Android Studio. Currently using version 1.5.1 Some time cursor is only visible in one file either in java or xml Right click is working but cursor is not visible in java/ or xml file so I am not able to type the code.</p> <p><strong>Observed scenario</strong> The text cursor is not visible or the cursor is gone when I open a different file (e.g. ApplicationTest.java instead of activity_main.xml) the cursor appears again.</p> <p><strong>Expected scenario:</strong> The text cursor should be located after the insertion point.</p> <p><strong>Action taken to solved</strong> I used synchronize, restart Android Studio….. but not able to get solution. I am using window 7 and I have cleared temp</p> <p><strong>R&amp;D</strong> <a href="https://code.google.com/p/android/issues/detail?id=78384" rel="noreferrer">https://code.google.com/p/android/issues/detail?id=78384</a></p> <p>I stuck to this problem so please help me. Appreciate, if anyone can help to troubleshoot.</p>
0debug
I am trying to design a program that compares two strings for the same character in the same positions but same error keeps popping up help please : Length does not matter in this regard so for example: string 1: "hi--there-you." "-15-389" "criminal-plan" "abc" string 2: "12--(134)-7539" "-xy-zzy" "(206)555-1384" "9.8" Both pairs would return True. My problem is that when I try to compile the code below I get the following error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.charAt(Unknown Source) at SameDashes.sameDashes(SameDashes.java:20) at SameDashes.main(SameDashes.java:4) public static boolean sameDashes(String a, String b){ int minlength = Math.min(a.length(), b.length()); String smallstring=""; String bigstring=""; if(a.length()== minlength){ smallstring = a; bigstring = b; } else { smallstring = b; bigstring =a; } int counter = 0; do { if(bigstring.charAt(smallstring.indexOf('-',counter))!='-'){ return false; } else if(bigstring.indexOf('-',counter)!= -1){ return false; } counter++; }while(counter<= bigstring.length()); return true; }
0debug
int avformat_write_header(AVFormatContext *s, AVDictionary **options) { int ret = 0, i; AVStream *st; AVDictionary *tmp = NULL; if (options) av_dict_copy(&tmp, *options, 0); if ((ret = av_opt_set_dict(s, &tmp)) < 0) goto fail; if (s->priv_data && s->oformat->priv_class && *(const AVClass**)s->priv_data==s->oformat->priv_class && (ret = av_opt_set_dict(s->priv_data, &tmp)) < 0) goto fail; if (s->nb_streams == 0 && !(s->oformat->flags & AVFMT_NOSTREAMS)) { av_log(s, AV_LOG_ERROR, "no streams\n"); ret = AVERROR(EINVAL); goto fail; } for(i=0;i<s->nb_streams;i++) { st = s->streams[i]; switch (st->codec->codec_type) { case AVMEDIA_TYPE_AUDIO: if(st->codec->sample_rate<=0){ av_log(s, AV_LOG_ERROR, "sample rate not set\n"); ret = AVERROR(EINVAL); goto fail; } if(!st->codec->block_align) st->codec->block_align = st->codec->channels * av_get_bits_per_sample(st->codec->codec_id) >> 3; break; case AVMEDIA_TYPE_VIDEO: if(st->codec->time_base.num<=0 || st->codec->time_base.den<=0){ av_log(s, AV_LOG_ERROR, "time base not set\n"); ret = AVERROR(EINVAL); goto fail; } if((st->codec->width<=0 || st->codec->height<=0) && !(s->oformat->flags & AVFMT_NODIMENSIONS)){ av_log(s, AV_LOG_ERROR, "dimensions not set\n"); ret = AVERROR(EINVAL); goto fail; } if(av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio) && FFABS(av_q2d(st->sample_aspect_ratio) - av_q2d(st->codec->sample_aspect_ratio)) > 0.004*av_q2d(st->sample_aspect_ratio) ){ av_log(s, AV_LOG_ERROR, "Aspect ratio mismatch between muxer " "(%d/%d) and encoder layer (%d/%d)\n", st->sample_aspect_ratio.num, st->sample_aspect_ratio.den, st->codec->sample_aspect_ratio.num, st->codec->sample_aspect_ratio.den); ret = AVERROR(EINVAL); goto fail; } break; } if(s->oformat->codec_tag){ if(st->codec->codec_tag && st->codec->codec_id == CODEC_ID_RAWVIDEO && av_codec_get_tag(s->oformat->codec_tag, st->codec->codec_id) == 0 && !validate_codec_tag(s, st)){ st->codec->codec_tag= 0; } if(st->codec->codec_tag){ if (!validate_codec_tag(s, st)) { char tagbuf[32], cortag[32]; av_get_codec_tag_string(tagbuf, sizeof(tagbuf), st->codec->codec_tag); av_get_codec_tag_string(cortag, sizeof(cortag), av_codec_get_tag(s->oformat->codec_tag, st->codec->codec_id)); av_log(s, AV_LOG_ERROR, "Tag %s/0x%08x incompatible with output codec id '%d' (%s)\n", tagbuf, st->codec->codec_tag, st->codec->codec_id, cortag); ret = AVERROR_INVALIDDATA; goto fail; } }else st->codec->codec_tag= av_codec_get_tag(s->oformat->codec_tag, st->codec->codec_id); } if(s->oformat->flags & AVFMT_GLOBALHEADER && !(st->codec->flags & CODEC_FLAG_GLOBAL_HEADER)) av_log(s, AV_LOG_WARNING, "Codec for stream %d does not use global headers but container format requires global headers\n", i); } if (!s->priv_data && s->oformat->priv_data_size > 0) { s->priv_data = av_mallocz(s->oformat->priv_data_size); if (!s->priv_data) { ret = AVERROR(ENOMEM); goto fail; } if (s->oformat->priv_class) { *(const AVClass**)s->priv_data= s->oformat->priv_class; av_opt_set_defaults(s->priv_data); if ((ret = av_opt_set_dict(s->priv_data, &tmp)) < 0) goto fail; } } if (s->nb_streams && !(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) { av_dict_set(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0); } if(s->oformat->write_header){ ret = s->oformat->write_header(s); if (ret < 0) goto fail; } for(i=0;i<s->nb_streams;i++) { int64_t den = AV_NOPTS_VALUE; st = s->streams[i]; switch (st->codec->codec_type) { case AVMEDIA_TYPE_AUDIO: den = (int64_t)st->time_base.num * st->codec->sample_rate; break; case AVMEDIA_TYPE_VIDEO: den = (int64_t)st->time_base.num * st->codec->time_base.den; break; default: break; } if (den != AV_NOPTS_VALUE) { if (den <= 0) { ret = AVERROR_INVALIDDATA; goto fail; } frac_init(&st->pts, 0, 0, den); } } if (options) { av_dict_free(options); *options = tmp; } return 0; fail: av_dict_free(&tmp); return ret; }
1threat
static av_cold int libopus_decode_init(AVCodecContext *avc) { struct libopus_context *opus = avc->priv_data; int ret, channel_map = 0, gain_db = 0, nb_streams, nb_coupled; uint8_t mapping_arr[8] = { 0, 1 }, *mapping; avc->sample_rate = 48000; avc->sample_fmt = avc->request_sample_fmt == AV_SAMPLE_FMT_FLT ? AV_SAMPLE_FMT_FLT : AV_SAMPLE_FMT_S16; avc->channel_layout = avc->channels > 8 ? 0 : ff_vorbis_channel_layouts[avc->channels - 1]; if (avc->extradata_size >= OPUS_HEAD_SIZE) { gain_db = sign_extend(AV_RL16(avc->extradata + 16), 16); channel_map = AV_RL8 (avc->extradata + 18); if (avc->extradata_size >= OPUS_HEAD_SIZE + 2 + avc->channels) { nb_streams = avc->extradata[OPUS_HEAD_SIZE + 0]; nb_coupled = avc->extradata[OPUS_HEAD_SIZE + 1]; if (nb_streams + nb_coupled != avc->channels) av_log(avc, AV_LOG_WARNING, "Inconsistent channel mapping.\n"); mapping = avc->extradata + OPUS_HEAD_SIZE + 2; } else { if (avc->channels > 2 || channel_map) { av_log(avc, AV_LOG_ERROR, "No channel mapping for %d channels.\n", avc->channels); return AVERROR(EINVAL); nb_streams = 1; nb_coupled = avc->channels > 1; mapping = mapping_arr; if (avc->channels > 2 && avc->channels <= 8) { const uint8_t *vorbis_offset = ff_vorbis_channel_layout_offsets[avc->channels - 1]; int ch; for (ch = 0; ch < avc->channels; ch++) mapping_arr[ch] = mapping[vorbis_offset[ch]]; mapping = mapping_arr; opus->dec = opus_multistream_decoder_create(avc->sample_rate, avc->channels, nb_streams, nb_coupled, mapping, &ret); if (!opus->dec) { av_log(avc, AV_LOG_ERROR, "Unable to create decoder: %s\n", opus_strerror(ret)); return ff_opus_error_to_averror(ret); ret = opus_multistream_decoder_ctl(opus->dec, OPUS_SET_GAIN(gain_db)); if (ret != OPUS_OK) av_log(avc, AV_LOG_WARNING, "Failed to set gain: %s\n", opus_strerror(ret)); avc->delay = 3840; return 0;
1threat
static void extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags, const char **throttling_group, ThrottleConfig *throttle_cfg, BlockdevDetectZeroesOptions *detect_zeroes, Error **errp) { const char *discard; Error *local_error = NULL; const char *aio; if (bdrv_flags) { if (!qemu_opt_get_bool(opts, "read-only", false)) { *bdrv_flags |= BDRV_O_RDWR; } if (qemu_opt_get_bool(opts, "copy-on-read", false)) { *bdrv_flags |= BDRV_O_COPY_ON_READ; } if ((discard = qemu_opt_get(opts, "discard")) != NULL) { if (bdrv_parse_discard_flags(discard, bdrv_flags) != 0) { error_setg(errp, "Invalid discard option"); return; } } if ((aio = qemu_opt_get(opts, "aio")) != NULL) { if (!strcmp(aio, "native")) { *bdrv_flags |= BDRV_O_NATIVE_AIO; } else if (!strcmp(aio, "threads")) { } else { error_setg(errp, "invalid aio option"); return; } } } if (throttling_group) { *throttling_group = qemu_opt_get(opts, "throttling.group"); } if (throttle_cfg) { memset(throttle_cfg, 0, sizeof(*throttle_cfg)); throttle_cfg->buckets[THROTTLE_BPS_TOTAL].avg = qemu_opt_get_number(opts, "throttling.bps-total", 0); throttle_cfg->buckets[THROTTLE_BPS_READ].avg = qemu_opt_get_number(opts, "throttling.bps-read", 0); throttle_cfg->buckets[THROTTLE_BPS_WRITE].avg = qemu_opt_get_number(opts, "throttling.bps-write", 0); throttle_cfg->buckets[THROTTLE_OPS_TOTAL].avg = qemu_opt_get_number(opts, "throttling.iops-total", 0); throttle_cfg->buckets[THROTTLE_OPS_READ].avg = qemu_opt_get_number(opts, "throttling.iops-read", 0); throttle_cfg->buckets[THROTTLE_OPS_WRITE].avg = qemu_opt_get_number(opts, "throttling.iops-write", 0); throttle_cfg->buckets[THROTTLE_BPS_TOTAL].max = qemu_opt_get_number(opts, "throttling.bps-total-max", 0); throttle_cfg->buckets[THROTTLE_BPS_READ].max = qemu_opt_get_number(opts, "throttling.bps-read-max", 0); throttle_cfg->buckets[THROTTLE_BPS_WRITE].max = qemu_opt_get_number(opts, "throttling.bps-write-max", 0); throttle_cfg->buckets[THROTTLE_OPS_TOTAL].max = qemu_opt_get_number(opts, "throttling.iops-total-max", 0); throttle_cfg->buckets[THROTTLE_OPS_READ].max = qemu_opt_get_number(opts, "throttling.iops-read-max", 0); throttle_cfg->buckets[THROTTLE_OPS_WRITE].max = qemu_opt_get_number(opts, "throttling.iops-write-max", 0); throttle_cfg->op_size = qemu_opt_get_number(opts, "throttling.iops-size", 0); if (!check_throttle_config(throttle_cfg, errp)) { return; } } if (detect_zeroes) { *detect_zeroes = qapi_enum_parse(BlockdevDetectZeroesOptions_lookup, qemu_opt_get(opts, "detect-zeroes"), BLOCKDEV_DETECT_ZEROES_OPTIONS__MAX, BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF, &local_error); if (local_error) { error_propagate(errp, local_error); return; } if (bdrv_flags && *detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP && !(*bdrv_flags & BDRV_O_UNMAP)) { error_setg(errp, "setting detect-zeroes to unmap is not allowed " "without setting discard operation to unmap"); return; } } }
1threat
static void pc_machine_initfn(Object *obj) { PCMachineState *pcms = PC_MACHINE(obj); object_property_add(obj, PC_MACHINE_MEMHP_REGION_SIZE, "int", pc_machine_get_hotplug_memory_region_size, NULL, NULL, NULL, &error_abort); pcms->max_ram_below_4g = 0xe0000000; object_property_add(obj, PC_MACHINE_MAX_RAM_BELOW_4G, "size", pc_machine_get_max_ram_below_4g, pc_machine_set_max_ram_below_4g, NULL, NULL, &error_abort); object_property_set_description(obj, PC_MACHINE_MAX_RAM_BELOW_4G, "Maximum ram below the 4G boundary (32bit boundary)", &error_abort); pcms->smm = ON_OFF_AUTO_AUTO; object_property_add(obj, PC_MACHINE_SMM, "OnOffAuto", pc_machine_get_smm, pc_machine_set_smm, NULL, NULL, &error_abort); object_property_set_description(obj, PC_MACHINE_SMM, "Enable SMM (pc & q35)", &error_abort); pcms->vmport = ON_OFF_AUTO_AUTO; object_property_add(obj, PC_MACHINE_VMPORT, "OnOffAuto", pc_machine_get_vmport, pc_machine_set_vmport, NULL, NULL, &error_abort); object_property_set_description(obj, PC_MACHINE_VMPORT, "Enable vmport (pc & q35)", &error_abort); pcms->acpi_nvdimm_state.is_enabled = false; object_property_add_bool(obj, PC_MACHINE_NVDIMM, pc_machine_get_nvdimm, pc_machine_set_nvdimm, &error_abort); }
1threat
static int decode_blocks(SnowContext *s){ int x, y; int w= s->b_width; int h= s->b_height; int res; for(y=0; y<h; y++){ for(x=0; x<w; x++){ if ((res = decode_q_branch(s, 0, x, y)) < 0) return res; } } return 0; }
1threat
R are not identified : <p>I creating a map project. Main Activity =</p> <pre><code>@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.mainlayout); if (googleHarita == null) { googleHarita = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.haritafragment)) .getMap(); </code></pre> <p>R says "cannot resolve symbol <em>R</em>". What can I do?</p>
0debug
Copy current URL to clipboard : <p>Not sure why this has been so difficult for me today, but for some reason I cannot seem to get it to copy the current URL to the clipboard. Overall, I'm looking for a way to do it <em>without</em> needing to create some hidden text elements.</p> <p>This is what I'm trying so far:</p> <pre><code>var shareBtn = document.querySelector(".share-button"); shareBtn.addEventListener('click', function(event) { var cpLink = window.location.href; cpLink.select(); try { var successful = document.execCommand('copy'); var msg = successful ? 'successful' : 'unsuccessful'; console.log('Copy command was ' + msg); } catch (err) { console.log('Oops, unable to copy'); } event.preventDefault; }); </code></pre> <p>When I try to go about it using the <code>.select()</code> I get this error: <code>t.select is not a function</code> So I'm not 100% sure what the best way to go about this. Again, without using jQuery (or any other JS library) and not using some sort of hidden textfield.</p>
0debug
static void taihu_405ep_init(MachineState *machine) { ram_addr_t ram_size = machine->ram_size; const char *kernel_filename = machine->kernel_filename; const char *initrd_filename = machine->initrd_filename; char *filename; qemu_irq *pic; MemoryRegion *sysmem = get_system_memory(); MemoryRegion *bios; MemoryRegion *ram_memories = g_malloc(2 * sizeof(*ram_memories)); hwaddr ram_bases[2], ram_sizes[2]; long bios_size; target_ulong kernel_base, initrd_base; long kernel_size, initrd_size; int linux_boot; int fl_idx, fl_sectors; DriveInfo *dinfo; memory_region_allocate_system_memory(&ram_memories[0], NULL, "taihu_405ep.ram-0", 0x04000000); ram_bases[0] = 0; ram_sizes[0] = 0x04000000; memory_region_allocate_system_memory(&ram_memories[1], NULL, "taihu_405ep.ram-1", 0x04000000); ram_bases[1] = 0x04000000; ram_sizes[1] = 0x04000000; ram_size = 0x08000000; #ifdef DEBUG_BOARD_INIT printf("%s: register cpu\n", __func__); #endif ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes, 33333333, &pic, kernel_filename == NULL ? 0 : 1); #ifdef DEBUG_BOARD_INIT printf("%s: register BIOS\n", __func__); #endif fl_idx = 0; #if defined(USE_FLASH_BIOS) dinfo = drive_get(IF_PFLASH, 0, fl_idx); if (dinfo) { bios_size = bdrv_getlength(dinfo->bdrv); fl_sectors = (bios_size + 65535) >> 16; #ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size %lx" " at addr %lx '%s' %d\n", fl_idx, bios_size, -bios_size, bdrv_get_device_name(dinfo->bdrv), fl_sectors); #endif pflash_cfi02_register((uint32_t)(-bios_size), NULL, "taihu_405ep.bios", bios_size, dinfo->bdrv, 65536, fl_sectors, 1, 4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA, 1); fl_idx++; } else #endif { #ifdef DEBUG_BOARD_INIT printf("Load BIOS from file\n"); #endif if (bios_name == NULL) bios_name = BIOS_FILENAME; bios = g_new(MemoryRegion, 1); memory_region_allocate_system_memory(bios, NULL, "taihu_405ep.bios", BIOS_SIZE); filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { bios_size = load_image(filename, memory_region_get_ram_ptr(bios)); g_free(filename); if (bios_size < 0 || bios_size > BIOS_SIZE) { error_report("Could not load PowerPC BIOS '%s'", bios_name); exit(1); } bios_size = (bios_size + 0xfff) & ~0xfff; memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios); } else if (!qtest_enabled()) { error_report("Could not load PowerPC BIOS '%s'", bios_name); exit(1); } memory_region_set_readonly(bios, true); } dinfo = drive_get(IF_PFLASH, 0, fl_idx); if (dinfo) { bios_size = bdrv_getlength(dinfo->bdrv); bios_size = 32 * 1024 * 1024; fl_sectors = (bios_size + 65535) >> 16; #ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size %lx" " at addr " TARGET_FMT_lx " '%s'\n", fl_idx, bios_size, (target_ulong)0xfc000000, bdrv_get_device_name(dinfo->bdrv)); #endif pflash_cfi02_register(0xfc000000, NULL, "taihu_405ep.flash", bios_size, dinfo->bdrv, 65536, fl_sectors, 1, 4, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA, 1); fl_idx++; } #ifdef DEBUG_BOARD_INIT printf("%s: register CPLD\n", __func__); #endif taihu_cpld_init(sysmem, 0x50100000); linux_boot = (kernel_filename != NULL); if (linux_boot) { #ifdef DEBUG_BOARD_INIT printf("%s: load kernel\n", __func__); #endif kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_image_targphys(kernel_filename, kernel_base, ram_size - kernel_base); if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } if (initrd_filename) { initrd_base = INITRD_LOAD_ADDR; initrd_size = load_image_targphys(initrd_filename, initrd_base, ram_size - initrd_base); if (initrd_size < 0) { fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", initrd_filename); exit(1); } } else { initrd_base = 0; initrd_size = 0; } } else { kernel_base = 0; kernel_size = 0; initrd_base = 0; initrd_size = 0; } #ifdef DEBUG_BOARD_INIT printf("%s: Done\n", __func__); #endif }
1threat
SocketAddress *socket_parse(const char *str, Error **errp) { SocketAddress *addr; addr = g_new0(SocketAddress, 1); if (strstart(str, "unix:", NULL)) { if (str[5] == '\0') { error_setg(errp, "invalid Unix socket address"); goto fail; } else { addr->type = SOCKET_ADDRESS_KIND_UNIX; addr->u.q_unix.data = g_new(UnixSocketAddress, 1); addr->u.q_unix.data->path = g_strdup(str + 5); } } else if (strstart(str, "fd:", NULL)) { if (str[3] == '\0') { error_setg(errp, "invalid file descriptor address"); goto fail; } else { addr->type = SOCKET_ADDRESS_KIND_FD; addr->u.fd.data = g_new(String, 1); addr->u.fd.data->str = g_strdup(str + 3); } } else if (strstart(str, "vsock:", NULL)) { addr->type = SOCKET_ADDRESS_KIND_VSOCK; addr->u.vsock.data = g_new(VsockSocketAddress, 1); if (vsock_parse(addr->u.vsock.data, str + strlen("vsock:"), errp)) { goto fail; } } else { addr->type = SOCKET_ADDRESS_KIND_INET; addr->u.inet.data = g_new(InetSocketAddress, 1); if (inet_parse(addr->u.inet.data, str, errp)) { goto fail; } } return addr; fail: qapi_free_SocketAddress(addr); return NULL; }
1threat
str.split(r'\n') doesn't split a string on a newline character in a raw string literal as expected : <p>Suppose I have a string <code>s = hi\nhellon\whatsup</code> and I want to split it.</p> <p>If I use <code>s.split('\n')</code>, I get the expected output: </p> <pre><code>['hi', 'hello', 'whatsup'] </code></pre> <p>However, if I use <code>re.split('\n', s)</code>, it is actually `re.split(r'\n', s) and I also get the same output: </p> <pre><code>['hi', 'hello', 'whatsup'] </code></pre> <p>Why does splitting on a raw string literal with <code>re.split()</code> work?</p> <p>What is this black magic?</p>
0debug
static void ppc_prep_init(MachineState *machine) { ram_addr_t ram_size = machine->ram_size; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; const char *boot_device = machine->boot_order; MemoryRegion *sysmem = get_system_memory(); PowerPCCPU *cpu = NULL; CPUPPCState *env = NULL; Nvram *m48t59; #if 0 MemoryRegion *xcsr = g_new(MemoryRegion, 1); #endif int linux_boot, i, nb_nics1; MemoryRegion *ram = g_new(MemoryRegion, 1); uint32_t kernel_base, initrd_base; long kernel_size, initrd_size; DeviceState *dev; PCIHostState *pcihost; PCIBus *pci_bus; PCIDevice *pci; ISABus *isa_bus; ISADevice *isa; int ppc_boot_device; DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; sysctrl = g_malloc0(sizeof(sysctrl_t)); linux_boot = (kernel_filename != NULL); if (machine->cpu_model == NULL) machine->cpu_model = "602"; for (i = 0; i < smp_cpus; i++) { cpu = POWERPC_CPU(cpu_generic_init(TYPE_POWERPC_CPU, machine->cpu_model)); if (cpu == NULL) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); } env = &cpu->env; if (env->flags & POWERPC_FLAG_RTC_CLK) { cpu_ppc_tb_init(env, 7812500UL); } else { cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); } qemu_register_reset(ppc_prep_reset, cpu); } memory_region_allocate_system_memory(ram, NULL, "ppc_prep.ram", ram_size); memory_region_add_subregion(sysmem, 0, ram); if (linux_boot) { kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_image_targphys(kernel_filename, kernel_base, ram_size - kernel_base); if (kernel_size < 0) { error_report("could not load kernel '%s'", kernel_filename); exit(1); } if (initrd_filename) { initrd_base = INITRD_LOAD_ADDR; initrd_size = load_image_targphys(initrd_filename, initrd_base, ram_size - initrd_base); if (initrd_size < 0) { error_report("could not load initial ram disk '%s'", initrd_filename); exit(1); } } else { initrd_base = 0; initrd_size = 0; } ppc_boot_device = 'm'; } else { kernel_base = 0; kernel_size = 0; initrd_base = 0; initrd_size = 0; ppc_boot_device = '\0'; for (i = 0; boot_device[i] != '\0'; i++) { if (boot_device[i] >= 'a' && boot_device[i] <= 'f') { ppc_boot_device = boot_device[i]; break; } } if (ppc_boot_device == '\0') { fprintf(stderr, "No valid boot device for Mac99 machine\n"); exit(1); } } if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { error_report("Only 6xx bus is supported on PREP machine"); exit(1); } dev = qdev_create(NULL, "raven-pcihost"); if (bios_name == NULL) { bios_name = BIOS_FILENAME; } qdev_prop_set_string(dev, "bios-name", bios_name); qdev_prop_set_uint32(dev, "elf-machine", PPC_ELF_MACHINE); pcihost = PCI_HOST_BRIDGE(dev); object_property_add_child(qdev_get_machine(), "raven", OBJECT(dev), NULL); qdev_init_nofail(dev); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci.0"); if (pci_bus == NULL) { fprintf(stderr, "Couldn't create PCI host controller.\n"); exit(1); } sysctrl->contiguous_map_irq = qdev_get_gpio_in(dev, 0); pci = pci_create_simple(pci_bus, PCI_DEVFN(1, 0), "i82378"); cpu = POWERPC_CPU(first_cpu); qdev_connect_gpio_out(&pci->qdev, 0, cpu->env.irq_inputs[PPC6xx_INPUT_INT]); sysbus_connect_irq(&pcihost->busdev, 0, qdev_get_gpio_in(&pci->qdev, 9)); sysbus_connect_irq(&pcihost->busdev, 1, qdev_get_gpio_in(&pci->qdev, 11)); sysbus_connect_irq(&pcihost->busdev, 2, qdev_get_gpio_in(&pci->qdev, 9)); sysbus_connect_irq(&pcihost->busdev, 3, qdev_get_gpio_in(&pci->qdev, 11)); isa_bus = ISA_BUS(qdev_get_child_bus(DEVICE(pci), "isa.0")); isa = isa_create(isa_bus, TYPE_PC87312); dev = DEVICE(isa); qdev_prop_set_uint8(dev, "config", 13); qdev_init_nofail(dev); pci_vga_init(pci_bus); nb_nics1 = nb_nics; if (nb_nics1 > NE2000_NB_MAX) nb_nics1 = NE2000_NB_MAX; for(i = 0; i < nb_nics1; i++) { if (nd_table[i].model == NULL) { nd_table[i].model = g_strdup("ne2k_isa"); } if (strcmp(nd_table[i].model, "ne2k_isa") == 0) { isa_ne2000_init(isa_bus, ne2000_io[i], ne2000_irq[i], &nd_table[i]); } else { pci_nic_init_nofail(&nd_table[i], pci_bus, "ne2k_pci", NULL); } } ide_drive_get(hd, ARRAY_SIZE(hd)); for(i = 0; i < MAX_IDE_BUS; i++) { isa_ide_init(isa_bus, ide_iobase[i], ide_iobase2[i], ide_irq[i], hd[2 * i], hd[2 * i + 1]); } isa_create_simple(isa_bus, "i8042"); cpu = POWERPC_CPU(first_cpu); sysctrl->reset_irq = cpu->env.irq_inputs[PPC6xx_INPUT_HRESET]; portio_list_init(&prep_port_list, NULL, prep_portio_list, sysctrl, "prep"); portio_list_add(&prep_port_list, isa_address_space_io(isa), 0x0); #if 0 memory_region_init_io(xcsr, NULL, &PPC_XCSR_ops, NULL, "ppc-xcsr", 0x1000); memory_region_add_subregion(sysmem, 0xFEFF0000, xcsr); #endif if (machine_usb(machine)) { pci_create_simple(pci_bus, -1, "pci-ohci"); } m48t59 = m48t59_init_isa(isa_bus, 0x0074, NVRAM_SIZE, 2000, 59); if (m48t59 == NULL) return; sysctrl->nvram = m48t59; PPC_NVRAM_set_params(m48t59, NVRAM_SIZE, "PREP", ram_size, ppc_boot_device, kernel_base, kernel_size, kernel_cmdline, initrd_base, initrd_size, 0, graphic_width, graphic_height, graphic_depth); }
1threat
October CMS - How to correctly route : <p>I've been reviewing the documentation for October CMS routing (<a href="https://octobercms.com/docs/plugin/registration#routing-initialization" rel="noreferrer">https://octobercms.com/docs/plugin/registration#routing-initialization</a>), but I think that I am missing something. I have a page called 'deals' that renders some basic information along with a plugin (called 'deals') component. The page normally appears at the url:</p> <pre><code>http://www.example.com/deals </code></pre> <p>However, I want to create a route so that if someone visits the url:</p> <pre><code>http://www.example.com/deals2 </code></pre> <p>it will automatically route them back to</p> <pre><code>http://www.example.com/deals </code></pre> <p>I know that I should create a routes.php file in my plugin directory. However, when I try using </p> <pre><code>Route::get('/deals2', function() { return View::make('deals'); }); </code></pre> <p>It complains that it can't find the 'deals' view. What am I doing wrong?</p> <p>Additionally, how can I route it so that my homepage</p> <pre><code>http://www.example.com </code></pre> <p>would route to </p> <pre><code>http://www.example.com/deals </code></pre>
0debug
In-memory file for testing : <p>How does one create in-memory files for unit testing in Go?</p> <p>In Python, I test reading from a file or writing to a file using <a href="https://docs.python.org/3/library/io.html?highlight=stringio#io.BytesIO" rel="noreferrer"><code>io.BytesIO</code></a> or <a href="https://docs.python.org/3/library/io.html?highlight=stringio#io.StringIO" rel="noreferrer"><code>io.StringIO</code></a>. For example, to test a file parser, I would have</p> <pre><code>def test_parse_function(): infile = io.StringIO('''\ line1 line2 line3 ''') parsed_contents = parse_function(infile) expected_contents = ['line1', 'line2', 'line3'] # or whatever is appropriate assert parsed_contents == expected_contents </code></pre> <p>Similarly for file output, I would have something like the following:</p> <pre><code>def test_write_function(): outfile = io.StringIO() write_function(outfile, ['line1', 'line2', 'line3']) outfile.seek(0) output = outfile.read() expected_output = '''\ line1 line2 line3 ''' assert output == expected_output </code></pre>
0debug
How to link thumbnail to a video on a new page : <p>When I click on a thumbnail, I want to have another web page open up with the video of that thumbnail. How would I do that? Thank you for your time.</p>
0debug
static unsigned int rms(const int *data) { int x; unsigned int res = 0x10000; int b = 0; for (x=0; x<10; x++) { res = (((0x1000000 - (*data) * (*data)) >> 12) * res) >> 12; if (res == 0) return 0; while (res <= 0x3fff) { b++; res <<= 2; } data++; } if (res > 0) res = t_sqrt(res); res >>= (b + 10); return res; }
1threat
How do I do I execute tests in Debug mode using .Net Core and VSCode? : <p>How do I execute tests in Debug mode using .Net Core and VSCode?</p> <p>I am currently running the following on the command line:</p> <pre><code>dotnet Test </code></pre> <p>However, this is not executing the tests in debug mode.</p> <p>Do I attach a debugger?</p> <p>If so... How?</p>
0debug
qio_channel_websock_extract_headers(char *buffer, QIOChannelWebsockHTTPHeader *hdrs, size_t nhdrsalloc, Error **errp) { char *nl, *sep, *tmp; size_t nhdrs = 0; nl = strstr(buffer, QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM); if (!nl) { error_setg(errp, "Missing HTTP header delimiter"); return 0; } *nl = '\0'; tmp = strchr(buffer, ' '); if (!tmp) { error_setg(errp, "Missing HTTP path delimiter"); return 0; } *tmp = '\0'; if (!g_str_equal(buffer, QIO_CHANNEL_WEBSOCK_HTTP_METHOD)) { error_setg(errp, "Unsupported HTTP method %s", buffer); return 0; } buffer = tmp + 1; tmp = strchr(buffer, ' '); if (!tmp) { error_setg(errp, "Missing HTTP version delimiter"); return 0; } *tmp = '\0'; if (!g_str_equal(buffer, QIO_CHANNEL_WEBSOCK_HTTP_PATH)) { error_setg(errp, "Unexpected HTTP path %s", buffer); return 0; } buffer = tmp + 1; if (!g_str_equal(buffer, QIO_CHANNEL_WEBSOCK_HTTP_VERSION)) { error_setg(errp, "Unsupported HTTP version %s", buffer); return 0; } buffer = nl + strlen(QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM); do { QIOChannelWebsockHTTPHeader *hdr; nl = strstr(buffer, QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM); if (nl) { *nl = '\0'; } sep = strchr(buffer, ':'); if (!sep) { error_setg(errp, "Malformed HTTP header"); return 0; } *sep = '\0'; sep++; while (*sep == ' ') { sep++; } if (nhdrs >= nhdrsalloc) { error_setg(errp, "Too many HTTP headers"); return 0; } hdr = &hdrs[nhdrs++]; hdr->name = buffer; hdr->value = sep; for (tmp = hdr->name; *tmp; tmp++) { *tmp = g_ascii_tolower(*tmp); } if (nl) { buffer = nl + strlen(QIO_CHANNEL_WEBSOCK_HANDSHAKE_DELIM); } } while (nl != NULL); return nhdrs; }
1threat
static uint32_t serial_ioport_read(void *opaque, uint32_t addr) { SerialState *s = opaque; uint32_t ret; addr &= 7; switch(addr) { default: case 0: if (s->lcr & UART_LCR_DLAB) { ret = s->divider & 0xff; } else { ret = s->rbr; s->lsr &= ~(UART_LSR_DR | UART_LSR_BI); serial_update_irq(s); if (!(s->mcr & UART_MCR_LOOP)) { qemu_chr_accept_input(s->chr); } } break; case 1: if (s->lcr & UART_LCR_DLAB) { ret = (s->divider >> 8) & 0xff; } else { ret = s->ier; } break; case 2: ret = s->iir; if ((ret & 0x7) == UART_IIR_THRI) s->thr_ipending = 0; serial_update_irq(s); break; case 3: ret = s->lcr; break; case 4: ret = s->mcr; break; case 5: ret = s->lsr; break; case 6: if (s->mcr & UART_MCR_LOOP) { ret = (s->mcr & 0x0c) << 4; ret |= (s->mcr & 0x02) << 3; ret |= (s->mcr & 0x01) << 5; } else { ret = s->msr; } break; case 7: ret = s->scr; break; } #ifdef DEBUG_SERIAL printf("serial: read addr=0x%02x val=0x%02x\n", addr, ret); #endif return ret; }
1threat
Whats wrong with my function not returning this char for my switch : <p>I've been trying to figure this out for a few hours now. Im suppose to use the function getMenuChoice to prompt the user to make a choice and return the choice. I just dont know how to use the return in the switch statement. Very confused.</p> <pre><code>#include &lt;iostream&gt; using namespace std; double milesToKilometers(); double kilometersToMiles(); void showMenu(); char getMenuChoice(); int main() { char choice; do { showMenu(); getMenuChoice(); switch (toupper(choice)) { case 'A': cout &lt;&lt; milesToKilometers() &lt;&lt; endl; break; case 'B': cout &lt;&lt; kilometersToMiles() &lt;&lt; endl; break; case 'Q': cout &lt;&lt; "Closing" &lt;&lt; endl; break; default: cout &lt;&lt; "Not Valid" &lt;&lt; endl; break; } }while (choice != 'Q'); return 0; } double milesToKilometers() { cout &lt;&lt; "Enter Miles:" &lt;&lt; endl; double m; cin &gt;&gt; m; m = m * 1.6093; return m; } double kilometersToMiles() { cout &lt;&lt; "Enter Kilometers: " &lt;&lt; endl; double k; cin &gt;&gt; k; k = k * .6214; return k; } void showMenu() { cout &lt;&lt; "A. Miles to Kilometers" &lt;&lt; endl; cout &lt;&lt; "B. Kilometers to Miles" &lt;&lt; endl; cout &lt;&lt; "Q. Quit" &lt;&lt; endl; return; } char getMenuChoice() { char choice; cout &lt;&lt; "Enter Choice: " &lt;&lt; endl; cin &gt;&gt; choice; return choice; } </code></pre>
0debug
void qmp_input_send_event(int64_t console, InputEventList *events, Error **errp) { InputEventList *e; QemuConsole *con; con = qemu_console_lookup_by_index(console); if (!con) { error_setg(errp, "console %" PRId64 " not found", console); return; } if (!runstate_is_running() && !runstate_check(RUN_STATE_SUSPENDED)) { error_setg(errp, "VM not running"); return; } for (e = events; e != NULL; e = e->next) { InputEvent *event = e->value; if (!qemu_input_find_handler(1 << event->kind, con)) { error_setg(errp, "Input handler not found for " "event type %s", InputEventKind_lookup[event->kind]); return; } } for (e = events; e != NULL; e = e->next) { InputEvent *event = e->value; qemu_input_event_send(con, event); } qemu_input_event_sync(); }
1threat
How to use html or wordpress to login to an existing angular app : <p>I want to create a membership site (either using html or wordpress) with a login form that will redirect the user to a running angular app (probably in another subdomain). Is it possible? Can I carry authentication information along with the redirection so that I can check if the user of the angular app is a member? Thank you!</p>
0debug
static int usb_net_handle_datain(USBNetState *s, USBPacket *p) { int ret = USB_RET_NAK; if (s->in_ptr > s->in_len) { s->in_ptr = s->in_len = 0; ret = USB_RET_NAK; return ret; } if (!s->in_len) { ret = USB_RET_NAK; return ret; } ret = s->in_len - s->in_ptr; if (ret > p->len) ret = p->len; memcpy(p->data, &s->in_buf[s->in_ptr], ret); s->in_ptr += ret; if (s->in_ptr >= s->in_len && (is_rndis(s) || (s->in_len & (64 - 1)) || !ret)) { s->in_ptr = s->in_len = 0; } #ifdef TRAFFIC_DEBUG fprintf(stderr, "usbnet: data in len %u return %d", p->len, ret); { int i; fprintf(stderr, ":"); for (i = 0; i < ret; i++) { if (!(i & 15)) fprintf(stderr, "\n%04x:", i); fprintf(stderr, " %02x", p->data[i]); } fprintf(stderr, "\n\n"); } #endif return ret; }
1threat
Laravel 5.2 method to check is view exists? : <p>Is there any method to check if view exists? </p> <p>Like PHP file_exists, but using internal laravel method for convenience</p> <p>i want to code like this:</p> <pre><code>if(__ifViewExist__($view)){ return view($view)-&gt;render(); } return "Page tidak ditemukan"; </code></pre>
0debug
How it increases the size and points to new location even if ArrayList has final reference : <p>I have final reference to the arraylist and I have learned that ArrayList internally copies the array contents to new location once it runs out of initial size and then adds new element to the new copied array then the reference points to new location. Then how can final reference variable points to new location of copied array?</p>
0debug
How do you use order of operations in programming? : <p>Is there a good way to use order of operation in programming? How could you write this equation in code for example? x = 2(100 - 50)</p>
0debug
How do i get the scanner media stream on an android MC40 using C# and xamarin? : [enter image description here][1] [1]: https://i.stack.imgur.com/PGQYe.png how do i access this stream using code in C# and xamarin android? I know i can get notification by using Stream.Notification. I can also access alarms by using Stream.Alarms. I want to know how to get the scanner media stream?
0debug
Need Letters at navbar to fade on click what should I use : <p>On my website I want to make my navbar list text to fade in from right to left exacly like this website does <a href="https://www.bravenewcreative.com" rel="nofollow noreferrer">https://www.bravenewcreative.com</a> , when u click the 3 bars the letters come from right to left.I would like to apply that same effect on my website <a href="https://i.stack.imgur.com/iIozz.png" rel="nofollow noreferrer">this is my website</a> , <a href="https://i.stack.imgur.com/duawF.png" rel="nofollow noreferrer">code</a> so from this I just want suggestions or even solutions in CSS or javascript or both whatever u guys think would make it look smoother and also something easy to use and customise</p>
0debug
Activity Cycle Method : Name the method that gets called when another Activity comes to foreground and when Current Activity Comes to Foreground. (The methods in both cases to be mentioned relate to the current activity)
0debug
static int decode_vop_header(Mpeg4DecContext *ctx, GetBitContext *gb) { MpegEncContext *s = &ctx->m; int time_incr, time_increment; int64_t pts; s->pict_type = get_bits(gb, 2) + AV_PICTURE_TYPE_I; if (s->pict_type == AV_PICTURE_TYPE_B && s->low_delay && ctx->vol_control_parameters == 0 && !(s->flags & CODEC_FLAG_LOW_DELAY)) { av_log(s->avctx, AV_LOG_ERROR, "low_delay flag set incorrectly, clearing it\n"); s->low_delay = 0; } s->partitioned_frame = s->data_partitioning && s->pict_type != AV_PICTURE_TYPE_B; if (s->partitioned_frame) s->decode_mb = mpeg4_decode_partitioned_mb; else s->decode_mb = mpeg4_decode_mb; time_incr = 0; while (get_bits1(gb) != 0) time_incr++; check_marker(gb, "before time_increment"); if (ctx->time_increment_bits == 0 || !(show_bits(gb, ctx->time_increment_bits + 1) & 1)) { av_log(s->avctx, AV_LOG_WARNING, "time_increment_bits %d is invalid in relation to the current bitstream, this is likely caused by a missing VOL header\n", ctx->time_increment_bits); for (ctx->time_increment_bits = 1; ctx->time_increment_bits < 16; ctx->time_increment_bits++) { if (s->pict_type == AV_PICTURE_TYPE_P || (s->pict_type == AV_PICTURE_TYPE_S && ctx->vol_sprite_usage == GMC_SPRITE)) { if ((show_bits(gb, ctx->time_increment_bits + 6) & 0x37) == 0x30) break; } else if ((show_bits(gb, ctx->time_increment_bits + 5) & 0x1F) == 0x18) break; } av_log(s->avctx, AV_LOG_WARNING, "time_increment_bits set to %d bits, based on bitstream analysis\n", ctx->time_increment_bits); if (s->avctx->framerate.num && 4*s->avctx->framerate.num < 1<<ctx->time_increment_bits) { s->avctx->framerate.num = 1<<ctx->time_increment_bits; s->avctx->time_base = av_inv_q(av_mul_q(s->avctx->framerate, (AVRational){s->avctx->ticks_per_frame, 1})); } } if (IS_3IV1) time_increment = get_bits1(gb); else time_increment = get_bits(gb, ctx->time_increment_bits); if (s->pict_type != AV_PICTURE_TYPE_B) { s->last_time_base = s->time_base; s->time_base += time_incr; s->time = s->time_base * s->avctx->framerate.num + time_increment; if (s->workaround_bugs & FF_BUG_UMP4) { if (s->time < s->last_non_b_time) { s->time_base++; s->time += s->avctx->framerate.num; } } s->pp_time = s->time - s->last_non_b_time; s->last_non_b_time = s->time; } else { s->time = (s->last_time_base + time_incr) * s->avctx->framerate.num + time_increment; s->pb_time = s->pp_time - (s->last_non_b_time - s->time); if (s->pp_time <= s->pb_time || s->pp_time <= s->pp_time - s->pb_time || s->pp_time <= 0) { return FRAME_SKIPPED; } ff_mpeg4_init_direct_mv(s); if (ctx->t_frame == 0) ctx->t_frame = s->pb_time; if (ctx->t_frame == 0) ctx->t_frame = 1; s->pp_field_time = (ROUNDED_DIV(s->last_non_b_time, ctx->t_frame) - ROUNDED_DIV(s->last_non_b_time - s->pp_time, ctx->t_frame)) * 2; s->pb_field_time = (ROUNDED_DIV(s->time, ctx->t_frame) - ROUNDED_DIV(s->last_non_b_time - s->pp_time, ctx->t_frame)) * 2; if (s->pp_field_time <= s->pb_field_time || s->pb_field_time <= 1) { s->pb_field_time = 2; s->pp_field_time = 4; if (!s->progressive_sequence) return FRAME_SKIPPED; } } if (s->avctx->framerate.den) pts = ROUNDED_DIV(s->time, s->avctx->framerate.den); else pts = AV_NOPTS_VALUE; if (s->avctx->debug&FF_DEBUG_PTS) av_log(s->avctx, AV_LOG_DEBUG, "MPEG4 PTS: %"PRId64"\n", pts); check_marker(gb, "before vop_coded"); if (get_bits1(gb) != 1) { if (s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_ERROR, "vop not coded\n"); return FRAME_SKIPPED; } if (ctx->new_pred) decode_new_pred(ctx, gb); if (ctx->shape != BIN_ONLY_SHAPE && (s->pict_type == AV_PICTURE_TYPE_P || (s->pict_type == AV_PICTURE_TYPE_S && ctx->vol_sprite_usage == GMC_SPRITE))) { s->no_rounding = get_bits1(gb); } else { s->no_rounding = 0; } if (ctx->shape != RECT_SHAPE) { if (ctx->vol_sprite_usage != 1 || s->pict_type != AV_PICTURE_TYPE_I) { skip_bits(gb, 13); skip_bits1(gb); skip_bits(gb, 13); skip_bits1(gb); skip_bits(gb, 13); skip_bits1(gb); skip_bits(gb, 13); } skip_bits1(gb); if (get_bits1(gb) != 0) skip_bits(gb, 8); } if (ctx->shape != BIN_ONLY_SHAPE) { skip_bits_long(gb, ctx->cplx_estimation_trash_i); if (s->pict_type != AV_PICTURE_TYPE_I) skip_bits_long(gb, ctx->cplx_estimation_trash_p); if (s->pict_type == AV_PICTURE_TYPE_B) skip_bits_long(gb, ctx->cplx_estimation_trash_b); if (get_bits_left(gb) < 3) { av_log(s->avctx, AV_LOG_ERROR, "Header truncated\n"); return AVERROR_INVALIDDATA; } ctx->intra_dc_threshold = ff_mpeg4_dc_threshold[get_bits(gb, 3)]; if (!s->progressive_sequence) { s->top_field_first = get_bits1(gb); s->alternate_scan = get_bits1(gb); } else s->alternate_scan = 0; } if (s->alternate_scan) { ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_alternate_vertical_scan); ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_alternate_vertical_scan); ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_alternate_vertical_scan); ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan); } else { ff_init_scantable(s->idsp.idct_permutation, &s->inter_scantable, ff_zigzag_direct); ff_init_scantable(s->idsp.idct_permutation, &s->intra_scantable, ff_zigzag_direct); ff_init_scantable(s->idsp.idct_permutation, &s->intra_h_scantable, ff_alternate_horizontal_scan); ff_init_scantable(s->idsp.idct_permutation, &s->intra_v_scantable, ff_alternate_vertical_scan); } if (s->pict_type == AV_PICTURE_TYPE_S && (ctx->vol_sprite_usage == STATIC_SPRITE || ctx->vol_sprite_usage == GMC_SPRITE)) { if (mpeg4_decode_sprite_trajectory(ctx, gb) < 0) return AVERROR_INVALIDDATA; if (ctx->sprite_brightness_change) av_log(s->avctx, AV_LOG_ERROR, "sprite_brightness_change not supported\n"); if (ctx->vol_sprite_usage == STATIC_SPRITE) av_log(s->avctx, AV_LOG_ERROR, "static sprite not supported\n"); } if (ctx->shape != BIN_ONLY_SHAPE) { s->chroma_qscale = s->qscale = get_bits(gb, s->quant_precision); if (s->qscale == 0) { av_log(s->avctx, AV_LOG_ERROR, "Error, header damaged or not MPEG4 header (qscale=0)\n"); return AVERROR_INVALIDDATA; } if (s->pict_type != AV_PICTURE_TYPE_I) { s->f_code = get_bits(gb, 3); if (s->f_code == 0) { av_log(s->avctx, AV_LOG_ERROR, "Error, header damaged or not MPEG4 header (f_code=0)\n"); s->f_code = 1; return AVERROR_INVALIDDATA; } } else s->f_code = 1; if (s->pict_type == AV_PICTURE_TYPE_B) { s->b_code = get_bits(gb, 3); if (s->b_code == 0) { av_log(s->avctx, AV_LOG_ERROR, "Error, header damaged or not MPEG4 header (b_code=0)\n"); s->b_code=1; return AVERROR_INVALIDDATA; } } else s->b_code = 1; if (s->avctx->debug & FF_DEBUG_PICT_INFO) { av_log(s->avctx, AV_LOG_DEBUG, "qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d rnd:%d vot:%d%s dc:%d ce:%d/%d/%d time:%"PRId64" tincr:%d\n", s->qscale, s->f_code, s->b_code, s->pict_type == AV_PICTURE_TYPE_I ? "I" : (s->pict_type == AV_PICTURE_TYPE_P ? "P" : (s->pict_type == AV_PICTURE_TYPE_B ? "B" : "S")), gb->size_in_bits,s->progressive_sequence, s->alternate_scan, s->top_field_first, s->quarter_sample ? "q" : "h", s->data_partitioning, ctx->resync_marker, ctx->num_sprite_warping_points, s->sprite_warping_accuracy, 1 - s->no_rounding, s->vo_type, ctx->vol_control_parameters ? " VOLC" : " ", ctx->intra_dc_threshold, ctx->cplx_estimation_trash_i, ctx->cplx_estimation_trash_p, ctx->cplx_estimation_trash_b, s->time, time_increment ); } if (!ctx->scalability) { if (ctx->shape != RECT_SHAPE && s->pict_type != AV_PICTURE_TYPE_I) skip_bits1(gb); } else { if (ctx->enhancement_type) { int load_backward_shape = get_bits1(gb); if (load_backward_shape) av_log(s->avctx, AV_LOG_ERROR, "load backward shape isn't supported\n"); } skip_bits(gb, 2); } } if (s->vo_type == 0 && ctx->vol_control_parameters == 0 && ctx->divx_version == -1 && s->picture_number == 0) { av_log(s->avctx, AV_LOG_WARNING, "looks like this file was encoded with (divx4/(old)xvid/opendivx) -> forcing low_delay flag\n"); s->low_delay = 1; } s->picture_number++; s->y_dc_scale_table = ff_mpeg4_y_dc_scale_table; s->c_dc_scale_table = ff_mpeg4_c_dc_scale_table; if (s->workaround_bugs & FF_BUG_EDGE) { s->h_edge_pos = s->width; s->v_edge_pos = s->height; } return 0; }
1threat
I am trying to read file from my pc located at any local disk using c++.For that I have written code.But it is not executing : <p>I am working on file project in that I want to open file using c++ which is located in any drive of my PC.User will enter file location and file name of it.So,only I want to open tat file from that folder.I have wrtten a code.</p> <pre><code>#include &lt;fstream&gt; #include &lt;iostream&gt; #include &lt;string&gt; using namespace std; int main() { string inp,fname; ofstream myfile; cout&lt;&lt;"Enter path for Input file:"; getline(cin, inp); fstream input&lt;&lt;( "inp",ios::app); myfile.open("Final.txt", ios_base::app); myfile &lt;&lt; "Thanks for your help.\n"; myfile.close(); return 0; } </code></pre>
0debug
static int fill_filter_caches(H264Context *h, H264SliceContext *sl, int mb_type) { const int mb_xy = h->mb_xy; int top_xy, left_xy[LEFT_MBS]; int top_type, left_type[LEFT_MBS]; uint8_t *nnz; uint8_t *nnz_cache; top_xy = mb_xy - (h->mb_stride << MB_FIELD(h)); left_xy[LBOT] = left_xy[LTOP] = mb_xy - 1; if (FRAME_MBAFF(h)) { const int left_mb_field_flag = IS_INTERLACED(h->cur_pic.mb_type[mb_xy - 1]); const int curr_mb_field_flag = IS_INTERLACED(mb_type); if (h->mb_y & 1) { if (left_mb_field_flag != curr_mb_field_flag) left_xy[LTOP] -= h->mb_stride; } else { if (curr_mb_field_flag) top_xy += h->mb_stride & (((h->cur_pic.mb_type[top_xy] >> 7) & 1) - 1); if (left_mb_field_flag != curr_mb_field_flag) left_xy[LBOT] += h->mb_stride; } } sl->top_mb_xy = top_xy; sl->left_mb_xy[LTOP] = left_xy[LTOP]; sl->left_mb_xy[LBOT] = left_xy[LBOT]; { int qp_thresh = sl->qp_thresh; int qp = h->cur_pic.qscale_table[mb_xy]; if (qp <= qp_thresh && (left_xy[LTOP] < 0 || ((qp + h->cur_pic.qscale_table[left_xy[LTOP]] + 1) >> 1) <= qp_thresh) && (top_xy < 0 || ((qp + h->cur_pic.qscale_table[top_xy] + 1) >> 1) <= qp_thresh)) { if (!FRAME_MBAFF(h)) return 1; if ((left_xy[LTOP] < 0 || ((qp + h->cur_pic.qscale_table[left_xy[LBOT]] + 1) >> 1) <= qp_thresh) && (top_xy < h->mb_stride || ((qp + h->cur_pic.qscale_table[top_xy - h->mb_stride] + 1) >> 1) <= qp_thresh)) return 1; } } top_type = h->cur_pic.mb_type[top_xy]; left_type[LTOP] = h->cur_pic.mb_type[left_xy[LTOP]]; left_type[LBOT] = h->cur_pic.mb_type[left_xy[LBOT]]; if (h->deblocking_filter == 2) { if (h->slice_table[top_xy] != sl->slice_num) top_type = 0; if (h->slice_table[left_xy[LBOT]] != sl->slice_num) left_type[LTOP] = left_type[LBOT] = 0; } else { if (h->slice_table[top_xy] == 0xFFFF) top_type = 0; if (h->slice_table[left_xy[LBOT]] == 0xFFFF) left_type[LTOP] = left_type[LBOT] = 0; } sl->top_type = top_type; sl->left_type[LTOP] = left_type[LTOP]; sl->left_type[LBOT] = left_type[LBOT]; if (IS_INTRA(mb_type)) return 0; fill_filter_caches_inter(h, sl, mb_type, top_xy, left_xy, top_type, left_type, mb_xy, 0); if (sl->list_count == 2) fill_filter_caches_inter(h, sl, mb_type, top_xy, left_xy, top_type, left_type, mb_xy, 1); nnz = h->non_zero_count[mb_xy]; nnz_cache = sl->non_zero_count_cache; AV_COPY32(&nnz_cache[4 + 8 * 1], &nnz[0]); AV_COPY32(&nnz_cache[4 + 8 * 2], &nnz[4]); AV_COPY32(&nnz_cache[4 + 8 * 3], &nnz[8]); AV_COPY32(&nnz_cache[4 + 8 * 4], &nnz[12]); sl->cbp = h->cbp_table[mb_xy]; if (top_type) { nnz = h->non_zero_count[top_xy]; AV_COPY32(&nnz_cache[4 + 8 * 0], &nnz[3 * 4]); } if (left_type[LTOP]) { nnz = h->non_zero_count[left_xy[LTOP]]; nnz_cache[3 + 8 * 1] = nnz[3 + 0 * 4]; nnz_cache[3 + 8 * 2] = nnz[3 + 1 * 4]; nnz_cache[3 + 8 * 3] = nnz[3 + 2 * 4]; nnz_cache[3 + 8 * 4] = nnz[3 + 3 * 4]; } if (!CABAC(h) && h->pps.transform_8x8_mode) { if (IS_8x8DCT(top_type)) { nnz_cache[4 + 8 * 0] = nnz_cache[5 + 8 * 0] = (h->cbp_table[top_xy] & 0x4000) >> 12; nnz_cache[6 + 8 * 0] = nnz_cache[7 + 8 * 0] = (h->cbp_table[top_xy] & 0x8000) >> 12; } if (IS_8x8DCT(left_type[LTOP])) { nnz_cache[3 + 8 * 1] = nnz_cache[3 + 8 * 2] = (h->cbp_table[left_xy[LTOP]] & 0x2000) >> 12; } if (IS_8x8DCT(left_type[LBOT])) { nnz_cache[3 + 8 * 3] = nnz_cache[3 + 8 * 4] = (h->cbp_table[left_xy[LBOT]] & 0x8000) >> 12; } if (IS_8x8DCT(mb_type)) { nnz_cache[scan8[0]] = nnz_cache[scan8[1]] = nnz_cache[scan8[2]] = nnz_cache[scan8[3]] = (sl->cbp & 0x1000) >> 12; nnz_cache[scan8[0 + 4]] = nnz_cache[scan8[1 + 4]] = nnz_cache[scan8[2 + 4]] = nnz_cache[scan8[3 + 4]] = (sl->cbp & 0x2000) >> 12; nnz_cache[scan8[0 + 8]] = nnz_cache[scan8[1 + 8]] = nnz_cache[scan8[2 + 8]] = nnz_cache[scan8[3 + 8]] = (sl->cbp & 0x4000) >> 12; nnz_cache[scan8[0 + 12]] = nnz_cache[scan8[1 + 12]] = nnz_cache[scan8[2 + 12]] = nnz_cache[scan8[3 + 12]] = (sl->cbp & 0x8000) >> 12; } } return 0; }
1threat
How to Move Button Text? : <p>Button text by default is centered horizontally and centered vertically. How do you vertically align the button text to the top? </p> <p>I've inspected the element and it has 0 padding. </p> <p>vertical-align: text-top; does not work.</p>
0debug
static inline void RENAME(rgb32ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, int width) { int i; assert(src1==src2); for(i=0; i<width; i++) { const int a= ((uint32_t*)src1)[2*i+0]; const int e= ((uint32_t*)src1)[2*i+1]; const int l= (a&0xFF00FF) + (e&0xFF00FF); const int h= (a&0x00FF00) + (e&0x00FF00); const int r= l&0x3FF; const int g= h>>8; const int b= l>>16; dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1)) + 128; dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1)) + 128; } }
1threat
I'm calculating the avrage of scores in a dictionary, but returns error and I don't know exactly what's the error, help please : [I'm calculating the average of scores in a dictionary, but returns an error and I don't know exactly what's the error, help please ][1] [1]: https://i.stack.imgur.com/jXUZ2.png
0debug
static void test_primitive_lists(gconstpointer opaque) { TestArgs *args = (TestArgs *) opaque; const SerializeOps *ops = args->ops; PrimitiveType *pt = args->test_data; PrimitiveList pl = { .value = { NULL } }; PrimitiveList pl_copy = { .value = { NULL } }; PrimitiveList *pl_copy_ptr = &pl_copy; Error *err = NULL; void *serialize_data; void *cur_head = NULL; int i; pl.type = pl_copy.type = pt->type; for (i = 0; i < 32; i++) { switch (pl.type) { case PTYPE_STRING: { strList *tmp = g_new0(strList, 1); tmp->value = g_strdup(pt->value.string); if (pl.value.strings == NULL) { pl.value.strings = tmp; } else { tmp->next = pl.value.strings; pl.value.strings = tmp; } break; } case PTYPE_INTEGER: { intList *tmp = g_new0(intList, 1); tmp->value = pt->value.integer; if (pl.value.integers == NULL) { pl.value.integers = tmp; } else { tmp->next = pl.value.integers; pl.value.integers = tmp; } break; } case PTYPE_S8: { int8List *tmp = g_new0(int8List, 1); tmp->value = pt->value.s8; if (pl.value.s8_integers == NULL) { pl.value.s8_integers = tmp; } else { tmp->next = pl.value.s8_integers; pl.value.s8_integers = tmp; } break; } case PTYPE_S16: { int16List *tmp = g_new0(int16List, 1); tmp->value = pt->value.s16; if (pl.value.s16_integers == NULL) { pl.value.s16_integers = tmp; } else { tmp->next = pl.value.s16_integers; pl.value.s16_integers = tmp; } break; } case PTYPE_S32: { int32List *tmp = g_new0(int32List, 1); tmp->value = pt->value.s32; if (pl.value.s32_integers == NULL) { pl.value.s32_integers = tmp; } else { tmp->next = pl.value.s32_integers; pl.value.s32_integers = tmp; } break; } case PTYPE_S64: { int64List *tmp = g_new0(int64List, 1); tmp->value = pt->value.s64; if (pl.value.s64_integers == NULL) { pl.value.s64_integers = tmp; } else { tmp->next = pl.value.s64_integers; pl.value.s64_integers = tmp; } break; } case PTYPE_U8: { uint8List *tmp = g_new0(uint8List, 1); tmp->value = pt->value.u8; if (pl.value.u8_integers == NULL) { pl.value.u8_integers = tmp; } else { tmp->next = pl.value.u8_integers; pl.value.u8_integers = tmp; } break; } case PTYPE_U16: { uint16List *tmp = g_new0(uint16List, 1); tmp->value = pt->value.u16; if (pl.value.u16_integers == NULL) { pl.value.u16_integers = tmp; } else { tmp->next = pl.value.u16_integers; pl.value.u16_integers = tmp; } break; } case PTYPE_U32: { uint32List *tmp = g_new0(uint32List, 1); tmp->value = pt->value.u32; if (pl.value.u32_integers == NULL) { pl.value.u32_integers = tmp; } else { tmp->next = pl.value.u32_integers; pl.value.u32_integers = tmp; } break; } case PTYPE_U64: { uint64List *tmp = g_new0(uint64List, 1); tmp->value = pt->value.u64; if (pl.value.u64_integers == NULL) { pl.value.u64_integers = tmp; } else { tmp->next = pl.value.u64_integers; pl.value.u64_integers = tmp; } break; } case PTYPE_NUMBER: { numberList *tmp = g_new0(numberList, 1); tmp->value = pt->value.number; if (pl.value.numbers == NULL) { pl.value.numbers = tmp; } else { tmp->next = pl.value.numbers; pl.value.numbers = tmp; } break; } case PTYPE_BOOLEAN: { boolList *tmp = g_new0(boolList, 1); tmp->value = pt->value.boolean; if (pl.value.booleans == NULL) { pl.value.booleans = tmp; } else { tmp->next = pl.value.booleans; pl.value.booleans = tmp; } break; } default: g_assert_not_reached(); } } ops->serialize((void **)&pl, &serialize_data, visit_primitive_list, &err); ops->deserialize((void **)&pl_copy_ptr, serialize_data, visit_primitive_list, &err); g_assert(err == NULL); i = 0; do { switch (pl_copy.type) { case PTYPE_STRING: { strList *ptr; if (cur_head) { ptr = cur_head; cur_head = ptr->next; } else { cur_head = ptr = pl_copy.value.strings; } g_assert_cmpstr(pt->value.string, ==, ptr->value); break; } case PTYPE_INTEGER: { intList *ptr; if (cur_head) { ptr = cur_head; cur_head = ptr->next; } else { cur_head = ptr = pl_copy.value.integers; } g_assert_cmpint(pt->value.integer, ==, ptr->value); break; } case PTYPE_S8: { int8List *ptr; if (cur_head) { ptr = cur_head; cur_head = ptr->next; } else { cur_head = ptr = pl_copy.value.s8_integers; } g_assert_cmpint(pt->value.s8, ==, ptr->value); break; } case PTYPE_S16: { int16List *ptr; if (cur_head) { ptr = cur_head; cur_head = ptr->next; } else { cur_head = ptr = pl_copy.value.s16_integers; } g_assert_cmpint(pt->value.s16, ==, ptr->value); break; } case PTYPE_S32: { int32List *ptr; if (cur_head) { ptr = cur_head; cur_head = ptr->next; } else { cur_head = ptr = pl_copy.value.s32_integers; } g_assert_cmpint(pt->value.s32, ==, ptr->value); break; } case PTYPE_S64: { int64List *ptr; if (cur_head) { ptr = cur_head; cur_head = ptr->next; } else { cur_head = ptr = pl_copy.value.s64_integers; } g_assert_cmpint(pt->value.s64, ==, ptr->value); break; } case PTYPE_U8: { uint8List *ptr; if (cur_head) { ptr = cur_head; cur_head = ptr->next; } else { cur_head = ptr = pl_copy.value.u8_integers; } g_assert_cmpint(pt->value.u8, ==, ptr->value); break; } case PTYPE_U16: { uint16List *ptr; if (cur_head) { ptr = cur_head; cur_head = ptr->next; } else { cur_head = ptr = pl_copy.value.u16_integers; } g_assert_cmpint(pt->value.u16, ==, ptr->value); break; } case PTYPE_U32: { uint32List *ptr; if (cur_head) { ptr = cur_head; cur_head = ptr->next; } else { cur_head = ptr = pl_copy.value.u32_integers; } g_assert_cmpint(pt->value.u32, ==, ptr->value); break; } case PTYPE_U64: { uint64List *ptr; if (cur_head) { ptr = cur_head; cur_head = ptr->next; } else { cur_head = ptr = pl_copy.value.u64_integers; } g_assert_cmpint(pt->value.u64, ==, ptr->value); break; } case PTYPE_NUMBER: { numberList *ptr; GString *double_expected = g_string_new(""); GString *double_actual = g_string_new(""); if (cur_head) { ptr = cur_head; cur_head = ptr->next; } else { cur_head = ptr = pl_copy.value.numbers; } g_string_printf(double_expected, "%.6f", pt->value.number); g_string_printf(double_actual, "%.6f", ptr->value); g_assert_cmpstr(double_actual->str, ==, double_expected->str); g_string_free(double_expected, true); g_string_free(double_actual, true); break; } case PTYPE_BOOLEAN: { boolList *ptr; if (cur_head) { ptr = cur_head; cur_head = ptr->next; } else { cur_head = ptr = pl_copy.value.booleans; } g_assert_cmpint(!!pt->value.boolean, ==, !!ptr->value); break; } default: g_assert_not_reached(); } i++; } while (cur_head); g_assert_cmpint(i, ==, 33); ops->cleanup(serialize_data); dealloc_helper(&pl, visit_primitive_list, &err); g_assert(!err); dealloc_helper(&pl_copy, visit_primitive_list, &err); g_assert(!err); g_free(args); }
1threat
int qemu_pixman_get_type(int rshift, int gshift, int bshift) { int type = PIXMAN_TYPE_OTHER; if (rshift > gshift && gshift > bshift) { if (bshift == 0) { type = PIXMAN_TYPE_ARGB; } else { #if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0, 21, 8) type = PIXMAN_TYPE_RGBA; #endif } } else if (rshift < gshift && gshift < bshift) { if (rshift == 0) { type = PIXMAN_TYPE_ABGR; } else { #if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0, 21, 8) type = PIXMAN_TYPE_BGRA; #endif } } return type; }
1threat
Confusing setter and getter? Python. str' object is not callable : I used to hear that have a functions such as **set_value()** and **get_value()** isn't pythonic way, and it always better to use property, setter and getter. I run the code bellow and recieve an error "**str' object is not callable**". When I search for this error- I find many examples of code, where class have attribute and method with the same name. (like if I write "**self.name**" instead of "**self.__name**" in the init statement) But I have write underscores before attribute - so it shouldn't happend. It look like when I try to call name.setter I actually call a property -and recieve back a string self.__name - and to this string - I then tryed to call something else. But why? In all examples of setter, they have the same name as property and it doesn't lead to problem. Why it throw an error here and how to fix it? class Dog(): def __init__(self, name): self.__name = name @property def name(self): return self.__name @name.setter def name(self, name_in): self.__name = name_in dog = Dog("Barbos") print(dog.name) # this work dog.name("Juchka") # and this throw an error: # 'str' object is not callable
0debug
static int vmdk_L2update(BlockDriverState *bs, VmdkMetaData *m_data) { BDRVVmdkState *s = bs->opaque; if (bdrv_pwrite(bs->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)), &(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset)) return -1; if (s->l1_backup_table_offset != 0) { m_data->l2_offset = s->l1_backup_table[m_data->l1_index]; if (bdrv_pwrite(bs->file, ((int64_t)m_data->l2_offset * 512) + (m_data->l2_index * sizeof(m_data->offset)), &(m_data->offset), sizeof(m_data->offset)) != sizeof(m_data->offset)) return -1; } return 0; }
1threat
alert('Hello ' + user_input);
1threat
How can I provide my own login screen for Spring Security? : <p>Currently Spring Security is displaying this default login screen:</p> <p><a href="https://i.stack.imgur.com/2NNgx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2NNgx.png" alt="enter image description here"></a></p> <p>How can I configure Spring boot security so that I can use my own template so that I can customize it?</p>
0debug
static int latm_write_packet(AVFormatContext *s, AVPacket *pkt) { LATMContext *ctx = s->priv_data; AVIOContext *pb = s->pb; PutBitContext bs; int i, len; uint8_t loas_header[] = "\x56\xe0\x00"; if (s->streams[0]->codecpar->codec_id == AV_CODEC_ID_AAC_LATM) return ff_raw_write_packet(s, pkt); if (!s->streams[0]->codecpar->extradata) { if(pkt->size > 2 && pkt->data[0] == 0x56 && (pkt->data[1] >> 4) == 0xe && (AV_RB16(pkt->data + 1) & 0x1FFF) + 3 == pkt->size) return ff_raw_write_packet(s, pkt); else return AVERROR_INVALIDDATA; } if (pkt->size > 0x1fff) goto too_large; init_put_bits(&bs, ctx->buffer, pkt->size+1024+MAX_EXTRADATA_SIZE); latm_write_frame_header(s, &bs); for (i = 0; i <= pkt->size-255; i+=255) put_bits(&bs, 8, 255); put_bits(&bs, 8, pkt->size-i); if (pkt->size && (pkt->data[0] & 0xe1) == 0x81) { put_bits(&bs, 8, pkt->data[0] & 0xfe); avpriv_copy_bits(&bs, pkt->data + 1, 8*pkt->size - 8); } else avpriv_copy_bits(&bs, pkt->data, 8*pkt->size); avpriv_align_put_bits(&bs); flush_put_bits(&bs); len = put_bits_count(&bs) >> 3; if (len > 0x1fff) goto too_large; loas_header[1] |= (len >> 8) & 0x1f; loas_header[2] |= len & 0xff; avio_write(pb, loas_header, 3); avio_write(pb, ctx->buffer, len); return 0; too_large: av_log(s, AV_LOG_ERROR, "LATM packet size larger than maximum size 0x1fff\n"); return AVERROR_INVALIDDATA; }
1threat
static void gen_dstst(DisasContext *ctx) { if (rA(ctx->opcode) == 0) { gen_inval_exception(ctx, POWERPC_EXCP_INVAL_LSWX); } else { } }
1threat
python string comparison unexpected results : <pre><code>&gt;&gt;&gt; '1.2.3'&gt;'1.1.5' True &gt;&gt;&gt; '1.1.3'&gt;'1.1.5' False &gt;&gt;&gt; '1.1.5'&gt;'1.1.5' False &gt;&gt;&gt; '1.1.7'&gt;'1.1.5' True &gt;&gt;&gt; '1.1.9'&gt;'1.1.5' True &gt;&gt;&gt; '1.1.10'&gt;'1.1.5' False &gt;&gt;&gt; '1.2'&gt;'1.1.5' True &gt;&gt;&gt; '1.2.9'&gt;'1.1.5' True &gt;&gt;&gt; '1.2.10'&gt;'1.1.5' True </code></pre> <p>Hi,</p> <p>I am trying to compare two strings as shown above. First of all, I am surprised that python comparing strings of numbers. firstly I thought that it will just compare lengths, but for different values it's giving exact values and I am astonished. But, for '1.1.10' > '1.1.5' it's false... i don't know why.... can anyone help...</p>
0debug
Any way of doing very thin border lines around more cells : anyone tell me how making border lines around more td that has same value <table> <tr> <td>101</td> <td>101</td> <td>102</td> <td>103</td> <td>103</td> </tr> </table>
0debug
void ff_aac_update_ltp(AACEncContext *s, SingleChannelElement *sce) { int i, j, lag; float corr, s0, s1, max_corr = 0.0f; float *samples = &s->planar_samples[s->cur_channel][1024]; float *pred_signal = &sce->ltp_state[0]; int samples_num = 2048; if (s->profile != FF_PROFILE_AAC_LTP) return; for (i = 0; i < samples_num; i++) { s0 = s1 = 0.0f; for (j = 0; j < samples_num; j++) { if (j + 1024 < i) continue; s0 += samples[j]*pred_signal[j-i+1024]; s1 += pred_signal[j-i+1024]*pred_signal[j-i+1024]; } corr = s1 > 0.0f ? s0/sqrt(s1) : 0.0f; if (corr > max_corr) { max_corr = corr; lag = i; } } lag = av_clip_uintp2(lag, 11); if (!lag) { sce->ics.ltp.lag = lag; return; } s0 = s1 = 0.0f; for (i = 0; i < lag; i++) { s0 += samples[i]; s1 += pred_signal[i-lag+1024]; } sce->ics.ltp.coef_idx = quant_array_idx(s0/s1, ltp_coef, 8); sce->ics.ltp.coef = ltp_coef[sce->ics.ltp.coef_idx]; if (lag < 1024) samples_num = lag + 1024; for (i = 0; i < samples_num; i++) pred_signal[i+1024] = sce->ics.ltp.coef*pred_signal[i-lag+1024]; memset(&pred_signal[samples_num], 0, (2048 - samples_num)*sizeof(float)); sce->ics.ltp.lag = lag; }
1threat
Java Mouse Event Listerner in Image : <p>is it possible to add mouse listener to an image for game development. Or to any class which puts an image to a JPanel.</p>
0debug
What code is more CPU expensive: while(*p) or while(i--)? : <p>What C code is more CPU expensive: </p> <pre><code>while(*pointer){ pointer++; } </code></pre> <p>or </p> <pre><code>while(counter &gt; 0){ pointer++; counter--; } </code></pre> <p>?</p>
0debug
static void wdt_ib700_realize(DeviceState *dev, Error **errp) { IB700State *s = IB700(dev); PortioList *port_list = g_new(PortioList, 1); ib700_debug("watchdog init\n"); s->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, ib700_timer_expired, s); portio_list_init(port_list, OBJECT(s), wdt_portio_list, s, "ib700"); portio_list_add(port_list, isa_address_space_io(&s->parent_obj), 0); }
1threat
static int mjpeg_decode_scan_progressive_ac(MJpegDecodeContext *s, int ss, int se, int Ah, int Al) { int mb_x, mb_y; int EOBRUN = 0; int c = s->comp_index[0]; uint8_t *data = s->picture_ptr->data[c]; int linesize = s->linesize[c]; int last_scan = 0; int16_t *quant_matrix = s->quant_matrixes[s->quant_sindex[0]]; int bytes_per_pixel = 1 + (s->bits > 8); av_assert0(ss>=0 && Ah>=0 && Al>=0); if (se < ss || se > 63) { av_log(s->avctx, AV_LOG_ERROR, "SS/SE %d/%d is invalid\n", ss, se); return AVERROR_INVALIDDATA; } if (!Al) { s->coefs_finished[c] |= (2LL << se) - (1LL << ss); last_scan = !~s->coefs_finished[c]; } if (s->interlaced && s->bottom_field) data += linesize >> 1; s->restart_count = 0; for (mb_y = 0; mb_y < s->mb_height; mb_y++) { uint8_t *ptr = data + (mb_y * linesize * 8 >> s->avctx->lowres); int block_idx = mb_y * s->block_stride[c]; int16_t (*block)[64] = &s->blocks[c][block_idx]; uint8_t *last_nnz = &s->last_nnz[c][block_idx]; for (mb_x = 0; mb_x < s->mb_width; mb_x++, block++, last_nnz++) { int ret; if (s->restart_interval && !s->restart_count) s->restart_count = s->restart_interval; if (Ah) ret = decode_block_refinement(s, *block, last_nnz, s->ac_index[0], quant_matrix, ss, se, Al, &EOBRUN); else ret = decode_block_progressive(s, *block, last_nnz, s->ac_index[0], quant_matrix, ss, se, Al, &EOBRUN); if (ret < 0) { av_log(s->avctx, AV_LOG_ERROR, "error y=%d x=%d\n", mb_y, mb_x); return AVERROR_INVALIDDATA; } if (last_scan) { s->dsp.idct_put(ptr, linesize, *block); if (s->bits & 7) shift_output(s, ptr, linesize); ptr += bytes_per_pixel*8 >> s->avctx->lowres; } if (handle_rstn(s, 0)) EOBRUN = 0; } } return 0; }
1threat
How to change ngx bootstrap modal width? : <p>How can I set the width to my ngx bootstrap modal, I've tried but like It is fixed?</p> <p>Here's the html </p> <pre><code> &lt;div bsModal #childModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" [config]="{backdrop: 'static'}" aria-hidden="true"&gt; &lt;div class="modal-dialog modal-sm"&gt; &lt;div class="modal-content"&gt; &lt;div class="modal-body text-center"&gt; &lt;button type="button" class="close" data-dismiss="modal" aria- label="Close" (click)="hide()"&gt;&lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt; &lt;/button&gt; &lt;h4 class="modal-title" id="myModalLabel"&gt;Are you sure?&lt;/h4&gt; &lt;div class="modal-footer"&gt; &lt;div class="col-xs-6 no-padding-left"&gt; &lt;button type="button" id="dialog_no" class="btn btn- default btn-block" data-dismiss="modal" (click)="hide()"&gt;No&lt;/button&gt; &lt;/div&gt; &lt;div class="col-xs-6 no-padding-right"&gt; &lt;button type="button" id="dialog_yes" class="btn btn- primary btn-block ladda-button" data-style="expand-right" (click)="confirm()"&gt;Yes&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>How can I set the width of the modal for buttons to be placed just on the edge of the modal, with lets say 5 px of border margin?</p> <p><a href="https://i.stack.imgur.com/bm8ff.png" rel="noreferrer">modal bootstrap</a></p> <p>I haven't put any styling yet in my css file, even tho I've tried to modify the width but didn't I guess know how...</p>
0debug
static int get_aiff_header(AVFormatContext *s, int size, unsigned version) { AVIOContext *pb = s->pb; AVCodecParameters *par = s->streams[0]->codecpar; AIFFInputContext *aiff = s->priv_data; int exp; uint64_t val; int sample_rate; unsigned int num_frames; if (size & 1) size++; par->codec_type = AVMEDIA_TYPE_AUDIO; par->channels = avio_rb16(pb); num_frames = avio_rb32(pb); par->bits_per_coded_sample = avio_rb16(pb); exp = avio_rb16(pb) - 16383 - 63; val = avio_rb64(pb); if (exp <-63 || exp >63) { av_log(s, AV_LOG_ERROR, "exp %d is out of range\n", exp); return AVERROR_INVALIDDATA; } if (exp >= 0) sample_rate = val << exp; else sample_rate = (val + (1ULL<<(-exp-1))) >> -exp; par->sample_rate = sample_rate; size -= 18; if (size < 4) { version = AIFF; } else if (version == AIFF_C_VERSION1) { par->codec_tag = avio_rl32(pb); par->codec_id = ff_codec_get_id(ff_codec_aiff_tags, par->codec_tag); if (par->codec_id == AV_CODEC_ID_NONE) { char tag[32]; av_get_codec_tag_string(tag, sizeof(tag), par->codec_tag); avpriv_request_sample(s, "unknown or unsupported codec tag: %s", tag); } size -= 4; } if (version != AIFF_C_VERSION1 || par->codec_id == AV_CODEC_ID_PCM_S16BE) { par->codec_id = aiff_codec_get_id(par->bits_per_coded_sample); par->bits_per_coded_sample = av_get_bits_per_sample(par->codec_id); aiff->block_duration = 1; } else { switch (par->codec_id) { case AV_CODEC_ID_PCM_F32BE: case AV_CODEC_ID_PCM_F64BE: case AV_CODEC_ID_PCM_S16LE: case AV_CODEC_ID_PCM_ALAW: case AV_CODEC_ID_PCM_MULAW: aiff->block_duration = 1; break; case AV_CODEC_ID_ADPCM_IMA_QT: par->block_align = 34 * par->channels; break; case AV_CODEC_ID_MACE3: par->block_align = 2 * par->channels; break; case AV_CODEC_ID_ADPCM_G726LE: par->bits_per_coded_sample = 5; case AV_CODEC_ID_ADPCM_IMA_WS: case AV_CODEC_ID_ADPCM_G722: case AV_CODEC_ID_MACE6: case AV_CODEC_ID_SDX2_DPCM: par->block_align = 1 * par->channels; break; case AV_CODEC_ID_GSM: par->block_align = 33; break; default: aiff->block_duration = 1; break; } if (par->block_align > 0) aiff->block_duration = av_get_audio_frame_duration2(par, par->block_align); } if (!par->block_align) par->block_align = (av_get_bits_per_sample(par->codec_id) * par->channels) >> 3; if (aiff->block_duration) { par->bit_rate = par->sample_rate * (par->block_align << 3) / aiff->block_duration; } if (size) avio_skip(pb, size); return num_frames; }
1threat
document.write('<script src="evil.js"></script>');
1threat
error 'Could not determine java version from ‘10’ : npm run android not working. node version v8.9.4 npm version 5.7.1 genymotion 2.12.0 getting error Could not determine java version from ‘10’ i dont have have an android studio installed but i have installed gradle 4.6 also set the path for java created JAVA_HOME and set path for genymotion.
0debug
static int lag_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; LagarithContext *l = avctx->priv_data; AVFrame *const p = &l->picture; uint8_t frametype = 0; uint32_t offset_gu = 0, offset_bv = 0, offset_ry = 9; int offs[4]; uint8_t *srcs[4], *dst; int i, j, planes = 3; AVFrame *picture = data; if (p->data[0]) avctx->release_buffer(avctx, p); p->reference = 0; p->key_frame = 1; frametype = buf[0]; offset_gu = AV_RL32(buf + 1); offset_bv = AV_RL32(buf + 5); switch (frametype) { case FRAME_SOLID_RGBA: avctx->pix_fmt = PIX_FMT_RGB32; if (avctx->get_buffer(avctx, p) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } dst = p->data[0]; for (j = 0; j < avctx->height; j++) { for (i = 0; i < avctx->width; i++) AV_WN32(dst + i * 4, offset_gu); dst += p->linesize[0]; } break; case FRAME_ARITH_RGBA: avctx->pix_fmt = PIX_FMT_RGB32; planes = 4; offset_ry += 4; offs[3] = AV_RL32(buf + 9); case FRAME_ARITH_RGB24: if (frametype == FRAME_ARITH_RGB24) avctx->pix_fmt = PIX_FMT_RGB24; if (avctx->get_buffer(avctx, p) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } offs[0] = offset_bv; offs[1] = offset_gu; offs[2] = offset_ry; if (!l->rgb_planes) { l->rgb_stride = FFALIGN(avctx->width, 16); l->rgb_planes = av_malloc(l->rgb_stride * avctx->height * planes + 16); if (!l->rgb_planes) { av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n"); return AVERROR(ENOMEM); } } for (i = 0; i < planes; i++) srcs[i] = l->rgb_planes + (i + 1) * l->rgb_stride * avctx->height - l->rgb_stride; for (i = 0; i < planes; i++) lag_decode_arith_plane(l, srcs[i], avctx->width, avctx->height, -l->rgb_stride, buf + offs[i], buf_size); dst = p->data[0]; for (i = 0; i < planes; i++) srcs[i] = l->rgb_planes + i * l->rgb_stride * avctx->height; for (j = 0; j < avctx->height; j++) { for (i = 0; i < avctx->width; i++) { uint8_t r, g, b, a; r = srcs[0][i]; g = srcs[1][i]; b = srcs[2][i]; r += g; b += g; if (frametype == FRAME_ARITH_RGBA) { a = srcs[3][i]; AV_WN32(dst + i * 4, MKBETAG(a, r, g, b)); } else { dst[i * 3 + 0] = r; dst[i * 3 + 1] = g; dst[i * 3 + 2] = b; } } dst += p->linesize[0]; for (i = 0; i < planes; i++) srcs[i] += l->rgb_stride; } break; case FRAME_ARITH_YV12: avctx->pix_fmt = PIX_FMT_YUV420P; if (avctx->get_buffer(avctx, p) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } lag_decode_arith_plane(l, p->data[0], avctx->width, avctx->height, p->linesize[0], buf + offset_ry, buf_size); lag_decode_arith_plane(l, p->data[2], avctx->width / 2, avctx->height / 2, p->linesize[2], buf + offset_gu, buf_size); lag_decode_arith_plane(l, p->data[1], avctx->width / 2, avctx->height / 2, p->linesize[1], buf + offset_bv, buf_size); break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported Lagarith frame type: %#x\n", frametype); return -1; } *picture = *p; *data_size = sizeof(AVFrame); return buf_size; }
1threat
List of length n with p randomly allocated ones else zero : <p>What's the shortest way (as in short code) to get a list of length n with p &lt; n randomly allocated ones else zero. Say n = 6 and p = 2, I'd like something like [0,1,0,0,1,0].</p>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
static av_cold int xvid_encode_init(AVCodecContext *avctx) { int xerr, i; int xvid_flags = avctx->flags; struct xvid_context *x = avctx->priv_data; uint16_t *intra, *inter; int fd; xvid_plugin_single_t single = { 0 }; struct xvid_ff_pass1 rc2pass1 = { 0 }; xvid_plugin_2pass2_t rc2pass2 = { 0 }; xvid_plugin_lumimasking_t masking_l = { 0 }; xvid_plugin_lumimasking_t masking_v = { 0 }; xvid_plugin_ssim_t ssim = { 0 }; xvid_gbl_init_t xvid_gbl_init = { 0 }; xvid_enc_create_t xvid_enc_create = { 0 }; xvid_enc_plugin_t plugins[7]; x->vop_flags = XVID_VOP_HALFPEL; if (xvid_flags & CODEC_FLAG_4MV) x->vop_flags |= XVID_VOP_INTER4V; if (avctx->trellis) x->vop_flags |= XVID_VOP_TRELLISQUANT; if (xvid_flags & CODEC_FLAG_AC_PRED) x->vop_flags |= XVID_VOP_HQACPRED; if (xvid_flags & CODEC_FLAG_GRAY) x->vop_flags |= XVID_VOP_GREYSCALE; x->me_flags = 0; switch (avctx->me_method) { case ME_FULL: x->me_flags |= XVID_ME_EXTSEARCH16 | XVID_ME_EXTSEARCH8; case ME_EPZS: x->me_flags |= XVID_ME_ADVANCEDDIAMOND8 | XVID_ME_HALFPELREFINE8 | XVID_ME_CHROMA_PVOP | XVID_ME_CHROMA_BVOP; case ME_LOG: case ME_PHODS: case ME_X1: x->me_flags |= XVID_ME_ADVANCEDDIAMOND16 | XVID_ME_HALFPELREFINE16; case ME_ZERO: default: break; } switch (avctx->mb_decision) { case 2: x->vop_flags |= XVID_VOP_MODEDECISION_RD; x->me_flags |= XVID_ME_HALFPELREFINE8_RD | XVID_ME_QUARTERPELREFINE8_RD | XVID_ME_EXTSEARCH_RD | XVID_ME_CHECKPREDICTION_RD; case 1: if (!(x->vop_flags & XVID_VOP_MODEDECISION_RD)) x->vop_flags |= XVID_VOP_FAST_MODEDECISION_RD; x->me_flags |= XVID_ME_HALFPELREFINE16_RD | XVID_ME_QUARTERPELREFINE16_RD; default: break; } #if FF_API_GMC if (avctx->flags & CODEC_FLAG_GMC) x->gmc = 1; #endif x->vol_flags = 0; if (x->gmc) { x->vol_flags |= XVID_VOL_GMC; x->me_flags |= XVID_ME_GME_REFINE; } if (xvid_flags & CODEC_FLAG_QPEL) { x->vol_flags |= XVID_VOL_QUARTERPEL; x->me_flags |= XVID_ME_QUARTERPELREFINE16; if (x->vop_flags & XVID_VOP_INTER4V) x->me_flags |= XVID_ME_QUARTERPELREFINE8; } xvid_gbl_init.version = XVID_VERSION; xvid_gbl_init.debug = 0; xvid_gbl_init.cpu_flags = 0; xvid_global(NULL, XVID_GBL_INIT, &xvid_gbl_init, NULL); xvid_enc_create.version = XVID_VERSION; xvid_enc_create.width = x->xsize = avctx->width; xvid_enc_create.height = x->ysize = avctx->height; xvid_enc_create.zones = NULL; xvid_enc_create.num_zones = 0; xvid_enc_create.num_threads = avctx->thread_count; xvid_enc_create.plugins = plugins; xvid_enc_create.num_plugins = 0; x->twopassbuffer = NULL; x->old_twopassbuffer = NULL; x->twopassfile = NULL; if (xvid_flags & CODEC_FLAG_PASS1) { rc2pass1.version = XVID_VERSION; rc2pass1.context = x; x->twopassbuffer = av_malloc(BUFFER_SIZE); x->old_twopassbuffer = av_malloc(BUFFER_SIZE); if (!x->twopassbuffer || !x->old_twopassbuffer) { av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot allocate 2-pass log buffers\n"); return AVERROR(ENOMEM); } x->twopassbuffer[0] = x->old_twopassbuffer[0] = 0; plugins[xvid_enc_create.num_plugins].func = xvid_ff_2pass; plugins[xvid_enc_create.num_plugins].param = &rc2pass1; xvid_enc_create.num_plugins++; } else if (xvid_flags & CODEC_FLAG_PASS2) { rc2pass2.version = XVID_VERSION; rc2pass2.bitrate = avctx->bit_rate; fd = ff_tempfile("xvidff.", &x->twopassfile); if (fd < 0) { av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write 2-pass pipe\n"); return fd; } if (!avctx->stats_in) { av_log(avctx, AV_LOG_ERROR, "Xvid: No 2-pass information loaded for second pass\n"); return AVERROR_INVALIDDATA; } if (strlen(avctx->stats_in) > write(fd, avctx->stats_in, strlen(avctx->stats_in))) { close(fd); av_log(avctx, AV_LOG_ERROR, "Xvid: Cannot write to 2-pass pipe\n"); return AVERROR(EIO); } close(fd); rc2pass2.filename = x->twopassfile; plugins[xvid_enc_create.num_plugins].func = xvid_plugin_2pass2; plugins[xvid_enc_create.num_plugins].param = &rc2pass2; xvid_enc_create.num_plugins++; } else if (!(xvid_flags & CODEC_FLAG_QSCALE)) { single.version = XVID_VERSION; single.bitrate = avctx->bit_rate; plugins[xvid_enc_create.num_plugins].func = xvid_plugin_single; plugins[xvid_enc_create.num_plugins].param = &single; xvid_enc_create.num_plugins++; } if (avctx->lumi_masking != 0.0) x->lumi_aq = 1; if (x->lumi_aq && x->variance_aq) { x->variance_aq = 0; av_log(avctx, AV_LOG_WARNING, "variance_aq is ignored when lumi_aq is set.\n"); } if (x->lumi_aq) { masking_l.method = 0; plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking; plugins[xvid_enc_create.num_plugins].param = avctx->lumi_masking ? NULL : &masking_l; xvid_enc_create.num_plugins++; } if (x->variance_aq) { masking_v.method = 1; plugins[xvid_enc_create.num_plugins].func = xvid_plugin_lumimasking; plugins[xvid_enc_create.num_plugins].param = &masking_v; xvid_enc_create.num_plugins++; } if (x->ssim) { plugins[xvid_enc_create.num_plugins].func = xvid_plugin_ssim; ssim.b_printstat = x->ssim == 2; ssim.acc = x->ssim_acc; ssim.cpu_flags = xvid_gbl_init.cpu_flags; ssim.b_visualize = 0; plugins[xvid_enc_create.num_plugins].param = &ssim; xvid_enc_create.num_plugins++; } xvid_correct_framerate(avctx); xvid_enc_create.fincr = avctx->time_base.num; xvid_enc_create.fbase = avctx->time_base.den; if (avctx->gop_size > 0) xvid_enc_create.max_key_interval = avctx->gop_size; else xvid_enc_create.max_key_interval = 240; if (xvid_flags & CODEC_FLAG_QSCALE) x->qscale = 1; else x->qscale = 0; xvid_enc_create.min_quant[0] = avctx->qmin; xvid_enc_create.min_quant[1] = avctx->qmin; xvid_enc_create.min_quant[2] = avctx->qmin; xvid_enc_create.max_quant[0] = avctx->qmax; xvid_enc_create.max_quant[1] = avctx->qmax; xvid_enc_create.max_quant[2] = avctx->qmax; x->intra_matrix = x->inter_matrix = NULL; if (avctx->mpeg_quant) x->vol_flags |= XVID_VOL_MPEGQUANT; if ((avctx->intra_matrix || avctx->inter_matrix)) { x->vol_flags |= XVID_VOL_MPEGQUANT; if (avctx->intra_matrix) { intra = avctx->intra_matrix; x->intra_matrix = av_malloc(sizeof(unsigned char) * 64); if (!x->intra_matrix) return AVERROR(ENOMEM); } else intra = NULL; if (avctx->inter_matrix) { inter = avctx->inter_matrix; x->inter_matrix = av_malloc(sizeof(unsigned char) * 64); if (!x->inter_matrix) return AVERROR(ENOMEM); } else inter = NULL; for (i = 0; i < 64; i++) { if (intra) x->intra_matrix[i] = (unsigned char) intra[i]; if (inter) x->inter_matrix[i] = (unsigned char) inter[i]; } } xvid_enc_create.frame_drop_ratio = 0; xvid_enc_create.global = 0; if (xvid_flags & CODEC_FLAG_CLOSED_GOP) xvid_enc_create.global |= XVID_GLOBAL_CLOSED_GOP; avctx->extradata = NULL; avctx->extradata_size = 0; if (xvid_flags & CODEC_FLAG_GLOBAL_HEADER) { x->quicktime_format = 1; avctx->codec_id = AV_CODEC_ID_MPEG4; } else { x->quicktime_format = 0; if (!avctx->codec_tag) avctx->codec_tag = AV_RL32("xvid"); } xvid_enc_create.max_bframes = avctx->max_b_frames; xvid_enc_create.bquant_offset = 100 * avctx->b_quant_offset; xvid_enc_create.bquant_ratio = 100 * avctx->b_quant_factor; if (avctx->max_b_frames > 0 && !x->quicktime_format) xvid_enc_create.global |= XVID_GLOBAL_PACKED; xerr = xvid_encore(NULL, XVID_ENC_CREATE, &xvid_enc_create, NULL); if (xerr) { av_log(avctx, AV_LOG_ERROR, "Xvid: Could not create encoder reference\n"); return -1; } x->encoder_handle = xvid_enc_create.handle; avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); return 0; }
1threat
static int flashsv_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { int buf_size = avpkt->size; FlashSVContext *s = avctx->priv_data; int h_blocks, v_blocks, h_part, v_part, i, j, ret; GetBitContext gb; if (buf_size == 0) return 0; if (buf_size < 4) return -1; init_get_bits(&gb, avpkt->data, buf_size * 8); s->block_width = 16 * (get_bits(&gb, 4) + 1); s->image_width = get_bits(&gb, 12); s->block_height = 16 * (get_bits(&gb, 4) + 1); s->image_height = get_bits(&gb, 12); if (s->ver == 2) { skip_bits(&gb, 6); if (get_bits1(&gb)) { avpriv_request_sample(avctx, "iframe"); return AVERROR_PATCHWELCOME; } if (get_bits1(&gb)) { avpriv_request_sample(avctx, "Custom palette"); return AVERROR_PATCHWELCOME; } } h_blocks = s->image_width / s->block_width; h_part = s->image_width % s->block_width; v_blocks = s->image_height / s->block_height; v_part = s->image_height % s->block_height; if (s->block_size < s->block_width * s->block_height) { int tmpblock_size = 3 * s->block_width * s->block_height, err; if ((err = av_reallocp(&s->tmpblock, tmpblock_size)) < 0) { s->block_size = 0; av_log(avctx, AV_LOG_ERROR, "Cannot allocate decompression buffer.\n"); return err; } if (s->ver == 2) { s->deflate_block_size = calc_deflate_block_size(tmpblock_size); if (s->deflate_block_size <= 0) { av_log(avctx, AV_LOG_ERROR, "Cannot determine deflate buffer size.\n"); return -1; } if ((err = av_reallocp(&s->deflate_block, s->deflate_block_size)) < 0) { s->block_size = 0; av_log(avctx, AV_LOG_ERROR, "Cannot allocate deflate buffer.\n"); return err; } } } s->block_size = s->block_width * s->block_height; if (avctx->width == 0 && avctx->height == 0) { avctx->width = s->image_width; avctx->height = s->image_height; } if (avctx->width != s->image_width || avctx->height != s->image_height) { av_log(avctx, AV_LOG_ERROR, "Frame width or height differs from first frame!\n"); av_log(avctx, AV_LOG_ERROR, "fh = %d, fv %d vs ch = %d, cv = %d\n", avctx->height, avctx->width, s->image_height, s->image_width); return AVERROR_INVALIDDATA; } s->is_keyframe = (avpkt->flags & AV_PKT_FLAG_KEY) && (s->ver == 2); if (s->is_keyframe) { int err; if ((err = av_reallocp(&s->keyframedata, avpkt->size)) < 0) return err; memcpy(s->keyframedata, avpkt->data, avpkt->size); if ((err = av_reallocp(&s->blocks, (v_blocks + !!v_part) * (h_blocks + !!h_part) * sizeof(s->blocks[0]))) < 0) return err; } ff_dlog(avctx, "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n", s->image_width, s->image_height, s->block_width, s->block_height, h_blocks, v_blocks, h_part, v_part); if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } for (j = 0; j < v_blocks + (v_part ? 1 : 0); j++) { int y_pos = j * s->block_height; int cur_blk_height = (j < v_blocks) ? s->block_height : v_part; for (i = 0; i < h_blocks + (h_part ? 1 : 0); i++) { int x_pos = i * s->block_width; int cur_blk_width = (i < h_blocks) ? s->block_width : h_part; int has_diff = 0; int size = get_bits(&gb, 16); s->color_depth = 0; s->zlibprime_curr = 0; s->zlibprime_prev = 0; s->diff_start = 0; s->diff_height = cur_blk_height; if (8 * size > get_bits_left(&gb)) { av_frame_unref(s->frame); return AVERROR_INVALIDDATA; } if (s->ver == 2 && size) { skip_bits(&gb, 3); s->color_depth = get_bits(&gb, 2); has_diff = get_bits1(&gb); s->zlibprime_curr = get_bits1(&gb); s->zlibprime_prev = get_bits1(&gb); if (s->color_depth != 0 && s->color_depth != 2) { av_log(avctx, AV_LOG_ERROR, "%dx%d invalid color depth %d\n", i, j, s->color_depth); return AVERROR_INVALIDDATA; } if (has_diff) { if (!s->keyframe) { av_log(avctx, AV_LOG_ERROR, "Inter frame without keyframe\n"); return AVERROR_INVALIDDATA; } s->diff_start = get_bits(&gb, 8); s->diff_height = get_bits(&gb, 8); if (s->diff_start + s->diff_height > cur_blk_height) { av_log(avctx, AV_LOG_ERROR, "Block parameters invalid: %d + %d > %d\n", s->diff_start, s->diff_height, cur_blk_height); return AVERROR_INVALIDDATA; } av_log(avctx, AV_LOG_DEBUG, "%dx%d diff start %d height %d\n", i, j, s->diff_start, s->diff_height); size -= 2; } if (s->zlibprime_prev) av_log(avctx, AV_LOG_DEBUG, "%dx%d zlibprime_prev\n", i, j); if (s->zlibprime_curr) { int col = get_bits(&gb, 8); int row = get_bits(&gb, 8); av_log(avctx, AV_LOG_DEBUG, "%dx%d zlibprime_curr %dx%d\n", i, j, col, row); size -= 2; avpriv_request_sample(avctx, "zlibprime_curr"); return AVERROR_PATCHWELCOME; } if (!s->blocks && (s->zlibprime_curr || s->zlibprime_prev)) { av_log(avctx, AV_LOG_ERROR, "no data available for zlib priming\n"); return AVERROR_INVALIDDATA; } size--; } if (has_diff) { int k; int off = (s->image_height - y_pos - 1) * s->frame->linesize[0]; for (k = 0; k < cur_blk_height; k++) { int x = off - k * s->frame->linesize[0] + x_pos * 3; memcpy(s->frame->data[0] + x, s->keyframe + x, cur_blk_width * 3); } } if (size) { if (flashsv_decode_block(avctx, avpkt, &gb, size, cur_blk_width, cur_blk_height, x_pos, y_pos, i + j * (h_blocks + !!h_part))) av_log(avctx, AV_LOG_ERROR, "error in decompression of block %dx%d\n", i, j); } } } if (s->is_keyframe && s->ver == 2) { if (!s->keyframe) { s->keyframe = av_malloc(s->frame->linesize[0] * avctx->height); if (!s->keyframe) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate image data\n"); return AVERROR(ENOMEM); } } memcpy(s->keyframe, s->frame->data[0], s->frame->linesize[0] * avctx->height); } if ((ret = av_frame_ref(data, s->frame)) < 0) return ret; *got_frame = 1; if ((get_bits_count(&gb) / 8) != buf_size) av_log(avctx, AV_LOG_ERROR, "buffer not fully consumed (%d != %d)\n", buf_size, (get_bits_count(&gb) / 8)); return buf_size; }
1threat
void input_type_enum(Visitor *v, int *obj, const char *strings[], const char *kind, const char *name, Error **errp) { int64_t value = 0; char *enum_str; assert(strings); visit_type_str(v, &enum_str, name, errp); if (error_is_set(errp)) { return; } while (strings[value] != NULL) { if (strcmp(strings[value], enum_str) == 0) { break; } value++; } if (strings[value] == NULL) { error_set(errp, QERR_INVALID_PARAMETER, enum_str); g_free(enum_str); return; } g_free(enum_str); *obj = value; }
1threat
socket_sockaddr_to_address_vsock(struct sockaddr_storage *sa, socklen_t salen, Error **errp) { SocketAddressLegacy *addr; VsockSocketAddress *vaddr; struct sockaddr_vm *svm = (struct sockaddr_vm *)sa; addr = g_new0(SocketAddressLegacy, 1); addr->type = SOCKET_ADDRESS_LEGACY_KIND_VSOCK; addr->u.vsock.data = vaddr = g_new0(VsockSocketAddress, 1); vaddr->cid = g_strdup_printf("%u", svm->svm_cid); vaddr->port = g_strdup_printf("%u", svm->svm_port); return addr; }
1threat
How to consume soap web service in android : How to consume a web service soap using ksoap2 library. I'm not sure which are these parameters: namescape, method_name, soapaction, url. my web service is: http://www2.sentinelperu.com/ws/aws_datosfoto.aspx?wsdl Request and Result in the next image: http://i.stack.imgur.com/bMcD6.png SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME); request.addProperty("Usuario", ""); ... ...= new HttpTransportSE(URL); androidHttpTransport.call(SOAP_ACTION, envelope); Thanks, sorry for my bad english.
0debug
how to make a random in c++ program : <p>I am want to make my program to choose a random number </p> <pre><code> #include &lt;iostream&gt; using namespace std; int main(){ int x=100 y=40; while (true) {if(x&gt;y) {x--;} else {break;}}} </code></pre>
0debug
Python original list still being modified after being copied : <pre><code> def get_all_children(self): zero = self.current_coords[0] zero_row, zero_col = zero states = [] # blank spot is not on top row(middle or bottom) so we move up! if zero_row &gt; 0: swapRow = zero_row - 1 tempState = copy.copy(self.current) # a list of list of strings tempState[zero_row][zero_col], tempState[swapRow][zero_col] = tempState[swapRow][zero_col], tempState[zero_row][zero_col] s = State(tempState) states.append(s) ## blank spot is not on the bottom row(middle or top) so we move down! if zero_row &lt; 2: swapRow = zero_row + 1 tempState = copy.copy(self.current) tempState[zero_row][zero_col], tempState[swapRow][zero_col] = tempState[swapRow][zero_col], tempState[zero_row][zero_col] s = State(tempState) states.append(s) </code></pre> <p>I have a State class that contains a list of lists named 'current' and i'm trying to define a function that gets all the possible children(moves) of the current state. in the first IF statement, i create a COPY of the current variable(which is a list of lists) and store it in a 'tempState' list and then i try to swap values on that tempState, create a State object passing that in and then append that object to a list. All that works fine. The problem is when it get's to the 2nd IF statement. After i did the swap, It modified the original 'current' variable even though i created a copy! and I can't figure out why. I tried list(self.current), self.current[:], copy.cop(self.current). Please help</p>
0debug
static int asink_query_formats(AVFilterContext *ctx) { BufferSinkContext *buf = ctx->priv; AVFilterFormats *formats = NULL; AVFilterChannelLayouts *layouts = NULL; unsigned i; int ret; if (buf->sample_fmts_size % sizeof(*buf->sample_fmts) || buf->sample_rates_size % sizeof(*buf->sample_rates) || buf->channel_layouts_size % sizeof(*buf->channel_layouts) || buf->channel_counts_size % sizeof(*buf->channel_counts)) { av_log(ctx, AV_LOG_ERROR, "Invalid size for format lists\n"); #define LOG_ERROR(field) \ if (buf->field ## _size % sizeof(*buf->field)) \ av_log(ctx, AV_LOG_ERROR, " " #field " is %d, should be " \ "multiple of %d\n", \ buf->field ## _size, (int)sizeof(*buf->field)); LOG_ERROR(sample_fmts); LOG_ERROR(sample_rates); LOG_ERROR(channel_layouts); LOG_ERROR(channel_counts); #undef LOG_ERROR return AVERROR(EINVAL); } if (buf->sample_fmts_size) { for (i = 0; i < NB_ITEMS(buf->sample_fmts); i++) if ((ret = ff_add_format(&formats, buf->sample_fmts[i])) < 0) return ret; ff_set_common_formats(ctx, formats); } if (buf->channel_layouts_size || buf->channel_counts_size || buf->all_channel_counts) { for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++) if ((ret = ff_add_channel_layout(&layouts, buf->channel_layouts[i])) < 0) return ret; for (i = 0; i < NB_ITEMS(buf->channel_counts); i++) if ((ret = ff_add_channel_layout(&layouts, FF_COUNT2LAYOUT(buf->channel_counts[i]))) < 0) return ret; if (buf->all_channel_counts) { if (layouts) av_log(ctx, AV_LOG_WARNING, "Conflicting all_channel_counts and list in options\n"); else if (!(layouts = ff_all_channel_counts())) return AVERROR(ENOMEM); } ff_set_common_channel_layouts(ctx, layouts); } if (buf->sample_rates_size) { formats = NULL; for (i = 0; i < NB_ITEMS(buf->sample_rates); i++) if ((ret = ff_add_format(&formats, buf->sample_rates[i])) < 0) return ret; ff_set_common_samplerates(ctx, formats); } return 0; }
1threat
Parent bottom views hide with parent center layout view on opening keyboard : <p>I am working on layout where I have aligned one <code>cardview</code> on the center of the screen and contact us <code>button</code> on bottom of the screen. This layout looks OK when keyboard is closed.</p> <p>It looks like below :-<a href="https://i.stack.imgur.com/lzc61.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lzc61.png" alt="enter image description here"></a></p> <p>layout.xml</p> <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true"&gt; &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:weightSum="2"&gt; &lt;ImageView android:id="@+id/login_image" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@drawable/login_background" /&gt; &lt;View android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@color/grey_background" /&gt; &lt;/LinearLayout&gt; &lt;android.support.v7.widget.CardView android:id="@+id/media_card_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:layout_marginLeft="24dp" android:layout_marginRight="24dp" card_view:cardBackgroundColor="@color/white" card_view:cardElevation="4dp" card_view:cardCornerRadius="5dp" &gt; &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" &gt; &lt;ImageView android:id="@+id/logoImageView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@color/grey_background" android:padding="15dp" android:src="@drawable/logo_login" /&gt; &lt;EditText android:id="@+id/usertext" android:layout_width="match_parent" android:layout_height="40dp" android:layout_below="@id/logoImageView" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:layout_marginTop="20dp" android:background="@drawable/edittext_background" android:hint="User ID" android:maxLength="50" android:padding="10dp" android:singleLine="true" android:textColorHint="@color/hint_text_color" android:textSize="16sp" /&gt; &lt;FrameLayout android:id="@+id/passwordLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/usertext" android:layout_marginTop="8dp" android:orientation="horizontal"&gt; &lt;EditText android:id="@+id/passtext" android:layout_width="match_parent" android:layout_height="40dp" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:background="@drawable/edittext_background" android:fontFamily="sans-serif" android:hint="@string/password" android:inputType="textPassword" android:maxLength="50" android:padding="10dp" android:singleLine="true" android:textColorHint="@color/hint_text_color" android:textSize="16sp" /&gt; &lt;ImageView android:id="@+id/passwordeye" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right|center_vertical" android:padding="8dp" android:layout_marginRight="25dp" android:src="@drawable/eye_close" /&gt; &lt;/FrameLayout&gt; &lt;LinearLayout android:id="@+id/termsLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@id/passwordLayout" android:layout_marginLeft="15dp" android:layout_marginRight="20dp" android:layout_marginTop="15dp" android:gravity="center" android:orientation="horizontal"&gt; &lt;ImageView android:id="@+id/check_box" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="5dp" android:src="@drawable/checkbox_checked" /&gt; &lt;TextView android:id="@+id/terms_and_cond" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:textColor="@color/black" android:textColorLink="#80000000" android:textSize="13sp" /&gt; &lt;/LinearLayout&gt; &lt;View android:id="@+id/lineView" android:layout_width="match_parent" android:layout_height="1dp" android:layout_below="@id/termsLayout" android:layout_marginTop="15dp" android:background="@color/grey_background" /&gt; &lt;LinearLayout android:id="@+id/newuser_login_layout" android:layout_width="match_parent" android:layout_height="50dp" android:background="@color/dark_grey" android:layout_below="@id/lineView" android:orientation="horizontal"&gt; &lt;TextView android:id="@+id/newUserButton" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/translucent_round_button" android:gravity="center" android:text="New User ?" android:textColor="@color/grey_text_color" android:textSize="17sp" /&gt; &lt;TextView android:id="@+id/loginbutton" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@drawable/bottom_round_button" android:gravity="center" android:text="Login" android:textColor="@color/white" android:textSize="17sp" /&gt; &lt;/LinearLayout&gt; &lt;/RelativeLayout&gt; &lt;/android.support.v7.widget.CardView&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_gravity="center" android:gravity="center" android:orientation="vertical"&gt; &lt;TextView android:id="@+id/contactus_button" android:layout_width="wrap_content" android:layout_height="35dp" android:layout_centerHorizontal="true" android:layout_marginBottom="15dp" android:background="@drawable/contact_us_selector" android:drawableLeft="@drawable/contact_us_green" android:drawablePadding="5dp" android:gravity="center" android:padding="8dp" android:text="Contact Us" android:textColor="@color/black" /&gt; &lt;TextView android:id="@+id/textviewone" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginBottom="10dp" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:gravity="center" android:textColor="@color/black" android:textColorLink="#80000000" android:textSize="13sp" /&gt; &lt;/LinearLayout&gt; &lt;/RelativeLayout&gt; &lt;/ScrollView&gt; &lt;android.support.design.widget.CoordinatorLayout android:id="@+id/snackbarCoordinatorLayout" android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;/android.support.design.widget.CoordinatorLayout&gt; &lt;ProgressBar android:id="@+id/progressBar" style="?android:attr/android:progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:visibility="gone" /&gt; &lt;/FrameLayout&gt; </code></pre> <h1>Question :-</h1> <p>When keyboard opens then contact us <code>button</code> and text which is at the bottom of above screen hide behind the center layout. I want it should not be hide, on opening keyboard screen should be scroll and contact us <code>button</code> should be at the bottom.</p> <p>On opening keyboard it looks like :-</p> <p><a href="https://i.stack.imgur.com/q1QVJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/q1QVJ.png" alt="enter image description here"></a></p>
0debug
How to get Date and Time from different textbox in c# and save to database? : <p>I have 2 text box name txtdate and TextBoxTime and 1 Dropdown list with name ddlampm now I need to insert date and time with format "yyyy-mm-dd HH:MM AM/PM" into sqlserver how can I do that?</p>
0debug
static void gd_update(DisplayChangeListener *dcl, DisplayState *ds, int x, int y, int w, int h) { GtkDisplayState *s = ds->opaque; int x1, x2, y1, y2; int mx, my; int fbw, fbh; int ww, wh; DPRINTF("update(x=%d, y=%d, w=%d, h=%d)\n", x, y, w, h); x1 = floor(x * s->scale_x); y1 = floor(y * s->scale_y); x2 = ceil(x * s->scale_x + w * s->scale_x); y2 = ceil(y * s->scale_y + h * s->scale_y); fbw = ds_get_width(s->ds) * s->scale_x; fbh = ds_get_height(s->ds) * s->scale_y; gdk_drawable_get_size(gtk_widget_get_window(s->drawing_area), &ww, &wh); mx = my = 0; if (ww > fbw) { mx = (ww - fbw) / 2; } if (wh > fbh) { my = (wh - fbh) / 2; } gtk_widget_queue_draw_area(s->drawing_area, mx + x1, my + y1, (x2 - x1), (y2 - y1)); }
1threat
How do I generate random float and round it to 1 decimal place in Python : How would I go about generating a random float and then rounding that float to the nearest decimal point in Python 3.4?
0debug
How to run system shell/terminal inside Eclipse? : <p>I am using Eclipse Neon, and I would like to execute system commands on a shell/terminal, inside Eclipse. </p> <p>In particular, I will need to open the system shell using the path of the current project folder on which I'm working in Eclipse.</p>
0debug
Entity Framework Core: How to solve Introducing FOREIGN KEY constraint may cause cycles or multiple cascade paths : <p>I'm using Entity Framework Core with Code First approach but recieve following error when updating the database:</p> <blockquote> <p>Introducing FOREIGN KEY constraint 'FK_AnEventUsers_Users_UserId' on table 'AnEventUsers' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint or index. See previous errors. </p> </blockquote> <p>My entities are these: </p> <pre><code>public class AnEvent { public int AnEventId { get; set; } public DateTime Time { get; set; } public Gender Gender { get; set; } public int Duration { get; set; } public Category Category { get; set; } public int MinParticipants { get; set; } public int MaxParticipants { get; set; } public string Description { get; set; } public Status EventStatus { get; set; } public int MinAge { get; set; } public int MaxAge { get; set; } public double Longitude { get; set; } public double Latitude { get; set; } public ICollection&lt;AnEventUser&gt; AnEventUsers { get; set; } public int UserId { get; set; } public User User { get; set; } } public class User { public int UserId { get; set; } public int Age { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public Gender Gender { get; set; } public double Rating { get; set; } public ICollection&lt;AnEventUser&gt; AnEventUsers { get; set; } } public class AnEventUser { public int AnEventId { get; set; } public AnEvent AnEvent { get; set; } public int UserId { get; set; } public User User { get; set; } } public class ApplicationDbContext:DbContext { public ApplicationDbContext(DbContextOptions&lt;ApplicationDbContext&gt; options):base(options) { } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity&lt;AnEventUser&gt;() .HasOne(u =&gt; u.User).WithMany(u =&gt; u.AnEventUsers).IsRequired().OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity&lt;AnEventUser&gt;() .HasKey(t =&gt; new { t.AnEventId, t.UserId }); modelBuilder.Entity&lt;AnEventUser&gt;() .HasOne(pt =&gt; pt.AnEvent) .WithMany(p =&gt; p.AnEventUsers) .HasForeignKey(pt =&gt; pt.AnEventId); modelBuilder.Entity&lt;AnEventUser&gt;() .HasOne(eu =&gt; eu.User) .WithMany(e =&gt; e.AnEventUsers) .HasForeignKey(eu =&gt; eu.UserId); } public DbSet&lt;AnEvent&gt; Events { get; set; } public DbSet&lt;User&gt; Users { get; set; } public DbSet&lt;AnEventUser&gt; AnEventUsers { get; set; } } </code></pre> <p>The issue I thought was that if we delete a User the reference to the AnEvent will be deleted and also the reference to AnEventUser will also be deleted, since there is a reference to AnEventUser from AnEvent as well we get cascading paths. But I remove the delete cascade from User to AnEventUser with:</p> <pre><code> modelBuilder.Entity&lt;AnEventUser&gt;() .HasOne(u =&gt; u.User).WithMany(u =&gt; u.AnEventUsers).IsRequired().OnDelete(DeleteBehavior.Restrict); </code></pre> <p>But the error doesn't get resolved, does anyone see what is wrong? Thanks!</p>
0debug
Java 8 - List Results are Printing Not Actual Content : <p>Using Java 8, I was checking out some of its new features...</p> <p>Created the following class:</p> <pre><code>public class Person { String name; int age; public Person(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } } </code></pre> <p>Created the PersonApp class:</p> <pre><code>import java.util.ArrayList; import java.util.Comparator; import java.util.List; import static java.util.Comparator.comparing; public class PersonApp { public static void printSorted(List&lt;Person&gt; people, Comparator&lt;Person&gt; comparator) { people.stream() .sorted(comparator) .forEach(System.out::println); } public static void main(String[] args) { List&lt;Person&gt; people = new ArrayList&lt;&gt;(); people.add(new Person("Sara", 12)); people.add(new Person("Mark", 43)); people.add(new Person("Bob", 12)); people.add(new Person("Jill", 64)); printSorted(people, comparing(Person::getAge).thenComparing(Person::getName)); } } </code></pre> <p>When I run this class, I get the following instead of the values I wanted to see:</p> <pre><code>Person@682a0b20 Person@3d075dc0 Person@214c265e Person@448139f0 </code></pre> <p>What am I possibly doing wrong?</p>
0debug
How to delete Github's wiki homepage? : <p>Today I put my password to Github's wiki <code>Home</code> page. Then, I know it's a mistake. </p> <p>How to remove this page? (I can remove child page, but I don't know how to delete wiki <code>Home</code> page)</p>
0debug
migration to MS SQL server 2017 and IIS10 is painful slow : We run complex ASP.NET MVC web platform online. Recently we are in the process of migration from MS SQL server 2014 and IIS 8.5 to MS SQL server 2017 and IIS 10 and afterward, everything working 3-5 times slower which is painfully annoying slow. Can anyone please HELP US? here is the new version after migration http://66.23.227.124/IdeaPhotoBrowser Here is an old version http://homez.design/IdeaPhotoBrowser
0debug
Similarity between two sentences using word2vec : <p>sentence1 = "this is a sentence" sentence2 = "this is sentence 2" i want to find similarity between these two sentence . could somebody help me out with a <strong>complete code</strong> of it using <strong>Word2Vec</strong></p>
0debug
I need a SQL server Func that will calculate a complete date from the week of the year : <p>I need to calculate to a string of dd-MM-yyyy </p> <p>From a wwyy string (I need the first day of the week or any other day of the week)</p> <p>for exmpl: Now we are in week 42 of 18 so if I'll enter 4218 I'll get 15-10-2018 or 14-10-2018</p> <p>BR, Idan</p>
0debug
How to add class to second main div element using jquery : I have the following html in my page <td id="tdCase" colspan="4" rowspan="2"> <div style="width: 100px;" unselectable="on"> <div style="overflow: hidden; width: 100%; border: 1px solid rgb(204, 204, 204); background-color: rgb(239, 239, 239);" class=" nicEdit-panelContain" unselectable="on"> </div> <div> </div> </div> <div style="width: 100px; border-color: currentcolor rgb(204, 204, 204) rgb(204, 204, 204); border-style: none solid solid; border-width: 0px 1px 1px; border-image: none 100% / 1 / 0 stretch; overflow-y: auto; overflow-x: hidden;"> <div> <div> </div> </div> </div> </td> in my td element i have 2 main div elements and those two main div elements have some inner elements. Here i want to add a class to my second div element using jquery, Can any help how to do that Thanks in advance, Srinivas.[![enter image description here][1]][1] [1]: https://i.stack.imgur.com/Sap9S.png
0debug