problem
stringlengths
26
131k
labels
class label
2 classes
docker-compose exec python the input device is not a TTY in AWS EC2 UserData : <p>I am using EC2 UserData to bootstrap the instance.</p> <p>TRacking log of bootstrap execution <code>/var/log/cloud-init-output.log</code>, I found that the script was stopped at :</p> <pre><code>+ docker-compose exec web python /var/www/flask/app/db_fixtures.py the input device is not a TTY </code></pre> <p>It seems like this command it's running in interactive mode, but why ? and how to force noninteractive mode for this command (docker-compose exec) ?</p>
0debug
int spapr_allocate_irq_block(int num, bool lsi) { int first = -1; int i; for (i = 0; i < num; ++i) { int irq; irq = spapr_allocate_irq(0, lsi); if (!irq) { return -1; } if (0 == i) { first = irq; } assert(irq == (first + i)); } return first; }
1threat
leetcode 109 : Convert Sorted List to Binary Search Tree : <pre><code>public class Solution { public TreeNode sortedListToBST(ListNode head) { if (head == null) return null; if (head.next == null) return new TreeNode (head.val); ListNode slow = head; ListNode fast = head; ListNode pre = null; ListNode mid = null; while (fast.next != null &amp;&amp; fast != null){ pre = slow; fast = fast.next.next; slow = slow.next; } mid = slow; pre.next = null; TreeNode root = new TreeNode(slow.val); root.right = sortedListToBST(mid.next); root.left = sortedListToBST(head); return root; } </code></pre> <p>}</p> <p>This is my solution but it shows: java.lang.NullPointerException</p> <p>when i change <code>while (fast.next != null &amp;&amp; fast != null){</code> to <code>while (fast != null &amp;&amp; fast.next != null){</code> the solution is accepted</p> <p>i don't know the differences between them. </p>
0debug
void macio_nvram_setup_bar(MacIONVRAMState *s, MemoryRegion *bar, target_phys_addr_t mem_base) { memory_region_add_subregion(bar, mem_base, &s->mem); }
1threat
JVM versus C++ compiler : <p>I have a query in which I cannot give a satisfactory answer. Java is notorious for its independence over machine architectures grace to JVM. I 've understood the following: </p> <ul> <li>Different JVM implementations are sitting on different machines as to produce the appropriate output (different for any different architecture) from the same input(.class files).</li> </ul> <p>Let's now consider C++. Why not to do the same with Java? Namely, implement different C++ compiler versions for different architectures, feed them with the same source and make every compiler produce the appropriate output; just make C++ compiler to mimic JVM! </p> <p><em>This is my query since I cannot understand why Java is unique in that...</em></p>
0debug
Is it posible to centre the box in HTML/CSS : I have created an HTML/CSS website, but I have a problem, and i don't know how to fix it. So, I would like the footer to be centered like the website, but i don't know how to make it. Can somebody help me? Files: https://github.com/TrainyBIG/help Website: https://trainybig.github.io/help/
0debug
type_init(pflash_cfi01_register_types) pflash_t *pflash_cfi01_register(hwaddr base, DeviceState *qdev, const char *name, hwaddr size, BlockDriverState *bs, uint32_t sector_len, int nb_blocs, int bank_width, uint16_t id0, uint16_t id1, uint16_t id2, uint16_t id3, int be) { DeviceState *dev = qdev_create(NULL, TYPE_CFI_PFLASH01); if (bs && qdev_prop_set_drive(dev, "drive", bs)) { abort(); } qdev_prop_set_uint32(dev, "num-blocks", nb_blocs); qdev_prop_set_uint64(dev, "sector-length", sector_len); qdev_prop_set_uint8(dev, "width", bank_width); qdev_prop_set_uint8(dev, "big-endian", !!be); qdev_prop_set_uint16(dev, "id0", id0); qdev_prop_set_uint16(dev, "id1", id1); qdev_prop_set_uint16(dev, "id2", id2); qdev_prop_set_uint16(dev, "id3", id3); qdev_prop_set_string(dev, "name", name); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base); return CFI_PFLASH01(dev); }
1threat
Why forbidden to use a remote function inside a guard : <p>Why I can't to use <code>String</code> or other module in guard?</p> <p>Code:</p> <pre><code>def foo(s1, s2) when String.length(s1) == String.length(s2) do # something end </code></pre> <p>And how I can elegantly reformat such case, when I wish to use module functions?</p>
0debug
av_cold int ff_opus_parse_extradata(AVCodecContext *avctx, OpusContext *s) { static const uint8_t default_channel_map[2] = { 0, 1 }; int (*channel_reorder)(int, int) = channel_reorder_unknown; const uint8_t *extradata, *channel_map; int extradata_size; int version, channels, map_type, streams, stereo_streams, i, j; uint64_t layout; if (!avctx->extradata) { if (avctx->channels > 2) { av_log(avctx, AV_LOG_ERROR, "Multichannel configuration without extradata.\n"); return AVERROR(EINVAL); } extradata = opus_default_extradata; extradata_size = sizeof(opus_default_extradata); } else { extradata = avctx->extradata; extradata_size = avctx->extradata_size; } if (extradata_size < 19) { av_log(avctx, AV_LOG_ERROR, "Invalid extradata size: %d\n", extradata_size); return AVERROR_INVALIDDATA; } version = extradata[8]; if (version > 15) { avpriv_request_sample(avctx, "Extradata version %d", version); return AVERROR_PATCHWELCOME; } avctx->delay = AV_RL16(extradata + 10); channels = avctx->extradata ? extradata[9] : (avctx->channels == 1) ? 1 : 2; if (!channels) { av_log(avctx, AV_LOG_ERROR, "Zero channel count specified in the extradata\n"); return AVERROR_INVALIDDATA; } s->gain_i = AV_RL16(extradata + 16); if (s->gain_i) s->gain = ff_exp10(s->gain_i / (20.0 * 256)); map_type = extradata[18]; if (!map_type) { if (channels > 2) { av_log(avctx, AV_LOG_ERROR, "Channel mapping 0 is only specified for up to 2 channels\n"); return AVERROR_INVALIDDATA; } layout = (channels == 1) ? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO; streams = 1; stereo_streams = channels - 1; channel_map = default_channel_map; } else if (map_type == 1 || map_type == 2 || map_type == 255) { if (extradata_size < 21 + channels) { av_log(avctx, AV_LOG_ERROR, "Invalid extradata size: %d\n", extradata_size); return AVERROR_INVALIDDATA; } streams = extradata[19]; stereo_streams = extradata[20]; if (!streams || stereo_streams > streams || streams + stereo_streams > 255) { av_log(avctx, AV_LOG_ERROR, "Invalid stream/stereo stream count: %d/%d\n", streams, stereo_streams); return AVERROR_INVALIDDATA; } if (map_type == 1) { if (channels > 8) { av_log(avctx, AV_LOG_ERROR, "Channel mapping 1 is only specified for up to 8 channels\n"); return AVERROR_INVALIDDATA; } layout = ff_vorbis_channel_layouts[channels - 1]; channel_reorder = channel_reorder_vorbis; } else if (map_type == 2) { int ambisonic_order = ff_sqrt(channels) - 1; if (channels != (ambisonic_order + 1) * (ambisonic_order + 1)) { av_log(avctx, AV_LOG_ERROR, "Channel mapping 2 is only specified for channel counts" " which can be written as (n + 1)^2 for nonnegative integer n\n"); return AVERROR_INVALIDDATA; } layout = 0; } else layout = 0; channel_map = extradata + 21; } else { avpriv_request_sample(avctx, "Mapping type %d", map_type); return AVERROR_PATCHWELCOME; } s->channel_maps = av_mallocz_array(channels, sizeof(*s->channel_maps)); if (!s->channel_maps) return AVERROR(ENOMEM); for (i = 0; i < channels; i++) { ChannelMap *map = &s->channel_maps[i]; uint8_t idx = channel_map[channel_reorder(channels, i)]; if (idx == 255) { map->silence = 1; continue; } else if (idx >= streams + stereo_streams) { av_log(avctx, AV_LOG_ERROR, "Invalid channel map for output channel %d: %d\n", i, idx); return AVERROR_INVALIDDATA; } map->copy = 0; for (j = 0; j < i; j++) if (channel_map[channel_reorder(channels, j)] == idx) { map->copy = 1; map->copy_idx = j; break; } if (idx < 2 * stereo_streams) { map->stream_idx = idx / 2; map->channel_idx = idx & 1; } else { map->stream_idx = idx - stereo_streams; map->channel_idx = 0; } } avctx->channels = channels; avctx->channel_layout = layout; s->nb_streams = streams; s->nb_stereo_streams = stereo_streams; return 0; }
1threat
Inconsistency in Parallel.ForEach : <p>I am using Parallel.foreach for more than 500 iterations.</p> <p>My loop is something like:</p> <pre><code>Parallel.ForEach(indexes, (index) =&gt; { //parentCreation with index object parent=create(index); //call of function to create children createChildrenOfType1(parent); createChildrenOfType2(parent); }); </code></pre> <p>I am facing inconsistent output. Parents are created correctly but child creation is inconsistent. Sometimes no child is created, sometimes only few are created and so on. Child creation method again has for loop to create 100s of children.</p> <p>How can I make my child creation consistent while using the parallel foreach for parent creation.</p>
0debug
Get clomuns with value 0 on group by sum : I'm using this query to get the sum of rows grupued by cmp2 field but I need to get a colum for every cmp2 even if its sum resul is 0, but I can't get it this way SELECT CMP2,COALESCE(count(*), 0) as count FROM datos_con851_0,datos_con851_1 WHERE datos_con851_0.REGISTRO = datos_con851_1.REGISTRO AND SPEEDER = 1 GROUP BY CMP2;
0debug
Getting TypeError: 'str' object is not callable while creating directory using os.mkdir in python 3 : import os os.mkdir(r'C:\Users\Puneeth.Prabhu\Documents\Hello') File "C:/Users/Puneeth.Prabhu/.spyder-py3/testingpage.py", line 3, in <module> os.mkdir(r'C:\Users\Puneeth.Prabhu\Documents\Hello') TypeError: 'str' object is not callable I'm running the above code to create a directory using python. But ending up with str object is not callable error message. Any help would be appreciated.
0debug
Get returno of async task : I hava a doubt. I have a class that request online json. Is works fine, but the function is void, I need the function return true or false to the activity. This is the example: public class Async extends AbstractService{ public void getData(fina Context context){ JSONObject param = new JSONObject(); try { param.put("field_1", "1"); param.put("field_3", "2"); param.put("field_3", "3"); }catch (Exception e) {} requester = new HttpRequestController().sendPost("auth/device", param, new HttpRequestController.CallBackRequest(){ @Override public void run(final String result) { new Thread(new Runnable() { @Override public void run() { if(resultObj.optBoolean("success")) { //here return true or false } } }).start(); System.out.println("test auth 1: " + result); } }); } } public class MainActivity extends baseActivity{ .... protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); Async auth = new Async(); auth.getUserDevice(this); //how to test is true or false ? } }
0debug
static int kvm_irqchip_get_virq(KVMState *s) { uint32_t *word = s->used_gsi_bitmap; int max_words = ALIGN(s->gsi_count, 32) / 32; int i, zeroes; bool retry = true; again: for (i = 0; i < max_words; i++) { zeroes = ctz32(~word[i]); if (zeroes == 32) { continue; } return zeroes + i * 32; } if (!s->direct_msi && retry) { retry = false; kvm_flush_dynamic_msi_routes(s); goto again; } return -ENOSPC; }
1threat
static void opt_target(const char *arg) { enum { PAL, NTSC, FILM, UNKNOWN } norm = UNKNOWN; static const char *const frame_rates[] = {"25", "30000/1001", "24000/1001"}; if(!strncmp(arg, "pal-", 4)) { norm = PAL; arg += 4; } else if(!strncmp(arg, "ntsc-", 5)) { norm = NTSC; arg += 5; } else if(!strncmp(arg, "film-", 5)) { norm = FILM; arg += 5; } else { int fr; fr = (int)(frame_rate.num * 1000.0 / frame_rate.den); if(fr == 25000) { norm = PAL; } else if((fr == 29970) || (fr == 23976)) { norm = NTSC; } else { if(nb_input_files) { int i, j; for(j = 0; j < nb_input_files; j++) { for(i = 0; i < input_files[j]->nb_streams; i++) { AVCodecContext *c = input_files[j]->streams[i]->codec; if(c->codec_type != AVMEDIA_TYPE_VIDEO) continue; fr = c->time_base.den * 1000 / c->time_base.num; if(fr == 25000) { norm = PAL; break; } else if((fr == 29970) || (fr == 23976)) { norm = NTSC; break; } } if(norm != UNKNOWN) break; } } } if(verbose && norm != UNKNOWN) fprintf(stderr, "Assuming %s for target.\n", norm == PAL ? "PAL" : "NTSC"); } if(norm == UNKNOWN) { fprintf(stderr, "Could not determine norm (PAL/NTSC/NTSC-Film) for target.\n"); fprintf(stderr, "Please prefix target with \"pal-\", \"ntsc-\" or \"film-\",\n"); fprintf(stderr, "or set a framerate with \"-r xxx\".\n"); ffmpeg_exit(1); } if(!strcmp(arg, "vcd")) { opt_video_codec("mpeg1video"); opt_audio_codec("mp2"); opt_format("vcd"); opt_frame_size(norm == PAL ? "352x288" : "352x240"); opt_frame_rate(NULL, frame_rates[norm]); opt_default("g", norm == PAL ? "15" : "18"); opt_default("b", "1150000"); opt_default("maxrate", "1150000"); opt_default("minrate", "1150000"); opt_default("bufsize", "327680"); opt_default("ab", "224000"); audio_sample_rate = 44100; audio_channels = 2; opt_default("packetsize", "2324"); opt_default("muxrate", "1411200"); mux_preload= (36000+3*1200) / 90000.0; } else if(!strcmp(arg, "svcd")) { opt_video_codec("mpeg2video"); opt_audio_codec("mp2"); opt_format("svcd"); opt_frame_size(norm == PAL ? "480x576" : "480x480"); opt_frame_rate(NULL, frame_rates[norm]); opt_default("g", norm == PAL ? "15" : "18"); opt_default("b", "2040000"); opt_default("maxrate", "2516000"); opt_default("minrate", "0"); opt_default("bufsize", "1835008"); opt_default("flags", "+scan_offset"); opt_default("ab", "224000"); audio_sample_rate = 44100; opt_default("packetsize", "2324"); } else if(!strcmp(arg, "dvd")) { opt_video_codec("mpeg2video"); opt_audio_codec("ac3"); opt_format("dvd"); opt_frame_size(norm == PAL ? "720x576" : "720x480"); opt_frame_rate(NULL, frame_rates[norm]); opt_default("g", norm == PAL ? "15" : "18"); opt_default("b", "6000000"); opt_default("maxrate", "9000000"); opt_default("minrate", "0"); opt_default("bufsize", "1835008"); opt_default("packetsize", "2048"); opt_default("muxrate", "10080000"); opt_default("ab", "448000"); audio_sample_rate = 48000; } else if(!strncmp(arg, "dv", 2)) { opt_format("dv"); opt_frame_size(norm == PAL ? "720x576" : "720x480"); opt_frame_pix_fmt(!strncmp(arg, "dv50", 4) ? "yuv422p" : (norm == PAL ? "yuv420p" : "yuv411p")); opt_frame_rate(NULL, frame_rates[norm]); audio_sample_rate = 48000; audio_channels = 2; } else { fprintf(stderr, "Unknown target: %s\n", arg); ffmpeg_exit(1); } }
1threat
struct omap_intr_handler_s *omap_inth_init(target_phys_addr_t base, unsigned long size, unsigned char nbanks, qemu_irq **pins, qemu_irq parent_irq, qemu_irq parent_fiq, omap_clk clk) { struct omap_intr_handler_s *s = (struct omap_intr_handler_s *) g_malloc0(sizeof(struct omap_intr_handler_s) + sizeof(struct omap_intr_handler_bank_s) * nbanks); s->parent_intr[0] = parent_irq; s->parent_intr[1] = parent_fiq; s->nbanks = nbanks; s->pins = qemu_allocate_irqs(omap_set_intr, s, nbanks * 32); if (pins) *pins = s->pins; memory_region_init_io(&s->mmio, &omap_inth_mem_ops, s, "omap-intc", size); memory_region_add_subregion(get_system_memory(), base, &s->mmio); omap_inth_reset(s); return s; }
1threat
static unsigned int mszh_decomp(const unsigned char * srcptr, int srclen, unsigned char * destptr, unsigned int destsize) { unsigned char *destptr_bak = destptr; unsigned char *destptr_end = destptr + destsize; const unsigned char *srcptr_end = srcptr + srclen; unsigned mask = *srcptr++; unsigned maskbit = 0x80; while (srcptr < srcptr_end && destptr < destptr_end) { if (!(mask & maskbit)) { memcpy(destptr, srcptr, 4); destptr += 4; srcptr += 4; } else { unsigned ofs = bytestream_get_le16(&srcptr); unsigned cnt = (ofs >> 11) + 1; ofs &= 0x7ff; ofs = FFMIN(ofs, destptr - destptr_bak); cnt *= 4; cnt = FFMIN(cnt, destptr_end - destptr); av_memcpy_backptr(destptr, ofs, cnt); destptr += cnt; } maskbit >>= 1; if (!maskbit) { mask = *srcptr++; while (!mask) { if (destptr_end - destptr < 32 || srcptr_end - srcptr < 32) break; memcpy(destptr, srcptr, 32); destptr += 32; srcptr += 32; mask = *srcptr++; } maskbit = 0x80; } } return destptr - destptr_bak; }
1threat
How can I delete images from firebase storage? : I want to delete images from firebase storage.[This is my Firebase Database.][1] [1]: https://i.stack.imgur.com/EDI00.png
0debug
bokeh layout for plot and widget arrangement : <p>I have a specific design in mind for my bokeh app. I am using <code>bokeh 0.12.3</code> and a bokeh server to keep everything in sync. Please, have a look at my mockup:</p> <p><a href="https://i.stack.imgur.com/KPZCd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/KPZCd.png" alt="enter image description here"></a></p> <p>On the left-hand side, there is a static navigation bar, the right part of the view will consist of plots, that are manually added. The amount of plot columns on the right-hand side shall change w.r.t. window size. I am well aware of the bokeh layout documentation <a href="http://bokeh.pydata.org/en/latest/docs/user_guide/layout.html" rel="noreferrer">laying out plots and widgets</a>, but it's a bit more complicated. This is the layout I currently have:</p> <pre><code>doc_layout = layout(children=[[column(radio_buttons, cbx_buttons, div, data_table, plot, button)]], sizing_mode='scale_width') curdoc().add_root(doc_layout) </code></pre> <p>In order to add new plots I use:</p> <pre><code>doc_layout.children[-1].children.append(plot) # appends plot to layout children [[column(..), plot]] </code></pre> <p>But the behavior is very strange, and not at all what I actually want to achieve. New plots are added on top of the column (menu panel) instead.</p> <p>Here, a short example where you can try out to see what I mean:</p> <pre><code>from bokeh.io import curdoc from bokeh.plotting import figure from bokeh.models.sources import ColumnDataSource from bokeh.models.widgets import Button, DataTable, TableColumn from bokeh.layouts import layout, widgetbox, column, row WIDTH = 200 HEIGHT = 200 def add_plot(): p = figure(width=WIDTH, height=HEIGHT, tools=[], toolbar_location=None) p.line([0, 1, 2, 3, 4, 5], [0, 1, 4, 9, 16, 25]) doc_layout.children[-1].children.append(p) src = ColumnDataSource(dict(x=[0, 1, 2, 3, 4, 5], y=[0, 1, 4, 9, 16, 25])) t1 = DataTable(source=src, width=WIDTH, height=HEIGHT, columns=[TableColumn(field='x', title='x'), TableColumn(field='y', title='y')]) b = Button(label='add plot') b.on_click(add_plot) doc_layout = layout([[widgetbox(b, t1)]], sizing_mode='scale_width') curdoc().add_root(doc_layout) </code></pre> <p>I am not sure what is the best solution to overcome this problem. I've tried several things, from <code>layout()</code> with different sizing modes, <code>gridplot()</code>, <code>column()</code>/<code>row()</code> in different combinations. In my previous version, where the navigation menu was placed on the top of the page instead on the left-hand side, everything seemed to work:</p> <pre><code>layout(children=[[widgetbox(radio_button, cbx_button), widgetbox(data_table), widgetbox(div), widgetbox(button)], [Spacer()]], sizing_mode='scale_width') </code></pre>
0debug
Ocaml: How can I return the first element of a list and after that remove it from the list? : I'm new in Functional Programming and I'm trying to learn a little bit of Ocaml and I tried to use **List.hd** and **List.tl** for this task: `let takeCard fst deck = fst = List.hd deck List.tl deck` 'List.hd' takes two arguments but I don't understand why. Please, help ! :'(
0debug
What is React component 'displayName' is used for? : <p>I know that is <a href="https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/display-name.md" rel="noreferrer">it considered a good practice</a> to name react component by adding a <code>displayName</code> property, but not sure I know why. In react docs, it say:</p> <blockquote> <p>The displayName string is used in debugging messages. JSX sets this value automatically; see JSX in Depth.</p> </blockquote> <p>Why is is so important? what will happen if I won't add it? (so far I didn't have it and had no issues debugging)</p> <p>Are there any recommendations / good practices on how to name the components? </p>
0debug
What is image hot link prevention? : <p>Can anybody help me to find out what is the image hot link prevention that is configured in .htaccess file. Why is this important and what is their advantages if we use? </p>
0debug
static void virgl_cmd_get_capset(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd) { struct virtio_gpu_get_capset gc; struct virtio_gpu_resp_capset *resp; uint32_t max_ver, max_size; VIRTIO_GPU_FILL_CMD(gc); virgl_renderer_get_cap_set(gc.capset_id, &max_ver, &max_size); resp = g_malloc(sizeof(*resp) + max_size); resp->hdr.type = VIRTIO_GPU_RESP_OK_CAPSET; virgl_renderer_fill_caps(gc.capset_id, gc.capset_version, (void *)resp->capset_data); virtio_gpu_ctrl_response(g, cmd, &resp->hdr, sizeof(*resp) + max_size); g_free(resp); }
1threat
int ff_amf_tag_size(const uint8_t *data, const uint8_t *data_end) { const uint8_t *base = data; if (data >= data_end) return -1; switch (*data++) { case AMF_DATA_TYPE_NUMBER: return 9; case AMF_DATA_TYPE_BOOL: return 2; case AMF_DATA_TYPE_STRING: return 3 + AV_RB16(data); case AMF_DATA_TYPE_LONG_STRING: return 5 + AV_RB32(data); case AMF_DATA_TYPE_NULL: return 1; case AMF_DATA_TYPE_ARRAY: data += 4; case AMF_DATA_TYPE_OBJECT: for (;;) { int size = bytestream_get_be16(&data); int t; if (!size) { data++; break; } if (data + size >= data_end || data + size < data) return -1; data += size; t = ff_amf_tag_size(data, data_end); if (t < 0 || data + t >= data_end) return -1; data += t; } return data - base; case AMF_DATA_TYPE_OBJECT_END: return 1; default: return -1; } }
1threat
static void dash_free(AVFormatContext *s) { DASHContext *c = s->priv_data; int i, j; if (c->as) { for (i = 0; i < c->nb_as; i++) av_dict_free(&c->as[i].metadata); av_freep(&c->as); c->nb_as = 0; } if (!c->streams) return; for (i = 0; i < s->nb_streams; i++) { OutputStream *os = &c->streams[i]; if (os->ctx && os->ctx_inited) av_write_trailer(os->ctx); if (os->ctx && os->ctx->pb) ffio_free_dyn_buf(&os->ctx->pb); ff_format_io_close(s, &os->out); if (os->ctx) avformat_free_context(os->ctx); for (j = 0; j < os->nb_segments; j++) av_free(os->segments[j]); av_free(os->segments); } av_freep(&c->streams); }
1threat
@RunWith(PowerMockRunner.class) vs @RunWith(MockitoJUnitRunner.class) : <p>In the usual mocking with <code>@Mock</code> and <code>@InjectMocks</code> annotations, the class under testing should be run with <code>@RunWith(MockitoJUnitRunner.class)</code>. </p> <pre><code>@RunWith(MockitoJUnitRunner.class) public class ReportServiceImplTestMockito { @Mock private TaskService mockTaskService; @InjectMocks private ReportServiceImpl service; // Some tests } </code></pre> <p>but in some example I am seeing <code>@RunWith(PowerMockRunner.class)</code> being used:</p> <pre><code>@RunWith(PowerMockRunner.class) public class Tests { @Mock private ISomething mockedSomething; @Test public void test1() { // Is the value of mockedSomething here } @Test public void test2() { // Is a new value of mockedSomething here } } </code></pre> <p>could someone point it out whats the difference and when I want to use one instead of another?</p>
0debug
void pcmcia_info(Monitor *mon, const QDict *qdict) { struct pcmcia_socket_entry_s *iter; if (!pcmcia_sockets) monitor_printf(mon, "No PCMCIA sockets\n"); for (iter = pcmcia_sockets; iter; iter = iter->next) monitor_printf(mon, "%s: %s\n", iter->socket->slot_string, iter->socket->attached ? iter->socket->card_string : "Empty"); }
1threat
Change state of Flutter widget from outside it's State class : <p>I created a DropdownButton as a StatefulWidget. The class is called MyDropDown, with the corresponding state called MyDropDownState.</p> <p>I created a reset function in the MyDropDownState class:</p> <pre><code>void reset(){ setState((){ _selection = null; }); } </code></pre> <p>which will set the selection to null and set the state of the dropdown, effectively resetting the dropdown.</p> <p>The core of the problem is I have to call this function when an IconButton on the AppBar is pressed. I have tried multiple ways and just can't get access to the state of the MyDropDown class I created.</p> <p>This is the code of MyDropDown and it's State, simplified:</p> <pre><code>class MyDropDown extends StatefulWidget { final Map&lt;String, String&gt; _itemMap; MyDropDown(this._itemMap); @override MyDropDownState createState() =&gt; new MyDropDownState(); } class MyDropDownState extends State&lt;MyDropDown&gt; { String _selection; void reset(){ setState((){ _selection = null; }); } @override void initState() { _selection = null; super.initState(); } @override Widget build(BuildContext context) { return new DropdownButton( value: _selection, //getDropItems builds dropdown items items: getDropItems(widget._itemMap), onChanged: (s) { setState(() { _selection = s; }); }, ); } } </code></pre> <p>In my main page, I create a new MyDropDown</p> <pre><code>final MyDropDown cityDropdown = new MyDropDown(cityLookup); </code></pre> <p>then this is the AppBar (inside a Scaffold) that holds the IconButton I want to press to reset the Dropdown.</p> <pre><code>appBar : new AppBar( title: new Text('Filter Jobs'), actions: &lt;Widget&gt;[ new IconButton( icon: new Icon(Icons.refresh), onPressed: () { print('Reset dropdowns'); //this is where I would call reset() on cityDropdown's state, if I could figure out how to get to it :/ }, ), ], ), </code></pre>
0debug
NameError (global name ... is not defined) when using reload() in Python 2.7 : Unfortunately I get an NameError on reloading a module in Python 2.7. class MyQThread(QtCore.QThread) import myModule def __init__(self, parent=None) super(MyQThread, self).__init__(parent) def run reload(myModule) print("Reloaded") #...do something And when I use `>>>thread = MyQThread()` `>>>thread.start()` I got this in the shell: > NameError: global name 'myModule' is not defined Any advice?
0debug
static int qsort_strcmp(const void *a, const void *b) { return strcmp(a, b); }
1threat
static void pm_reset(void *opaque) { ICH9LPCPMRegs *pm = opaque; ich9_pm_iospace_update(pm, 0); acpi_pm1_evt_reset(&pm->acpi_regs); acpi_pm1_cnt_reset(&pm->acpi_regs); acpi_pm_tmr_reset(&pm->acpi_regs); acpi_gpe_reset(&pm->acpi_regs); pm_update_sci(pm);
1threat
C Code declares expected variable type after function call : <p>Currently I am looking at some C code. The code was created to make a .dll for use in visual basic. As I was going through the usual rigor of linking a new c project in visual studio I came across something I haven't seen before. Here is an example:</p> <pre><code>BOOL WINAPI DLLMain(VEGETABLE Carrot, SOILTYPE Dirt, TOOLTYPE Spade) { return TRUE; } int WINAPI initialize(myVar) char* myVar; { myCalc = do_a_thing(myVar) return myCalc } </code></pre> <p>The declaration of myVar as a char* is really the item in question here. My feeble google attempts haven't shown me anything like what I am seeing here. Is this simply an alternative way to perform type declarations, or is there something more interesting going on here?</p> <p>Thanks!</p>
0debug
static int virtio_rng_load(QEMUFile *f, void *opaque, int version_id) { VirtIORNG *vrng = opaque; VirtIODevice *vdev = VIRTIO_DEVICE(vrng); if (version_id != 1) { return -EINVAL; } virtio_load(vdev, f, version_id); virtio_rng_process(vrng); return 0; }
1threat
static void gic_thiscpu_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { GICState *s = (GICState *)opaque; gic_cpu_write(s, gic_get_current_cpu(s), addr, value); }
1threat
Fetech single record in a table having duplicate values using Linq : I am stuck with below issue. Kindly help [Table structure][1] I want to fetch records as below [ExpectedResults][2] So the address should follow this order Mail Home Work If Mail is present pick the record else if check if Home is present then pick the record and else if check if Work is present then pick that record. [1]: http://i.stack.imgur.com/1MGm6.jpg [2]: http://i.stack.imgur.com/b46Pd.jpg
0debug
Are there any other options to style an html page than css? : <p>Css got pretty much features and has a fair amount of flexibility. Unlike other languages ive never heard of other options to expect the same result. Event js seams to be the only active laguage in html pages. Did i miss anything? Or are there acctually no other options?</p>
0debug
int cpu_x86_handle_mmu_fault(CPUX86State *env, target_ulong addr, int is_write1, int mmu_idx, int is_softmmu) { uint64_t ptep, pte; target_ulong pde_addr, pte_addr; int error_code, is_dirty, prot, page_size, ret, is_write, is_user; target_phys_addr_t paddr; uint32_t page_offset; target_ulong vaddr, virt_addr; is_user = mmu_idx == MMU_USER_IDX; #if defined(DEBUG_MMU) printf("MMU fault: addr=" TARGET_FMT_lx " w=%d u=%d eip=" TARGET_FMT_lx "\n", addr, is_write1, is_user, env->eip); #endif is_write = is_write1 & 1; if (!(env->cr[0] & CR0_PG_MASK)) { pte = addr; virt_addr = addr & TARGET_PAGE_MASK; prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC; page_size = 4096; goto do_mapping; } if (env->cr[4] & CR4_PAE_MASK) { uint64_t pde, pdpe; target_ulong pdpe_addr; #ifdef TARGET_X86_64 if (env->hflags & HF_LMA_MASK) { uint64_t pml4e_addr, pml4e; int32_t sext; sext = (int64_t)addr >> 47; if (sext != 0 && sext != -1) { env->error_code = 0; env->exception_index = EXCP0D_GPF; return 1; } pml4e_addr = ((env->cr[3] & ~0xfff) + (((addr >> 39) & 0x1ff) << 3)) & env->a20_mask; pml4e = ldq_phys(pml4e_addr); if (!(pml4e & PG_PRESENT_MASK)) { error_code = 0; goto do_fault; } if (!(env->efer & MSR_EFER_NXE) && (pml4e & PG_NX_MASK)) { error_code = PG_ERROR_RSVD_MASK; goto do_fault; } if (!(pml4e & PG_ACCESSED_MASK)) { pml4e |= PG_ACCESSED_MASK; stl_phys_notdirty(pml4e_addr, pml4e); } ptep = pml4e ^ PG_NX_MASK; pdpe_addr = ((pml4e & PHYS_ADDR_MASK) + (((addr >> 30) & 0x1ff) << 3)) & env->a20_mask; pdpe = ldq_phys(pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) { error_code = 0; goto do_fault; } if (!(env->efer & MSR_EFER_NXE) && (pdpe & PG_NX_MASK)) { error_code = PG_ERROR_RSVD_MASK; goto do_fault; } ptep &= pdpe ^ PG_NX_MASK; if (!(pdpe & PG_ACCESSED_MASK)) { pdpe |= PG_ACCESSED_MASK; stl_phys_notdirty(pdpe_addr, pdpe); } } else #endif { pdpe_addr = ((env->cr[3] & ~0x1f) + ((addr >> 27) & 0x18)) & env->a20_mask; pdpe = ldq_phys(pdpe_addr); if (!(pdpe & PG_PRESENT_MASK)) { error_code = 0; goto do_fault; } ptep = PG_NX_MASK | PG_USER_MASK | PG_RW_MASK; } pde_addr = ((pdpe & PHYS_ADDR_MASK) + (((addr >> 21) & 0x1ff) << 3)) & env->a20_mask; pde = ldq_phys(pde_addr); if (!(pde & PG_PRESENT_MASK)) { error_code = 0; goto do_fault; } if (!(env->efer & MSR_EFER_NXE) && (pde & PG_NX_MASK)) { error_code = PG_ERROR_RSVD_MASK; goto do_fault; } ptep &= pde ^ PG_NX_MASK; if (pde & PG_PSE_MASK) { page_size = 2048 * 1024; ptep ^= PG_NX_MASK; if ((ptep & PG_NX_MASK) && is_write1 == 2) goto do_fault_protect; if (is_user) { if (!(ptep & PG_USER_MASK)) goto do_fault_protect; if (is_write && !(ptep & PG_RW_MASK)) goto do_fault_protect; } else { if ((env->cr[0] & CR0_WP_MASK) && is_write && !(ptep & PG_RW_MASK)) goto do_fault_protect; } is_dirty = is_write && !(pde & PG_DIRTY_MASK); if (!(pde & PG_ACCESSED_MASK) || is_dirty) { pde |= PG_ACCESSED_MASK; if (is_dirty) pde |= PG_DIRTY_MASK; stl_phys_notdirty(pde_addr, pde); } pte = pde & ((PHYS_ADDR_MASK & ~(page_size - 1)) | 0xfff); virt_addr = addr & ~(page_size - 1); } else { if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_phys_notdirty(pde_addr, pde); } pte_addr = ((pde & PHYS_ADDR_MASK) + (((addr >> 12) & 0x1ff) << 3)) & env->a20_mask; pte = ldq_phys(pte_addr); if (!(pte & PG_PRESENT_MASK)) { error_code = 0; goto do_fault; } if (!(env->efer & MSR_EFER_NXE) && (pte & PG_NX_MASK)) { error_code = PG_ERROR_RSVD_MASK; goto do_fault; } ptep &= pte ^ PG_NX_MASK; ptep ^= PG_NX_MASK; if ((ptep & PG_NX_MASK) && is_write1 == 2) goto do_fault_protect; if (is_user) { if (!(ptep & PG_USER_MASK)) goto do_fault_protect; if (is_write && !(ptep & PG_RW_MASK)) goto do_fault_protect; } else { if ((env->cr[0] & CR0_WP_MASK) && is_write && !(ptep & PG_RW_MASK)) goto do_fault_protect; } is_dirty = is_write && !(pte & PG_DIRTY_MASK); if (!(pte & PG_ACCESSED_MASK) || is_dirty) { pte |= PG_ACCESSED_MASK; if (is_dirty) pte |= PG_DIRTY_MASK; stl_phys_notdirty(pte_addr, pte); } page_size = 4096; virt_addr = addr & ~0xfff; pte = pte & (PHYS_ADDR_MASK | 0xfff); } } else { uint32_t pde; pde_addr = ((env->cr[3] & ~0xfff) + ((addr >> 20) & 0xffc)) & env->a20_mask; pde = ldl_phys(pde_addr); if (!(pde & PG_PRESENT_MASK)) { error_code = 0; goto do_fault; } if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { page_size = 4096 * 1024; if (is_user) { if (!(pde & PG_USER_MASK)) goto do_fault_protect; if (is_write && !(pde & PG_RW_MASK)) goto do_fault_protect; } else { if ((env->cr[0] & CR0_WP_MASK) && is_write && !(pde & PG_RW_MASK)) goto do_fault_protect; } is_dirty = is_write && !(pde & PG_DIRTY_MASK); if (!(pde & PG_ACCESSED_MASK) || is_dirty) { pde |= PG_ACCESSED_MASK; if (is_dirty) pde |= PG_DIRTY_MASK; stl_phys_notdirty(pde_addr, pde); } pte = pde & ~( (page_size - 1) & ~0xfff); ptep = pte; virt_addr = addr & ~(page_size - 1); } else { if (!(pde & PG_ACCESSED_MASK)) { pde |= PG_ACCESSED_MASK; stl_phys_notdirty(pde_addr, pde); } pte_addr = ((pde & ~0xfff) + ((addr >> 10) & 0xffc)) & env->a20_mask; pte = ldl_phys(pte_addr); if (!(pte & PG_PRESENT_MASK)) { error_code = 0; goto do_fault; } ptep = pte & pde; if (is_user) { if (!(ptep & PG_USER_MASK)) goto do_fault_protect; if (is_write && !(ptep & PG_RW_MASK)) goto do_fault_protect; } else { if ((env->cr[0] & CR0_WP_MASK) && is_write && !(ptep & PG_RW_MASK)) goto do_fault_protect; } is_dirty = is_write && !(pte & PG_DIRTY_MASK); if (!(pte & PG_ACCESSED_MASK) || is_dirty) { pte |= PG_ACCESSED_MASK; if (is_dirty) pte |= PG_DIRTY_MASK; stl_phys_notdirty(pte_addr, pte); } page_size = 4096; virt_addr = addr & ~0xfff; } } prot = PAGE_READ; if (!(ptep & PG_NX_MASK)) prot |= PAGE_EXEC; if (pte & PG_DIRTY_MASK) { if (is_user) { if (ptep & PG_RW_MASK) prot |= PAGE_WRITE; } else { if (!(env->cr[0] & CR0_WP_MASK) || (ptep & PG_RW_MASK)) prot |= PAGE_WRITE; } } do_mapping: pte = pte & env->a20_mask; page_offset = (addr & TARGET_PAGE_MASK) & (page_size - 1); paddr = (pte & TARGET_PAGE_MASK) + page_offset; vaddr = virt_addr + page_offset; ret = tlb_set_page_exec(env, vaddr, paddr, prot, mmu_idx, is_softmmu); return ret; do_fault_protect: error_code = PG_ERROR_P_MASK; do_fault: error_code |= (is_write << PG_ERROR_W_BIT); if (is_user) error_code |= PG_ERROR_U_MASK; if (is_write1 == 2 && (env->efer & MSR_EFER_NXE) && (env->cr[4] & CR4_PAE_MASK)) error_code |= PG_ERROR_I_D_MASK; if (env->intercept_exceptions & (1 << EXCP0E_PAGE)) { stq_phys(env->vm_vmcb + offsetof(struct vmcb, control.exit_info_2), addr); } else { env->cr[2] = addr; } env->error_code = error_code; env->exception_index = EXCP0E_PAGE; return 1; }
1threat
int ff_hevc_decode_extradata(const uint8_t *data, int size, HEVCParamSets *ps, int *is_nalff, int *nal_length_size, int err_recognition, void *logctx) { int ret = 0; GetByteContext gb; bytestream2_init(&gb, data, size); if (size > 3 && (data[0] || data[1] || data[2] > 1)) { int i, j, num_arrays, nal_len_size; *is_nalff = 1; bytestream2_skip(&gb, 21); nal_len_size = (bytestream2_get_byte(&gb) & 3) + 1; num_arrays = bytestream2_get_byte(&gb); *nal_length_size = 2; for (i = 0; i < num_arrays; i++) { int type = bytestream2_get_byte(&gb) & 0x3f; int cnt = bytestream2_get_be16(&gb); for (j = 0; j < cnt; j++) { int nalsize = bytestream2_peek_be16(&gb) + 2; if (bytestream2_get_bytes_left(&gb) < nalsize) { av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit size in extradata.\n"); return AVERROR_INVALIDDATA; } ret = hevc_decode_nal_units(gb.buffer, nalsize, ps, *is_nalff, *nal_length_size, logctx); if (ret < 0) { av_log(logctx, AV_LOG_ERROR, "Decoding nal unit %d %d from hvcC failed\n", type, i); return ret; } bytestream2_skip(&gb, nalsize); } } *nal_length_size = nal_len_size; } else { *is_nalff = 0; ret = hevc_decode_nal_units(data, size, ps, *is_nalff, *nal_length_size, logctx); if (ret < 0) return ret; } return ret; }
1threat
SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv, int unit, bool removable, int bootindex, const char *serial, Error **errp) { const char *driver; DeviceState *dev; Error *err = NULL; driver = bdrv_is_sg(bdrv) ? "scsi-generic" : "scsi-disk"; dev = qdev_create(&bus->qbus, driver); qdev_prop_set_uint32(dev, "scsi-id", unit); if (bootindex >= 0) { qdev_prop_set_int32(dev, "bootindex", bootindex); } if (object_property_find(OBJECT(dev), "removable", NULL)) { qdev_prop_set_bit(dev, "removable", removable); } if (serial) { qdev_prop_set_string(dev, "serial", serial); } if (qdev_prop_set_drive(dev, "drive", bdrv) < 0) { error_setg(errp, "Setting drive property failed"); qdev_free(dev); return NULL; } object_property_set_bool(OBJECT(dev), true, "realized", &err); if (err != NULL) { error_propagate(errp, err); qdev_free(dev); return NULL; } return SCSI_DEVICE(dev); }
1threat
Cannot debug serverless application in Visual Studio Code : <p>I have tried to debug serverless application developed using serverless framework in VS code. I have followed <a href="http://networkfights.com/2017/07/27/running-and-debugging-aws-lambda-functions-locally-with-the-serverless-framework-and-vs-code/" rel="noreferrer">this</a> article. </p> <p>But when I trying to debug the code I'm getting an error from VS code as below.</p> <p>Cannot launch program 'g:\Projects\Serverless1\node_modules.bin\sls'; setting the 'outDir or outFiles' attribute might help.</p> <p>sls command file already exists in the folder and following are the launch.json file settings</p> <pre><code>"version": "0.2.0", "configurations": [ { "type": "node", "request": "launch", "protocol": "inspector", "name": "run hello function", "program": "${workspaceRoot}\\node_modules\\.bin\\sls", "args": [ "invoke", "local", "-f", "hello", "--data", "{}" ] } ] </code></pre> <p>Please help me to fix this issue.</p>
0debug
how to remove wight spaces from the output of the following python script? : for i in range(1,4): print i, Output is 1 2 3, but i want the output like 123 i.e without spaces. so how to do it?
0debug
static int dirac_decode_frame_internal(DiracContext *s) { DWTContext d; int y, i, comp, dsty; if (s->low_delay) { for (comp = 0; comp < 3; comp++) { Plane *p = &s->plane[comp]; memset(p->idwt_buf, 0, p->idwt_stride * p->idwt_height * sizeof(IDWTELEM)); } if (!s->zero_res) decode_lowdelay(s); } for (comp = 0; comp < 3; comp++) { Plane *p = &s->plane[comp]; uint8_t *frame = s->current_picture->avframe->data[comp]; for (i = 0; i < 4; i++) s->edge_emu_buffer[i] = s->edge_emu_buffer_base + i*FFALIGN(p->width, 16); if (!s->zero_res && !s->low_delay) { memset(p->idwt_buf, 0, p->idwt_stride * p->idwt_height * sizeof(IDWTELEM)); decode_component(s, comp); } if (ff_spatial_idwt_init2(&d, p->idwt_buf, p->idwt_width, p->idwt_height, p->idwt_stride, s->wavelet_idx+2, s->wavelet_depth, p->idwt_tmp)) return -1; if (!s->num_refs) { for (y = 0; y < p->height; y += 16) { ff_spatial_idwt_slice2(&d, y+16); s->diracdsp.put_signed_rect_clamped(frame + y*p->stride, p->stride, p->idwt_buf + y*p->idwt_stride, p->idwt_stride, p->width, 16); } } else { int rowheight = p->ybsep*p->stride; select_dsp_funcs(s, p->width, p->height, p->xblen, p->yblen); for (i = 0; i < s->num_refs; i++) interpolate_refplane(s, s->ref_pics[i], comp, p->width, p->height); memset(s->mctmp, 0, 4*p->yoffset*p->stride); dsty = -p->yoffset; for (y = 0; y < s->blheight; y++) { int h = 0, start = FFMAX(dsty, 0); uint16_t *mctmp = s->mctmp + y*rowheight; DiracBlock *blocks = s->blmotion + y*s->blwidth; init_obmc_weights(s, p, y); if (y == s->blheight-1 || start+p->ybsep > p->height) h = p->height - start; else h = p->ybsep - (start - dsty); if (h < 0) break; memset(mctmp+2*p->yoffset*p->stride, 0, 2*rowheight); mc_row(s, blocks, mctmp, comp, dsty); mctmp += (start - dsty)*p->stride + p->xoffset; ff_spatial_idwt_slice2(&d, start + h); s->diracdsp.add_rect_clamped(frame + start*p->stride, mctmp, p->stride, p->idwt_buf + start*p->idwt_stride, p->idwt_stride, p->width, h); dsty += p->ybsep; } } } return 0; }
1threat
Prevent pandas from reading "NA" as NaN : <p>The .csv-file I'm reading from contains cells with the value "NA". Pandas automatically converts these into NaN, which I don't want. I'm aware of the <code>keep_default_na=False</code> parameter, but that changes the dtype of the columns to <code>object</code> which means <code>pd.get_dummies</code> doesn't work correctly.</p> <p>Is there any way to prevent pandas from reading "NA" as NaN without changing the dtype?</p>
0debug
Start resolution for result in a fragment : <p>In my app if the user doesn't have the location turned on I am prompting with a dialog and then trying to return that result (probably incorrectly) by overriding on activity result.</p> <p>This is inside a fragment so not sure how that changes things:</p> <p>This is how I am calling it the dialog with startResolutionForResult:</p> <pre><code>public void checkDeviceLocationIsOn() { System.out.println("Test running setting request" ); LocationRequest locationRequest = LocationRequest.create(); locationRequest.setPriority(LocationRequest.PRIORITY_LOW_POWER); LocationSettingsRequest.Builder builder = new LocationSettingsRequest.Builder() .addLocationRequest(locationRequest); builder.setAlwaysShow(true); //this is the key ingredient PendingResult&lt;LocationSettingsResult&gt; result = LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, builder.build()); result.setResultCallback(new ResultCallback&lt;LocationSettingsResult&gt;() { @Override public void onResult(LocationSettingsResult result) { final Status status = result.getStatus(); final LocationSettingsStates state = result.getLocationSettingsStates(); switch (status.getStatusCode()) { case LocationSettingsStatusCodes.SUCCESS: // All location settings are satisfied. System.out.println("Test setting all fine starting location request" ); getLocation(); break; case LocationSettingsStatusCodes.RESOLUTION_REQUIRED: // Location settings are not satisfied. But could be fixed by showing the user // a dialog. try { // Show the dialog by calling startResolutionForResult(), // and check the result in onActivityResult(). status.startResolutionForResult(getActivity(), LOCATION_SETTINGS_REQUEST_CODE); System.out.println("Test setting not met starting dialog to prompt user" ); } catch (IntentSender.SendIntentException e) { // Ignore the error. } break; case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE: // Location settings are not satisfied. However, we have no way to fix the // settings so we won't show the dialog. break; } } }); } </code></pre> <p>And then I try to get the result like this below it (This never gets called):</p> <pre><code> @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { // Check for the integer request code originally supplied to startResolutionForResult(). case LOCATION_SETTINGS_REQUEST_CODE: switch (resultCode) { case Activity.RESULT_OK: System.out.println("test user has turned the gps back on"); getLocation(); break; case Activity.RESULT_CANCELED: System.out.println("test user has denied the gps to be turned on"); Toast.makeText(getActivity(), "Location is required to order stations", Toast.LENGTH_SHORT).show(); break; } break; } } </code></pre> <p>Thanks in advance for your help</p>
0debug
static void x86_cpu_realizefn(DeviceState *dev, Error **errp) { CPUState *cs = CPU(dev); X86CPU *cpu = X86_CPU(dev); X86CPUClass *xcc = X86_CPU_GET_CLASS(dev); CPUX86State *env = &cpu->env; Error *local_err = NULL; static bool ht_warned; if (xcc->kvm_required && !kvm_enabled()) { char *name = x86_cpu_class_get_model_name(xcc); error_setg(&local_err, "CPU model '%s' requires KVM", name); g_free(name); goto out; } if (cpu->apic_id == UNASSIGNED_APIC_ID) { error_setg(errp, "apic-id property was not initialized properly"); return; } x86_cpu_expand_features(cpu, &local_err); if (local_err) { goto out; } if (x86_cpu_filter_features(cpu) && (cpu->check_cpuid || cpu->enforce_cpuid)) { x86_cpu_report_filtered_features(cpu); if (cpu->enforce_cpuid) { error_setg(&local_err, kvm_enabled() ? "Host doesn't support requested features" : "TCG doesn't support requested features"); goto out; } } if (IS_AMD_CPU(env)) { env->features[FEAT_8000_0001_EDX] &= ~CPUID_EXT2_AMD_ALIASES; env->features[FEAT_8000_0001_EDX] |= (env->features[FEAT_1_EDX] & CPUID_EXT2_AMD_ALIASES); } if (env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM) { if (kvm_enabled()) { uint32_t host_phys_bits = x86_host_phys_bits(); static bool warned; if (cpu->host_phys_bits) { cpu->phys_bits = host_phys_bits; } if (cpu->phys_bits != host_phys_bits && cpu->phys_bits != 0 && !warned) { error_report("Warning: Host physical bits (%u)" " does not match phys-bits property (%u)", host_phys_bits, cpu->phys_bits); warned = true; } if (cpu->phys_bits && (cpu->phys_bits > TARGET_PHYS_ADDR_SPACE_BITS || cpu->phys_bits < 32)) { error_setg(errp, "phys-bits should be between 32 and %u " " (but is %u)", TARGET_PHYS_ADDR_SPACE_BITS, cpu->phys_bits); return; } } else { if (cpu->phys_bits && cpu->phys_bits != TCG_PHYS_ADDR_BITS) { error_setg(errp, "TCG only supports phys-bits=%u", TCG_PHYS_ADDR_BITS); return; } } if (cpu->phys_bits == 0) { cpu->phys_bits = TCG_PHYS_ADDR_BITS; } } else { if (cpu->phys_bits != 0) { error_setg(errp, "phys-bits is not user-configurable in 32 bit"); return; } if (env->features[FEAT_1_EDX] & CPUID_PSE36) { cpu->phys_bits = 36; } else { cpu->phys_bits = 32; } } cpu_exec_realizefn(cs, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); return; } if (tcg_enabled()) { tcg_x86_init(); } #ifndef CONFIG_USER_ONLY qemu_register_reset(x86_cpu_machine_reset_cb, cpu); if (cpu->env.features[FEAT_1_EDX] & CPUID_APIC || smp_cpus > 1) { x86_cpu_apic_create(cpu, &local_err); if (local_err != NULL) { goto out; } } #endif mce_init(cpu); #ifndef CONFIG_USER_ONLY if (tcg_enabled()) { AddressSpace *as_normal = address_space_init_shareable(cs->memory, "cpu-memory"); AddressSpace *as_smm = g_new(AddressSpace, 1); cpu->cpu_as_mem = g_new(MemoryRegion, 1); cpu->cpu_as_root = g_new(MemoryRegion, 1); memory_region_init(cpu->cpu_as_root, OBJECT(cpu), "memory", ~0ull); memory_region_set_enabled(cpu->cpu_as_root, true); memory_region_init_alias(cpu->cpu_as_mem, OBJECT(cpu), "memory", get_system_memory(), 0, ~0ull); memory_region_add_subregion_overlap(cpu->cpu_as_root, 0, cpu->cpu_as_mem, 0); memory_region_set_enabled(cpu->cpu_as_mem, true); address_space_init(as_smm, cpu->cpu_as_root, "CPU"); cs->num_ases = 2; cpu_address_space_init(cs, as_normal, 0); cpu_address_space_init(cs, as_smm, 1); cpu->machine_done.notify = x86_cpu_machine_done; qemu_add_machine_init_done_notifier(&cpu->machine_done); } #endif qemu_init_vcpu(cs); if (!IS_INTEL_CPU(env) && cs->nr_threads > 1 && !ht_warned) { error_report("AMD CPU doesn't support hyperthreading. Please configure" " -smp options properly."); ht_warned = true; } x86_cpu_apic_realize(cpu, &local_err); if (local_err != NULL) { goto out; } cpu_reset(cs); xcc->parent_realize(dev, &local_err); out: if (local_err != NULL) { error_propagate(errp, local_err); return; } }
1threat
static bool hyperv_enabled(X86CPU *cpu) { CPUState *cs = CPU(cpu); return kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV) > 0 && (hyperv_hypercall_available(cpu) || cpu->hyperv_time || cpu->hyperv_relaxed_timing); }
1threat
ivshmem_client_handle_server_msg(IvshmemClient *client) { IvshmemClientPeer *peer; long peer_id; int ret, fd; ret = ivshmem_client_read_one_msg(client, &peer_id, &fd); if (ret < 0) { peer = ivshmem_client_search_peer(client, peer_id); if (fd == -1) { if (peer == NULL || peer == &client->local) { IVSHMEM_CLIENT_DEBUG(client, "receive delete for invalid " "peer %ld\n", peer_id); IVSHMEM_CLIENT_DEBUG(client, "delete peer id = %ld\n", peer_id); ivshmem_client_free_peer(client, peer); return 0; if (peer == NULL) { peer = g_malloc0(sizeof(*peer)); peer->id = peer_id; peer->vectors_count = 0; QTAILQ_INSERT_TAIL(&client->peer_list, peer, next); IVSHMEM_CLIENT_DEBUG(client, "new peer id = %ld\n", peer_id); IVSHMEM_CLIENT_DEBUG(client, " new vector %d (fd=%d) for peer id %ld\n", peer->vectors_count, fd, peer->id); peer->vectors[peer->vectors_count] = fd; peer->vectors_count++; return 0;
1threat
how to format date in Component of angular 5 : <p>I am new to angular and looking to format date in component ngOnInit method. I have seen some example where pipe operator are used to format the data but i dont know how to format date in component file.</p> <p>below is code </p> <pre><code>export class DashboardComponent implements OnInit { formatdate = 'dd/MM/yyyy'; constructor(private auth: AuthService) { } ngOnInit() { console.log(new Date().toISOString()) } } </code></pre>
0debug
read data from list of tuples without paranthesis in python 2.7 : list = [(u'SFG2',), (u'FG2',), (u'FG3',), (u'SFG1',), (u'RM1',), (u'RM2',), (u'RM3',), (u'FG1',)] expected o/p: u'SFG2' u'FG2' u'FG3'
0debug
Using a map to find subarray with given sum (with negative numbers) : <p>Consider the following problem statement:</p> <blockquote> <p>Given an unsorted array of integers, find a subarray which adds to a given number. If there are more than one subarrays with sum as the given number, print any of them.</p> </blockquote> <pre><code>Examples: Input: arr[] = {1, 4, 20, 3, 10, 5}, sum = 33 Ouptut: Sum found between indexes 2 and 4 Input: arr[] = {10, 2, -2, -20, 10}, sum = -10 Ouptut: Sum found between indexes 0 to 3 Input: arr[] = {-10, 0, 2, -2, -20, 10}, sum = 20 Ouptut: No subarray with given sum exists </code></pre> <p>On this <a href="http://www.geeksforgeeks.org/find-subarray-with-given-sum-in-array-of-integers/" rel="noreferrer">site</a>, the following linear time solution was suggested involving the use of a map to store the sums of the current subsets as the algorithm iterates through the array:</p> <pre><code>// Function to print subarray with sum as given sum void subArraySum(int arr[], int n, int sum) { // create an empty map unordered_map&lt;int, int&gt; map; // Maintains sum of elements so far int curr_sum = 0; for (int i = 0; i &lt; n; i++) { // add current element to curr_sum curr_sum = curr_sum + arr[i]; // if curr_sum is equal to target sum // we found a subarray starting from index 0 // and ending at index i if (curr_sum == sum) { cout &lt;&lt; "Sum found between indexes " &lt;&lt; 0 &lt;&lt; " to " &lt;&lt; i &lt;&lt; endl; return; } // If curr_sum - sum already exists in map // we have found a subarray with target sum if (map.find(curr_sum - sum) != map.end()) { cout &lt;&lt; "Sum found between indexes " &lt;&lt; map[curr_sum - sum] + 1 &lt;&lt; " to " &lt;&lt; i &lt;&lt; endl; return; } map[curr_sum] = i; } // If we reach here, then no subarray exists cout &lt;&lt; "No subarray with given sum exists"; } // Driver program to test above function int main() { int arr[] = {10, 2, -2, -20, 10}; int n = sizeof(arr)/sizeof(arr[0]); int sum = -10; subArraySum(arr, n, sum); return 0; } </code></pre> <p>With the test case that is provided in the post, the second if statement checking whether current_sum - sum is never entered. Instead, the sum is found and is printed in the first if statement. <strong>So there a few points of confusion here</strong>:</p> <p><strong>1: What is the purpose of looking up <code>current_sum-sum</code> in the map?</strong></p> <p><strong>2: In which cases would the second if statement even be entered to put the map to use in solving the problem?</strong></p>
0debug
Size of the request headers is too long : <p>I'm currently working on an ASP.NET MVC website and it works fine. </p> <p>But I have a problem that I don't understand at all... When I launch my website on Visual Studio with Chrome for example no problem, but when I stop it and try to launch an other test with Firefox for example, my url is growing and then I get this error : </p> <blockquote> <p>HTTP 400. The size of the request headers is too long.</p> </blockquote> <p>Can someone explain me why this is happening ? Is it something with my code or does it come from IIS express or anything else ?</p> <p>Thanks in advance</p>
0debug
How to wrap checked exceptions but keep the original runtime exceptions in Java : <p>I have some code that might throw both checked and runtime exceptions.</p> <p>I'd like to catch the checked exception and wrap it with a runtime exception. But if a RuntimeException is thrown, I don't have to wrap it as it's already a runtime exception.</p> <p>The solution I have has a bit overhead and isn't "neat":</p> <pre><code>try { // some code that can throw both checked and runtime exception } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException(e); } </code></pre> <p><strong>Any idea for a more elegant way?</strong></p>
0debug
how to create HDFS for a text file in apache spark : this is the first time i deal with big data and use cluster. In order to distribute the bytes among the slaves nodes i read that it is easy to use the HDFS with apache spark. how to create HDFS?
0debug
static int audio_decode_frame(VideoState *is) { AVPacket *pkt_temp = &is->audio_pkt_temp; AVPacket *pkt = &is->audio_pkt; AVCodecContext *dec = is->audio_st->codec; int len1, data_size, resampled_data_size; int64_t dec_channel_layout; int got_frame; av_unused double audio_clock0; int new_packet = 0; int flush_complete = 0; int wanted_nb_samples; AVRational tb; int ret; int reconfigure; for (;;) { while (pkt_temp->size > 0 || (!pkt_temp->data && new_packet) || is->audio_buf_frames_pending) { if (!is->frame) { if (!(is->frame = avcodec_alloc_frame())) return AVERROR(ENOMEM); } else { av_frame_unref(is->frame); avcodec_get_frame_defaults(is->frame); } if (is->audioq.serial != is->audio_pkt_temp_serial) break; if (is->paused) return -1; if (!is->audio_buf_frames_pending) { if (flush_complete) break; new_packet = 0; len1 = avcodec_decode_audio4(dec, is->frame, &got_frame, pkt_temp); if (len1 < 0) { pkt_temp->size = 0; break; } pkt_temp->data += len1; pkt_temp->size -= len1; if (!got_frame) { if (!pkt_temp->data && dec->codec->capabilities & CODEC_CAP_DELAY) flush_complete = 1; continue; } tb = (AVRational){1, is->frame->sample_rate}; if (is->frame->pts != AV_NOPTS_VALUE) is->frame->pts = av_rescale_q(is->frame->pts, dec->time_base, tb); else if (is->frame->pkt_pts != AV_NOPTS_VALUE) is->frame->pts = av_rescale_q(is->frame->pkt_pts, is->audio_st->time_base, tb); if (pkt_temp->pts != AV_NOPTS_VALUE) pkt_temp->pts += (double) is->frame->nb_samples / is->frame->sample_rate / av_q2d(is->audio_st->time_base); #if CONFIG_AVFILTER dec_channel_layout = get_valid_channel_layout(is->frame->channel_layout, av_frame_get_channels(is->frame)); reconfigure = cmp_audio_fmts(is->audio_filter_src.fmt, is->audio_filter_src.channels, is->frame->format, av_frame_get_channels(is->frame)) || is->audio_filter_src.channel_layout != dec_channel_layout || is->audio_filter_src.freq != is->frame->sample_rate || is->audio_pkt_temp_serial != is->audio_last_serial; if (reconfigure) { char buf1[1024], buf2[1024]; av_get_channel_layout_string(buf1, sizeof(buf1), -1, is->audio_filter_src.channel_layout); av_get_channel_layout_string(buf2, sizeof(buf2), -1, dec_channel_layout); av_log(NULL, AV_LOG_DEBUG, "Audio frame changed from rate:%d ch:%d fmt:%s layout:%s serial:%d to rate:%d ch:%d fmt:%s layout:%s serial:%d\n", is->audio_filter_src.freq, is->audio_filter_src.channels, av_get_sample_fmt_name(is->audio_filter_src.fmt), buf1, is->audio_last_serial, is->frame->sample_rate, av_frame_get_channels(is->frame), av_get_sample_fmt_name(is->frame->format), buf2, is->audio_pkt_temp_serial); is->audio_filter_src.fmt = is->frame->format; is->audio_filter_src.channels = av_frame_get_channels(is->frame); is->audio_filter_src.channel_layout = dec_channel_layout; is->audio_filter_src.freq = is->frame->sample_rate; is->audio_last_serial = is->audio_pkt_temp_serial; if ((ret = configure_audio_filters(is, afilters, 1)) < 0) return ret; } if ((ret = av_buffersrc_add_frame(is->in_audio_filter, is->frame)) < 0) return ret; av_frame_unref(is->frame); #endif } #if CONFIG_AVFILTER if ((ret = av_buffersink_get_frame_flags(is->out_audio_filter, is->frame, 0)) < 0) { if (ret == AVERROR(EAGAIN)) { is->audio_buf_frames_pending = 0; continue; } return ret; } is->audio_buf_frames_pending = 1; tb = is->out_audio_filter->inputs[0]->time_base; #endif data_size = av_samples_get_buffer_size(NULL, av_frame_get_channels(is->frame), is->frame->nb_samples, is->frame->format, 1); dec_channel_layout = (is->frame->channel_layout && av_frame_get_channels(is->frame) == av_get_channel_layout_nb_channels(is->frame->channel_layout)) ? is->frame->channel_layout : av_get_default_channel_layout(av_frame_get_channels(is->frame)); wanted_nb_samples = synchronize_audio(is, is->frame->nb_samples); if (is->frame->format != is->audio_src.fmt || dec_channel_layout != is->audio_src.channel_layout || is->frame->sample_rate != is->audio_src.freq || (wanted_nb_samples != is->frame->nb_samples && !is->swr_ctx)) { swr_free(&is->swr_ctx); is->swr_ctx = swr_alloc_set_opts(NULL, is->audio_tgt.channel_layout, is->audio_tgt.fmt, is->audio_tgt.freq, dec_channel_layout, is->frame->format, is->frame->sample_rate, 0, NULL); if (!is->swr_ctx || swr_init(is->swr_ctx) < 0) { av_log(NULL, AV_LOG_ERROR, "Cannot create sample rate converter for conversion of %d Hz %s %d channels to %d Hz %s %d channels!\n", is->frame->sample_rate, av_get_sample_fmt_name(is->frame->format), av_frame_get_channels(is->frame), is->audio_tgt.freq, av_get_sample_fmt_name(is->audio_tgt.fmt), is->audio_tgt.channels); break; } is->audio_src.channel_layout = dec_channel_layout; is->audio_src.channels = av_frame_get_channels(is->frame); is->audio_src.freq = is->frame->sample_rate; is->audio_src.fmt = is->frame->format; } if (is->swr_ctx) { const uint8_t **in = (const uint8_t **)is->frame->extended_data; uint8_t **out = &is->audio_buf1; int out_count = (int64_t)wanted_nb_samples * is->audio_tgt.freq / is->frame->sample_rate + 256; int out_size = av_samples_get_buffer_size(NULL, is->audio_tgt.channels, out_count, is->audio_tgt.fmt, 0); int len2; if (out_size < 0) { av_log(NULL, AV_LOG_ERROR, "av_samples_get_buffer_size() failed\n"); break; } if (wanted_nb_samples != is->frame->nb_samples) { if (swr_set_compensation(is->swr_ctx, (wanted_nb_samples - is->frame->nb_samples) * is->audio_tgt.freq / is->frame->sample_rate, wanted_nb_samples * is->audio_tgt.freq / is->frame->sample_rate) < 0) { av_log(NULL, AV_LOG_ERROR, "swr_set_compensation() failed\n"); break; } } av_fast_malloc(&is->audio_buf1, &is->audio_buf1_size, out_size); if (!is->audio_buf1) return AVERROR(ENOMEM); len2 = swr_convert(is->swr_ctx, out, out_count, in, is->frame->nb_samples); if (len2 < 0) { av_log(NULL, AV_LOG_ERROR, "swr_convert() failed\n"); break; } if (len2 == out_count) { av_log(NULL, AV_LOG_WARNING, "audio buffer is probably too small\n"); swr_init(is->swr_ctx); } is->audio_buf = is->audio_buf1; resampled_data_size = len2 * is->audio_tgt.channels * av_get_bytes_per_sample(is->audio_tgt.fmt); } else { is->audio_buf = is->frame->data[0]; resampled_data_size = data_size; } audio_clock0 = is->audio_clock; if (is->frame->pts != AV_NOPTS_VALUE) is->audio_clock = is->frame->pts * av_q2d(tb) + (double) is->frame->nb_samples / is->frame->sample_rate; else is->audio_clock = NAN; is->audio_clock_serial = is->audio_pkt_temp_serial; #ifdef DEBUG { static double last_clock; printf("audio: delay=%0.3f clock=%0.3f clock0=%0.3f\n", is->audio_clock - last_clock, is->audio_clock, audio_clock0); last_clock = is->audio_clock; } #endif return resampled_data_size; } if (pkt->data) av_free_packet(pkt); memset(pkt_temp, 0, sizeof(*pkt_temp)); if (is->audioq.abort_request) { return -1; } if (is->audioq.nb_packets == 0) SDL_CondSignal(is->continue_read_thread); if ((new_packet = packet_queue_get(&is->audioq, pkt, 1, &is->audio_pkt_temp_serial)) < 0) return -1; if (pkt->data == flush_pkt.data) { avcodec_flush_buffers(dec); flush_complete = 0; is->audio_buf_frames_pending = 0; } *pkt_temp = *pkt; } }
1threat
issues with unsigned long long and printing c++ : <p>I'm a begginer in coding and I'm trying to solve a problem. I need variables that can get to about 22 digits so I used unsigned long long. However there's an issue.</p> <pre><code>unsigned long long n; fin&gt;&gt;n; unsigned long long cn=n+1; n++; fout&lt;&lt;n&lt;&lt;" "; fout&lt;&lt;cn; </code></pre> <p>fin and fout are the commands I use to enter and print a variable.</p> <p>for example, let's say n is 99 so I should see "100 100" but all i see is "100". Why does this happen?</p>
0debug
Quiz app to pick questions from 8 group of questions randomly? swift - json : I build an application for iOS and i want it to pick questions from 8 different groups of questions and randomly. The number of questions is 356 and only 50 of them must be picked randomly. 1. 8 questions from 1st group 2. 5 questions from 2nd group 3. 5 questions from 3rd group 4. 6 questions from 4th group 5. 6 questions from 5th group 6. 5 questions from 6th group 7. 9 questions from 7th group 8. 6 questions from 8th group **Total: 50 questions.** What i did is that, i build the quiz, but it reads all the questions and shows them to the user. The questions are read from a .json file. **Here is my code:** import UIKit struct Question { var Question: String! var Answers: [String]! var Answer: Int! init(item: [String: Any]) { self.Question = item["Question"] as? String self.Answers = item["Answers"] as? [String] self.Answer = item["Answer"] as? Int } } class LittleTestViewController: UIViewController { //MARK: Properties @IBOutlet weak var questionLabel: UILabel! @IBOutlet var buttons: [UIButton]! var Questions = [Question]() var QNumber = Int() var answerNumber = Int() override func viewDidLoad() { super.viewDidLoad() jsonParsingQuestionsFile() pickQuestion() } func jsonParsingQuestionsFile () { guard let path = Bundle.main.path(forResource: "data", ofType: "json"), let array = (try? JSONSerialization.jsonObject(with: Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe), options: JSONSerialization.ReadingOptions.allowFragments)) as? [[String : Any]] else{ return } for item in array { self.Questions.append(Question(item: item)) } } func pickQuestion () { if Questions.count > 0 { QNumber = 0 questionLabel.text = Questions[QNumber].Question answerNumber = Questions[QNumber].Answer for i in 0..<buttons.count{ buttons[i].setTitle(Questions[QNumber].Answers[i], for: UIControlState.normal) } Questions.remove(at: QNumber) } else { print ("End") } } @IBAction func btn1(_ sender: UIButton){ Unhide() if answerNumber == 0 { print ("Correct!!") } else { } } @IBAction func btn2(_ sender: UIButton) { Unhide() if answerNumber == 1 { print ("Correct!!") } else { } } @IBAction func btn3(_ sender: UIButton) { Unhide() if answerNumber == 2 { print ("Correct!!") } else { } } @IBAction func btn4(_ sender: UIButton) { Unhide() if answerNumber == 3 { print ("Correct!!") } else { } } } **data.json** [ {"Question":"Group 1. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 2}, {"Question":"Group 1. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 2}, {"Question":"Group 1. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 3}, {"Question":"Group 2. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 2}, {"Question":"Group 2. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 1}, {"Question":"Group 2. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 2}, {"Question":"Group 3. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 2}, {"Question":"Group 3. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 2}, {"Question":"Group 4. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 2}, {"Question":"Group 4. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 3}, {"Question":"Group 4. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 2}, {"Question":"Group 5. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 0}, {"Question":"Group 5. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 2}, {"Question":"Group 6. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 0}, {"Question":"Group 7. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 2}, {"Question":"Group 8. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 0}, {"Question":"Group 8. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 1}, {"Question":"Group 9. lalala?", "Answers":["lala","trtr","asas","bbbb"],"Answer": 2},] > This .json file is just an example there are more questions for every > group. Every group has about 45 questions.
0debug
static void ff_id3v2_parse(AVFormatContext *s, int len, uint8_t version, uint8_t flags, ID3v2ExtraMeta **extra_meta) { int isv34, tlen, unsync; char tag[5]; int64_t next, end = avio_tell(s->pb) + len; int taghdrlen; const char *reason = NULL; AVIOContext pb; AVIOContext *pbx; unsigned char *buffer = NULL; int buffer_size = 0; void (*extra_func)(AVFormatContext*, AVIOContext*, int, char*, ID3v2ExtraMeta**) = NULL; switch (version) { case 2: if (flags & 0x40) { reason = "compression"; goto error; } isv34 = 0; taghdrlen = 6; break; case 3: case 4: isv34 = 1; taghdrlen = 10; break; default: reason = "version"; goto error; } unsync = flags & 0x80; if (isv34 && flags & 0x40) avio_skip(s->pb, get_size(s->pb, 4)); while (len >= taghdrlen) { unsigned int tflags = 0; int tunsync = 0; if (isv34) { avio_read(s->pb, tag, 4); tag[4] = 0; if(version==3){ tlen = avio_rb32(s->pb); }else tlen = get_size(s->pb, 4); tflags = avio_rb16(s->pb); tunsync = tflags & ID3v2_FLAG_UNSYNCH; } else { avio_read(s->pb, tag, 3); tag[3] = 0; tlen = avio_rb24(s->pb); } if (tlen < 0 || tlen > len - taghdrlen) { av_log(s, AV_LOG_WARNING, "Invalid size in frame %s, skipping the rest of tag.\n", tag); break; } len -= taghdrlen + tlen; next = avio_tell(s->pb) + tlen; if (!tlen) { if (tag[0]) av_log(s, AV_LOG_DEBUG, "Invalid empty frame %s, skipping.\n", tag); continue; } if (tflags & ID3v2_FLAG_DATALEN) { avio_rb32(s->pb); tlen -= 4; } if (tflags & (ID3v2_FLAG_ENCRYPTION | ID3v2_FLAG_COMPRESSION)) { av_log(s, AV_LOG_WARNING, "Skipping encrypted/compressed ID3v2 frame %s.\n", tag); avio_skip(s->pb, tlen); } else if (tag[0] == 'T' || (extra_meta && (extra_func = get_extra_meta_func(tag, isv34)->read))) { if (unsync || tunsync) { int i, j; av_fast_malloc(&buffer, &buffer_size, tlen); if (!buffer) { av_log(s, AV_LOG_ERROR, "Failed to alloc %d bytes\n", tlen); goto seek; } for (i = 0, j = 0; i < tlen; i++, j++) { buffer[j] = avio_r8(s->pb); if (j > 0 && !buffer[j] && buffer[j - 1] == 0xff) { j--; } } ffio_init_context(&pb, buffer, j, 0, NULL, NULL, NULL, NULL); tlen = j; pbx = &pb; } else { pbx = s->pb; } if (tag[0] == 'T') read_ttag(s, pbx, tlen, tag); else extra_func(s, pbx, tlen, tag, extra_meta); } else if (!tag[0]) { if (tag[1]) av_log(s, AV_LOG_WARNING, "invalid frame id, assuming padding"); avio_skip(s->pb, tlen); break; } seek: avio_seek(s->pb, next, SEEK_SET); } if (version == 4 && flags & 0x10) end += 10; error: if (reason) av_log(s, AV_LOG_INFO, "ID3v2.%d tag skipped, cannot handle %s\n", version, reason); avio_seek(s->pb, end, SEEK_SET); av_free(buffer); return; }
1threat
constexpr error but const fine : [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/cvPIv.png What the difference of those two?Why constexpr failed?
0debug
How do I listen to onClick events for a Bootstrap modal button using JQuery? : <p>I have this JavaScript, but the event is never firing. </p> <pre><code>jQuery(function() { $('#emailButton').click(function() { console.log("emailButton()..."); </code></pre> <p>The HTML is </p> <pre><code>&lt;button type="button" class="btn btn-default" title="Email Page to a Friend" data-toggle="modal" data-target="#emailModal" id="#emailButton"&gt; </code></pre> <p>The modal pops up, but the click handler isn't working. Nothing shows up in the console. Here is a jsFiddle: <a href="https://jsfiddle.net/y59qys4j/8/" rel="nofollow">https://jsfiddle.net/y59qys4j/8/</a></p>
0debug
static void qapi_dealloc_type_str(Visitor *v, char **obj, const char *name, Error **errp) { g_free(*obj); }
1threat
MATLAB sort file lines by fisrt word : I have a file like in this format : 22 BLBL asas saaa212 x:12 y:123 66 BLadsBL asas saaa212 x:12 y:123 32 BLadsBL asas saaa212 x:13212 y:123 66 BLadsBL asas saaa212 x:1332 y:123 How would one create a new file with those lines sorted by the first value? Preferred in MATLAB
0debug
How to migrate an odoo 11 app to odoo 12 successfully? : <p>What are the steps ? In my case i need to migrate the hotel management app to odoo 12 git. </p> <p><strong><em><a href="https://github.com/athulvMkRz/vertical-hotel.git" rel="nofollow noreferrer">click here for the git repository of vertical hotel</a></em></strong></p>
0debug
FabricElementNotFoundException: Application type and version not found : <p>An unhandled exception occurred while processing the request. COMException: Exception from HRESULT: 0x80071BDA System.Fabric.Interop.NativeClient+IFabricApplicationManagementClient10.EndCreateApplication(IFabricAsyncOperationContext context)</p> <p>FabricElementNotFoundException: Application type and version not found System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()</p> <p>Stack Query Cookies Headers COMException: Exception from HRESULT: 0x80071BDA System.Fabric.Interop.NativeClient+IFabricApplicationManagementClient10.EndCreateApplication(IFabricAsyncOperationContext context) System.Fabric.Interop.Utility+&lt;>c__DisplayClass22_0.b__0(IFabricAsyncOperationContext context) System.Fabric.Interop.AsyncCallOutAdapter2.Finish(IFabricAsyncOperationContext context, bool expectedCompletedSynchronously)</p> <p>Show raw exception details FabricElementNotFoundException: Application type and version not found System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Keefe.InmateStore.Administration.Controllers.AgencyController+d__5.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__27.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__25.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__22.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ResourceExecutedContext context) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted) Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker+d__20.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Builder.RouterMiddleware+d__4.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIIndexMiddleware+d__4.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware+d__6.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware+d__7.MoveNext()</p>
0debug
int qemu_chr_fe_ioctl(CharDriverState *s, int cmd, void *arg) { if (!s->chr_ioctl) return -ENOTSUP; return s->chr_ioctl(s, cmd, arg); }
1threat
A definition of the ^ operation in javascript : <p>Can't seem to find a definition anywhere.</p> <p>Typing into the console I can see...</p> <pre><code> 5^4 = 1 5^3 = 6 5^2 = 7 </code></pre> <p>Any ideas why?</p>
0debug
How to read the object inside json array android : I have json in this format.I m trying to create serialization class to store the value. how to read the "personaldata" field. I am making a separate class PersonalData to read it. And in my main serialization class i am reading it as List<PersonalData>personalData. Is it the right way to do it. And if yes .how will i fetch the personal data values. { "result": [{ "name": 0, "age": 1, "class": 0…….some more data “personalData” : { “isMarried” : true/false, “isEligible” : true/false, “Indian” : true/false, } ]}
0debug
GO - global variable not accessible to methods when used with testing : I am facing problem while using Golang Testing.Global variable not accessible to methods. Following is the code snippet test1.go var map1 = make(map[string]string) func f()(req *http.Request) (ismime bool, map1 map[string]string, err error) { map1["key"]="value" return true,map1,nil } I am getting following error panic: assignment to entry in nil map [recovered] panic: assignment to entry in nil map
0debug
Combining MVC + Blazor in the same project : <p>Our current application is now running on ASP.NET Core (MVC) and I was wondering is there will be an offical way to use MVC and Blazor (client side) in the same project?</p> <p>The reason why I want to do that is because we won't be able to migrated from MVC to Blazor in one big bang since, the application is just too big. I was thinking on a step by step transition from MVC to Blazor. Just not sure if this will be possible?</p>
0debug
How to use pug with react? : <p>How to use pug and react together? </p> <p>Something like </p> <pre><code>btn = ({click, text})-&gt; a.pug.btn(target='blank' on-click=click) #{text} </code></pre>
0debug
static void audio_run_in (AudioState *s) { HWVoiceIn *hw = NULL; while ((hw = audio_pcm_hw_find_any_enabled_in (hw))) { SWVoiceIn *sw; int captured, min; captured = hw->pcm_ops->run_in (hw); min = audio_pcm_hw_find_min_in (hw); hw->total_samples_captured += captured - min; hw->ts_helper += captured; for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) { sw->total_hw_samples_acquired -= min; if (sw->active) { int avail; avail = audio_get_avail (sw); if (avail > 0) { sw->callback.fn (sw->callback.opaque, avail); } } } } }
1threat
Can I delete an item using DynamoDB Mapper without loading it first? : <p>I am using DynamoDB mapper for deleting an item but have to make sure it exists before deleting it?</p> <p>So I'm currently doing</p> <pre><code>public void delete(final String hashKey, final Long rangeKey) { final Object obj = mapper.load(Object.class, hashKey, rangeKey); if (obj != null) { mapper.delete(obj); } } </code></pre> <p>If there a way to delete an item without loading it first? I want it to silently return if the item was not found</p>
0debug
static void nic_cleanup(VLANClientState *nc) { dp8393xState *s = DO_UPCAST(NICState, nc, nc)->opaque; cpu_unregister_io_memory(s->mmio_index); qemu_del_timer(s->watchdog); qemu_free_timer(s->watchdog); g_free(s); }
1threat
What is Salesforce development : <p>What is meant by salesforce development? What are the products they are developing? Anyone please help me about this development, I had no idea what they are.</p>
0debug
Interpreting negative Word2Vec similarity from gensim : <p>E.g. we train a word2vec model using <code>gensim</code>:</p> <pre><code>from gensim import corpora, models, similarities from gensim.models.word2vec import Word2Vec documents = ["Human machine interface for lab abc computer applications", "A survey of user opinion of computer system response time", "The EPS user interface management system", "System and human system engineering testing of EPS", "Relation of user perceived response time to error measurement", "The generation of random binary unordered trees", "The intersection graph of paths in trees", "Graph minors IV Widths of trees and well quasi ordering", "Graph minors A survey"] texts = [[word for word in document.lower().split()] for document in documents] w2v_model = Word2Vec(texts, size=500, window=5, min_count=1) </code></pre> <p>And when we query the similarity between words, we find negative similarity scores:</p> <pre><code>&gt;&gt;&gt; w2v_model.similarity('graph', 'computer') 0.046929569156789336 &gt;&gt;&gt; w2v_model.similarity('graph', 'system') 0.063683518562347399 &gt;&gt;&gt; w2v_model.similarity('survey', 'generation') -0.040026775040430063 &gt;&gt;&gt; w2v_model.similarity('graph', 'trees') -0.0072684112978664561 </code></pre> <p><strong>How do we interpret the negative scores?</strong> </p> <p>If it's a cosine similarity shouldn't the range be <code>[0,1]</code>?</p> <p><strong>What is the upper bound and lower bound of the <code>Word2Vec.similarity(x,y)</code> function?</strong> There isn't much written in the docs: <a href="https://radimrehurek.com/gensim/models/word2vec.html#gensim.models.word2vec.Word2Vec.similarity" rel="noreferrer">https://radimrehurek.com/gensim/models/word2vec.html#gensim.models.word2vec.Word2Vec.similarity</a> =(</p> <p>Looking at the Python wrapper code, there isn't much too: <a href="https://github.com/RaRe-Technologies/gensim/blob/develop/gensim/models/word2vec.py#L1165" rel="noreferrer">https://github.com/RaRe-Technologies/gensim/blob/develop/gensim/models/word2vec.py#L1165</a></p> <p>(If possible, please do point me to the <code>.pyx</code> code of where the similarity function is implemented.)</p>
0debug
ASP.NET Core MediatR error: Register your handlers with the container : <p>I have a .Net Core app where i use the <code>.AddMediatR</code> extension to register the assembly for my commands and handlers following a CQRS approach.</p> <p>In ConfigureServices in Startup.cs i have used the extension method from the official package <code>MediatR.Extensions.Microsoft.DependencyInjection</code> with the following parameter:</p> <pre><code>services.AddMediatR(typeof(AddEducationCommand).GetTypeInfo().Assembly); </code></pre> <p>The command and commandhandler classes are as follow:</p> <p><strong>AddEducationCommand.cs</strong></p> <pre><code>public class AddEducationCommand : IRequest&lt;bool&gt; { [DataMember] public int UniversityId { get; set; } [DataMember] public int FacultyId { get; set; } [DataMember] public string Name { get; set; } } </code></pre> <p><strong>AddEducationCommandHandler.cs</strong></p> <pre><code>public class AddEducationCommandHandler : IRequestHandler&lt;AddEducationCommand, bool&gt; { private readonly IUniversityRepository _repository; public AddEducationCommandHandler(IUniversityRepository repository) { _repository = repository; } public async Task&lt;bool&gt; Handle(AddEducationCommand command, CancellationToken cancellationToken) { var university = await _repository.GetAsync(command.UniversityId); university.Faculties .FirstOrDefault(f =&gt; f.Id == command.FacultyId) .CreateEducation(command.Name); return await _repository.UnitOfWork.SaveEntitiesAsync(); } } </code></pre> <p>When i run the REST endpoint that executes a simple <code>await _mediator.Send(command);</code> code, i get the following error from my log:</p> <pre><code>Error constructing handler for request of type MediatR.IRequestHandler`2[UniversityService.Application.Commands.AddEducationCommand,System.Boolean]. Register your handlers withthe container. See the samples in GitHub for examples. </code></pre> <p>I tried to look through the official examples from the docs without any luck. Does anyone know how i configure MediatR to work properly? Thanks in advance.</p>
0debug
How to get the count of # data rows in .csv file in R using nrow() function : <p>I have a data file (data.csv file) in my working directory. The first row of my file has column names. I want to count all the rows in my .csv file (excluding the first row) using the nrow() function. Size of the file is 4kb on disk, otherwise 2.83 kb Thanks Jyoti</p>
0debug
static bool qemu_vmstop_requested(RunState *r) { if (vmstop_requested < RUN_STATE_MAX) { *r = vmstop_requested; vmstop_requested = RUN_STATE_MAX; return true; } return false; }
1threat
What is difference between arm64 and armhf? : <p>Raspberry Pi Type 3 has 64-bit CPU, but its architecture is not <code>arm64</code> but <code>armhf</code>. What is the difference between <code>arm64</code> and <code>armhf</code>?</p>
0debug
static int truemotion1_decode_header(TrueMotion1Context *s) { int i; int width_shift = 0; int new_pix_fmt; struct frame_header header; uint8_t header_buffer[128]; const uint8_t *sel_vector_table; header.header_size = ((s->buf[0] >> 5) | (s->buf[0] << 3)) & 0x7f; if (s->buf[0] < 0x10) { av_log(s->avctx, AV_LOG_ERROR, "invalid header size (%d)\n", s->buf[0]); return -1; } memset(header_buffer, 0, 128); for (i = 1; i < header.header_size; i++) header_buffer[i - 1] = s->buf[i] ^ s->buf[i + 1]; header.compression = header_buffer[0]; header.deltaset = header_buffer[1]; header.vectable = header_buffer[2]; header.ysize = AV_RL16(&header_buffer[3]); header.xsize = AV_RL16(&header_buffer[5]); header.checksum = AV_RL16(&header_buffer[7]); header.version = header_buffer[9]; header.header_type = header_buffer[10]; header.flags = header_buffer[11]; header.control = header_buffer[12]; if (header.version >= 2) { if (header.header_type > 3) { av_log(s->avctx, AV_LOG_ERROR, "invalid header type (%d)\n", header.header_type); return -1; } else if ((header.header_type == 2) || (header.header_type == 3)) { s->flags = header.flags; if (!(s->flags & FLAG_INTERFRAME)) s->flags |= FLAG_KEYFRAME; } else s->flags = FLAG_KEYFRAME; } else s->flags = FLAG_KEYFRAME; if (s->flags & FLAG_SPRITE) { av_log(s->avctx, AV_LOG_INFO, "SPRITE frame found, please report the sample to the developers\n"); #if 0 s->w = header.width; s->h = header.height; s->x = header.xoffset; s->y = header.yoffset; #else return -1; #endif } else { s->w = header.xsize; s->h = header.ysize; if (header.header_type < 2) { if ((s->w < 213) && (s->h >= 176)) { s->flags |= FLAG_INTERPOLATED; av_log(s->avctx, AV_LOG_INFO, "INTERPOLATION selected, please report the sample to the developers\n"); } } } if (header.compression >= 17) { av_log(s->avctx, AV_LOG_ERROR, "invalid compression type (%d)\n", header.compression); return -1; } if ((header.deltaset != s->last_deltaset) || (header.vectable != s->last_vectable)) select_delta_tables(s, header.deltaset); if ((header.compression & 1) && header.header_type) sel_vector_table = pc_tbl2; else { if (header.vectable < 4) sel_vector_table = tables[header.vectable - 1]; else { av_log(s->avctx, AV_LOG_ERROR, "invalid vector table id (%d)\n", header.vectable); return -1; } } if (compression_types[header.compression].algorithm == ALGO_RGB24H) { new_pix_fmt = PIX_FMT_RGB32; width_shift = 1; } else new_pix_fmt = PIX_FMT_RGB555; s->w >>= width_shift; if (av_image_check_size(s->w, s->h, 0, s->avctx) < 0) return -1; if (s->w != s->avctx->width || s->h != s->avctx->height || new_pix_fmt != s->avctx->pix_fmt) { if (s->frame.data[0]) s->avctx->release_buffer(s->avctx, &s->frame); s->avctx->sample_aspect_ratio = (AVRational){ 1 << width_shift, 1 }; s->avctx->pix_fmt = new_pix_fmt; avcodec_set_dimensions(s->avctx, s->w, s->h); av_fast_malloc(&s->vert_pred, &s->vert_pred_size, s->avctx->width * sizeof(unsigned int)); } s->mb_change_bits_row_size = ((s->avctx->width >> (2 - width_shift)) + 7) >> 3; if ((header.deltaset != s->last_deltaset) || (header.vectable != s->last_vectable)) { if (compression_types[header.compression].algorithm == ALGO_RGB24H) gen_vector_table24(s, sel_vector_table); else if (s->avctx->pix_fmt == PIX_FMT_RGB555) gen_vector_table15(s, sel_vector_table); else gen_vector_table16(s, sel_vector_table); } s->mb_change_bits = s->buf + header.header_size; if (s->flags & FLAG_KEYFRAME) { s->index_stream = s->mb_change_bits; } else { s->index_stream = s->mb_change_bits + (s->mb_change_bits_row_size * (s->avctx->height >> 2)); } s->index_stream_size = s->size - (s->index_stream - s->buf); s->last_deltaset = header.deltaset; s->last_vectable = header.vectable; s->compression = header.compression; s->block_width = compression_types[header.compression].block_width; s->block_height = compression_types[header.compression].block_height; s->block_type = compression_types[header.compression].block_type; if (s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_INFO, "tables: %d / %d c:%d %dx%d t:%d %s%s%s%s\n", s->last_deltaset, s->last_vectable, s->compression, s->block_width, s->block_height, s->block_type, s->flags & FLAG_KEYFRAME ? " KEY" : "", s->flags & FLAG_INTERFRAME ? " INTER" : "", s->flags & FLAG_SPRITE ? " SPRITE" : "", s->flags & FLAG_INTERPOLATED ? " INTERPOL" : ""); return header.header_size; }
1threat
static void virtio_net_save_device(VirtIODevice *vdev, QEMUFile *f) { VirtIONet *n = VIRTIO_NET(vdev); int i; qemu_put_buffer(f, n->mac, ETH_ALEN); qemu_put_be32(f, n->vqs[0].tx_waiting); qemu_put_be32(f, n->mergeable_rx_bufs); qemu_put_be16(f, n->status); qemu_put_byte(f, n->promisc); qemu_put_byte(f, n->allmulti); qemu_put_be32(f, n->mac_table.in_use); qemu_put_buffer(f, n->mac_table.macs, n->mac_table.in_use * ETH_ALEN); qemu_put_buffer(f, (uint8_t *)n->vlans, MAX_VLAN >> 3); qemu_put_be32(f, n->has_vnet_hdr); qemu_put_byte(f, n->mac_table.multi_overflow); qemu_put_byte(f, n->mac_table.uni_overflow); qemu_put_byte(f, n->alluni); qemu_put_byte(f, n->nomulti); qemu_put_byte(f, n->nouni); qemu_put_byte(f, n->nobcast); qemu_put_byte(f, n->has_ufo); if (n->max_queues > 1) { qemu_put_be16(f, n->max_queues); qemu_put_be16(f, n->curr_queues); for (i = 1; i < n->curr_queues; i++) { qemu_put_be32(f, n->vqs[i].tx_waiting); } } if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS)) { qemu_put_be64(f, n->curr_guest_offloads); } }
1threat
How to Split string before '@' in angularJS : <p>I want to split an email of user before letter </p> <blockquote> <p>@</p> </blockquote> <p>in Javascript especialy in angularJS. for example if its</p> <blockquote> <p>blabla@gla.com</p> </blockquote> <p>it will turn into</p> <blockquote> <p>blabla</p> </blockquote> <p>can someone give me a simple example to make it? because i must split it from API and store it as localstorage, some of example that i find its use limitTo but can we use it to cut it in specific way from <code>@</code> until end?</p>
0debug
static int decode_recovery_point(H264Context *h) { h->sei_recovery_frame_cnt = get_ue_golomb(&h->gb); skip_bits(&h->gb, 4); if (h->avctx->debug & FF_DEBUG_PICT_INFO) av_log(h->avctx, AV_LOG_DEBUG, "sei_recovery_frame_cnt: %d\n", h->sei_recovery_frame_cnt); h->has_recovery_point = 1; return 0; }
1threat
Where is MSBuild.exe installed in Windows when installed using BuildTools_Full.exe? : <p>I'm trying to set up a build server for .NET, but can't figure out where MSBuild.exe is installed.</p> <p>I'm trying to install MSBuild using the Microsoft Build Tools 2013: <a href="https://www.microsoft.com/en-us/download/details.aspx?id=40760" rel="noreferrer">https://www.microsoft.com/en-us/download/details.aspx?id=40760</a></p>
0debug
how to erase several characters in a cell? : <p>I would like to erase characters "(B)" in the code column, so then I could do "summarise" the 'stock_needed'. My data looks like this.</p> <pre><code> code stock_need (B)1234 200 (B)5678 240 1234 700 5678 200 0123 200 </code></pre> <p>to be like this.</p> <pre><code>code stock_need 1234 200 5678 240 1234 700 5678 200 0123 200 </code></pre> <p>How could these "(B)" erased? Thanx in advance</p>
0debug
static bool gen_wsr_ccount(DisasContext *dc, uint32_t sr, TCGv_i32 v) { if (dc->tb->cflags & CF_USE_ICOUNT) { gen_io_start(); } gen_helper_wsr_ccount(cpu_env, v); if (dc->tb->cflags & CF_USE_ICOUNT) { gen_io_end(); gen_jumpi_check_loop_end(dc, 0); return true; } return false; }
1threat
error while excecuting : [enter image description here][1] [enter image description here][2]ack.imgur.com/C1Xvj.png [1]: https://i.st [2]: https://i.stack.imgur.com/52Vjr. i m trying to execute this but errors occured in line one. can any senior guide me.
0debug
C++ error with just Visual studio : <pre><code>#include &lt;iostream&gt; using namespace std; int main() { int Pass; cout &lt;&lt; "Enter Pass Please"; cin &gt;&gt; Pass; switch (Pass) { case 1996: { cout &lt;&lt; "O" &lt;&lt; endl; } break; case 2015: { cout &lt;&lt; "N\n"; } break; default: cout &lt;&lt; "Z" &lt;&lt; endl; break; system("PAUSE"); } } </code></pre> <p>Whats wrong with this code when i run it on visual studio consle app just disappear after writing value of pass like its no system pause </p>
0debug
Drawing dotted line between the cells of UICollectionView : <p>I have to achieve something like this(please check attached ScreenShot). The best possible solution which came to my mind is <code>UICollectionView</code>. I have created rounded border along the cell and put a button on the cell. Now for the dotted straight line I have used <code>CAShapeLayer</code> with <code>BezierPath</code> and added the layer to my <code>collectionview background with background color set to clear color</code>. Here comes the problem, I am not seeing any dotted line. Here is what I have tried. Now I have couple of questions. While answering please consider me as a beginner.</p> <p>1) Why my lines are not showing.<br> 2) How to calculate the width between the two cell, right now i am setting a random number.<br> 3) Is there any other approach which can solve this use-case more efficiently. </p> <p><a href="https://i.stack.imgur.com/kmUf2.png"><img src="https://i.stack.imgur.com/kmUf2.png" alt="required"></a></p> <pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ UIBezierPath *borderPath; CGFloat borderWidth; KKCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"testCell" forIndexPath:indexPath]; borderPath = [UIBezierPath bezierPath]; [borderPath moveToPoint:CGPointMake(cell.frame.origin.x + cell.frame.size.width -1 , cell.frame.origin.y + 2)]; [borderPath addLineToPoint:CGPointMake(cell.frame.origin.x + cell.frame.size.width + 50, cell.frame.origin.y +2)]; borderWidth = 1.0; [self dottedLineWithPath:borderPath withborderWidth:borderWidth]; return cell; } /** creating dotted line **/ - (void)dottedLineWithPath:(UIBezierPath *)path withborderWidth:(CGFloat)lineWidth { CAShapeLayer *shapelayer = [CAShapeLayer layer]; shapelayer.strokeStart = 0.0; shapelayer.strokeColor = [UIColor blackColor].CGColor; shapelayer.lineWidth = borderWidth; shapelayer.lineJoin = kCALineJoinRound; shapelayer.lineDashPattern = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:2 ], nil]; shapelayer.path = path.CGPath; [self.milestoneCollection.backgroundView.layer addSublayer:shapelayer]; } </code></pre> <p><strong>Here is what I have achieved till now</strong>.<a href="https://i.stack.imgur.com/g7AMQ.png"><img src="https://i.stack.imgur.com/g7AMQ.png" alt="enter image description here"></a></p>
0debug
Using pointer to channel : <p>Is it good practice to use pointer to channel? For example I read the data concurrently and pass those data <code>map[string]sting</code> using channel and process this channel inside <code>getSameValues()</code>.</p> <pre><code>func getSameValues(results *chan map[string]string) []string { var datas = make([]map[string]string, len(*results)) i := 0 for values := range *results { datas[i] = values i++ } } </code></pre> <p>The reason I do this is because the <code>chan map[string]string</code> there will be around millions of data inside the map and it will be more than one map. </p> <p>So I think it would be a good approach if I can pass pointer to the function so that it will not copy the data to save some resource of memory.</p> <p>I didn't find a good practice in <a href="https://golang.org/doc/effective_go.html#channels" rel="noreferrer">effective go</a>. So I'm kinda doubt about my approach here. </p>
0debug
State of Thread before start of run is not New, its runnable, Isn't it wrong : <p>I am new to threads in Java from the basic learning I understand that when a thread is created, it is in the new state. The thread has not yet started to run when the thread is in this state </p> <pre><code>public class MainClassForThread { public static void main(String[] args) { // TODO Auto-generated method stub Thread t1 = new ExtendingThreadClass(); Thread t2 = new ExtendingThreadClass(); Thread t3 = new ExtendingThreadClass(); System.out.println("Before start of thread the state of thread is " + t1.currentThread().getState()); t1.start(); t2.start(); t3.start(); } } package Threads; public class ExtendingThreadClass extends Thread { public void run() { System.out.println("Thread running : " + Thread.currentThread().getId()); for (int i = 0; i &lt; 100; i++) { System.out.println("Thread " + Thread.currentThread().getName() + " is running for value of i " + i); System.out.println("State " + Thread.currentThread().getState()); } } } </code></pre> <p>I am expecting the output of the first line of code should be NEW as the thread t1 is not started yet, but Output is as below</p> <pre><code>Before start of thread the state of thread is RUNNABLE Thread running : 10 Thread running : 12 Thread Thread-2 is running for value of i 0 Thread running : 11 Thread Thread-0 is running for value of i 0 State RUNNABLE Thread Thread-0 is running for value of i 1 State RUNNABLE Thread Thread-0 is running for value of i 2 </code></pre>
0debug
new to android studio...advice to become developer in shorter way : <h1>Development for android</h1> <p>i'm new to android development,any one help me the best way to become developer in shorter way specially i'm web for more than 9 years. what is the best reference?courses and so on</p>
0debug
static ssize_t sdp_attr_get(struct bt_l2cap_sdp_state_s *sdp, uint8_t *rsp, const uint8_t *req, ssize_t len) { ssize_t seqlen; int i, start, end, max; int32_t handle; struct sdp_service_record_s *record; uint8_t *lst; if (len < 7) return -SDP_INVALID_SYNTAX; memcpy(&handle, req, 4); req += 4; len -= 4; if (handle < 0 || handle > sdp->services) return -SDP_INVALID_RECORD_HANDLE; record = &sdp->service_list[handle]; for (i = 0; i < record->attributes; i ++) record->attribute_list[i].match = 0; max = (req[0] << 8) | req[1]; req += 2; len -= 2; if (max < 0x0007) return -SDP_INVALID_SYNTAX; if ((*req & ~SDP_DSIZE_MASK) == SDP_DTYPE_SEQ) { seqlen = sdp_datalen(&req, &len); if (seqlen < 3 || len < seqlen) return -SDP_INVALID_SYNTAX; len -= seqlen; while (seqlen) if (sdp_attr_match(record, &req, &seqlen)) return -SDP_INVALID_SYNTAX; } else if (sdp_attr_match(record, &req, &seqlen)) return -SDP_INVALID_SYNTAX; if (len < 1) return -SDP_INVALID_SYNTAX; if (*req) { if (len <= sizeof(int)) return -SDP_INVALID_SYNTAX; len -= sizeof(int); memcpy(&start, req + 1, sizeof(int)); } else start = 0; if (len > 1) return -SDP_INVALID_SYNTAX; lst = rsp + 2; max = MIN(max, MAX_RSP_PARAM_SIZE); len = 3 - start; end = 0; for (i = 0; i < record->attributes; i ++) if (record->attribute_list[i].match) { if (len >= 0 && len + record->attribute_list[i].len < max) { memcpy(lst + len, record->attribute_list[i].pair, record->attribute_list[i].len); end = len + record->attribute_list[i].len; } len += record->attribute_list[i].len; } if (0 >= start) { lst[0] = SDP_DTYPE_SEQ | SDP_DSIZE_NEXT2; lst[1] = (len + start - 3) >> 8; lst[2] = (len + start - 3) & 0xff; } rsp[0] = end >> 8; rsp[1] = end & 0xff; if (end < len) { len = end + start; lst[end ++] = sizeof(int); memcpy(lst + end, &len, sizeof(int)); end += sizeof(int); } else lst[end ++] = 0; return end + 2; }
1threat
C Programming - #define function : <p>I am learning C in depth. But I am not getting this program. Somebody, please tell me how the output of the below program is <strong>m=2, n=3</strong></p> <pre><code>#include &lt;stdio.h&gt; #define MAX(a,b) a&gt;b ? a:b int main() { int m,n; m=3+MAX(2,3); n=2*MAX(3,2); printf("m=%d, n=%d\n",m,n); return 0; } </code></pre>
0debug
ExtensionlessUrlHandler and "Recursion too deep; the stack overflowed" : <p>I'm trying to get a fellow developer's app working on my machine. Solution is built in VS 2015 using Web API and I'm running it using 64-bit IIS Express. Every request is returning 500.0 errors. Request tracing log says this about it:</p> <pre><code>1517. -MODULE_SET_RESPONSE_ERROR_STATUS ModuleName ManagedPipelineHandler Notification EXECUTE_REQUEST_HANDLER HttpStatus 500 HttpReason Internal Server Error HttpSubStatus 0 ErrorCode Recursion too deep; the stack overflowed. (0x800703e9) ConfigExceptionInfo </code></pre> <p>The relevant config section looks like this:</p> <pre><code>&lt;system.webServer&gt; &lt;handlers&gt; &lt;remove name="OPTIONS" /&gt; &lt;remove name="OPTIONSVerbHandler" /&gt; &lt;remove name="TRACEVerbHandler" /&gt; &lt;remove name="ExtensionlessUrlHandler-Integrated-4.0" /&gt; &lt;remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" /&gt; &lt;remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" /&gt; &lt;add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" /&gt; &lt;add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*" verb="*" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" /&gt; &lt;add name="ExtensionlessUrlHandler-Integrated-4.0" path="*" verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" /&gt; &lt;/handlers&gt; &lt;/system.webServer&gt; </code></pre> <p>Other possibly relevant facts:</p> <ul> <li>The machine hasn't been used for web hosting before, but I've been doing a lot of VS2013 development and only installed 2015 last week to run this project.</li> <li>The project does contain some C# 6.0 features, namely the new string interpolation goodies.</li> </ul> <p>How would I even begin to debug this? I'm getting zero relevant hits on Google.</p>
0debug
void helper_ldq_data(uint64_t t0, uint64_t t1) { ldq_data(t1, t0); }
1threat
Warning initialization makes integer from pointer without a cast with fgets : <p>I want want to read a character string, over the stdin, so I have chosen fgets. But I got this warning: initialization makes integer from pointer without a cast.</p> <p>Here is my code:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string.h&gt; #include &lt;stddef.h&gt; #define MAX_LINIA 301 int main(int argc,char *argv[]){ char *buffer; printf("Enter the input\n"); if (fgets(buffer,MAX_LINIA-1,stdin)==NULL) printf("Error") else printf("%s", buffer); return 0: } </code></pre>
0debug
Modify value outside of closure : I'm trying to change value of `date` in TimeTravel. Comments indicate what values I would like, but it's not what I get. use std::cell::{Cell}; #[derive(Debug)] #[derive(Clone)] pub struct TimeTravel { pub date: Cell<i32>, } impl TimeTravel { pub fn new() -> Self { TimeTravel{ date: Cell::new(1), } } pub fn forward(&self) -> &Self { let d = self.date.get(); self.date.set(d + 1); self } } fn main() { let travel: TimeTravel = TimeTravel::new(); println!("{:?}", travel); // 1 travel.forward(); println!("{:?}", travel); // 2 { let t1 = travel.clone(); let first = || { t1.forward(); println!("{:?}", t1); // 3 t1.forward(); println!("{:?}", t1); // 4 }; first(); } { let t2 = travel.clone(); let second = || { t2.forward(); println!("{:?}", t2); //5 }; second(); } } However I get this TimeTravel { date: Cell { value: 1 } } TimeTravel { date: Cell { value: 2 } } TimeTravel { date: Cell { value: 3 } } TimeTravel { date: Cell { value: 4 } } TimeTravel { date: Cell { value: 3 } } If I understand correctly what is happening, I am changing value in `t1` and `t2`, and not `travel`. How can I change value of `travel` inside a closure? [Example in Rust Playground](https://play.rust-lang.org/?gist=a7a21ff881217d703b53209307254b88&version=nightly)
0debug
static void fdctrl_write_data (fdctrl_t *fdctrl, uint32_t value) { fdrive_t *cur_drv; int pos; if (!(fdctrl->dor & FD_DOR_nRESET)) { FLOPPY_DPRINTF("Floppy controller in RESET state !\n"); return; } if (!(fdctrl->msr & FD_MSR_RQM) || (fdctrl->msr & FD_MSR_DIO)) { FLOPPY_ERROR("controller not ready for writing\n"); return; } fdctrl->dsr &= ~FD_DSR_PWRDOWN; if (fdctrl->msr & FD_MSR_NONDMA) { fdctrl->fifo[fdctrl->data_pos++] = value; if (fdctrl->data_pos % FD_SECTOR_LEN == (FD_SECTOR_LEN - 1) || fdctrl->data_pos == fdctrl->data_len) { cur_drv = get_cur_drv(fdctrl); if (bdrv_write(cur_drv->bs, fd_sector(cur_drv), fdctrl->fifo, 1) < 0) { FLOPPY_ERROR("writing sector %d\n", fd_sector(cur_drv)); return; } if (!fdctrl_seek_to_next_sect(fdctrl, cur_drv)) { FLOPPY_DPRINTF("error seeking to next sector %d\n", fd_sector(cur_drv)); return; } } if (fdctrl->data_pos == fdctrl->data_len) fdctrl_stop_transfer(fdctrl, FD_SR0_SEEK, 0x00, 0x00); return; } if (fdctrl->data_pos == 0) { pos = command_to_handler[value & 0xff]; FLOPPY_DPRINTF("%s command\n", handlers[pos].name); fdctrl->data_len = handlers[pos].parameters + 1; } FLOPPY_DPRINTF("%s: %02x\n", __func__, value); fdctrl->fifo[fdctrl->data_pos++] = value; if (fdctrl->data_pos == fdctrl->data_len) { if (fdctrl->data_state & FD_STATE_FORMAT) { fdctrl_format_sector(fdctrl); return; } pos = command_to_handler[fdctrl->fifo[0] & 0xff]; FLOPPY_DPRINTF("treat %s command\n", handlers[pos].name); (*handlers[pos].handler)(fdctrl, handlers[pos].direction); } }
1threat
static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov, AVFormatContext *s) { int64_t pos = avio_tell(pb); avio_wb32(pb, 0); ffio_wfourcc(pb, "ilst"); mov_write_string_metadata(s, pb, "\251nam", "title" , 1); mov_write_string_metadata(s, pb, "\251ART", "artist" , 1); mov_write_string_metadata(s, pb, "aART", "album_artist", 1); mov_write_string_metadata(s, pb, "\251wrt", "composer" , 1); mov_write_string_metadata(s, pb, "\251alb", "album" , 1); mov_write_string_metadata(s, pb, "\251day", "date" , 1); mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 0, 1); mov_write_string_metadata(s, pb, "\251cmt", "comment" , 1); mov_write_string_metadata(s, pb, "\251gen", "genre" , 1); mov_write_string_metadata(s, pb, "\251cpy", "copyright", 1); mov_write_string_metadata(s, pb, "\251grp", "grouping" , 1); mov_write_string_metadata(s, pb, "\251lyr", "lyrics" , 1); mov_write_string_metadata(s, pb, "desc", "description",1); mov_write_string_metadata(s, pb, "ldes", "synopsis" , 1); mov_write_string_metadata(s, pb, "tvsh", "show" , 1); mov_write_string_metadata(s, pb, "tven", "episode_id",1); mov_write_string_metadata(s, pb, "tvnn", "network" , 1); mov_write_trkn_tag(pb, mov, s); return update_size(pb, pos); }
1threat
How to iterate over an array of tuples? : So I'm new at learning rust and we're doing a poker assignment in which a base of 2 hands is given as such: let hand1 = [(3, 'H'), (10, 'S'), (4, 'S'), (4, 'C'), (5, 'C')]; let hand2 = [(2, 'H'), (2, 'S'), (5, 'S'), (2, 'C'), (13, 'C')]; let xxx = highest_card(&hand1, &hand2); My first goal with this is to figure out in each hand what the highest card is. What I've tried to is pass in the reference to each array to another function, that is suppose to figure it out. fn highest_card(c: &[(i32, char)] , d: &[(i32, char)]) { let mut max = 0; let mut m : usize = 0; let n: usize = 0; while m < c.len() { if c[m].n > max { max = c[m].n; } m += 1; } println!("The max number is: {}", max); } But when running this it displays the error: [Picture of terminal displaying errors, stack overflow doesn't yet let me embed pics to my post because of < 10 exp][1] [1]: https://i.stack.imgur.com/oJjZg.png What should I do to address this issue?
0debug