problem
stringlengths
26
131k
labels
class label
2 classes
Write a function to accept an integer and return a number made up of digits from the input number in ascending order. : Write a function to accept an integer and return a number made up of digits from the input number in ascending order. Also, If the input is a negative, then the change the order to descending. For example, if the input is 48455, the output should be 44558. if the input is -15243, the output should be -54321 .
0debug
React-Navigation: Use/Change header title with Redux state : <p>Is it possible to access the whole Redux state inside the React Navigation's header title?</p> <p>The <a href="https://reactnavigation.org/docs/intro/headers" rel="noreferrer">official docs</a> says that the state corresponding to the navigation is accessible:</p> <pre><code> static navigationOptions = { title: ({ state }) =&gt; `Chat with ${state.params.user}` }; </code></pre> <p>But I wish to access other parts of my Redux state, with the title updating when that state updates. Is that possible today?</p>
0debug
React useEffect Hook when only one of the effect's deps changes, but not the others : <p>I have a functional component using Hooks:</p> <pre><code>function Component(props) { const [ items, setItems ] = useState([]); // In a callback Hook to prevent unnecessary re-renders const handleFetchItems = useCallback(() =&gt; { fetchItemsFromApi().then(setItems); }, []); // Fetch items on mount useEffect(() =&gt; { handleFetchItems(); }, []); // I want this effect to run only when 'props.itemId' changes, // not when 'items' changes useEffect(() =&gt; { if (items) { const item = items.find(item =&gt; item.id === props.itemId); console.log("Item changed to " item.name); } }, [ items, props.itemId ]) // Clicking the button should NOT log anything to console return ( &lt;Button onClick={handleFetchItems}&gt;Fetch items&lt;/Button&gt; ); } </code></pre> <p>The component fetches some <code>items</code> on mount and saves them to state.</p> <p>The component receives an <code>itemId</code> prop (from React Router).</p> <p>Whenever the <code>props.itemId</code> changes, I want this to trigger an effect, in this case logging it to console.</p> <hr> <p>The problem is that, since the effect is also dependent on <code>items</code>, the effect will also run whenever <code>items</code> changes, for instance when the <code>items</code> are re-fetched by pressing the button.</p> <p>This can be fixed by storing the previous <code>props.itemId</code> in a separate state variable and comparing the two, but this seems like a hack and adds boilerplate. Using Component classes this is solved by comparing current and previous props in <code>componentDidUpdate</code>, but this is not possible using functional components, which is a requirement for using Hooks.</p> <hr> <p><strong>What is the best way to trigger an effect dependent on multiple parameters, only when one of the parameters change?</strong></p> <hr> <p><em>PS. Hooks are kind of a new thing, and I think we all are trying our best to figure out how to properly work with them, so if my way of thinking about this seems wrong or awkward to you, please point it out.</em></p>
0debug
How do dynamically generate this kind of nested li objects using javascript/jquery? : <p>I want to dynamically generate following kind of nested li objects in my jsp. How Should I do this. I am unable to solve by using simple document.createElement("LI"); and appendElement as I also want to add class to that elements.</p> <pre><code>&lt;li class="level1"&gt; &lt;div class="thumb"&gt; &lt;a href="detail.html#"&gt;&lt;img src="images/comments1.gif" alt="" /&gt;&lt;/a&gt; &lt;/div&gt; &lt;div class="desc"&gt; &lt;div class="commentlinks"&gt; &lt;a href="detail.html#" class="reply"&gt;Reply&lt;/a&gt; &lt;a href="detail.html#" class="like"&gt;Like&lt;/a&gt; &lt;a href="detail.html#" class="dislike"&gt;Dislike&lt;/a&gt; &lt;/div&gt; &lt;h5&gt; &lt;a href="detail.html#" class="colr"&gt;By MySebbb:&lt;/a&gt; &lt;/h5&gt; &lt;p class="time"&gt;7 months ago&lt;/p&gt; &lt;div class="clear"&gt;&lt;/div&gt; &lt;p class="txt"&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed elit. Nulla sem risus, vestibulum in, volutpat eget, dapibus ac, lectus. Curabitur dolor sapien.&lt;/p&gt; &lt;/div&gt; &lt;/li&gt; </code></pre>
0debug
static int rtp_parse_mp4_au(PayloadContext *data, const uint8_t *buf) { int au_headers_length, au_header_size, i; GetBitContext getbitcontext; au_headers_length = AV_RB16(buf); if (au_headers_length > RTP_MAX_PACKET_LENGTH) return -1; data->au_headers_length_bytes = (au_headers_length + 7) / 8; buf += 2; init_get_bits(&getbitcontext, buf, data->au_headers_length_bytes * 8); au_header_size = data->sizelength + data->indexlength; if (au_header_size <= 0 || (au_headers_length % au_header_size != 0)) return -1; data->nb_au_headers = au_headers_length / au_header_size; if (!data->au_headers || data->au_headers_allocated < data->nb_au_headers) { av_free(data->au_headers); data->au_headers = av_malloc(sizeof(struct AUHeaders) * data->nb_au_headers); if (!data->au_headers) return AVERROR(ENOMEM); data->au_headers_allocated = data->nb_au_headers; } data->au_headers[0].size = 0; data->au_headers[0].index = 0; for (i = 0; i < data->nb_au_headers; ++i) { data->au_headers[0].size += get_bits_long(&getbitcontext, data->sizelength); data->au_headers[0].index = get_bits_long(&getbitcontext, data->indexlength); } data->nb_au_headers = 1; return 0; }
1threat
static int op_to_mov(int op) { switch (op_bits(op)) { case 32: return INDEX_op_mov_i32; #if TCG_TARGET_REG_BITS == 64 case 64: return INDEX_op_mov_i64; #endif default: fprintf(stderr, "op_to_mov: unexpected return value of " "function op_bits.\n"); tcg_abort(); } }
1threat
SSIBus *ssi_create_bus(DeviceState *parent, const char *name) { BusState *bus; bus = qbus_create(BUS_TYPE_SSI, sizeof(SSIBus), parent, name); return FROM_QBUS(SSIBus, bus); }
1threat
static void imx_timerg_write(void *opaque, target_phys_addr_t offset, uint64_t value, unsigned size) { IMXTimerGState *s = (IMXTimerGState *)opaque; DPRINTF("g-write(offset=%x, value = 0x%x)\n", (unsigned int)offset >> 2, (unsigned int)value); switch (offset >> 2) { case 0: { uint32_t oldcr = s->cr; if (value & GPT_CR_SWR) { value &= ~GPT_CR_SWR; imx_timerg_reset(&s->busdev.qdev); imx_timerg_update(s); } s->cr = value & ~0x7c00; imx_timerg_set_freq(s); if ((oldcr ^ value) & GPT_CR_EN) { if (value & GPT_CR_EN) { if (value & GPT_CR_ENMOD) { ptimer_set_count(s->timer, s->ocr1); s->cnt = 0; } ptimer_run(s->timer, (value & GPT_CR_FRR) && (s->ocr1 != TIMER_MAX)); } else { ptimer_stop(s->timer); }; } return; } case 1: s->pr = value & 0xfff; imx_timerg_set_freq(s); return; case 2: value &= GPT_SR_OF1 | GPT_SR_ROV; s->sr &= ~value; imx_timerg_update(s); return; case 3: s->ir = value & 0x3f; imx_timerg_update(s); return; case 4: if (!(s->cr & GPT_CR_FRR)) { s->waiting_rov = 0; ptimer_set_limit(s->timer, value, 1); } else { imx_timerg_update_counts(s); if (value > s->cnt) { s->waiting_rov = 0; imx_timerg_reload(s, value); } else { s->waiting_rov = 1; imx_timerg_reload(s, TIMER_MAX - s->cnt); } } s->ocr1 = value; return; default: IPRINTF("imx_timerg_write: Bad offset %x\n", (int)offset >> 2); } }
1threat
Submit POST form when rvest doesn't recognize submit button : <p>I would like to submit the following form (the form appears after you click on link "Kliknite na ..."): <a href="http://www1.biznet.hr/HgkWeb/do/extlogon" rel="noreferrer">http://www1.biznet.hr/HgkWeb/do/extlogon</a></p> <p>I have to enter one parameter, named "OIB" and submit the form by clicking "Trazi".</p> <p>Here is my code:</p> <pre><code>library(httr) library(rvest) sess &lt;- html_session("http://www1.biznet.hr/HgkWeb/do/extlogon") search_page &lt;- sess %&gt;% follow_link(1) form &lt;- html_form(search_page)[[6]] fill_form &lt;- set_values(form, 'clanica.cla_oib' = '94989605030') firma_i &lt;- submit_form(search_page, fill_form, submit = 'submit') </code></pre> <p>Last line produces an error:</p> <blockquote> <p>Error: Unknown submission name 'submit'. Possible values: clanica.asTextDatumGasenjaTo, clanica.asTextUdr_id</p> </blockquote> <p>I don't understand why rvest recognize this two parameters as submit buttons when they don't contain submit name or type. And why rvest doesn't recognize submit button "Trazi" as submit parameter? In, short, how to change filled form to execute the form?</p>
0debug
How to get a list from txt file and explode it in PHP? : <p>Hi I have a txt file like this:</p> <pre><code>lenovo,pc,mouse mac,pc,mouse dell,pc,mouse </code></pre> <p>and I want to make a drop down list of first part of txt file string (pc name). Here is my code but it doesnt work how I want. It doesnt explode it. Any help? </p> <pre><code>echo "Which pc are you using?? &lt;br&gt;"; $pc = file('pc.txt'); $name = ' '; $name.="&lt;option&gt;Choose please&lt;/option&gt;"; foreach ($pc as $type) { $name .= '&lt;option value="'.$type.'"&gt;'.$type.'&lt;/option&gt;'; explode(',',$name);} $select = '&lt;select name="pc"&gt;'.$name.'&lt;/select&gt;'; echo $select; </code></pre>
0debug
static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool single) { VFIOGroup *group; struct vfio_pci_hot_reset_info *info; struct vfio_pci_dependent_device *devices; struct vfio_pci_hot_reset *reset; int32_t *fds; int ret, i, count; bool multi = false; trace_vfio_pci_hot_reset(vdev->vbasedev.name, single ? "one" : "multi"); vfio_pci_pre_reset(vdev); vdev->vbasedev.needs_reset = false; info = g_malloc0(sizeof(*info)); info->argsz = sizeof(*info); ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_GET_PCI_HOT_RESET_INFO, info); if (ret && errno != ENOSPC) { ret = -errno; if (!vdev->has_pm_reset) { error_report("vfio: Cannot reset device %04x:%02x:%02x.%x, " "no available reset mechanism.", vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function); } goto out_single; } count = info->count; info = g_realloc(info, sizeof(*info) + (count * sizeof(*devices))); info->argsz = sizeof(*info) + (count * sizeof(*devices)); devices = &info->devices[0]; ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_GET_PCI_HOT_RESET_INFO, info); if (ret) { ret = -errno; error_report("vfio: hot reset info failed: %m"); goto out_single; } trace_vfio_pci_hot_reset_has_dep_devices(vdev->vbasedev.name); for (i = 0; i < info->count; i++) { PCIHostDeviceAddress host; VFIOPCIDevice *tmp; VFIODevice *vbasedev_iter; host.domain = devices[i].segment; host.bus = devices[i].bus; host.slot = PCI_SLOT(devices[i].devfn); host.function = PCI_FUNC(devices[i].devfn); trace_vfio_pci_hot_reset_dep_devices(host.domain, host.bus, host.slot, host.function, devices[i].group_id); if (vfio_pci_host_match(&host, &vdev->host)) { continue; } QLIST_FOREACH(group, &vfio_group_list, next) { if (group->groupid == devices[i].group_id) { break; } } if (!group) { if (!vdev->has_pm_reset) { error_report("vfio: Cannot reset device %s, " "depends on group %d which is not owned.", vdev->vbasedev.name, devices[i].group_id); } ret = -EPERM; goto out; } QLIST_FOREACH(vbasedev_iter, &group->device_list, next) { if (vbasedev_iter->type != VFIO_DEVICE_TYPE_PCI) { continue; } tmp = container_of(vbasedev_iter, VFIOPCIDevice, vbasedev); if (vfio_pci_host_match(&host, &tmp->host)) { if (single) { ret = -EINVAL; goto out_single; } vfio_pci_pre_reset(tmp); tmp->vbasedev.needs_reset = false; multi = true; break; } } } if (!single && !multi) { ret = -EINVAL; goto out_single; } count = 0; QLIST_FOREACH(group, &vfio_group_list, next) { for (i = 0; i < info->count; i++) { if (group->groupid == devices[i].group_id) { count++; break; } } } reset = g_malloc0(sizeof(*reset) + (count * sizeof(*fds))); reset->argsz = sizeof(*reset) + (count * sizeof(*fds)); fds = &reset->group_fds[0]; QLIST_FOREACH(group, &vfio_group_list, next) { for (i = 0; i < info->count; i++) { if (group->groupid == devices[i].group_id) { fds[reset->count++] = group->fd; break; } } } ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_PCI_HOT_RESET, reset); g_free(reset); trace_vfio_pci_hot_reset_result(vdev->vbasedev.name, ret ? "%m" : "Success"); out: for (i = 0; i < info->count; i++) { PCIHostDeviceAddress host; VFIOPCIDevice *tmp; VFIODevice *vbasedev_iter; host.domain = devices[i].segment; host.bus = devices[i].bus; host.slot = PCI_SLOT(devices[i].devfn); host.function = PCI_FUNC(devices[i].devfn); if (vfio_pci_host_match(&host, &vdev->host)) { continue; } QLIST_FOREACH(group, &vfio_group_list, next) { if (group->groupid == devices[i].group_id) { break; } } if (!group) { break; } QLIST_FOREACH(vbasedev_iter, &group->device_list, next) { if (vbasedev_iter->type != VFIO_DEVICE_TYPE_PCI) { continue; } tmp = container_of(vbasedev_iter, VFIOPCIDevice, vbasedev); if (vfio_pci_host_match(&host, &tmp->host)) { vfio_pci_post_reset(tmp); break; } } } out_single: vfio_pci_post_reset(vdev); g_free(info); return ret; }
1threat
Android Studio - Cannot resolve symbol 'OnClickListener' : [Cannot resolve symbol 'OnClickListener'][1] [1]: https://i.stack.imgur.com/6JJAQ.jpg Can any one help me resolve this thing. I tried adding View. before the OnClickListener but then it shows another error that is- Error:(82, 70) error: type OnClickListener does not take parameters please help!!!
0debug
Xamarin Forms Button Command binding inside a ListView : <p>I have the following problem, in my view I have a Listview. In this listview I would like to have two buttons. One for editing the item, one to delete it.</p> <p><strong>Here is my listview in XAML</strong></p> <pre><code>&lt;ListView Grid.Row="1" x:Name="ArbeitsEinträgeList" ItemsSource="{Binding EintragList}" SelectedItem="{Binding SelectedItem}"&gt; &lt;ListView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;ViewCell&gt; &lt;ViewCell.View&gt; &lt;Grid&gt; &lt;Grid.ColumnDefinitions&gt; &lt;ColumnDefinition/&gt; &lt;ColumnDefinition/&gt; &lt;ColumnDefinition/&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;ColumnDefinition Width="Auto"/&gt; &lt;/Grid.ColumnDefinitions&gt; &lt;Label Text="{Binding Titel}" TextColor="{Binding Fehlerhaft, Converter={StaticResource EintragartConverter}}"&gt;&lt;/Label&gt; &lt;Label Grid.Column="1" Text="{Binding Beginn}" TextColor="{Binding BeginnManuell, Converter={StaticResource EintragartConverter}}"&gt;&lt;/Label&gt; &lt;Label Grid.Column="2" Text="{Binding Ende}" TextColor="{Binding EndeManuell, Converter={StaticResource EintragartConverter}}"&gt;&lt;/Label&gt; &lt;Button Grid.Column="3" Command="{Binding EditEintragCommand}" Text="&amp;#xf040;" FontFamily="../Ressources/fontawesome.ttf#FontAwesome"&gt;&lt;/Button&gt; &lt;Button Grid.Column="4" Command="{Binding DeleteEintragCommand}" Text="&amp;#xF00D;" FontFamily="../Ressources/fontawesome.ttf#FontAwesome"&gt;&lt;/Button&gt; &lt;/Grid&gt; &lt;/ViewCell.View&gt; &lt;/ViewCell&gt; &lt;/DataTemplate&gt; &lt;/ListView.ItemTemplate&gt; &lt;/ListView&gt; </code></pre> <p>In my ViewModel is everything I need, I have tested the commands with a button not in the listview and it works perfect.</p> <p>If I hover over the binding, the message "Cannot resolve symbol '...'" appears</p> <p><a href="https://i.stack.imgur.com/5ctt5.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5ctt5.png" alt="Cannot resolve symbol"></a></p>
0debug
void ff_tls_deinit(void) { #if CONFIG_TLS_OPENSSL_PROTOCOL ff_openssl_deinit(); #endif #if CONFIG_TLS_GNUTLS_PROTOCOL ff_gnutls_deinit(); #endif }
1threat
int ff_sws_alphablendaway(SwsContext *c, const uint8_t *src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t *dst[], int dstStride[]) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat); int nb_components = desc->nb_components; int plane, x, y; int plane_count = isGray(c->srcFormat) ? 1 : 3; int sixteen_bits = desc->comp[0].depth_minus1 >= 8; unsigned off = 1<<desc->comp[0].depth_minus1; unsigned shift = desc->comp[0].depth_minus1 + 1; unsigned max = (1<<shift) - 1; av_assert0(plane_count == nb_components - 1); if (desc->flags & AV_PIX_FMT_FLAG_PLANAR) { for (plane = 0; plane < plane_count; plane++) { int w = plane ? c->chrSrcW : c->srcW; int y_subsample = plane ? desc->log2_chroma_h: 0; for (y = srcSliceY >> y_subsample; y < FF_CEIL_RSHIFT(srcSliceH, y_subsample); y++) { if (sixteen_bits) { const uint16_t *s = src[plane ] + srcStride[plane] * y; const uint16_t *a = src[plane_count] + srcStride[plane_count] * y; uint16_t *d = dst[plane ] + dstStride[plane] * y; unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0; if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) { for (x = 0; x < w; x++) { unsigned u = s[x]*a[x] + target*(max-a[x]) + off; d[x] = av_clip((u + (u >> shift)) >> shift, 0, max); } } else { for (x = 0; x < w; x++) { unsigned aswap =av_bswap16(a[x]); unsigned u = av_bswap16(s[x])*aswap + target*(max-aswap) + off; d[x] = av_clip((u + (u >> shift)) >> shift, 0, max); } } } else { const uint8_t *s = src[plane ] + srcStride[plane] * y; const uint8_t *a = src[plane_count] + srcStride[plane_count] * y; uint8_t *d = dst[plane ] + dstStride[plane] * y; unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0; for (x = 0; x < w; x++) { unsigned u = s[x]*a[x] + target*(255-a[x]) + 128; d[x] = (257*u) >> 16; } } } } } else { int alpha_pos = desc->comp[plane_count].offset_plus1 - 1; int w = c->srcW; for (y = srcSliceY; y < srcSliceH; y++) { if (sixteen_bits) { const uint16_t *s = src[0] + srcStride[0] * y + 2*!alpha_pos; const uint16_t *a = src[0] + srcStride[0] * y + alpha_pos; uint16_t *d = dst[0] + dstStride[0] * y; if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) { for (x = 0; x < w; x++) { for (plane = 0; plane < plane_count; plane++) { unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0; int x_index = (plane_count + 1) * x; unsigned u = s[x_index + plane]*a[x_index] + target*(max-a[x_index]) + off; d[plane_count*x + plane] = av_clip((u + (u >> shift)) >> shift, 0, max); } } } else { for (x = 0; x < w; x++) { for (plane = 0; plane < plane_count; plane++) { unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 1<<desc->comp[0].depth_minus1 : 0; int x_index = (plane_count + 1) * x; unsigned aswap =av_bswap16(a[x_index]); unsigned u = av_bswap16(s[x_index + plane])*aswap + target*(max-aswap) + off; d[plane_count*x + plane] = av_clip((u + (u >> shift)) >> shift, 0, max); } } } } else { const uint8_t *s = src[0] + srcStride[0] * y + !alpha_pos; const uint8_t *a = src[0] + srcStride[0] * y + alpha_pos; uint8_t *d = dst[0] + dstStride[0] * y; for (x = 0; x < w; x++) { for (plane = 0; plane < plane_count; plane++) { unsigned target = plane && !(desc->flags & AV_PIX_FMT_FLAG_RGB) ? 128 : 0; int x_index = (plane_count + 1) * x; unsigned u = s[x_index + plane]*a[x_index] + target*(255-a[x_index]) + 128; d[plane_count*x + plane] = (257*u) >> 16; } } } } } return 0; }
1threat
Ruby gem, color codes and string interpolation : I am trying to create a Ruby gem to colorize text. I am having hard time with string interpolation and color codes. Say I want blue text puts "\e[34mThis is blue text.\e[0m" That's the way I get it. I am using the "define_method" metaprogramming technique to create multiple methods(one for every color). The methods are created just fine, but I keep the color code for each color in an array. I iterate over both the color array and the color code one, and I do this puts "\e#{code}m[#{self}\e[0m" When I run it I get "m[test" instead of the colorized text. Any thoughts? If instead of #{code} I put the actual code, it works just fine, but that'd be like 20 ifs, one for each color and it won't be DRY. Thank you.
0debug
static int cirrus_bitblt_solidfill(CirrusVGAState *s, int blt_rop) { cirrus_fill_t rop_func; if (blit_is_unsafe(s, true)) { return 0; } rop_func = cirrus_fill[rop_to_index[blt_rop]][s->cirrus_blt_pixelwidth - 1]; rop_func(s, s->vga.vram_ptr + s->cirrus_blt_dstaddr, s->cirrus_blt_dstpitch, s->cirrus_blt_width, s->cirrus_blt_height); cirrus_invalidate_region(s, s->cirrus_blt_dstaddr, s->cirrus_blt_dstpitch, s->cirrus_blt_width, s->cirrus_blt_height); cirrus_bitblt_reset(s); return 1; }
1threat
compressing and decompressing text which resluts numeric value after compression in java. Can anyone help me : import java.util.Scanner; import java.io.HashMap; import java.io.Set; class Hema { public static void main(String args[]) { HashMap<String, Integer> map = new HashMap<>(); int c=0; Scanner scanner = new Scanner(System.in); //it is for entering the string System.out.println("Enter the sentence"); String sentence = scanner.nextLine(); String[] words = sentence.split(" "); //After entering the string we have to split the sentences into words System.out.println("Words in the given sentence are :"); //After splitting we have to display the value,keys pairs for(String word:words) { map.put(words,c++); } print(map); //by using this maps we have to display the keys as a compressed one for(int key: keys) { System.out.println(key); } //after compression by using the keys we have to display the values of the keys as the entered text Set<String> keys = map.keySet(); for(String key: keys){ System.out.println("Value of "+key+" is: "+map.get(key)); } } } //I am getting this error when i am trying to compile mycode // illegal character: '\u00a0'         //for (String word : words) ^ //Can anyone help me regarding this problem
0debug
static int vmdk_write(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { BDRVVmdkState *s = bs->opaque; VmdkExtent *extent = NULL; int n, ret; int64_t index_in_cluster; uint64_t cluster_offset; VmdkMetaData m_data; if (sector_num > bs->total_sectors) { fprintf(stderr, "(VMDK) Wrong offset: sector_num=0x%" PRIx64 " total_sectors=0x%" PRIx64 "\n", sector_num, bs->total_sectors); return -EIO; } while (nb_sectors > 0) { extent = find_extent(s, sector_num, extent); if (!extent) { return -EIO; } ret = get_cluster_offset( bs, extent, &m_data, sector_num << 9, !extent->compressed, &cluster_offset); if (extent->compressed) { if (ret == 0) { fprintf(stderr, "VMDK: can't write to allocated cluster" " for streamOptimized\n"); return -EIO; } else { ret = get_cluster_offset( bs, extent, &m_data, sector_num << 9, 1, &cluster_offset); } } if (ret) { return -EINVAL; } index_in_cluster = sector_num % extent->cluster_sectors; n = extent->cluster_sectors - index_in_cluster; if (n > nb_sectors) { n = nb_sectors; } ret = vmdk_write_extent(extent, cluster_offset, index_in_cluster * 512, buf, n, sector_num); if (ret) { return ret; } if (m_data.valid) { if (vmdk_L2update(extent, &m_data) == -1) { return -EIO; } } nb_sectors -= n; sector_num += n; buf += n * 512; if (!s->cid_updated) { ret = vmdk_write_cid(bs, time(NULL)); if (ret < 0) { return ret; } s->cid_updated = true; } } return 0; }
1threat
How to create batch file in python : <p>I need help with creating and then runing batch file (<code>.bat</code>) in python or create a <code>.txt</code> file and save it as <code>.bat</code> the context of the file should be: </p> <blockquote> <p><code>[Command] number</code> etc...</p> </blockquote> <p>Thanks for your support!</p>
0debug
uint32_t HELPER(lcdbr)(CPUS390XState *env, uint32_t f1, uint32_t f2) { env->fregs[f1].d = float64_chs(env->fregs[f2].d); return set_cc_nz_f64(env->fregs[f1].d); }
1threat
Extension API internal error: org.powermock.api.extension.reporter.MockingFrameworkReporterFactoryImpl : <p>I'm trying to write a unit test using PowerMockRunner but I got the following error:</p> <blockquote> <p>java.lang.IllegalStateException: Extension API internal error: org.powermock.api.extension.reporter.MockingFrameworkReporterFactoryImpl could not be located in classpath. at org.powermock.tests.utils.impl.AbstractTestSuiteChunkerImpl.getFrameworkReporterFactory(AbstractTestSuiteChunkerImpl.java:190) at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.getMockingFrameworkReporter(JUnit4TestSuiteChunkerImpl.java:140) at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:119) at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53) at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)</p> </blockquote> <p>I've checked all the dependencies and it's ok, do I need somehthing else?</p>
0debug
How chrome browser determine memory cache and disk cache? : <p>I knew that chrome supports <code>from memory cache</code> and <code>from disk cache</code> when I request resources. I didn't see <code>from memory cache</code> before. BTW how chrome determine which resource should be cached in memory?</p> <p><a href="https://i.stack.imgur.com/G53Uc.png" rel="noreferrer"><img src="https://i.stack.imgur.com/G53Uc.png" alt="enter image description here"></a></p>
0debug
int64_t throttle_compute_wait(LeakyBucket *bkt) { double extra; double bucket_size; double burst_bucket_size; if (!bkt->avg) { return 0; } if (!bkt->max) { bucket_size = (double) bkt->avg / 10; burst_bucket_size = 0; } else { bucket_size = bkt->max * bkt->burst_length; burst_bucket_size = (double) bkt->max / 10; } extra = bkt->level - bucket_size; if (extra > 0) { return throttle_do_compute_wait(bkt->avg, extra); } if (bkt->burst_length > 1) { extra = bkt->burst_level - burst_bucket_size; if (extra > 0) { return throttle_do_compute_wait(bkt->max, extra); } } return 0; }
1threat
static void mpeg4_encode_gop_header(MpegEncContext * s){ int hours, minutes, seconds; int64_t time; put_bits(&s->pb, 16, 0); put_bits(&s->pb, 16, GOP_STARTCODE); time= s->current_picture_ptr->pts; if(s->reordered_input_picture[1]) time= FFMIN(time, s->reordered_input_picture[1]->pts); time= time*s->avctx->time_base.num; seconds= time/s->avctx->time_base.den; minutes= seconds/60; seconds %= 60; hours= minutes/60; minutes %= 60; hours%=24; put_bits(&s->pb, 5, hours); put_bits(&s->pb, 6, minutes); put_bits(&s->pb, 1, 1); put_bits(&s->pb, 6, seconds); put_bits(&s->pb, 1, !!(s->flags&CODEC_FLAG_CLOSED_GOP)); put_bits(&s->pb, 1, 0); s->last_time_base= time / s->avctx->time_base.den; ff_mpeg4_stuffing(&s->pb); }
1threat
static void filter_frame(H264Context *h) { int mb_x = 0; int mb_y = 0; for( mb_y = 0; mb_y < h->s.mb_height; mb_y++ ) { for( mb_x = 0; mb_x < h->s.mb_width; mb_x++ ) { filter_mb( h, mb_x, mb_y ); } } }
1threat
static int decode_zbuf(AVBPrint *bp, const uint8_t *data, const uint8_t *data_end) { z_stream zstream; unsigned char *buf; unsigned buf_size; int ret; zstream.zalloc = ff_png_zalloc; zstream.zfree = ff_png_zfree; zstream.opaque = NULL; if (inflateInit(&zstream) != Z_OK) return AVERROR_EXTERNAL; zstream.next_in = (unsigned char *)data; zstream.avail_in = data_end - data; av_bprint_init(bp, 0, -1); while (zstream.avail_in > 0) { av_bprint_get_buffer(bp, 1, &buf, &buf_size); if (!buf_size) { ret = AVERROR(ENOMEM); goto fail; } zstream.next_out = buf; zstream.avail_out = buf_size; ret = inflate(&zstream, Z_PARTIAL_FLUSH); if (ret != Z_OK && ret != Z_STREAM_END) { ret = AVERROR_EXTERNAL; goto fail; } bp->len += zstream.next_out - buf; if (ret == Z_STREAM_END) break; } inflateEnd(&zstream); bp->str[bp->len] = 0; return 0; fail: inflateEnd(&zstream); av_bprint_finalize(bp, NULL); return ret; }
1threat
Flutter: Should I use Bloc, or should I use redux? : <p>Hello I am new to flutter and is intertwined if I should use Bloc for State Management or redux. I am having a restaurant POS app where I state management is a must. I have a good experience with redux but Bloc has been recommended for flutter. </p> <p>My Question is:</p> <p>1.) Should I switch to Bloc or remain using redux where I am comfortable?</p> <p>2.) What would be the pros and cooons of the two?</p> <p>3.) Which of the are more scalable and mantainable?</p> <p>Thanks for the replies.</p>
0debug
Route object validation as props in React : <p>What is the correct way to validate route props in React class?</p> <p>I tried:</p> <ul> <li><code>route: React.PropTypes.object</code> - my eslint complains: <em>Prop type <code>object</code> is forbidden react/forbid-prop-types</em> </li> <li><code>route: React.PropTypes.instanceOf(React.propTypes)</code> - this results in a warning at runtime: <em>Right-hand side of 'instanceof' is not callable Check the render method of bla</em></li> </ul> <p>We have the policy to validate props enforced by eslint rules, how can I validate route object?</p> <p>My code: </p> <pre><code>var bla = React.createClass({ displayName: 'bla', propTypes: { route: React.PropTypes.object, }) class RootRoute extends React.Component { render() { return ( &lt;Router history={hashHistory}&gt; &lt;Route path="/" component={bla}/&gt; &lt;/Router&gt; ); } } </code></pre>
0debug
When you coding, it is not very often have to write duplicate code? : As shown, the two pieces of code is almost the same, but a little different, each written duplicates a lot of trouble, if you encounter such situations, you are how to solve? [enter image description here][1] [enter image description here][2] [1]: http://i.stack.imgur.com/j6VdG.png [2]: http://i.stack.imgur.com/fzQha.png
0debug
static int imc_decode_frame(AVCodecContext * avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; IMCContext *q = avctx->priv_data; int stream_format_code; int imc_hdr, i, j; int flag; int bits, summer; int counter, bitscount; LOCAL_ALIGNED_16(uint16_t, buf16, [IMC_BLOCK_SIZE / 2]); if (buf_size < IMC_BLOCK_SIZE) { av_log(avctx, AV_LOG_ERROR, "imc frame too small!\n"); return -1; } q->dsp.bswap16_buf(buf16, (const uint16_t*)buf, IMC_BLOCK_SIZE / 2); q->out_samples = data; init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8); imc_hdr = get_bits(&q->gb, 9); if (imc_hdr != IMC_FRAME_ID) { av_log(avctx, AV_LOG_ERROR, "imc frame header check failed!\n"); av_log(avctx, AV_LOG_ERROR, "got %x instead of 0x21.\n", imc_hdr); return -1; } stream_format_code = get_bits(&q->gb, 3); if(stream_format_code & 1){ av_log(avctx, AV_LOG_ERROR, "Stream code format %X is not supported\n", stream_format_code); return -1; } if (stream_format_code & 0x04) q->decoder_reset = 1; if(q->decoder_reset) { memset(q->out_samples, 0, sizeof(q->out_samples)); for(i = 0; i < BANDS; i++)q->old_floor[i] = 1.0; for(i = 0; i < COEFFS; i++)q->CWdecoded[i] = 0; q->decoder_reset = 0; } flag = get_bits1(&q->gb); imc_read_level_coeffs(q, stream_format_code, q->levlCoeffBuf); if (stream_format_code & 0x4) imc_decode_level_coefficients(q, q->levlCoeffBuf, q->flcoeffs1, q->flcoeffs2); else imc_decode_level_coefficients2(q, q->levlCoeffBuf, q->old_floor, q->flcoeffs1, q->flcoeffs2); memcpy(q->old_floor, q->flcoeffs1, 32 * sizeof(float)); counter = 0; for (i=0 ; i<BANDS ; i++) { if (q->levlCoeffBuf[i] == 16) { q->bandWidthT[i] = 0; counter++; } else q->bandWidthT[i] = band_tab[i+1] - band_tab[i]; } memset(q->bandFlagsBuf, 0, BANDS * sizeof(int)); for(i = 0; i < BANDS-1; i++) { if (q->bandWidthT[i]) q->bandFlagsBuf[i] = get_bits1(&q->gb); } imc_calculate_coeffs(q, q->flcoeffs1, q->flcoeffs2, q->bandWidthT, q->flcoeffs3, q->flcoeffs5); bitscount = 0; if (stream_format_code & 0x2) { bitscount += 15; q->bitsBandT[0] = 5; q->CWlengthT[0] = 5; q->CWlengthT[1] = 5; q->CWlengthT[2] = 5; for(i = 1; i < 4; i++){ bits = (q->levlCoeffBuf[i] == 16) ? 0 : 5; q->bitsBandT[i] = bits; for(j = band_tab[i]; j < band_tab[i+1]; j++) { q->CWlengthT[j] = bits; bitscount += bits; } } } if(bit_allocation (q, stream_format_code, 512 - bitscount - get_bits_count(&q->gb), flag) < 0) { av_log(avctx, AV_LOG_ERROR, "Bit allocations failed\n"); q->decoder_reset = 1; return -1; } for(i = 0; i < BANDS; i++) { q->sumLenArr[i] = 0; q->skipFlagRaw[i] = 0; for(j = band_tab[i]; j < band_tab[i+1]; j++) q->sumLenArr[i] += q->CWlengthT[j]; if (q->bandFlagsBuf[i]) if( (((band_tab[i+1] - band_tab[i]) * 1.5) > q->sumLenArr[i]) && (q->sumLenArr[i] > 0)) q->skipFlagRaw[i] = 1; } imc_get_skip_coeff(q); for(i = 0; i < BANDS; i++) { q->flcoeffs6[i] = q->flcoeffs1[i]; if (q->bandFlagsBuf[i] && (band_tab[i+1] - band_tab[i]) != q->skipFlagCount[i]){ q->flcoeffs6[i] *= q->sqrt_tab[band_tab[i+1] - band_tab[i]] / q->sqrt_tab[(band_tab[i+1] - band_tab[i] - q->skipFlagCount[i])]; } } bits = summer = 0; for(i = 0; i < BANDS; i++) { if (q->bandFlagsBuf[i]) { for(j = band_tab[i]; j < band_tab[i+1]; j++) { if(q->skipFlags[j]) { summer += q->CWlengthT[j]; q->CWlengthT[j] = 0; } } bits += q->skipFlagBits[i]; summer -= q->skipFlagBits[i]; } } imc_adjust_bit_allocation(q, summer); for(i = 0; i < BANDS; i++) { q->sumLenArr[i] = 0; for(j = band_tab[i]; j < band_tab[i+1]; j++) if (!q->skipFlags[j]) q->sumLenArr[i] += q->CWlengthT[j]; } memset(q->codewords, 0, sizeof(q->codewords)); if(imc_get_coeffs(q) < 0) { av_log(avctx, AV_LOG_ERROR, "Read coefficients failed\n"); q->decoder_reset = 1; return 0; } if(inverse_quant_coeff(q, stream_format_code) < 0) { av_log(avctx, AV_LOG_ERROR, "Inverse quantization of coefficients failed\n"); q->decoder_reset = 1; return 0; } memset(q->skipFlags, 0, sizeof(q->skipFlags)); imc_imdct256(q); *data_size = COEFFS * sizeof(float); return IMC_BLOCK_SIZE; }
1threat
static int parse_uint64(DeviceState *dev, Property *prop, const char *str) { uint64_t *ptr = qdev_get_prop_ptr(dev, prop); char *end; *ptr = strtoull(str, &end, 0); if ((*end != '\0') || (end == str)) { return -EINVAL; } return 0; }
1threat
static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { AACEncContext *s = avctx->priv_data; float **samples = s->planar_samples, *samples2, *la, *overlap; ChannelElement *cpe; SingleChannelElement *sce; int i, its, ch, w, chans, tag, start_ch, ret, frame_bits; int ms_mode = 0, is_mode = 0, tns_mode = 0, pred_mode = 0; int chan_el_counter[4]; FFPsyWindowInfo windows[AAC_MAX_CHANNELS]; if (s->last_frame == 2) return 0; if (frame) { if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) return ret; } copy_input_samples(s, frame); if (s->psypp) ff_psy_preprocess(s->psypp, s->planar_samples, s->channels); if (!avctx->frame_number) return 0; start_ch = 0; for (i = 0; i < s->chan_map[0]; i++) { FFPsyWindowInfo* wi = windows + start_ch; tag = s->chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; for (ch = 0; ch < chans; ch++) { IndividualChannelStream *ics = &cpe->ch[ch].ics; int cur_channel = start_ch + ch; float clip_avoidance_factor; overlap = &samples[cur_channel][0]; samples2 = overlap + 1024; la = samples2 + (448+64); if (!frame) la = NULL; if (tag == TYPE_LFE) { wi[ch].window_type[0] = ONLY_LONG_SEQUENCE; wi[ch].window_shape = 0; wi[ch].num_windows = 1; wi[ch].grouping[0] = 1; ics->num_swb = s->samplerate_index >= 8 ? 1 : 3; } else { wi[ch] = s->psy.model->window(&s->psy, samples2, la, cur_channel, ics->window_sequence[0]); } ics->window_sequence[1] = ics->window_sequence[0]; ics->window_sequence[0] = wi[ch].window_type[0]; ics->use_kb_window[1] = ics->use_kb_window[0]; ics->use_kb_window[0] = wi[ch].window_shape; ics->num_windows = wi[ch].num_windows; ics->swb_sizes = s->psy.bands [ics->num_windows == 8]; ics->num_swb = tag == TYPE_LFE ? ics->num_swb : s->psy.num_bands[ics->num_windows == 8]; ics->swb_offset = wi[ch].window_type[0] == EIGHT_SHORT_SEQUENCE ? ff_swb_offset_128 [s->samplerate_index]: ff_swb_offset_1024[s->samplerate_index]; ics->tns_max_bands = wi[ch].window_type[0] == EIGHT_SHORT_SEQUENCE ? ff_tns_max_bands_128 [s->samplerate_index]: ff_tns_max_bands_1024[s->samplerate_index]; clip_avoidance_factor = 0.0f; for (w = 0; w < ics->num_windows; w++) ics->group_len[w] = wi[ch].grouping[w]; for (w = 0; w < ics->num_windows; w++) { if (wi[ch].clipping[w] > CLIP_AVOIDANCE_FACTOR) { ics->window_clipping[w] = 1; clip_avoidance_factor = FFMAX(clip_avoidance_factor, wi[ch].clipping[w]); } else { ics->window_clipping[w] = 0; } } if (clip_avoidance_factor > CLIP_AVOIDANCE_FACTOR) { ics->clip_avoidance_factor = CLIP_AVOIDANCE_FACTOR / clip_avoidance_factor; } else { ics->clip_avoidance_factor = 1.0f; } apply_window_and_mdct(s, &cpe->ch[ch], overlap); if (isnan(cpe->ch->coeffs[0])) { av_log(avctx, AV_LOG_ERROR, "Input contains NaN\n"); return AVERROR(EINVAL); } avoid_clipping(s, &cpe->ch[ch]); } start_ch += chans; } if ((ret = ff_alloc_packet2(avctx, avpkt, 8192 * s->channels, 0)) < 0) return ret; frame_bits = its = 0; do { int target_bits, too_many_bits, too_few_bits; init_put_bits(&s->pb, avpkt->data, avpkt->size); if ((avctx->frame_number & 0xFF)==1 && !(avctx->flags & AV_CODEC_FLAG_BITEXACT)) put_bitstream_info(s, LIBAVCODEC_IDENT); start_ch = 0; target_bits = 0; memset(chan_el_counter, 0, sizeof(chan_el_counter)); for (i = 0; i < s->chan_map[0]; i++) { FFPsyWindowInfo* wi = windows + start_ch; const float *coeffs[2]; tag = s->chan_map[i+1]; chans = tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; cpe->common_window = 0; memset(cpe->is_mask, 0, sizeof(cpe->is_mask)); memset(cpe->ms_mask, 0, sizeof(cpe->ms_mask)); put_bits(&s->pb, 3, tag); put_bits(&s->pb, 4, chan_el_counter[tag]++); for (ch = 0; ch < chans; ch++) { sce = &cpe->ch[ch]; coeffs[ch] = sce->coeffs; sce->ics.predictor_present = 0; memset(&sce->ics.prediction_used, 0, sizeof(sce->ics.prediction_used)); memset(&sce->tns, 0, sizeof(TemporalNoiseShaping)); for (w = 0; w < 128; w++) if (sce->band_type[w] > RESERVED_BT) sce->band_type[w] = 0; } s->psy.bitres.alloc = -1; s->psy.bitres.bits = avctx->frame_bits / s->channels; s->psy.model->analyze(&s->psy, start_ch, coeffs, wi); if (s->psy.bitres.alloc > 0) { target_bits += s->psy.bitres.alloc; s->psy.bitres.alloc /= chans; } s->cur_type = tag; for (ch = 0; ch < chans; ch++) { s->cur_channel = start_ch + ch; s->coder->search_for_quantizers(avctx, s, &cpe->ch[ch], s->lambda); } if (chans > 1 && wi[0].window_type[0] == wi[1].window_type[0] && wi[0].window_shape == wi[1].window_shape) { cpe->common_window = 1; for (w = 0; w < wi[0].num_windows; w++) { if (wi[0].grouping[w] != wi[1].grouping[w]) { cpe->common_window = 0; break; } } } for (ch = 0; ch < chans; ch++) { sce = &cpe->ch[ch]; s->cur_channel = start_ch + ch; if (s->options.pns && s->coder->search_for_pns) s->coder->search_for_pns(s, avctx, sce); if (s->options.tns && s->coder->search_for_tns) s->coder->search_for_tns(s, sce); if (s->options.tns && s->coder->apply_tns_filt) s->coder->apply_tns_filt(s, sce); if (sce->tns.present) tns_mode = 1; } s->cur_channel = start_ch; if (s->options.intensity_stereo) { if (s->coder->search_for_is) s->coder->search_for_is(s, avctx, cpe); if (cpe->is_mode) is_mode = 1; apply_intensity_stereo(cpe); } if (s->options.pred) { for (ch = 0; ch < chans; ch++) { sce = &cpe->ch[ch]; s->cur_channel = start_ch + ch; if (s->options.pred && s->coder->search_for_pred) s->coder->search_for_pred(s, sce); if (cpe->ch[ch].ics.predictor_present) pred_mode = 1; } if (s->coder->adjust_common_prediction) s->coder->adjust_common_prediction(s, cpe); for (ch = 0; ch < chans; ch++) { sce = &cpe->ch[ch]; s->cur_channel = start_ch + ch; if (s->options.pred && s->coder->apply_main_pred) s->coder->apply_main_pred(s, sce); } s->cur_channel = start_ch; } if (s->options.stereo_mode) { if (s->options.stereo_mode == -1 && s->coder->search_for_ms) s->coder->search_for_ms(s, cpe); else if (cpe->common_window) memset(cpe->ms_mask, 1, sizeof(cpe->ms_mask)); for (w = 0; w < 128; w++) cpe->ms_mask[w] = cpe->is_mask[w] ? 0 : cpe->ms_mask[w]; apply_mid_side_stereo(cpe); } adjust_frame_information(cpe, chans); if (chans == 2) { put_bits(&s->pb, 1, cpe->common_window); if (cpe->common_window) { put_ics_info(s, &cpe->ch[0].ics); if (s->coder->encode_main_pred) s->coder->encode_main_pred(s, &cpe->ch[0]); encode_ms_info(&s->pb, cpe); if (cpe->ms_mode) ms_mode = 1; } } for (ch = 0; ch < chans; ch++) { s->cur_channel = start_ch + ch; encode_individual_channel(avctx, s, &cpe->ch[ch], cpe->common_window); } start_ch += chans; } if (avctx->flags & CODEC_FLAG_QSCALE) { break; } frame_bits = put_bits_count(&s->pb); target_bits = FFMAX(target_bits, avctx->bit_rate * 1024 / avctx->sample_rate); target_bits = FFMIN(target_bits, 6144 * s->channels - 3); too_many_bits = target_bits + target_bits/2; too_few_bits = target_bits - target_bits/8; if ( its == 0 || (its < 5 && (frame_bits < too_few_bits || frame_bits > too_many_bits)) || frame_bits >= 6144 * s->channels - 3 ) { float ratio = ((float)target_bits) / frame_bits; if (frame_bits >= too_few_bits && frame_bits <= too_many_bits) { ratio = sqrtf(sqrtf(ratio)); ratio = av_clipf(ratio, 0.9f, 1.1f); } else { ratio = sqrtf(ratio); } s->lambda = FFMIN(s->lambda * ratio, 65536.f); if (s->lambda < 300.f || ratio > 0.9f) { break; } else { if (is_mode || ms_mode || tns_mode || pred_mode) { for (i = 0; i < s->chan_map[0]; i++) { chans = tag == TYPE_CPE ? 2 : 1; cpe = &s->cpe[i]; for (ch = 0; ch < chans; ch++) memcpy(cpe->ch[ch].coeffs, cpe->ch[ch].pcoeffs, sizeof(cpe->ch[ch].coeffs)); } } its++; } } else { break; } } while (1); put_bits(&s->pb, 3, TYPE_END); flush_put_bits(&s->pb); avctx->frame_bits = put_bits_count(&s->pb); if (!frame) s->last_frame++; ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts, &avpkt->duration); avpkt->size = put_bits_count(&s->pb) >> 3; *got_packet_ptr = 1; return 0; }
1threat
spark dataframe drop duplicates and keep first : <p>Question: in pandas when dropping duplicates you can specify which columns to keep. Is there an equivalent in Spark Dataframes?</p> <p>Pandas:</p> <pre><code>df.sort_values('actual_datetime', ascending=False).drop_duplicates(subset=['scheduled_datetime', 'flt_flightnumber'], keep='first') </code></pre> <p>Spark dataframe (I use Spark 1.6.0) doesn't have the keep option</p> <pre><code>df.orderBy(['actual_datetime']).dropDuplicates(subset=['scheduled_datetime', 'flt_flightnumber']) </code></pre> <p>Imagine 'scheduled_datetime' and 'flt_flightnumber' are columns 6 ,17. By creating keys based on the values of these columns we can also deduplicate </p> <pre><code>def get_key(x): return "{0}{1}".format(x[6],x[17]) df= df.map(lambda x: (get_key(x),x)).reduceByKey(lambda x,y: (x)) </code></pre> <p>but how to specify <strong>to keep the first row</strong> and get rid of the other duplicates ? What about the last row ? </p>
0debug
I provide complete path in href tag still it says resource not available. why? : <p><a href="https://i.stack.imgur.com/nTfcN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nTfcN.jpg" alt="enter image description here"></a></p> <p>I give complete from web-Inf path here I don't know why its not working when i click contact it give me error 400 The requested resource () is not available.</p>
0debug
static GenericList *next_list(Visitor *v, GenericList **list, size_t size) { StringOutputVisitor *sov = to_sov(v); GenericList *ret = NULL; if (*list) { if (sov->head) { ret = *list; } else { ret = (*list)->next; } if (sov->head) { if (ret && ret->next == NULL) { sov->list_mode = LM_NONE; } sov->head = false; } else { if (ret && ret->next == NULL) { sov->list_mode = LM_END; } } } return ret; }
1threat
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
i think my code is all correct but it does not work : i coded this to show me this: 1 + (1/2!) + (1/3!) + … + (1/n!) if ( n < 10 ) #include <iostream> using namespace std; int main() { int n; float factn=1,m,sum; cout<<"enter n\n"; cin>>n; if(n<10&&n>=0){ do{ factn=factn*n; m=1/factn; sum=sum+m; n--; }while(n>=1); cout<<sum; } else{ cout<<"error!\n"; } return 0; } this code must show this: ( n < 10 ) 1 + (1/2!) + (1/3!) + … + (1/n!) what is the problem? it returns wrong values :(
0debug
Regex for python that puts quotation marks around all 6-12 digit numbers in a text file : <p>I currently have the following regex that identifies 6-12 numbers:</p> <pre><code>regex_did = re.compile(r"\b\d{6,12}\b") </code></pre> <p>What would be the correct approach to put all matches between two quotation marks. For example <code>123456</code> should be replaced with <code>"123456"</code>.</p>
0debug
Boolean comparison says it is true but the if says it is false : <p>sorry if this question too basic for you guys, but I have this code that make me confuse. I create a boolean comparison before the if and put the same comparison to the if condition but it doesn't get executed inside the if block.</p> <pre><code>#include&lt;iostream&gt; #include&lt;cstdio&gt; using namespace std; int main() { float s[2] = {0.24}; printf("Is this is true? (1 = yes, 0= false): %d", s[0] &gt;= 0) &amp;&amp; (s[0] &lt; (1/7 + 1/14)); printf("\nBefore if: s[%d] %f\n", 0, s[0]); if ((s[0] &gt;= 0) &amp;&amp; (s[0] &lt; (1/7 + 1/14))) { s[0] = 10; } printf("\nAfter if: s[%d] %f\n", 0, s[0]); return 0; } </code></pre>
0debug
The VBA documentation is poorly structured : <p>How to understand the VBA documentation? The documentation is poorly structured. For example, there are various libraries such as Microsoft Internet Controls and Microsoft HTML Object Library. But if you look for information about the contents of these libraries by their name, you will not find single (or main) pages of these libraries. The data is scattered and there is not a single page with content titles to the required libraries. If I'm right in this aspect, then it's terrible. I have experience programming in Python in terms of data analysis and there the information is clearly structured by libraries (the main thing is to know the name of the required libraries). Hence several questions.</p> <p>1) What is the most effective way to find the necessary VBA documentation for specific libraries?</p> <p>2) Am I right that the VBA documentation is poorly structured?</p>
0debug
jQuery doesn't give a proper output, but gives these : <pre><code>(function() { var a = document.createElement('a'); var mref = 'http://www.someprivatelink.net'; var linkText = document.createTextNode(title1); var title1 = $('#node-264152').find('.audio-description').html(); alert(title1); a.appendChild(linkText); a.title = title1; a.href = mref; document.body.appendChild(a); })(); </code></pre> <p>I'm using this script to add an download link to the bottem of my page wich doesn't to to be permanent so I enter it via console with Google Chrome.</p> <p>The ID and the Class are correct to the value I need to extract, I've added the alert to check if the fault was in the HTML or in my javascript.</p> <p>The output at the bottem of the page has the value of 'Undefined', while it has to be 'Log moving along in body of water 2'</p> <p>But the alert does display (<a href="https://i.stack.imgur.com/O160f.png" rel="nofollow noreferrer">screenshot</a>) this message with a few boxxes before and after the message, I think this is causing the undefined error.</p> <p>Is there any solution my var can be converted into only text?</p> <p>Thanks in advance, Tjalle</p>
0debug
Passung args to commandline app doese not Working : Morning, I can‘t passing Arguments to my console App. I tryed as follow: - App.exe arg1 - App.exe „arg1“ - App.exe When i run the App with Args, the App quit running without any messages. By Debuging still is nothing in string[] args. My C# Project is a plain .net 4.5.2 command line Project. My OS is Windows 10 x64 Have anyone an idea?
0debug
static void fft_test(AC3MDCTContext *mdct, AVLFG *lfg) { IComplex in[FN], in1[FN]; int k, n, i; float sum_re, sum_im, a; for (i = 0; i < FN; i++) { in[i].re = av_lfg_get(lfg) % 65535 - 32767; in[i].im = av_lfg_get(lfg) % 65535 - 32767; in1[i] = in[i]; } fft(mdct, in, 7); for (k = 0; k < FN; k++) { sum_re = 0; sum_im = 0; for (n = 0; n < FN; n++) { a = -2 * M_PI * (n * k) / FN; sum_re += in1[n].re * cos(a) - in1[n].im * sin(a); sum_im += in1[n].re * sin(a) + in1[n].im * cos(a); } av_log(NULL, AV_LOG_DEBUG, "%3d: %6d,%6d %6.0f,%6.0f\n", k, in[k].re, in[k].im, sum_re / FN, sum_im / FN); } }
1threat
bool memory_region_present(MemoryRegion *parent, hwaddr addr) { MemoryRegion *mr = memory_region_find(parent, addr, 1).mr; if (!mr) { return false; } memory_region_unref(mr); return true; }
1threat
How to convert multi String array to string array in swift : <p>var names:[[String]] = [["google"],["yahoo"],["facebook"]]</p> <p>var convertNames:[String] = []</p> <p>//how to convert names multi String array to convertNames String Array</p>
0debug
Get Values from array object using String type object id : <p>Is there a way to get the values of an array object if we have the object id as String value</p> <p>//assume this is a real object id value,</p> <p>A PC send an array to my and then i get this id from a that PC as String (Using Sockets). I want to get the content of the array by using that object name. </p> <h1>client</h1> <pre><code>` Random random = new Random(); for ( int i = 0 ; i&lt;5 ; i++ ) { weatherDetails[i] = random.nextDouble() * 100; } out.println(weatherDetails); </code></pre> <p>`</p> <h1>server</h1> <pre><code> while (true) { input = in.readLine(); if (input == null) { return; } System.out.println("Input value weather-&gt;" + input);//[D@514713 } </code></pre>
0debug
Dabase server is not connecting with pg admin : Database server os = Ubuntu 16.04 client machine= widows os 8. we are not able to connect database server from pagadmin wihich I have installed on my laptop(while its promting for password ). Error screenshot attached,[enter image description here][1] [1]: https://i.stack.imgur.com/XZOEA.png
0debug
, double click on edit text then datepicker dialouge show how to show it on single click : editdate.setOnClickListener( new View.`OnClickListener`() { @Override public void onClick(View v) { Calendar mcurrentDate = Calendar.getInstance(); int mYear = mcurrentDate.get(Calendar.YEAR); int mMonth = mcurrentDate.get(Calendar.MONTH); int mDay = mcurrentDate.get(Calendar.DAY_OF_MONTH); DatePickerDialog mDatePicker; mDatePicker = new DatePickerDialog(CreatNotes.this, new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) { // TODO Auto-generated method stub /* Your code to get date and time */ //, selectedmonth = selectedmonth + 1; editdate.setText("" + selectedday + "/" + selectedmonth + "/" + selectedyear); } }, mYear, mMonth, mDay); // mDatePicker.setTitle("Select Date"); mDatePicker.show(); } } );``
0debug
How to add a C# class object to an Enitity table using LINQ : How to add a class object to an Enitity table using LINQ???The prescriber object is built from FullMasters Entity but I need to take that object and save it to EPCS_Prescriber table. Im using linq. public void SavePrescriber(string id) { var data = context.FullMasters.Where(x => x.NPI == id).FirstOrDefault(); Prescriber p = new Prescriber { First = data.FirstName, Last = data.LastName, DEA = data.DEA, License = data.LIC, Life = data.Life_Hosp, NPI = data.NPI }; epcs.EPCS_Prescriber.AddObject(p); epcs.SaveChanges(); }
0debug
Hello! How can I change this condition so that it does not always evaluate to "false" since it was reported as a "Code smell" violation : <p><a href="https://i.stack.imgur.com/pqYTy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pqYTy.png" alt="enter image description here"></a></p> <p>Hello! How can I change this condition so that it does not always evaluate to "false" since it was reported as a "Code smell" violation in sonarqube? Thank you</p>
0debug
static av_cold int vdadec_close(AVCodecContext *avctx) { VDADecoderContext *ctx = avctx->priv_data; ff_vda_destroy_decoder(&ctx->vda_ctx); if (ctx->h264_initialized) ff_h264_decoder.close(avctx); return 0; }
1threat
JAVA programming - Abstract class : abstract class Concept{ public void Mymethod() { System.out.println("this is concrete method"); } abstract public void junk(); } class king extends Concept{ public void junk() { System.out.println("this is abstract method"); } public static void main(String[] args) { king n = new king(); n.junk(); } } Please check the error in this!!! While compiling this, i was hit with an following issue : Error: Main method not found in class Concept, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application
0debug
How do I make a Null character in Kotlin : <p>In Java, one can use the escape sequence <code>\0</code> to represent the <a href="https://en.wikipedia.org/wiki/Null_character" rel="noreferrer">Null character</a></p> <p><code>\0</code> and <code>\0000</code> are not valid escape sequences in Kotlin, so I've been using a static java char and accessing that from Kotlin.</p> <pre><code>public class StringUtils{ public static char escapeChar = '\0'; } </code></pre> <p>Is there a Null character literal, or a better way of doing this in Kotlin?</p>
0debug
to all coders whether beginners or experiences please help me with this c code : "please give me quite an explaination so that i can understand my query properly...thank you :) " i am a beginner and was learning to code using k&r's c programming book. now there is this example of "a program to input set of text lines and print the longest" i am giving you the whole code...... #define MAXLINE 1000 int getline(char line[], int maxline); void copy(char to[], char from[]); int main() { int len; int max; char line[MAXLINE]; char longest[MAXLINE]; max=0; while((len=getline(line,MAXLINE))>0) if(len>max) { max=len; copy(longest,line); } if(max>0) printf("%s",longest); return 0; } int getline(char s[], int lim) { int c,i; for(i=0;i<lim-1&&(c=getchar())!=EOF&&c!='\n';i++) { s[i]=c; if(c=='\n') { s[i]='\n'; i++; } s[i]='\0'; return i; } void copy(char to[], char from[]) { int i; i=0; while((to[i]=from[i])!='\0') i++; } now tell me.... in getline function.... in the statement for(i=0;i<lim-1&&(c=getchar())!=EOF&&c!='\n';i++) why do we use " c!='\n' " and what is the meaning of code after this for statement i.e. s[i]=c; if(c=='\n) { s[i]=c; i++; } s[i]='\0' why have we used s[i]='\0' in this and i++; statement in if(c=='\n') condition
0debug
static void spatial_compose97i_dy(dwt_compose_t *cs, DWTELEM *buffer, int width, int height, int stride){ int y = cs->y; DWTELEM *b0= cs->b0; DWTELEM *b1= cs->b1; DWTELEM *b2= cs->b2; DWTELEM *b3= cs->b3; DWTELEM *b4= buffer + mirror(y+3, height-1)*stride; DWTELEM *b5= buffer + mirror(y+4, height-1)*stride; if(stride == width && y+4 < height && 0){ int x; for(x=0; x<width/2; x++) b5[x] += 64*2; for(; x<width; x++) b5[x] += 169*2; } {START_TIMER if(b3 <= b5) vertical_compose97iL1(b3, b4, b5, width); if(b2 <= b4) vertical_compose97iH1(b2, b3, b4, width); if(b1 <= b3) vertical_compose97iL0(b1, b2, b3, width); if(b0 <= b2) vertical_compose97iH0(b0, b1, b2, width); if(width>400){ STOP_TIMER("vertical_compose97i")}} {START_TIMER if(y-1>= 0) horizontal_compose97i(b0, width); if(b0 <= b2) horizontal_compose97i(b1, width); if(width>400 && b0 <= b2){ STOP_TIMER("horizontal_compose97i")}} cs->b0=b2; cs->b1=b3; cs->b2=b4; cs->b3=b5; cs->y += 2; }
1threat
How to print char value in int array : <p>I have an array board[3][3] of type int. I want to show 8 numbers and on the last place "_" must be shown. I don't know how to do that. Please help</p>
0debug
Variable assignment in Unix : <p>When I try following statements, it doesn't assign values properly to variables and loop goes infinite- </p> <pre><code>while ( [ $nos -ne 0 ] ) do rem = `expr $nos % 10` sum = `expr $sum + $rem` nos = `expr $nos / 10` done </code></pre> <p>But when I remove spaces from left and right side of assignment operator, it works fine. Like this - </p> <pre><code>while ( [ $nos -ne 0 ] ) do rem=`expr $nos % 10` sum=`expr $sum + $rem` nos=`expr $nos / 10` done </code></pre> <p>Why the Shell behaviour is like that?</p>
0debug
Input pattern regex : <p>I was looking for a pattern that allows only 6 numbers with hyphen separating in the middle like <code>123-456</code></p>
0debug
How could I line up images on the same line? : <p>I need help aligning 5 images on the same lines using HTML5 and CSS3!</p> <p>I have tried using other methods (which I have forgotten so I can't leave an example) but they don't work. I don't want to use absolute positioning because I want my website to be as mobile friendly as possible.</p> <p>Could someone reply with some code of how to do this?</p>
0debug
Get the script codes from .sh file : <p>I have an auto script that I want to use. But I don't want to use it blindly, I am new to Linux.</p> <p>The script is a VPS script: From: <a href="http://script.hostingtermurah.net/script/debian/debian8-kvm.sh" rel="nofollow noreferrer">http://script.hostingtermurah.net/script/debian/debian8-kvm.sh</a></p> <p>Whenever I try to view the .sh file it's all gibberish (maybe binary?) nonetheless, it this Convertable to a normal script so I can see what will it execute and maybe edit it.</p> <p>Thanks</p>
0debug
Parent div did't get height if child div is absolute : I just stuck in `position`, I used `position:relative` for parent and `position:absolute` for child now parent div did't get height and i don't want to use `min-height` or `height`. You can see the red `border` on top which is the parent div `border`. **[fiddle code][1]** <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-css --> .box { text-align: center; border: 1px solid red; width: 500px; margin: 0 auto; position: relative; } .content { width: 50%; position: absolute; left: 0; right: 0; margin: 0 auto; } <!-- language: lang-html --> <div class="box"> <div class="content"> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda adipisci vel, dolore aspernatur iste iure blanditiis quam esse repudiandae aperiam debitis doloribus necessitatibus placeat tempora voluptate totam exercitationem neque quae. </div> </div> <!-- end snippet --> Anyone help me to how i get it ? Thanks [1]: https://jsfiddle.net/f8ugb7c8/
0debug
Return multiple values from dictionary, python : I've this dictionary `{'people': [{'name': 'Christina Koch', 'craft': 'ISS'}, {'name': 'Alexander Skvortsov', 'craft': 'ISS'}, {'name': 'Luca Parmitano', 'craft': 'ISS'}, {'name': 'Andrew Morgan', 'craft': 'ISS'}, {'name': 'Oleg Skripochka', 'craft': 'ISS'}, {'name': 'Jessica Meir', 'craft': 'ISS'}], 'number': 6, 'message': 'success'}` I need to get just the names, like below Alexander Skvortsov Alexey Ovchinin Andrew Morgan Christina Koch Luca Parmitano Nick Hague Thank you for your help
0debug
.babelrc configuration placed in package.JSON : <p>Currently exploring webpack different tools associated with it. Now I am using Babel for transpiling <code>ES6</code> code into <code>ES5</code> code. I came accross the need for a <code>.babelrc</code> file which holds the configurations for Babel. However, on the website of Babel I also saw that you could also place these configurations into the <code>package.json</code> file. Like this:</p> <p><strong>Package.json File:</strong></p> <pre><code>{ "name": "webpack-tutorial", "version": "1.0.0", "description": "", "main": "app.js", "scripts": { "dev": "webpack --mode development", "build": "webpack --mode production" }, "author": "", "license": "ISC", "devDependencies": { "babel-core": "^6.26.3", "babel-loader": "^7.1.5", "babel-preset-env": "^1.7.0", "webpack": "^4.16.2", "webpack-cli": "^3.1.0" }, "babel": { "presets": [ "env" ] } } </code></pre> <p>Now when I run <code>npm run dev</code> Babel also works and the code gets transpiled succesfully. </p> <p>How does Babel know to access the package.json file? Does it first look for an <code>.babelrc</code> file and then if this is not present does it automatically look for its configurations in the <code>package.json</code>? How does Webpack interact with both <code>Babel</code> and the <code>package.json</code> file to produce this result?</p>
0debug
How to extract the dynamically generated access token from the text file in perl : I am Beginner to perl programming and I want know solution for this problem. I have this below information in the text file called token.txt. I want to extract only dynamically generated access_token value and store that value to mysql database.As mentioned access_token will be auto generated everytime so how I need to store this access_token value everytime. Anyone help me with the perl code. Thanks in advance { "access_token" : "JgV8Ln1lRGE8JTz4olEQW0rJJHUYsq2LO8Ny9o6m", "token_type" : "abcdef", "expires_in" : 123456 }
0debug
how to upload image to azure DB : I read and found that the best way to upload is using blob (create container) I want to use it with node.js how can I upload for example an image to blob using node.js code?
0debug
static XICSState *try_create_xics(const char *type, int nr_servers, int nr_irqs) { DeviceState *dev; dev = qdev_create(NULL, type); qdev_prop_set_uint32(dev, "nr_servers", nr_servers); qdev_prop_set_uint32(dev, "nr_irqs", nr_irqs); if (qdev_init(dev) < 0) { return NULL; } return XICS(dev); }
1threat
How EarlyStopping Can be Used to Stop at that Epoch which gives Best Val_Accuray : Early Stopping has two advantages. It stops when val_accuracy starts decreasing & it avoids time wastage by stopping if val_accuracy does not improve for certain number of epoches (i.e patience). But, I want that the training should stop at the epoch which gives best val_accuracy. How can I do that????
0debug
how to use coordinates outside of didUpdateLocation function in swift : Im trying to use the coordinates outside of did update locations function but i can not get it to work i try to declare the coordinates as a degree outside of the function but that does not work how can i get some guidance on this. var currentUserLatitude:CLLocationDegrees? var currentUserLongitude:CLLocationDegrees? func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]){ //location info about the user let location = locations.last let center = CLLocationCoordinate2D(latitude: (location?.coordinate.latitude)!, longitude: (location?.coordinate.longitude)!) let span = MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05) let region = MKCoordinateRegion(center: center, span:span) self.mapView.setRegion(region, animated: true) // i want to use these variables outside the function var currentUserLatitude = location!.coordinate.latitude var currentUserLongitude = location!.coordinate.longitude }
0debug
I Want Update DATETIME but i can not changed it. it takes current time by default in sql server : I have a table in which I have a column datatype "datetimeoffset". now when I update it with previous years values then execute the query the what I get is current date and time values. [![enter image description here][1]][1] I Want Change 2015 instead of 2017 but i can not change it. it takes current time by default in sqlserver. [1]: https://i.stack.imgur.com/HHN6W.png
0debug
Delete empty dictionary from dictionary of dictionaries : <p>I have a dictionary A:</p> <pre><code>A = {"('All', 'Delhi', 'Mumbai')": {}, "('Container', 'Delhi', 'Mumbai')": {}, "('Open', 'Delhi', 'Mumbai')": {12: [12, 22, 25], 7: [9, 5]}, "('Open', 'Doon', 'Gurgaon')": {10: [1, 2, 24], 8: [4], 9: [28, 8], 7:[21]}} </code></pre> <p>I want to remove all the empty dictionaries, How can I do that ?</p>
0debug
static int dv_read_header(AVFormatContext *s, AVFormatParameters *ap) { unsigned state; RawDVContext *c = s->priv_data; c->dv_demux = dv_init_demux(s); if (!c->dv_demux) return -1; state = get_be32(s->pb); while ((state & 0xffffff7f) != 0x1f07003f) { if (url_feof(s->pb)) { av_log(s, AV_LOG_ERROR, "Cannot find DV header.\n"); return -1; } state = (state << 8) | get_byte(s->pb); } AV_WB32(c->buf, state); if (get_buffer(s->pb, c->buf + 4, DV_PROFILE_BYTES - 4) <= 0 || url_fseek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0) return AVERROR(EIO); c->dv_demux->sys = dv_frame_profile(c->buf); if (!c->dv_demux->sys) { av_log(s, AV_LOG_ERROR, "Can't determine profile of DV input stream.\n"); return -1; } s->bit_rate = av_rescale_q(c->dv_demux->sys->frame_size, (AVRational){8,1}, c->dv_demux->sys->time_base); return 0; }
1threat
How to set array of array in single array in php : <p>Following is my array</p> <pre><code>Array ( [0] =&gt; Array ( [1] =&gt; Beanie ) [1] =&gt; Array ( [2] =&gt; Cap ) [2] =&gt; Array ( [1] =&gt; Beanie with Logo ) ) </code></pre> <p>I want this into a single array like set key and value of array.</p> <pre><code>array( [1]=&gt;Beanie, [2]=&gt;Cap, [1]=&gt;Beanie with Logo, ) </code></pre>
0debug
Java - How to force a gamemode in minecraft mod? : So, I am making this private modpack in Minecraft. It all is ready, but I need help with making a mod: It forces all players to be in gamemode 2 (adventure mode), or just make players unable to place/destroy blocks. I am not good in java, how can I make a mod like that? Any help is appreciated.
0debug
How to setup debugging in Visual Studio Code for React Native? : <p>I searched but I can't find any external sources except for Visual Studio Code docs, and just following those docs don't allow to debug React Native apps both in iOS or Android.</p> <p>I keep getting the error message (this one for Android, for iOS is similar:</p> <blockquote> <p>[vscode-react-native] [Warning] Couldn't import script at <a href="http://localhost:8081/index.android.bundle?platform=android&amp;dev=true&amp;hot=false&amp;minify=false" rel="noreferrer">http://localhost:8081/index.android.bundle?platform=android&amp;dev=true&amp;hot=false&amp;minify=false</a>. Debugging won't work: Try reloading the JS from inside the app, or Reconnect the VS Code debugger: path must be a string</p> </blockquote> <p>My <code>launch.json</code> file as:</p> <pre><code>{ "version": "0.2.0", "configurations": [ { "name": "Debug Android", "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", "platform": "android", "internalDebuggerPort": 9090, "sourceMaps": true, "outDir": "${workspaceRoot}/.vscode/.react" }, { "name": "Debug iOS", "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", "platform": "ios", "target": "iPhone 6s", "internalDebuggerPort": 9090, "sourceMaps": true, "outDir": "${workspaceRoot}/.vscode/.react" }, { "name": "Attach to packager", "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "attach", "internalDebuggerPort": 9090, "sourceMaps": true, "outDir": "${workspaceRoot}/.vscode/.react" }, { "name": "Debug in Exponent", "program": "${workspaceRoot}/.vscode/launchReactNative.js", "type": "reactnative", "request": "launch", "platform": "exponent", "internalDebuggerPort": 9090, "sourceMaps": true, "outDir": "${workspaceRoot}/.vscode/.react" } ] } </code></pre> <p>I'm trying to debug both in the iOS simulator or in an Android device but the process never attaches to the external JS debugger.</p>
0debug
Numeric to Date in R Excel Central Time : I cant seem to find the answers to this, I have tried multiple things - I am still very new to R I have two variables in a dataset "Old Data" "Open Date" - num from Excel and "Closed Date" - POSIXct, format: "2017-10-11 12:39:37" I can't get them to subtract for each line within the dataset, the conversions seem to be off This is what I am trying to do (without the syntax Newdata <- Newtime=(Closed Date-Open Date) from "Old Data" Thanks in advance!
0debug
void tcg_register_helper(void *func, const char *name) { TCGContext *s = &tcg_ctx; GHashTable *table = s->helpers; if (table == NULL) { table = g_hash_table_new(NULL, NULL); s->helpers = table; } g_hash_table_insert(table, (gpointer)func, (gpointer)name); }
1threat
void YM3812UpdateOne(FM_OPL *OPL, INT16 *buffer, int length) { int i; int data; OPLSAMPLE *buf = buffer; UINT32 amsCnt = OPL->amsCnt; UINT32 vibCnt = OPL->vibCnt; UINT8 rythm = OPL->rythm&0x20; OPL_CH *CH,*R_CH; if( (void *)OPL != cur_chip ){ cur_chip = (void *)OPL; S_CH = OPL->P_CH; E_CH = &S_CH[9]; SLOT7_1 = &S_CH[7].SLOT[SLOT1]; SLOT7_2 = &S_CH[7].SLOT[SLOT2]; SLOT8_1 = &S_CH[8].SLOT[SLOT1]; SLOT8_2 = &S_CH[8].SLOT[SLOT2]; amsIncr = OPL->amsIncr; vibIncr = OPL->vibIncr; ams_table = OPL->ams_table; vib_table = OPL->vib_table; } R_CH = rythm ? &S_CH[6] : E_CH; for( i=0; i < length ; i++ ) { ams = ams_table[(amsCnt+=amsIncr)>>AMS_SHIFT]; vib = vib_table[(vibCnt+=vibIncr)>>VIB_SHIFT]; outd[0] = 0; for(CH=S_CH ; CH < R_CH ; CH++) OPL_CALC_CH(CH); if(rythm) OPL_CALC_RH(S_CH); data = Limit( outd[0] , OPL_MAXOUT, OPL_MINOUT ); buf[i] = data >> OPL_OUTSB; } OPL->amsCnt = amsCnt; OPL->vibCnt = vibCnt; #ifdef OPL_OUTPUT_LOG if(opl_dbg_fp) { for(opl_dbg_chip=0;opl_dbg_chip<opl_dbg_maxchip;opl_dbg_chip++) if( opl_dbg_opl[opl_dbg_chip] == OPL) break; fprintf(opl_dbg_fp,"%c%c%c",0x20+opl_dbg_chip,length&0xff,length/256); } #endif }
1threat
POWERPC_FAMILY(POWER7P)(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); dc->fw_name = "PowerPC,POWER7+"; dc->desc = "POWER7+"; pcc->pvr = CPU_POWERPC_POWER7P_BASE; pcc->pvr_mask = CPU_POWERPC_POWER7P_MASK; pcc->init_proc = init_proc_POWER7; pcc->check_pow = check_pow_nocheck; pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | PPC_FLOAT_FRSQRTES | PPC_FLOAT_STFIWX | PPC_FLOAT_EXT | PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | PPC_MEM_SYNC | PPC_MEM_EIEIO | PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_64B | PPC_ALTIVEC | PPC_SEGMENT_64B | PPC_SLBI | PPC_POPCNTB | PPC_POPCNTWD; pcc->insns_flags2 = PPC2_VSX | PPC2_DFP | PPC2_DBRX | PPC2_ISA205 | PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | PPC2_FP_TST_ISA206; pcc->msr_mask = (1ull << MSR_SF) | (1ull << MSR_VR) | (1ull << MSR_VSX) | (1ull << MSR_EE) | (1ull << MSR_PR) | (1ull << MSR_FP) | (1ull << MSR_ME) | (1ull << MSR_FE0) | (1ull << MSR_SE) | (1ull << MSR_DE) | (1ull << MSR_FE1) | (1ull << MSR_IR) | (1ull << MSR_DR) | (1ull << MSR_PMM) | (1ull << MSR_RI) | (1ull << MSR_LE); pcc->mmu_model = POWERPC_MMU_2_06; #if defined(CONFIG_SOFTMMU) pcc->handle_mmu_fault = ppc_hash64_handle_mmu_fault; #endif pcc->excp_model = POWERPC_EXCP_POWER7; pcc->bus_model = PPC_FLAGS_INPUT_POWER7; pcc->bfd_mach = bfd_mach_ppc64; pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | POWERPC_FLAG_BE | POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | POWERPC_FLAG_VSX; pcc->l1_dcache_size = 0x8000; pcc->l1_icache_size = 0x8000; pcc->interrupts_big_endian = ppc_cpu_interrupts_big_endian_lpcr; }
1threat
generate N points following a a normal distribution fortran : Does anyone know how could easily generate N random numbers following a normal distribution, with a mean mu and a standard deviation sigma, in fortran90? Or even the logic process to produce the N values?
0debug
sizeof(T) being interpreted as two arguments : <pre><code>error: no matching function for call to 'operator new(sizetype, long long unsigned int, long long unsigned int*&amp;)' new(sizeof(T), tmp) T{std::move(buffer[i])}; </code></pre> <p>I'm getting this error which leads me to believe that <code>sizeof(T)</code> is being interpreted as <code>sizetype, T</code>. Why is this happening and how do I fix it? </p> <p><code>tmp</code> is of the type <code>T*</code>, the new operator is being defined by <code>#include &lt;new&gt;</code>, and I don't define the comma operator anywhere. When I googled this error the only similar occurrence I could find was debug mode redefining the new operator, but that isn't the case for this.</p>
0debug
void qemu_announce_self(void) { static QEMUTimer *timer; timer = qemu_new_timer(rt_clock, qemu_announce_self_once, &timer); qemu_announce_self_once(&timer); }
1threat
static inline void RENAME(uyvyToY)(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused) { #if COMPILE_TEMPLATE_MMX __asm__ volatile( "mov %0, %%"REG_a" \n\t" "1: \n\t" "movq (%1, %%"REG_a",2), %%mm0 \n\t" "movq 8(%1, %%"REG_a",2), %%mm1 \n\t" "psrlw $8, %%mm0 \n\t" "psrlw $8, %%mm1 \n\t" "packuswb %%mm1, %%mm0 \n\t" "movq %%mm0, (%2, %%"REG_a") \n\t" "add $8, %%"REG_a" \n\t" " js 1b \n\t" : : "g" ((x86_reg)-width), "r" (src+width*2), "r" (dst+width) : "%"REG_a ); #else int i; for (i=0; i<width; i++) dst[i]= src[2*i+1]; #endif }
1threat
Change <li> list vertically to horozontally with 4 lines interval : <p>I have a list with ul li like this</p> <ul> <li>Item line 1</li> <li>Item line 2</li> <li>Item line 3</li> <li>Item line 4</li> <li>Item line 5</li> <li>Item line 6</li> <li>Item line 7</li> <li>Item line 8</li> <li>Item line 9</li> <li>Item line 10</li> <li>Item line 11</li> <li>Item line 12</li> </ul> <p>And I need to change to this, its possible only with CSS ?</p> <pre> Item line 1 Item line 5 Item line 9 Item line 2 Item line 6 Item line 10 Item line 3 Item line 7 Item line 11 Item line 4 Item line 8 Item line 12 </pre> <p>Regards</p> <p>Daniel</p>
0debug
struct pxa2xx_state_s *pxa270_init(unsigned int sdram_size, DisplayState *ds, const char *revision) { struct pxa2xx_state_s *s; struct pxa2xx_ssp_s *ssp; int iomemtype, i; s = (struct pxa2xx_state_s *) qemu_mallocz(sizeof(struct pxa2xx_state_s)); if (revision && strncmp(revision, "pxa27", 5)) { fprintf(stderr, "Machine requires a PXA27x processor.\n"); exit(1); } s->env = cpu_init(); cpu_arm_set_model(s->env, revision ?: "pxa270"); register_savevm("cpu", 0, 0, cpu_save, cpu_load, s->env); cpu_register_physical_memory(PXA2XX_SDRAM_BASE, sdram_size, qemu_ram_alloc(sdram_size) | IO_MEM_RAM); cpu_register_physical_memory(PXA2XX_INTERNAL_BASE, 0x40000, qemu_ram_alloc(0x40000) | IO_MEM_RAM); s->pic = pxa2xx_pic_init(0x40d00000, s->env); s->dma = pxa27x_dma_init(0x40000000, s->pic[PXA2XX_PIC_DMA]); pxa27x_timer_init(0x40a00000, &s->pic[PXA2XX_PIC_OST_0], s->pic[PXA27X_PIC_OST_4_11]); s->gpio = pxa2xx_gpio_init(0x40e00000, s->env, s->pic, 121); s->mmc = pxa2xx_mmci_init(0x41100000, s->pic[PXA2XX_PIC_MMC], s->dma); for (i = 0; pxa270_serial[i].io_base; i ++) if (serial_hds[i]) serial_mm_init(pxa270_serial[i].io_base, 2, s->pic[pxa270_serial[i].irqn], serial_hds[i], 1); else break; if (serial_hds[i]) s->fir = pxa2xx_fir_init(0x40800000, s->pic[PXA2XX_PIC_ICP], s->dma, serial_hds[i]); if (ds) s->lcd = pxa2xx_lcdc_init(0x44000000, s->pic[PXA2XX_PIC_LCD], ds); s->cm_base = 0x41300000; s->cm_regs[CCCR >> 4] = 0x02000210; s->clkcfg = 0x00000009; iomemtype = cpu_register_io_memory(0, pxa2xx_cm_readfn, pxa2xx_cm_writefn, s); cpu_register_physical_memory(s->cm_base, 0xfff, iomemtype); register_savevm("pxa2xx_cm", 0, 0, pxa2xx_cm_save, pxa2xx_cm_load, s); cpu_arm_set_cp_io(s->env, 14, pxa2xx_cp14_read, pxa2xx_cp14_write, s); s->mm_base = 0x48000000; s->mm_regs[MDMRS >> 2] = 0x00020002; s->mm_regs[MDREFR >> 2] = 0x03ca4000; s->mm_regs[MECR >> 2] = 0x00000001; iomemtype = cpu_register_io_memory(0, pxa2xx_mm_readfn, pxa2xx_mm_writefn, s); cpu_register_physical_memory(s->mm_base, 0xfff, iomemtype); register_savevm("pxa2xx_mm", 0, 0, pxa2xx_mm_save, pxa2xx_mm_load, s); s->pm_base = 0x40f00000; iomemtype = cpu_register_io_memory(0, pxa2xx_pm_readfn, pxa2xx_pm_writefn, s); cpu_register_physical_memory(s->pm_base, 0xff, iomemtype); register_savevm("pxa2xx_pm", 0, 0, pxa2xx_pm_save, pxa2xx_pm_load, s); for (i = 0; pxa27x_ssp[i].io_base; i ++); s->ssp = (struct pxa2xx_ssp_s **) qemu_mallocz(sizeof(struct pxa2xx_ssp_s *) * i); ssp = (struct pxa2xx_ssp_s *) qemu_mallocz(sizeof(struct pxa2xx_ssp_s) * i); for (i = 0; pxa27x_ssp[i].io_base; i ++) { s->ssp[i] = &ssp[i]; ssp[i].base = pxa27x_ssp[i].io_base; ssp[i].irq = s->pic[pxa27x_ssp[i].irqn]; iomemtype = cpu_register_io_memory(0, pxa2xx_ssp_readfn, pxa2xx_ssp_writefn, &ssp[i]); cpu_register_physical_memory(ssp[i].base, 0xfff, iomemtype); register_savevm("pxa2xx_ssp", i, 0, pxa2xx_ssp_save, pxa2xx_ssp_load, s); } if (usb_enabled) { usb_ohci_init_pxa(0x4c000000, 3, -1, s->pic[PXA2XX_PIC_USBH1]); } s->pcmcia[0] = pxa2xx_pcmcia_init(0x20000000); s->pcmcia[1] = pxa2xx_pcmcia_init(0x30000000); s->rtc_base = 0x40900000; iomemtype = cpu_register_io_memory(0, pxa2xx_rtc_readfn, pxa2xx_rtc_writefn, s); cpu_register_physical_memory(s->rtc_base, 0xfff, iomemtype); pxa2xx_rtc_init(s); register_savevm("pxa2xx_rtc", 0, 0, pxa2xx_rtc_save, pxa2xx_rtc_load, s); s->i2c[0] = pxa2xx_i2c_init(0x40301600, s->pic[PXA2XX_PIC_I2C], 0xffff); s->i2c[1] = pxa2xx_i2c_init(0x40f00100, s->pic[PXA2XX_PIC_PWRI2C], 0xff); s->i2s = pxa2xx_i2s_init(0x40400000, s->pic[PXA2XX_PIC_I2S], s->dma); pxa2xx_gpio_handler_set(s->gpio, 1, pxa2xx_reset, s); return s; }
1threat
Javascript Substring missing characters? : I am trying to use substring to differentiate between data in java script. The raw data I am pulling is: 0.! 3.0011632! 0.01! 2.9417362! The code I am using is var lastPosition = 0; var count = 0; //This code will continue looking for ! until it reaches three occurances while (count <3) { console.log(lastPosition); console.log(contents.indexOf("!",lastPosition+1)); console.log(contents.substr(lastPosition+1, contents.indexOf("!",lastPosition+1))); lastPosition = contents.indexOf("!",lastPosition+1); count++; } The problem is the output I am getting is: 0 //start 3 //end 0.! //# 3 //start 14 //end 3.0011632! //# 14 //start 23 //end 0.01! 2.9417362! //# As you can see its not properly locating the ! at the third cycle. This continues with more data and it eventually starts missing more and more !'s. Can anyone tell me what I'm doing wrong here?
0debug
Communication between Activity and Fragment in Kotlin : <p>As google announced the Kotlin as an official language for Android development, I am trying to build an app using Kotlin. </p> <p><strong>Question: How can I communicate between activity and fragment using Kotlin?</strong></p> <p>Thanks!.</p>
0debug
When I run this code it gives me a syntax error highlighting "print" as an error. Cant figure out why its doing this : def skipline (value): if value >= 3 : return(" This person is eligible to kip the line") else: returne (" This person is not eligible to skip the line") value =int(input("Enter a clearance value") print(skipline(value))
0debug
When is the parent class variables available to use in Python? : <pre><code>class frozen(object) : isFrozen = False print 'In base' class layer(frozen): print isFrozen </code></pre> <p>I am trying to understand the inheritance concept in Python, the above lines are a silly example. "print" statement in the parent class is working as I try to create an object of layer class. But it's throwing an error at the "print" statement of the child class. Saying "isFrozen" is not defined.</p> <p>But, if I comment out the "print" statement in child class, I can create an object of the child class and access "isFrozen" as "layerObject.isFrozen".</p> <p>So, could anyone please point out my misunderstanding here? </p>
0debug
Starting Android emulator failed: QXcbConnection: Could not connect to display : <p>I would like to do some debugging(Android native program without GUI) on a remote server which doesn't have display.</p> <p>The command is:</p> <pre><code>./emulator -writable-system -avd Pixel_XL_API_25 -no-snapshot-load -qemu -no-skin -no-audio -no-window -v </code></pre> <p>Error msg:</p> <pre><code>emulator: WARNING: System image is writable QXcbConnection: Could not connect to display Aborted </code></pre> <p>I have the <code>-no-window</code> option why it still tried to connect to display? I searched through Internet. It looks like it's a QT bug. Any idea to walk around it? </p> <p>I tried to set the DISPLAY env var by <code>export DISPLAY=:0</code>. It doesn't work out.</p>
0debug
Array.prototype.some not working with ternary operator : <p>Why do the following two snippets not return the same value?</p> <pre><code>[1,2,3,4].some((el) =&gt; { if (el === 4) { return true; } else { return false; } }); </code></pre> <p>--> returns true</p> <pre><code>[1,2,3,4].some((el) =&gt; { el === 4 ? true : false; }); </code></pre> <p>--> returns false</p>
0debug
static void kvm_s390_stattrib_synchronize(S390StAttribState *sa) { KVMS390StAttribState *sas = KVM_S390_STATTRIB(sa); MachineState *machine = MACHINE(qdev_get_machine()); unsigned long max = machine->maxram_size / TARGET_PAGE_SIZE; unsigned long cx, len = 1 << 19; int r; struct kvm_s390_cmma_log clog = { .flags = 0, .mask = ~0ULL, }; if (sas->incoming_buffer) { for (cx = 0; cx + len <= max; cx += len) { clog.start_gfn = cx; clog.count = len; clog.values = (uint64_t)(sas->incoming_buffer + cx * len); r = kvm_vm_ioctl(kvm_state, KVM_S390_SET_CMMA_BITS, &clog); if (r) { error_report("KVM_S390_SET_CMMA_BITS failed: %s", strerror(-r)); return; } } if (cx < max) { clog.start_gfn = cx; clog.count = max - cx; clog.values = (uint64_t)(sas->incoming_buffer + cx * len); r = kvm_vm_ioctl(kvm_state, KVM_S390_SET_CMMA_BITS, &clog); if (r) { error_report("KVM_S390_SET_CMMA_BITS failed: %s", strerror(-r)); } } g_free(sas->incoming_buffer); sas->incoming_buffer = NULL; } }
1threat
Need help, specifically with removing repeated word in list : I need to develop a program in which it takes in a user inputted string, e.g. ‘to be or not to be’. Then separate the string into its separate words, ‘to’, ’be’, ’or’, ’not’, ’to’, ’be’. The words are then put into a list, [‘to’, ’be’, ’or’, ’not’, ’to’, ’be’] where they are changed into their position in the list. However, if a word is repeated, only the first use of the word is counted and replaced with its position number. So, for example, both ‘to’s in ‘to be or not to be’ will be counted as 1. This is because the word ‘to’ is repeated and so the first appearance of ‘to’ accounts for both of the words. After the words are replaced with their position number, the sentence should be recreated with these numbers. So ‘to be or not to be’ should become ‘1, 2, 3, 4, 1, 2’. The list of both words and numbers should be saved as either separate files or one single file. This is all i have so far: UserSentence = input('Enter your chosen sentence: ') #this is where the user inputs their sentence UserSentence = UserSentence.split()#.split()takes the inputted string and breaks it down into individual words... #... and turns it into a list List1 = UserSentence List2 = UserSentence
0debug
How to read string in C : I try to run this code in c and expected runtime error but actually it did run,can you tell me the reason? char str[10]; scanf("%s",str); printf("%s",str); As i initialized the size of array as 10,how can code prints string of more than 10 letters?
0debug
Base64 encoding new line : <p>I am trying to encode some hex values to base64 in shell script.</p> <pre><code>nmurshed@ugster05:~$ echo -n "1906 1d8b fb01 3e78 5c21 85db 58a7 0bf9 a6bf 1e42 cb59 95cd 99be 66f7 8758 cf46 315f 1607 66f7 6793 e5b3 61f9 fa03 952d 9101 b129 7180 6f1d ca93 3494 55e0 0e2e" | xxd -r -p | base64 GQYdi/sBPnhcIYXbWKcL+aa/HkLLWZXNmb5m94dYz0YxXxYHZvdnk+WzYfn6A5UtkQGxKXGAbx3K kzSUVeAOLg== </code></pre> <p>I get a automatic new line after 76 charecters, Is there a way to avoid that ?</p> <p>Online i found, use "-n" to ignore new lines...Can anyone suggest something ?</p>
0debug
USBDevice *usbdevice_create(const char *cmdline) { USBBus *bus = usb_bus_find(-1 ); DeviceInfo *info; USBDeviceInfo *usb; char driver[32]; const char *params; int len; params = strchr(cmdline,':'); if (params) { params++; len = params - cmdline; if (len > sizeof(driver)) len = sizeof(driver); pstrcpy(driver, len, cmdline); } else { params = ""; pstrcpy(driver, sizeof(driver), cmdline); } for (info = device_info_list; info != NULL; info = info->next) { if (info->bus_info != &usb_bus_info) continue; usb = DO_UPCAST(USBDeviceInfo, qdev, info); if (usb->usbdevice_name == NULL) continue; if (strcmp(usb->usbdevice_name, driver) != 0) continue; break; } if (info == NULL) { #if 0 error_report("usbdevice %s not found", driver); #endif return NULL; } if (!usb->usbdevice_init) { if (params) { error_report("usbdevice %s accepts no params", driver); return NULL; } return usb_create_simple(bus, usb->qdev.name); } return usb->usbdevice_init(params); }
1threat
Find and draw the largest contour in opencv on a specific color (Python) : <p>Im trying to get the largest contour of a red book. I've got a little problem with the code because its getting the contours of the smallest objects (blobs) instead of the largest one and I can't seem to figure out why this is happening</p> <p>The code I use:</p> <pre><code>camera = cv2.VideoCapture(0) kernel = np.ones((2,2),np.uint8) while True: #Loading Camera ret, frame = camera.read() blurred = cv2.pyrMeanShiftFiltering(frame, 3, 3) hsv = cv2.cvtColor(blurred, cv2.COLOR_BGR2HSV) lower_range = np.array([150, 10, 10]) upper_range = np.array([180, 255, 255]) mask = cv2.inRange(hsv, lower_range, upper_range) dilation = cv2.dilate(mask,kernel,iterations = 1) closing = cv2.morphologyEx(dilation, cv2.MORPH_GRADIENT, kernel) closing = cv2.morphologyEx(dilation, cv2.MORPH_CLOSE, kernel) #Getting the edge of morphology edge = cv2.Canny(closing, 175, 175) _, contours,hierarchy = cv2.findContours(edge, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) # Find the index of the largest contour areas = [cv2.contourArea(c) for c in contours] max_index = np.argmax(areas) cnt=contours[max_index] x,y,w,h = cv2.boundingRect(cnt) cv2.rectangle(frame,(x,y),(x+w,y+h),(0,255,0),2) cv2.imshow('threshold', frame) cv2.imshow('edge', edge) if cv2.waitKey(1) == 27: break camera.release() cv2.destroyAllWindows() </code></pre> <p><a href="https://i.stack.imgur.com/yuyGo.png" rel="noreferrer">As you can see on this picture</a></p> <p>Hopefully there is someone who can help</p>
0debug
void object_add(const char *type, const char *id, const QDict *qdict, Visitor *v, Error **errp) { Object *obj; const QDictEntry *e; Error *local_err = NULL; if (!object_class_by_name(type)) { error_setg(errp, "invalid class name"); return; } obj = object_new(type); if (qdict) { for (e = qdict_first(qdict); e; e = qdict_next(qdict, e)) { object_property_set(obj, v, e->key, &local_err); if (local_err) { goto out; } } } if (!object_dynamic_cast(obj, TYPE_USER_CREATABLE)) { error_setg(&local_err, "object type '%s' isn't supported by object-add", type); goto out; } user_creatable_complete(obj, &local_err); if (local_err) { goto out; } object_property_add_child(container_get(object_get_root(), "/objects"), id, obj, &local_err); out: if (local_err) { error_propagate(errp, local_err); } object_unref(obj); }
1threat
Why is ToString() defined on Object in .NET? : <p>I have always wondered the design choices that lead to the creation of ToString on Object in .NET.</p>
0debug
Java Scanner won't read through the whole file : <p>So I'm trying to read through a whole file and print its content, which it does. But when I go through it again with a new Scanner to print the content with some section names, it only goes through some of the file.</p> <p>Here's my code:</p> <pre><code>import java.util.*; import java.io.*; public class FileReader { public static void main(String[] args) throws FileNotFoundException { Scanner read = new Scanner(new File("sample.txt")); while(read.hasNextLine()) { System.out.println(read.nextLine()); } System.out.println(); Scanner read2 = new Scanner(new File("sample.txt")); int numQuestions = read2.nextInt(); System.out.println("Numbers of questions: " + numQuestions); System.out.println(); while(read2.hasNextLine()) { int points, numChoices; String question, answer; if(read2.next().equals("TF")) { points = read2.nextInt(); System.out.println("Points for TF: " + points); read2.nextLine(); // must be done because it does not consume the \n character question = read2.nextLine(); System.out.println("Question for TF: " + question); answer = read2.next(); System.out.println("Answer for TF: " + answer); } else if(read2.next().equals("SA")) { points = read2.nextInt(); System.out.println("Points for SA: " + points); read2.nextLine(); // must be done because it does not consume the \n character question = read2.nextLine(); System.out.println("Question for SA: " + question); answer = read2.next(); System.out.println("Answer for SA: " + answer); } else if(read2.next().equals("MC")) { points = read2.nextInt(); System.out.println("Points for MC: " + points); read2.nextLine(); // must be done because it does not consume the \n character question = read2.nextLine(); System.out.println("Question for MC: " + question); read2.nextLine(); numChoices = read2.nextInt(); for(int i = 0; i &lt; numChoices; i++) { System.out.println(read2.nextLine()); } answer = read2.next(); System.out.println("Answer for MC: " + answer); } } } } </code></pre> <p>Here's the file I'm reading from:</p> <pre><code>3 TF 5 There exist birds that can not fly. (true/false) true MC 10 Who was the president of the USA in 1991? 6 Richard Nixon Gerald Ford Jimmy Carter Ronald Reagan George Bush Sr. Bill Clinton E SA 20 What city hosted the 2004 Summer Olympics? Athens </code></pre> <p>And here is the output I get:</p> <pre><code>3 TF 5 There exist birds that can not fly. (true/false) true MC 10 Who was the president of the USA in 1991? 6 Richard Nixon Gerald Ford Jimmy Carter Ronald Reagan George Bush Sr. Bill Clinton E SA 20 What city hosted the 2004 Summer Olympics? Athens Numbers of questions: 3 Points for TF: 5 Question for TF: There exist birds that can not fly. (true/false) Answer for TF: true </code></pre> <p>As you can see, the first <code>Scanner</code> reads through the whole file and prints it. But when I try for the second time with the section names, it only goes through question 1's part.</p>
0debug