problem
stringlengths
26
131k
labels
class label
2 classes
static av_cold int avisynth_load_library(void) { avs_library = av_mallocz(sizeof(AviSynthLibrary)); if (!avs_library) return AVERROR_UNKNOWN; avs_library->library = LoadLibrary(AVISYNTH_LIB); if (!avs_library->library) goto init_fail; #define LOAD_AVS_FUNC(name, continue_on_fail) \ { \ avs_library->name = (void*)GetProcAddress(avs_library->library, #name); \ if(!continue_on_fail && !avs_library->name) \ goto fail; \ } LOAD_AVS_FUNC(avs_bit_blt, 0); LOAD_AVS_FUNC(avs_clip_get_error, 0); LOAD_AVS_FUNC(avs_create_script_environment, 0); LOAD_AVS_FUNC(avs_delete_script_environment, 0); LOAD_AVS_FUNC(avs_get_audio, 0); LOAD_AVS_FUNC(avs_get_error, 1); LOAD_AVS_FUNC(avs_get_frame, 0); LOAD_AVS_FUNC(avs_get_video_info, 0); LOAD_AVS_FUNC(avs_invoke, 0); LOAD_AVS_FUNC(avs_release_clip, 0); LOAD_AVS_FUNC(avs_release_value, 0); LOAD_AVS_FUNC(avs_release_video_frame, 0); LOAD_AVS_FUNC(avs_take_clip, 0); #undef LOAD_AVS_FUNC atexit(avisynth_atexit_handler); return 0; fail: FreeLibrary(avs_library->library); init_fail: av_freep(&avs_library); return AVERROR_UNKNOWN; }
1threat
How to parse digits from a multiline string? : <p>What's the recommended approach to parse the digits from the following multiline string in C#?</p> <pre><code>--- --- | | | ----- / _| | |___| |___ \ | | | | -- --- | | ____| | | | ----- | |___| |___ | | | | | ____| </code></pre>
0debug
static int parse_sandbox(void *opaque, QemuOpts *opts, Error **errp) { if (qemu_opt_get_bool(opts, "enable", false)) { #ifdef CONFIG_SECCOMP uint32_t seccomp_opts = QEMU_SECCOMP_SET_DEFAULT | QEMU_SECCOMP_SET_OBSOLETE; const char *value = NULL; value = qemu_opt_get(opts, "obsolete"); if (g_str_equal(value, "allow")) { seccomp_opts &= ~QEMU_SECCOMP_SET_OBSOLETE; } else if (g_str_equal(value, "deny")) { error_report("invalid argument for obsolete"); if (seccomp_start(seccomp_opts) < 0) { error_report("failed to install seccomp syscall filter " "in the kernel"); #else error_report("seccomp support is disabled"); #endif return 0;
1threat
How to correctly use Scanner to print output stream : <p>I am using Scanner to take in input and print output but ln.nextLine() jumps to next line to scan.</p> <pre><code> Scanner in = new Scanner(System.in); System.out.println("ENTER ID: "); String line = null; while (in.hasNext()) { line = in.nextLine(); if (line.toLowerCase().equals("exit")) { break; } else { System.out.println("number entered "+Integer.parseInt(line)); } System.out.println("ENTER ID: "); } </code></pre> <p><strong>This produces a output like:</strong><br> ENTER ID:<br> 78<br> number entered 78<br> ENTER ID:<br> 89<br> number entered 89</p> <p><strong>Desired output is:</strong><br> ENTER ID: 78<br> number entered 78<br> ENTER ID: 89<br> number entered 89 </p> <p>what part of println sequence should I change to achieve this?</p>
0debug
Different behavior async/await in almost the same methods : <p>Let's say I have two async methods</p> <pre><code>public async static Task RunAsync1() { await Task.Delay(2000); await Task.Delay(2000); } </code></pre> <p>and</p> <pre><code>public async static Task RunAsync2() { var t1 = Task.Delay(2000); var t2 = Task.Delay(2000); await t1; await t2; } </code></pre> <p>Then I use it like</p> <pre><code>public static void M() { RunAsync1().GetAwaiter().GetResult(); RunAsync2().GetAwaiter().GetResult(); } </code></pre> <p>In a result the <code>RunAsync1</code> will run <strong>4sec</strong> but <code>RunAsync2</code> only <strong>2sec</strong> <br> Can anybody explain why? Methods are almost the same. What is the difference? </p>
0debug
static void load_linux(PCMachineState *pcms, FWCfgState *fw_cfg) { uint16_t protocol; int setup_size, kernel_size, initrd_size = 0, cmdline_size; uint32_t initrd_max; uint8_t header[8192], *setup, *kernel, *initrd_data; hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0; FILE *f; char *vmode; MachineState *machine = MACHINE(pcms); const char *kernel_filename = machine->kernel_filename; const char *initrd_filename = machine->initrd_filename; const char *kernel_cmdline = machine->kernel_cmdline; cmdline_size = (strlen(kernel_cmdline)+16) & ~15; f = fopen(kernel_filename, "rb"); if (!f || !(kernel_size = get_file_size(f)) || fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) != MIN(ARRAY_SIZE(header), kernel_size)) { fprintf(stderr, "qemu: could not load kernel '%s': %s\n", kernel_filename, strerror(errno)); #if 0 fprintf(stderr, "header magic: %#x\n", ldl_p(header+0x202)); #endif if (ldl_p(header+0x202) == 0x53726448) { protocol = lduw_p(header+0x206); } else { if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename, kernel_cmdline, kernel_size, header)) { return; protocol = 0; if (protocol < 0x200 || !(header[0x211] & 0x01)) { real_addr = 0x90000; cmdline_addr = 0x9a000 - cmdline_size; prot_addr = 0x10000; } else if (protocol < 0x202) { real_addr = 0x90000; cmdline_addr = 0x9a000 - cmdline_size; prot_addr = 0x100000; } else { real_addr = 0x10000; cmdline_addr = 0x20000; prot_addr = 0x100000; #if 0 fprintf(stderr, "qemu: real_addr = 0x" TARGET_FMT_plx "\n" "qemu: cmdline_addr = 0x" TARGET_FMT_plx "\n" "qemu: prot_addr = 0x" TARGET_FMT_plx "\n", real_addr, cmdline_addr, prot_addr); #endif if (protocol >= 0x203) { initrd_max = ldl_p(header+0x22c); } else { initrd_max = 0x37ffffff; if (initrd_max >= pcms->below_4g_mem_size - acpi_data_size) { initrd_max = pcms->below_4g_mem_size - acpi_data_size - 1; fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_ADDR, cmdline_addr); fw_cfg_add_i32(fw_cfg, FW_CFG_CMDLINE_SIZE, strlen(kernel_cmdline)+1); fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline); if (protocol >= 0x202) { stl_p(header+0x228, cmdline_addr); } else { stw_p(header+0x20, 0xA33F); stw_p(header+0x22, cmdline_addr-real_addr); vmode = strstr(kernel_cmdline, "vga="); if (vmode) { unsigned int video_mode; vmode += 4; if (!strncmp(vmode, "normal", 6)) { video_mode = 0xffff; } else if (!strncmp(vmode, "ext", 3)) { video_mode = 0xfffe; } else if (!strncmp(vmode, "ask", 3)) { video_mode = 0xfffd; } else { video_mode = strtol(vmode, NULL, 0); stw_p(header+0x1fa, video_mode); if (protocol >= 0x200) { header[0x210] = 0xB0; if (protocol >= 0x201) { header[0x211] |= 0x80; stw_p(header+0x224, cmdline_addr-real_addr-0x200); if (initrd_filename) { if (protocol < 0x200) { fprintf(stderr, "qemu: linux kernel too old to load a ram disk\n"); initrd_size = get_image_size(initrd_filename); if (initrd_size < 0) { fprintf(stderr, "qemu: error reading initrd %s: %s\n", initrd_filename, strerror(errno)); initrd_addr = (initrd_max-initrd_size) & ~4095; initrd_data = g_malloc(initrd_size); load_image(initrd_filename, initrd_data); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, initrd_addr); fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, initrd_data, initrd_size); stl_p(header+0x218, initrd_addr); stl_p(header+0x21c, initrd_size); setup_size = header[0x1f1]; if (setup_size == 0) { setup_size = 4; setup_size = (setup_size+1)*512; kernel_size -= setup_size; setup = g_malloc(setup_size); kernel = g_malloc(kernel_size); fseek(f, 0, SEEK_SET); if (fread(setup, 1, setup_size, f) != setup_size) { fprintf(stderr, "fread() failed\n"); if (fread(kernel, 1, kernel_size, f) != kernel_size) { fprintf(stderr, "fread() failed\n"); fclose(f); memcpy(setup, header, MIN(sizeof(header), setup_size)); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size); fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr); fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size); option_rom[nb_option_roms].name = "linuxboot.bin"; option_rom[nb_option_roms].bootindex = 0; nb_option_roms++;
1threat
static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output) { AVFrame *decoded_frame, *f; AVCodecContext *avctx = ist->dec_ctx; int i, ret, err = 0, resample_changed; AVRational decoded_frame_tb; if (!ist->decoded_frame && !(ist->decoded_frame = av_frame_alloc())) return AVERROR(ENOMEM); if (!ist->filter_frame && !(ist->filter_frame = av_frame_alloc())) return AVERROR(ENOMEM); decoded_frame = ist->decoded_frame; update_benchmark(NULL); ret = avcodec_decode_audio4(avctx, decoded_frame, got_output, pkt); update_benchmark("decode_audio %d.%d", ist->file_index, ist->st->index); if (ret >= 0 && avctx->sample_rate <= 0) { av_log(avctx, AV_LOG_ERROR, "Sample rate %d invalid\n", avctx->sample_rate); ret = AVERROR_INVALIDDATA; } if (*got_output || ret<0) decode_error_stat[ret<0] ++; if (ret < 0 && exit_on_error) exit_program(1); if (!*got_output || ret < 0) return ret; ist->samples_decoded += decoded_frame->nb_samples; ist->frames_decoded++; #if 1 ist->next_pts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) / avctx->sample_rate; ist->next_dts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) / avctx->sample_rate; #endif resample_changed = ist->resample_sample_fmt != decoded_frame->format || ist->resample_channels != avctx->channels || ist->resample_channel_layout != decoded_frame->channel_layout || ist->resample_sample_rate != decoded_frame->sample_rate; if (resample_changed) { char layout1[64], layout2[64]; if (!guess_input_channel_layout(ist)) { av_log(NULL, AV_LOG_FATAL, "Unable to find default channel " "layout for Input Stream #%d.%d\n", ist->file_index, ist->st->index); exit_program(1); } decoded_frame->channel_layout = avctx->channel_layout; av_get_channel_layout_string(layout1, sizeof(layout1), ist->resample_channels, ist->resample_channel_layout); av_get_channel_layout_string(layout2, sizeof(layout2), avctx->channels, decoded_frame->channel_layout); av_log(NULL, AV_LOG_INFO, "Input stream #%d:%d frame changed from rate:%d fmt:%s ch:%d chl:%s to rate:%d fmt:%s ch:%d chl:%s\n", ist->file_index, ist->st->index, ist->resample_sample_rate, av_get_sample_fmt_name(ist->resample_sample_fmt), ist->resample_channels, layout1, decoded_frame->sample_rate, av_get_sample_fmt_name(decoded_frame->format), avctx->channels, layout2); ist->resample_sample_fmt = decoded_frame->format; ist->resample_sample_rate = decoded_frame->sample_rate; ist->resample_channel_layout = decoded_frame->channel_layout; ist->resample_channels = avctx->channels; for (i = 0; i < nb_filtergraphs; i++) if (ist_in_filtergraph(filtergraphs[i], ist)) { FilterGraph *fg = filtergraphs[i]; if (configure_filtergraph(fg) < 0) { av_log(NULL, AV_LOG_FATAL, "Error reinitializing filters!\n"); exit_program(1); } } } if (decoded_frame->pts != AV_NOPTS_VALUE) { ist->dts = ist->next_dts = ist->pts = ist->next_pts = av_rescale_q(decoded_frame->pts, avctx->time_base, AV_TIME_BASE_Q); decoded_frame_tb = avctx->time_base; } else if (decoded_frame->pkt_pts != AV_NOPTS_VALUE) { decoded_frame->pts = decoded_frame->pkt_pts; decoded_frame_tb = ist->st->time_base; } else if (pkt->pts != AV_NOPTS_VALUE) { decoded_frame->pts = pkt->pts; decoded_frame_tb = ist->st->time_base; }else { decoded_frame->pts = ist->dts; decoded_frame_tb = AV_TIME_BASE_Q; } pkt->pts = AV_NOPTS_VALUE; if (decoded_frame->pts != AV_NOPTS_VALUE) decoded_frame->pts = av_rescale_delta(decoded_frame_tb, decoded_frame->pts, (AVRational){1, avctx->sample_rate}, decoded_frame->nb_samples, &ist->filter_in_rescale_delta_last, (AVRational){1, avctx->sample_rate}); ist->nb_samples = decoded_frame->nb_samples; for (i = 0; i < ist->nb_filters; i++) { if (i < ist->nb_filters - 1) { f = ist->filter_frame; err = av_frame_ref(f, decoded_frame); if (err < 0) break; } else f = decoded_frame; err = av_buffersrc_add_frame_flags(ist->filters[i]->filter, f, AV_BUFFERSRC_FLAG_PUSH); if (err == AVERROR_EOF) err = 0; if (err < 0) break; } decoded_frame->pts = AV_NOPTS_VALUE; av_frame_unref(ist->filter_frame); av_frame_unref(decoded_frame); return err < 0 ? err : ret; }
1threat
Swift How to decode JSON without knowing the key name? : <p>I have json that looks something like this:</p> <pre><code>"events": { "1": { "id": 1, "name": "something" }, "2": { "id": 2, "name": "something2" },... } </code></pre> <p>Is there any way to decode this type of JSON where I dont know the name of the key?</p>
0debug
Can I instanciate a multi nic vm in a devtest lab environment? : Can I have multiple nics ressource and assigne them to the devtest lab vm ? Can I specied the Lab virtual network CIDR ? Can I set subnet address range ?
0debug
storing 64*64 integers from a file into a 2D array : <p>If i have a file that has a table of 64*64 integers. (The first 64 will be row 0; the next 64 will be row 1, and so on..). How do I store that table into a 2D array. Here is my code </p> <pre><code> #include &lt;iostream&gt; #include &lt;fstream&gt; using namespace std; int main() { ifstream infile; infile.open("table.txt"); if (infile.fail()) { cout &lt;&lt; "could not open file" &lt;&lt; endl; exit(6); } int array[63][63]; while (!infile.eof()) { infile &gt;&gt; array[63][63]; } cout &lt;&lt; array[63][63] &lt;&lt; endl; return 0; } </code></pre> <p>when this is executed I only get "1"</p>
0debug
WPF Path disappears at some size : <p>I have encountered this problem while scaling graph, which is drawn over GIS control Greatmap. But a simple experiment persuades me that problems is somewhere deeper in WPF.</p> <p>Consider simple WPF application:</p> <p>This is MainWindow.xaml</p> <pre><code>&lt;Grid&gt; &lt;StackPanel&gt; &lt;Slider ValueChanged="Size_Changed" Minimum="0" Maximum="300000"/&gt; &lt;TextBox x:Name="Value"&gt;&lt;/TextBox&gt; &lt;/StackPanel&gt; &lt;Canvas&gt; &lt;Path x:Name="MyPath" Stroke="Black" StrokeThickness="2" /&gt; &lt;/Canvas&gt; &lt;/Grid&gt; </code></pre> <p>And this is its code behind</p> <pre><code>private void Size_Changed(object sender, RoutedPropertyChangedEventArgs&lt;double&gt; e) { if (MyPath == null) return; var g = new StreamGeometry(); using (var s = g.Open()) { var pointA = new Point(0, 200); s.BeginFigure(pointA, false, false); var pointB = new Point(e.NewValue, 200); s.PolyLineTo(new[] {pointB}, true, true); Value.Text = $"zoom = {e.NewValue:0.0} ; pointA = {pointA.X:#,0} ; pointB = {pointB.X:#,0}"; } g.Freeze(); MyPath.Data = g; } </code></pre> <p>While I drag slider from 0 to 249999 it’s all right. I can see line on my view. But at the very moment slider’s value becomes 250000 – line disappears.</p> <p>Is there any limitations in WPF ?</p>
0debug
static void es1370_class_init (ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS (klass); PCIDeviceClass *k = PCI_DEVICE_CLASS (klass); k->realize = es1370_realize; k->vendor_id = PCI_VENDOR_ID_ENSONIQ; k->device_id = PCI_DEVICE_ID_ENSONIQ_ES1370; k->class_id = PCI_CLASS_MULTIMEDIA_AUDIO; k->subsystem_vendor_id = 0x4942; k->subsystem_id = 0x4c4c; set_bit(DEVICE_CATEGORY_SOUND, dc->categories); dc->desc = "ENSONIQ AudioPCI ES1370"; dc->vmsd = &vmstate_es1370; }
1threat
Why is the receiver thread not receiving anything in my Java piped streaming program? : <p>I have 3 very small classes.</p> <p>The main class:</p> <pre><code>import java.io.*; public class ConnectionManager { public static void main(String argv[]) { try { PipedOutputStream pout = new PipedOutputStream(); PipedInputStream pin = new PipedInputStream(pout); Sender s = new Sender(pout, true); Receiver r = new Receiver(pin, true); System.out.println("Starting threads"); s.start(); r.start(); } catch (Exception e) {} } } </code></pre> <p>The Sender class</p> <pre><code>import java.io.*; import java.util.Random; public class Sender extends Thread { ObjectOutputStream oos; boolean primitive; public Sender(OutputStream os, boolean primitive) { try { oos = new ObjectOutputStream(os); } catch (Exception e) {} this.primitive = primitive; } public void run() { Random rand = new Random(); while (true) { try { System.out.println("Integer is being sent"); oos.writeInt(10); Thread.sleep(1000); } catch (Exception e) {} } } } </code></pre> <p>And the Receiver class</p> <pre><code>import java.io.*; public class Receiver extends Thread { ObjectInputStream ois; boolean primitive; public Receiver(InputStream is, boolean primitive) { try { ois = new ObjectInputStream(is); } catch (Exception e) {} this.primitive = primitive; } public void run() { System.out.println("Receiver is starting"); while (true) { try { int x = ois.readInt(); System.out.print("An int was read: " + x); } catch (Exception e) {} } } } </code></pre> <p>Please ignore seemingly unused variables like <code>primitive</code> and <code>rand</code>. They're holdovers from slightly different versions that I was testing out earlier and I was too lazy to remove them.</p> <p>Anyway, when I run the main method in <code>ConnectionManager</code>, I get this as output:</p> <pre><code>Starting threads Receiver is starting Integer is being sent Integer is being sent Integer is being sent Integer is being sent Integer is being sent Integer is being sent Integer is being sent Integer is being sent //... ad infinitum </code></pre> <p>Why is the receiver thread not getting the messages that are piped through? What am I missing here?</p>
0debug
How can I log outside of main Flask module? : <p>I have a Python Flask application, the entry file configures a logger on the app, like so:</p> <pre><code>app = Flask(__name__) handler = logging.StreamHandler(sys.stdout) app.logger.addHandler(handler) app.logger.setLevel(logging.DEBUG) </code></pre> <p>I then do a bunch of logging using </p> <p><code>app.logger.debug("Log Message")</code></p> <p>which works fine. However, I have a few API functions like:</p> <pre><code>@app.route('/api/my-stuff', methods=['GET']) def get_my_stuff(): db_manager = get_manager() query = create_query(request.args) service = Service(db_manager, query) app.logger.debug("Req: {}".format(request.url)) </code></pre> <p>What I would like to know is how can I do logging within that <code>Service</code> module/python class. Do I have to pass the app to it? That seems like a bad practice, but I don't know how to get a handle to the app.logger from outside of the main Flask file...</p>
0debug
static int parse_bit(DeviceState *dev, Property *prop, const char *str) { if (!strcasecmp(str, "on")) bit_prop_set(dev, prop, true); else if (!strcasecmp(str, "off")) bit_prop_set(dev, prop, false); else return -EINVAL; return 0; }
1threat
static void vfio_add_ext_cap(VFIOPCIDevice *vdev) { PCIDevice *pdev = &vdev->pdev; uint32_t header; uint16_t cap_id, next, size; uint8_t cap_ver; uint8_t *config; if (!pci_is_express(pdev) || !pci_bus_is_express(pdev->bus) || !pci_get_long(pdev->config + PCI_CONFIG_SPACE_SIZE)) { return; } config = g_memdup(pdev->config, vdev->config_size); pci_set_long(pdev->config + PCI_CONFIG_SPACE_SIZE, PCI_EXT_CAP(0xFFFF, 0, 0)); pci_set_long(pdev->wmask + PCI_CONFIG_SPACE_SIZE, 0); pci_set_long(vdev->emulated_config_bits + PCI_CONFIG_SPACE_SIZE, ~0); for (next = PCI_CONFIG_SPACE_SIZE; next; next = PCI_EXT_CAP_NEXT(pci_get_long(config + next))) { header = pci_get_long(config + next); cap_id = PCI_EXT_CAP_ID(header); cap_ver = PCI_EXT_CAP_VER(header); size = vfio_ext_cap_max_size(config, next); pci_long_test_and_set_mask(vdev->emulated_config_bits + next, PCI_EXT_CAP_NEXT_MASK); switch (cap_id) { case PCI_EXT_CAP_ID_SRIOV: case PCI_EXT_CAP_ID_ARI: trace_vfio_add_ext_cap_dropped(vdev->vbasedev.name, cap_id, next); break; default: pcie_add_capability(pdev, cap_id, cap_ver, next, size); } } if (pci_get_word(pdev->config + PCI_CONFIG_SPACE_SIZE) == 0xFFFF) { pci_set_word(pdev->config + PCI_CONFIG_SPACE_SIZE, 0); } g_free(config); return; }
1threat
How to split or tokenize an array of strings by a space " " delimiter to find the second word in each string in C : I have an array that holds a bunch of strings. I want to find the second word in each of the strings that are contained in this array so I can sort the sentences alphabetically by the second word in the sentence. I tried using strtok but it doesn't work for tokenizing an array of strings. The delimiter is just the space between each word. I have to do this in c
0debug
Instance variable heap or stack ? ( with specific example) : <p>With the following code:</p> <pre><code>public class Main { public static void main(String args[]) { A objectA = new A(); objectA.deleteB(); } } public class A { private B objectB; public A() { this.objectB = new B(); } public void deleteB() { this.objectB = null; } } public class B { public B() {} } </code></pre> <p>The first frame in the stack is for main()</p> <p>with local variable objectA in the stack that contain reference to real Object A in the heap and in Object A in the heap we have a reference Object B pointing the real Object B also in the heap.</p> <p>The question is for the second frame in the stack deleteB()</p> <p>In the method I do: this.objectB = null;</p> <p>what does it mean in the memory ?</p>
0debug
How to use the UnsafeMutablePointer<UInt>? in Swift 3? : if let fileObject = NSString(contentsOfFile: strBundle, usedEncoding:Int32? Every time that I try to work this out, I get more frustrated! Please help me! I am not sure what I need to fill in the "usedEncoding:" parameter. Here is the error it gives me. Cannot convert value of type 'Int32?.Type' (aka 'Optional<Int32>.Type') to expected argument type 'UnsafeMutablePointer<UInt>?'
0debug
static void png_filter_row(DSPContext *dsp, uint8_t *dst, int filter_type, uint8_t *src, uint8_t *top, int size, int bpp) { int i; switch(filter_type) { case PNG_FILTER_VALUE_NONE: memcpy(dst, src, size); break; case PNG_FILTER_VALUE_SUB: dsp->diff_bytes(dst, src, src-bpp, size); memcpy(dst, src, bpp); break; case PNG_FILTER_VALUE_UP: dsp->diff_bytes(dst, src, top, size); break; case PNG_FILTER_VALUE_AVG: for(i = 0; i < bpp; i++) dst[i] = src[i] - (top[i] >> 1); for(; i < size; i++) dst[i] = src[i] - ((src[i-bpp] + top[i]) >> 1); break; case PNG_FILTER_VALUE_PAETH: for(i = 0; i < bpp; i++) dst[i] = src[i] - top[i]; sub_png_paeth_prediction(dst+i, src+i, top+i, size-i, bpp); break; } }
1threat
how to store an array of cllocationcoordinate2d to draw polyline : i want to store an array of cllocationcoordinate2d in core Data but the error always appear while executing the code [enter image description here][1] [1]: https://i.stack.imgur.com/UMuOc.png
0debug
Convert SQL or UTIL DATE to expected format "dd-MMM-yyyy", but not in String value : <p>I have a java util Date object and I need to write it in the format "dd-MMM-yyyy", but not as a String ( it can be sql or util Date, it does not matter ) and I do not understand what I am doing wrong because instead of "Nov" for month, I get "11". The right output is given only when I format to String...</p> <p>Can anyone help me ? This is what I tried so far and the reason I do not want a String is because I need to use this date as a parameter to run a database query and the field type in sql is Date.</p> <pre><code> Date currentDate = new Date(Calendar.getInstance().getTimeInMillis()); output value: Thu Nov 14 17:21:44 EET 2019 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MMM-yyyy"); String formattedDate = simpleDateFormat.format(currentDate); output value: 14-Nov-2019 java.util.Date date = simpleDateFormat.parse(formattedDate); output value: Thu Nov 14 00:00:00 EET 2019 java.sql.Date sqlStartDate = new java.sql.Date(date.getTime()); output value: 2019-11-14 </code></pre>
0debug
form posting other page getting error with php : problem with form posting to other page (redirection)and db storage and getting results i am beginner in php **here is the code** include 'include/header.php'; include 'include/connect.php'; if(isset($_SESSION['id']) && $_SESSION['id']!='') $reslt = mysqli_query($connection,"SELECT * FROM `queries` WHERE id='".$_SESSION['id']."'"); $row1= mysqli_fetch_array($reslt); if(isset($_POST['submitquary'])){ $title= $_POST['title']; $contact = $_POST['queries']; header("Location:pnf.php"); } else { $msg='<span style="color:red;text-align:center;font-size:15px">Sorry you miss some</span>'; } **html** <form method="post" class="postquations"> <label><b><class="p">Set your quaition title</b></label> <br> <input type="text" placeholder="Title"id="title" name="title" minlength="25" required=""autocomplete="off" oninvalid="true"><br> <label><b>ask your quation</b></label> <br> <textarea class="textinput" rows="10" minlength="100" id="queries"name="queries" style="overflow:hidden" placeholder="Comment Here.." required></textarea> <input type="submit"id="submit" class="butn"value="POST" name="submitquary"> </form> pnf.php <div class="title" > <?php echo $row['title'];?></div> <div class="quation"> <?php echo $row['queries'];?></div> please help me and explain why we are not getting results Thanks in advance
0debug
Vue/Vuetify - Unknown custom element: <v-app> - did you register the component correctly? : <p>I am new to Vue and Vuetify. I just created quick app to check both of them. But I am a running into issues in beginning. The vue fails to identify vuetify components despite following all the steps outlined in document. The error is like below - </p> <blockquote> <p>vue.runtime.esm.js?ff9b:587 [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.</p> <p>found in</p> <p>---> at src\App.vue </p> </blockquote> <p>You can access the entire code at sandbox <a href="https://codesandbox.io/s/40rqnl8kw" rel="noreferrer">https://codesandbox.io/s/40rqnl8kw</a></p>
0debug
Angular2 what is providers, when injector create service instance with provider, : <p>I really want to know What is providers? what relationship with DI in angular2?</p> <p>app.module.ts</p> <pre><code>@NgModule({ imports: [ BrowserModule, FormsModule, ], declarations: [ test, ], bootstrap: [ AppComponent ], providers: [ userService ] }) export class AppModule { } </code></pre> <p>test.component.ts</p> <pre><code>export class TestComponent implements OnInit, OnDestroy { constructor(public user: userService) } </code></pre> <p>In my understanding, provider contains services list token, injector will use these service token to new service instance. service must be registered in providers.</p> <p>I'm not sure services instance is created by injector or provider? If created by injector, why we need providers?</p>
0debug
void process_incoming_migration(QEMUFile *f) { if (qemu_loadvm_state(f) < 0) { fprintf(stderr, "load of migration failed\n"); exit(0); } qemu_announce_self(); DPRINTF("successfully loaded vm state\n"); if (autostart) vm_start(); }
1threat
Coroutine *qemu_coroutine_new(void) { const size_t stack_size = 1 << 20; CoroutineUContext *co; CoroutineThreadState *coTS; struct sigaction sa; struct sigaction osa; stack_t ss; stack_t oss; sigset_t sigs; sigset_t osigs; jmp_buf old_env; co = g_malloc0(sizeof(*co)); co->stack = g_malloc(stack_size); co->base.entry_arg = &old_env; coTS = coroutine_get_thread_state(); coTS->tr_handler = co; sigemptyset(&sigs); sigaddset(&sigs, SIGUSR2); pthread_sigmask(SIG_BLOCK, &sigs, &osigs); sa.sa_handler = coroutine_trampoline; sigfillset(&sa.sa_mask); sa.sa_flags = SA_ONSTACK; if (sigaction(SIGUSR2, &sa, &osa) != 0) { abort(); } ss.ss_sp = co->stack; ss.ss_size = stack_size; ss.ss_flags = 0; if (sigaltstack(&ss, &oss) < 0) { abort(); } coTS->tr_called = 0; pthread_kill(pthread_self(), SIGUSR2); sigfillset(&sigs); sigdelset(&sigs, SIGUSR2); while (!coTS->tr_called) { sigsuspend(&sigs); } sigaltstack(NULL, &ss); ss.ss_flags = SS_DISABLE; if (sigaltstack(&ss, NULL) < 0) { abort(); } sigaltstack(NULL, &ss); if (!(oss.ss_flags & SS_DISABLE)) { sigaltstack(&oss, NULL); } sigaction(SIGUSR2, &osa, NULL); pthread_sigmask(SIG_SETMASK, &osigs, NULL); if (!sigsetjmp(old_env, 0)) { siglongjmp(coTS->tr_reenter, 1); } return &co->base; }
1threat
Gradle - "enforceUniquePackageName" deprecated with version 3.0.0+? : <pre><code>android { enforceUniquePackageName = false } </code></pre> <p>"enforceUniquePackageName" works with the gradle version:</p> <pre><code>dependencies { classpath 'com.android.tools.build:gradle:2.3.1' } </code></pre> <p>However, if I change the gradle version to 3.0.0</p> <pre><code>dependencies { classpath 'com.android.tools.build:gradle:3.0.0-alpha9' } </code></pre> <p>I get: </p> <pre><code>Could not set unknown property 'enforceUniquePackageName' for object of type com.android.build.gradle.AppExtension. Open File </code></pre> <p>If 'enforceUniquePackageName' property is deprecated, then what would be the alternative option?</p>
0debug
Why does the one call on null succeeds and other fails? : <p>I am trying to run the following program : </p> <pre><code>#include &lt;iostream&gt; struct Foo { int x; void bar() { std::cout &lt;&lt; "La la la" &lt;&lt; std::endl; } void baz() { std::cout &lt;&lt; x &lt;&lt; std::endl; } }; int main() { Foo *foo = NULL; foo-&gt;bar(); foo-&gt;baz(); } </code></pre> <p><code>Output</code> : </p> <pre><code>./a.out La la la Segmentation fault (core dumped) </code></pre> <p>I am using g++ version 7.3.0 on ubuntu 18.04. Shouldn't both the calls fail as the object has been set to null?</p>
0debug
void hmp_info_local_apic(Monitor *mon, const QDict *qdict) { x86_cpu_dump_local_apic_state(mon_get_cpu(), (FILE *)mon, monitor_fprintf, CPU_DUMP_FPU); }
1threat
int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask, const AVFrame *reference) { int len, nb_components, i, h, v, predictor, point_transform; int index, id, ret; const int block_size = s->lossless ? 1 : 8; int ilv, prev_shift; if (!s->got_picture) { av_log(s->avctx, AV_LOG_WARNING, "Can not process SOS before SOF, skipping\n"); return -1; } av_assert0(s->picture_ptr->data[0]); len = get_bits(&s->gb, 16); nb_components = get_bits(&s->gb, 8); if (nb_components == 0 || nb_components > MAX_COMPONENTS) { av_log(s->avctx, AV_LOG_ERROR, "decode_sos: nb_components (%d) unsupported\n", nb_components); return AVERROR_PATCHWELCOME; } if (len != 6 + 2 * nb_components) { av_log(s->avctx, AV_LOG_ERROR, "decode_sos: invalid len (%d)\n", len); return AVERROR_INVALIDDATA; } for (i = 0; i < nb_components; i++) { id = get_bits(&s->gb, 8) - 1; av_log(s->avctx, AV_LOG_DEBUG, "component: %d\n", id); for (index = 0; index < s->nb_components; index++) if (id == s->component_id[index]) break; if (index == s->nb_components) { av_log(s->avctx, AV_LOG_ERROR, "decode_sos: index(%d) out of components\n", index); return AVERROR_INVALIDDATA; } if (s->avctx->codec_tag == MKTAG('M', 'T', 'S', 'J') && nb_components == 3 && s->nb_components == 3 && i) index = 3 - i; if(nb_components == 3 && s->nb_components == 3 && s->avctx->pix_fmt == AV_PIX_FMT_GBR24P) index = (i+2)%3; if(nb_components == 1 && s->nb_components == 3 && s->avctx->pix_fmt == AV_PIX_FMT_GBR24P) index = (index+2)%3; s->comp_index[i] = index; s->nb_blocks[i] = s->h_count[index] * s->v_count[index]; s->h_scount[i] = s->h_count[index]; s->v_scount[i] = s->v_count[index]; s->dc_index[i] = get_bits(&s->gb, 4); s->ac_index[i] = get_bits(&s->gb, 4); if (s->dc_index[i] < 0 || s->ac_index[i] < 0 || s->dc_index[i] >= 4 || s->ac_index[i] >= 4) goto out_of_range; if (!s->vlcs[0][s->dc_index[i]].table || !(s->progressive ? s->vlcs[2][s->ac_index[0]].table : s->vlcs[1][s->ac_index[i]].table)) goto out_of_range; } predictor = get_bits(&s->gb, 8); ilv = get_bits(&s->gb, 8); if(s->avctx->codec_tag != AV_RL32("CJPG")){ prev_shift = get_bits(&s->gb, 4); point_transform = get_bits(&s->gb, 4); }else prev_shift = point_transform = 0; if (nb_components > 1) { s->mb_width = (s->width + s->h_max * block_size - 1) / (s->h_max * block_size); s->mb_height = (s->height + s->v_max * block_size - 1) / (s->v_max * block_size); } else if (!s->ls) { h = s->h_max / s->h_scount[0]; v = s->v_max / s->v_scount[0]; s->mb_width = (s->width + h * block_size - 1) / (h * block_size); s->mb_height = (s->height + v * block_size - 1) / (v * block_size); s->nb_blocks[0] = 1; s->h_scount[0] = 1; s->v_scount[0] = 1; } if (s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_DEBUG, "%s %s p:%d >>:%d ilv:%d bits:%d skip:%d %s comp:%d\n", s->lossless ? "lossless" : "sequential DCT", s->rgb ? "RGB" : "", predictor, point_transform, ilv, s->bits, s->mjpb_skiptosod, s->pegasus_rct ? "PRCT" : (s->rct ? "RCT" : ""), nb_components); for (i = s->mjpb_skiptosod; i > 0; i--) skip_bits(&s->gb, 8); next_field: for (i = 0; i < nb_components; i++) s->last_dc[i] = 1024; if (s->lossless) { av_assert0(s->picture_ptr == &s->picture); if (CONFIG_JPEGLS_DECODER && s->ls) { if ((ret = ff_jpegls_decode_picture(s, predictor, point_transform, ilv)) < 0) return ret; } else { if (s->rgb) { if ((ret = ljpeg_decode_rgb_scan(s, nb_components, predictor, point_transform)) < 0) return ret; } else { if ((ret = ljpeg_decode_yuv_scan(s, predictor, point_transform, nb_components)) < 0) return ret; } } } else { if (s->progressive && predictor) { av_assert0(s->picture_ptr == &s->picture); if ((ret = mjpeg_decode_scan_progressive_ac(s, predictor, ilv, prev_shift, point_transform)) < 0) return ret; } else { if ((ret = mjpeg_decode_scan(s, nb_components, prev_shift, point_transform, mb_bitmask, reference)) < 0) return ret; } } if (s->interlaced && get_bits_left(&s->gb) > 32 && show_bits(&s->gb, 8) == 0xFF) { GetBitContext bak = s->gb; align_get_bits(&bak); if (show_bits(&bak, 16) == 0xFFD1) { av_log(s->avctx, AV_LOG_DEBUG, "AVRn interlaced picture marker found\n"); s->gb = bak; skip_bits(&s->gb, 16); s->bottom_field ^= 1; goto next_field; } } emms_c(); return 0; out_of_range: av_log(s->avctx, AV_LOG_ERROR, "decode_sos: ac/dc index out of range\n"); return AVERROR_INVALIDDATA; }
1threat
C# How can I get Process.Start to open an explorer window to the parent of c,d,e etc.)? : <p>I know I can open directory blah by doing </p> <p><code>System.Diagnostics.Process.Start(@"c:\");</code> </p> <p>But suppose I want to get the explorer window to the parent of c and list drives c,d,e e.t.c.. How can I do that? Note <code>(@"\")</code> doesn't do it.</p> <p>i.e. I want </p> <p><a href="https://i.stack.imgur.com/ZNpSx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZNpSx.png" alt="enter image description here"></a></p> <p>and not within <code>C:\</code> so I don't want</p> <p><a href="https://i.stack.imgur.com/k1Bmz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k1Bmz.png" alt="enter image description here"></a></p>
0debug
Is NodeJS required for a build Electron App? : <p>I have created my own app using electron and now built it using electron-packager to an .app file.</p> <p>Of course on my Mac — with NodeJS installed — it works. Now I wonder if it would work if I sent my app to a friend who doesn't have NodeJS installed. So my question is: <strong>Is NodeJS required to run a packaged electron app?</strong></p> <p>Thank you!</p>
0debug
How to get width of an element in react native? : <p>How get width of an element in react native such as View ? As there is not percent usage for width in react native, how to get width of an element or parent element?</p>
0debug
subset dataframe with sqldf : i try to subset dataframe using sqlfd but it don't work.can someone explain what don't work?i have processed like this. > library(sqldf) >dataf <- read.csv("zert.csv") >agep, pwgt1 are columns of dataf > dd <- sqldf("select * from dataf where AGEP < 50 and pwgtp1") >Error in .local(drv, ...) : >Failed to connect to database: Error: Access denied for user 'rodrigue'@'localhost' (using password: NO) Error in !dbPreExists : invalid argument type
0debug
static int ipvideo_decode_block_opcode_0xE(IpvideoContext *s) { int y; unsigned char pix; CHECK_STREAM_PTR(1); pix = *s->stream_ptr++; for (y = 0; y < 8; y++) { memset(s->pixel_ptr, pix, 8); s->pixel_ptr += s->stride; } return 0; }
1threat
Error in C# insert statement to sql server : I am trying to pass an insert statement in a c# winform to sql server. I keep getting a syntax error that just doesnt make sense to me "error in syntax near "(". My syntax is perfectly fine, as when I copy and paste into sql server mgmt studio, the code runs perfectly. Any help would be greatly appreciated! Thanks! [![error][1]][1] [Code][2] [![ErrorScreenshot[![\]\[2\]][3]][3]][4].png ***emphasized text*** [1]: https://i.stack.imgur.com/0qnnk.png [2]: https://i.stack.imgur.com/jsGL6 [3]: https://i.stack.imgur.com/IluxO.png [4]: https://i.stack.imgur.com/ZtjTT.png
0debug
VB.Net calling win32 api on 32 and 64 bit systems : To make an existing managed application with unmanaged 'appendages' 64-bit capable, I decided to rewrite a 32 bit unmanaged VC++ dll as a managed VB.Net class library. The application must be able to run on any framework from 2.0 up, and the VC++ code I ported was using named pipes, which are supported only from framework 3.5 up. So I had to resort to reflection, calling windows API functions for everything related to the pipes. The result works perfectly in 32 bit mode, but in 64 bit, I get all kinds of trouble. The actual behavior may change dramatically with even the least change in source code, just swapping some variable declarations around or moving a simple assignment statement to another location in the code may cause any effect from - "a barely noticeable hiccup every X hours of running fine", - "appear to receive some bad data from time to time" (it actually took WireShark and a decent portion of luck to find out that the first byte of a 13-byte packet received on the named pipe was passed as 0x00 to managed code, while it was actually received as 0x02 in the pipe data packet, while the rest of the packet was passed intact) to - "crash the entire .Net runtime with an error 0xc0000409 in mscorwks.dll soon as a client tries to connect to the pipe". If you ask me, the latter points towards something somewhere, probably a pointer or handle, is still being stored or passed to/from Win32 API at 32 bit sizes when running at 64 bit, but I can't figure out what. It must be in the API declarations, the rest is all managed code, and compiled with options 'strict' and 'explicit' both on. Can someone have a look at this and see if he can spot something I keep overlooking? Operation is asynchonous. The actual waits are performed at managed level on an array containing managed as well as unmanaged handles (through SafeWaitHandle wrapping), so events in managed together with unmanaged stuff can be dealt with by the same wait. <DllImport("kernel32", SetLastError:=True)> Private Shared Function CreateNamedPipe( lpName As String, dwOpenMode As Int32, dwPipeMode As Int32, nMaxInstances As Int32, nOutBufferSize As Int32, nInBufferSize As Int32, nDefaultTimeOut As Int32, lpSecurityAttributes As IntPtr ' when declared as SECURITY_ATTRIBUTES runtime won't accept passing Nothing, even when marked <[Optional]> ) As Microsoft.Win32.SafeHandles.SafeFileHandle : End Function <DllImport("kernel32", SetLastError:=True)> Private Shared Function ConnectNamedPipe( hNamedPipe As SafeHandle, ByRef lpOverlapped As System.Threading.NativeOverlapped ) As Boolean : End Function <DllImport("kernel32", SetLastError:=True)> Private Shared Function DisconnectNamedPipe( ByVal hNamedPipe As SafeHandle ) As Boolean : End Function <DllImport("kernel32", SetLastError:=True)> Private Shared Function ReadFile( <[In]> hFile As SafeHandle, <Out> lpBuffer As IntPtr, <[In]> nNumberOfBytesToRead As Int32, <Out, [Optional]> ByRef lpNumberOfBytesRead As Int32, <[In], Out, [Optional]> ByRef lpOverlapped As System.Threading.NativeOverlapped ) As Boolean : End Function <DllImport("kernel32", SetLastError:=True)> Private Shared Function WriteFile( <[In]> hFile As SafeHandle, <[In]> lpBuffer As IntPtr, <[In]> nNumberOfBytesToWrite As Int32, <[Out], [Optional]> ByRef lpNumberOfBytesWritten As Int32, <[In], [Out], [Optional]> ByRef lpOverlapped As NativeOverlapped ) As Boolean : End Function <DllImport("kernel32", SetLastError:=True)> Private Shared Function CloseHandle(hHandle As SafeHandle) As Boolean : End Function <DllImport("kernel32", SetLastError:=True)> Private Shared Function CloseHandle(hHandle As IntPtr) As Boolean : End Function <DllImport("kernel32", SetLastError:=True)> Private Shared Function GetOverlappedResult( ByVal hFile As SafeHandle, ByRef lpOverlapped As System.Threading.NativeOverlapped, ByRef lpNumberOfBytesTransferred As Int32, ByVal bWait As Boolean ) As Boolean : End Function <DllImport("kernel32", SetLastError:=True)> Private Shared Function CancelIo( <[In]> hFile As SafeHandle ) As Boolean : End Function <DllImport("kernel32", SetLastError:=True)> Private Shared Function PeekNamedPipe( <[In]> hNamedPipe As SafeHandle, <Out, [Optional]> ByRef lpBuffer As Byte(), <[In]> nBufferSize As Integer, <Out, [Optional]> ByRef lpBytesRead As Integer, <Out, [Optional]> ByRef lpTotalBytesAvail As Integer, <Out, [Optional]> ByRef lpBytesLeftThisMessage As Integer ) As Boolean : End Function <DllImport("kernel32", SetLastError:=True)> Private Shared Function GetProcessHeap() As IntPtr : End Function <DllImport("kernel32", SetLastError:=True)> Private Shared Function HeapAlloc( <[In]> hHeap As IntPtr, <[In]> dwFlags As Int32, <[In]> dwBytes As IntPtr ) As IntPtr : End Function <DllImport("kernel32", SetLastError:=True)> Private Shared Function HeapFree( <[In]> hHeap As IntPtr, <[In]> dwFlags As Int32, <[In]> lpMem As IntPtr ) As Boolean : End Function <DllImport("kernel32", SetLastError:=True)> Private Shared Function CreateEvent( <[In], [Optional]> lpEventAttributes As IntPtr, <[In]> bManualReset As Boolean, <[In]> bInitialState As Boolean, <[In], [Optional]> lpName As String ) As IntPtr : End Function This is how CreateEvent is used to create a handle managed code can wait for: Private Shared Function AllocateEventHandle() As Microsoft.Win32.SafeHandles.SafeWaitHandle Return New Microsoft.Win32.SafeHandles.SafeWaitHandle(CreateEvent(Nothing, False, False, Nothing), True) End Function Buffers to be used in calls to unmanaged code are created like this: Private Shared Function AllocateBuffer(nBytes As Integer) As IntPtr Return HeapAlloc(GetProcessHeap(), 0, New IntPtr(nBytes)) End Function
0debug
static int xen_pt_msgctrl_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, uint16_t *val, uint16_t dev_value, uint16_t valid_mask) { XenPTRegInfo *reg = cfg_entry->reg; XenPTMSI *msi = s->msi; uint16_t writable_mask = 0; uint16_t throughable_mask = get_throughable_mask(s, reg, valid_mask); if (*val & PCI_MSI_FLAGS_QSIZE) { XEN_PT_WARN(&s->dev, "Tries to set more than 1 vector ctrl %x\n", *val); } writable_mask = reg->emu_mask & ~reg->ro_mask & valid_mask; cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask); msi->flags |= cfg_entry->data & ~PCI_MSI_FLAGS_ENABLE; *val = XEN_PT_MERGE_VALUE(*val, dev_value, throughable_mask); if (*val & PCI_MSI_FLAGS_ENABLE) { if (!msi->initialized) { XEN_PT_LOG(&s->dev, "setup MSI (register: %x).\n", *val); if (xen_pt_msi_setup(s)) { *val &= ~PCI_MSI_FLAGS_ENABLE; XEN_PT_WARN(&s->dev, "Can not map MSI (register: %x)!\n", *val); return 0; } if (xen_pt_msi_update(s)) { *val &= ~PCI_MSI_FLAGS_ENABLE; XEN_PT_WARN(&s->dev, "Can not bind MSI (register: %x)!\n", *val); return 0; } msi->initialized = true; msi->mapped = true; } msi->flags |= PCI_MSI_FLAGS_ENABLE; } else if (msi->mapped) { xen_pt_msi_disable(s); } return 0; }
1threat
Your app has entered a break state, but there is no code to show because all threads were executing external code (typically system or framework code) : <p>Visual Studio 2017 breaks in debug mode and displays the message:</p> <blockquote> <p>Your app has entered a break state, but there is no code to show because all threads were executing external code (typically system or framework code).</p> </blockquote> <p>The message is in the <code>Break Mode Window</code>.</p> <p>What to do?</p>
0debug
Relational DB : is it a bad practice to store data on relationships? : <p>I work for a firm with a relational database. Some of my colleagues once told me that storing data directly on relationships (and not on entities) was a bad pratice. I can't remember why. Can you help me with that ? Do you agree ? What are the risks ?</p> <p>Many thanks !</p>
0debug
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { BinkAudioContext *s = avctx->priv_data; AVFrame *frame = data; GetBitContext *gb = &s->gb; int ret, consumed = 0; if (!get_bits_left(gb)) { uint8_t *buf; if (!avpkt->size) { *got_frame_ptr = 0; return 0; } if (avpkt->size < 4) { av_log(avctx, AV_LOG_ERROR, "Packet is too small\n"); return AVERROR_INVALIDDATA; } buf = av_realloc(s->packet_buffer, avpkt->size + FF_INPUT_BUFFER_PADDING_SIZE); if (!buf) return AVERROR(ENOMEM); s->packet_buffer = buf; memcpy(s->packet_buffer, avpkt->data, avpkt->size); if ((ret = init_get_bits8(gb, s->packet_buffer, avpkt->size)) < 0) return ret; consumed = avpkt->size; skip_bits_long(gb, 32); } frame->nb_samples = s->frame_len; if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) return ret; if (decode_block(s, (float **)frame->extended_data, avctx->codec->id == AV_CODEC_ID_BINKAUDIO_DCT)) { av_log(avctx, AV_LOG_ERROR, "Incomplete packet\n"); return AVERROR_INVALIDDATA; } get_bits_align32(gb); frame->nb_samples = s->block_size / avctx->channels; *got_frame_ptr = 1; return consumed; }
1threat
OpenVPN multiple IP addresses : <p>I have an OpenVPN server running on my Linux box and it's working fine. The server has a lot of IP addresses but it only uses one for all the clients (of course).</p> <p>Is it possible to use multiple IP addresses (public) on the same server?</p>
0debug
NoClassDefFoundError: com/google/common/base/Function in selenium web driver : <p>I want to run my first selenium web driver program but I got an Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Function</p> <pre><code>public class SimpleSelenium { WebDriver driver = null; String url = "http://www.google.com"; public static void main(String args[]){ SimpleSelenium ss = new SimpleSelenium(); ss.openBrowser(); ss.getPage(); ss.quitPage(); } private void openBrowser() { driver = new FirefoxDriver(); } private void quitPage() { driver.quit(); } private void getPage() { driver.get(url); } </code></pre>
0debug
how to remove duplicate record from results doing left join in sql : I have three tables User Table,Enquiry table and Activity Table .when I do a inner and LEFT JOIN, I am getting duplicate records because of NULL values. User Table -1 user_id | user_firstName | user_lastName 1 | Joe | Smith 2 | John | Doe 3 | Robert | Smith Enquiry Table -2 EnquiryID | CreatedBy| | 1 | 1 | 2 | 1 | Activiy Table - 3 ActivityID | CreatedBy| AssignedBy| AssignedTO| 1 | 1 | null | null | 2 | 1 | 2 | 3 | Expected Output of all three combining result is Enquiry ID | | CreatedBy| AssignedBy| AssignedTO| 1 | Joe | null | null | 2 | Joe | John | Rober | SQL: SELECT DISTINCT E.EnquirdID as Enquiry,U.FirstName as CreatedBY ,U1.FirstName as AssignedBY , U2,FirstName as AssignedTO FROM Enquiry E inner join User U on E.UserID = U.UserID inner join Activity A on E.Enquiry = A.EnquiryID Left Join User U1 on A.AssignedBY = U1.UserID Left Join User U2 on A.AssignedTO = U2.UserID I am getting duplicate Enquiry record from above query even though using Distinct for EnquiryID END RESULT: My plan is to use the SQL to select the data and display it in PHP on a website. It's a Enquiry management website. I want to be able to have PHP pull the variables from SQL so I can use them however I feel fit.
0debug
Which regular expression should I use to validate weight in VB? : <p>In one of my program's procedures; I want to use a regular expression along with a match statement, to make sure that the user properly input's the weight of an individual into a text box and also to make sure that it is entered in the right format. But I don't know which one to implement and am not very experienced with using the RegEx class in VB.Net.</p> <p>However, I know that the regex which is used must make sure that the user has entered the information in the following format:</p> <p><strong><em>123lb or 122223lb or 987LB or 23lB</em></strong></p> <p>The number of digits used before the 'lb' does not matter but the 'lb' section must be case-insensitive. The RegEx must also look for no other letters apart from "lb".</p> <p>For instance, some examples that shouldn't be matched:</p> <ul> <li>lb123 (The lb has to come after the digits)</li> <li>ab987 (The only letters that should be matched are lb)</li> <li>4875638546cder (Here the number of digits are fine, but the letters aren't just lb)</li> </ul> <p>Therefore in summary, the regex must:</p> <ul> <li>Look for no letters other than 'lb'</li> <li>Make sure that 'lb' comes after the digits entered by the user</li> <li>Be case-insensitive</li> </ul> <p>Any help would be much appreciated!</p> <p>Thanks for reading and have a good day!</p>
0debug
How to create/modify a jupyter notebook from code (python)? : <p>I am trying to automate my project create process and would like as part of it to create a new jupyter notebook and populate it with some cells and content that I usually have in every notebook (i.e., imports, titles, etc.)</p> <p>Is it possible to do this via python?</p>
0debug
static void assigned_dev_msix_mmio_write(void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { AssignedDevice *adev = opaque; PCIDevice *pdev = &adev->dev; uint16_t ctrl; MSIXTableEntry orig; int i = addr >> 4; if (i >= adev->msix_max) { return; } ctrl = pci_get_word(pdev->config + pdev->msix_cap + PCI_MSIX_FLAGS); DEBUG("write to MSI-X table offset 0x%lx, val 0x%lx\n", addr, val); if (ctrl & PCI_MSIX_FLAGS_ENABLE) { orig = adev->msix_table[i]; } memcpy((uint8_t *)adev->msix_table + addr, &val, size); if (ctrl & PCI_MSIX_FLAGS_ENABLE) { MSIXTableEntry *entry = &adev->msix_table[i]; if (!assigned_dev_msix_masked(&orig) && assigned_dev_msix_masked(entry)) { } else if (assigned_dev_msix_masked(&orig) && !assigned_dev_msix_masked(entry)) { if (i >= adev->msi_virq_nr || adev->msi_virq[i] < 0) { assigned_dev_update_msix(pdev); return; } else { MSIMessage msg; int ret; msg.address = entry->addr_lo | ((uint64_t)entry->addr_hi << 32); msg.data = entry->data; ret = kvm_irqchip_update_msi_route(kvm_state, adev->msi_virq[i], msg); if (ret) { error_report("Error updating irq routing entry (%d)", ret); } } } } }
1threat
static int decode_gop_header(IVI45DecContext *ctx, AVCodecContext *avctx) { int result, i, p, tile_size, pic_size_indx, mb_size, blk_size; int quant_mat, blk_size_changed = 0; IVIBandDesc *band, *band1, *band2; IVIPicConfig pic_conf; ctx->gop_flags = get_bits(&ctx->gb, 8); ctx->gop_hdr_size = (ctx->gop_flags & 1) ? get_bits(&ctx->gb, 16) : 0; if (ctx->gop_flags & IVI5_IS_PROTECTED) ctx->lock_word = get_bits_long(&ctx->gb, 32); tile_size = (ctx->gop_flags & 0x40) ? 64 << get_bits(&ctx->gb, 2) : 0; if (tile_size > 256) { av_log(avctx, AV_LOG_ERROR, "Invalid tile size: %d\n", tile_size); return -1; } pic_conf.luma_bands = get_bits(&ctx->gb, 2) * 3 + 1; pic_conf.chroma_bands = get_bits1(&ctx->gb) * 3 + 1; ctx->is_scalable = pic_conf.luma_bands != 1 || pic_conf.chroma_bands != 1; if (ctx->is_scalable && (pic_conf.luma_bands != 4 || pic_conf.chroma_bands != 1)) { av_log(avctx, AV_LOG_ERROR, "Scalability: unsupported subdivision! Luma bands: %d, chroma bands: %d\n", pic_conf.luma_bands, pic_conf.chroma_bands); return -1; } pic_size_indx = get_bits(&ctx->gb, 4); if (pic_size_indx == IVI5_PIC_SIZE_ESC) { pic_conf.pic_height = get_bits(&ctx->gb, 13); pic_conf.pic_width = get_bits(&ctx->gb, 13); } else { pic_conf.pic_height = ivi5_common_pic_sizes[pic_size_indx * 2 + 1] << 2; pic_conf.pic_width = ivi5_common_pic_sizes[pic_size_indx * 2 ] << 2; } if (ctx->gop_flags & 2) { av_log(avctx, AV_LOG_ERROR, "YV12 picture format not supported!\n"); return -1; } pic_conf.chroma_height = (pic_conf.pic_height + 3) >> 2; pic_conf.chroma_width = (pic_conf.pic_width + 3) >> 2; if (!tile_size) { pic_conf.tile_height = pic_conf.pic_height; pic_conf.tile_width = pic_conf.pic_width; } else { pic_conf.tile_height = pic_conf.tile_width = tile_size; } if (ivi_pic_config_cmp(&pic_conf, &ctx->pic_conf)) { result = ff_ivi_init_planes(ctx->planes, &pic_conf); if (result) { av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate color planes!\n"); return -1; } ctx->pic_conf = pic_conf; blk_size_changed = 1; } for (p = 0; p <= 1; p++) { for (i = 0; i < (!p ? pic_conf.luma_bands : pic_conf.chroma_bands); i++) { band = &ctx->planes[p].bands[i]; band->is_halfpel = get_bits1(&ctx->gb); mb_size = get_bits1(&ctx->gb); blk_size = 8 >> get_bits1(&ctx->gb); mb_size = blk_size << !mb_size; blk_size_changed = mb_size != band->mb_size || blk_size != band->blk_size; if (blk_size_changed) { band->mb_size = mb_size; band->blk_size = blk_size; } if (get_bits1(&ctx->gb)) { av_log(avctx, AV_LOG_ERROR, "Extended transform info encountered!\n"); return -1; } switch ((p << 2) + i) { case 0: band->inv_transform = ff_ivi_inverse_slant_8x8; band->dc_transform = ff_ivi_dc_slant_2d; band->scan = ff_zigzag_direct; break; case 1: band->inv_transform = ff_ivi_row_slant8; band->dc_transform = ff_ivi_dc_row_slant; band->scan = ff_ivi_vertical_scan_8x8; break; case 2: band->inv_transform = ff_ivi_col_slant8; band->dc_transform = ff_ivi_dc_col_slant; band->scan = ff_ivi_horizontal_scan_8x8; break; case 3: band->inv_transform = ff_ivi_put_pixels_8x8; band->dc_transform = ff_ivi_put_dc_pixel_8x8; band->scan = ff_ivi_horizontal_scan_8x8; break; case 4: band->inv_transform = ff_ivi_inverse_slant_4x4; band->dc_transform = ff_ivi_dc_slant_2d; band->scan = ff_ivi_direct_scan_4x4; break; } band->is_2d_trans = band->inv_transform == ff_ivi_inverse_slant_8x8 || band->inv_transform == ff_ivi_inverse_slant_4x4; if (!p) { quant_mat = (pic_conf.luma_bands > 1) ? i+1 : 0; } else { quant_mat = 5; } if (band->blk_size == 8) { band->intra_base = &ivi5_base_quant_8x8_intra[quant_mat][0]; band->inter_base = &ivi5_base_quant_8x8_inter[quant_mat][0]; band->intra_scale = &ivi5_scale_quant_8x8_intra[quant_mat][0]; band->inter_scale = &ivi5_scale_quant_8x8_inter[quant_mat][0]; } else { band->intra_base = ivi5_base_quant_4x4_intra; band->inter_base = ivi5_base_quant_4x4_inter; band->intra_scale = ivi5_scale_quant_4x4_intra; band->inter_scale = ivi5_scale_quant_4x4_inter; } if (get_bits(&ctx->gb, 2)) { av_log(avctx, AV_LOG_ERROR, "End marker missing!\n"); return -1; } } } for (i = 0; i < pic_conf.chroma_bands; i++) { band1 = &ctx->planes[1].bands[i]; band2 = &ctx->planes[2].bands[i]; band2->width = band1->width; band2->height = band1->height; band2->mb_size = band1->mb_size; band2->blk_size = band1->blk_size; band2->is_halfpel = band1->is_halfpel; band2->intra_base = band1->intra_base; band2->inter_base = band1->inter_base; band2->intra_scale = band1->intra_scale; band2->inter_scale = band1->inter_scale; band2->scan = band1->scan; band2->inv_transform = band1->inv_transform; band2->dc_transform = band1->dc_transform; band2->is_2d_trans = band1->is_2d_trans; } if (blk_size_changed) { result = ff_ivi_init_tiles(ctx->planes, pic_conf.tile_width, pic_conf.tile_height); if (result) { av_log(avctx, AV_LOG_ERROR, "Couldn't reallocate internal structures!\n"); return -1; } } if (ctx->gop_flags & 8) { if (get_bits(&ctx->gb, 3)) { av_log(avctx, AV_LOG_ERROR, "Alignment bits are not zero!\n"); return -1; } if (get_bits1(&ctx->gb)) skip_bits_long(&ctx->gb, 24); } align_get_bits(&ctx->gb); skip_bits(&ctx->gb, 23); if (get_bits1(&ctx->gb)) { do { i = get_bits(&ctx->gb, 16); } while (i & 0x8000); } align_get_bits(&ctx->gb); return 0; }
1threat
C++ How to Check if Array contents can add up to a specific number : <p>Let's say I got this Array:</p> <pre><code>int myArray[] = {2,5,8,3,2,1,9}; </code></pre> <p>is ther any way I could check if some of the contents can add up to 20? I managed to check if any two values add up to 20 but I just don't know how to handle it if is irrelevant how many values it needs.</p> <p>Thank you for your help.</p>
0debug
How to shift a block of code left/right by one space in VSCode? : <p>In VSCode, I can use alt-up and alt-down to move a line or block up or down, but I can't find a command to increase or decrease indent by one space.</p> <p>I <em>can</em> indent/outdent by multiples of tabSize, but that's not quite general enough for me, and I don't really want to set tabSize=1.</p> <p>(In Vim I made handy shortcuts to move a line or lines up/down/left/right with ctrl-k/j/h/l - it was probably the most useful bit of Vimscript I ever wrote.)</p>
0debug
value error in python statsmodels.tsa.seasonal : <p>I have this dataframe with date time indices:</p> <pre><code>ts_log: </code></pre> <p><code>date price_per_unit 2013-04-04 12.762369 2013-04-05 12.777120 2013-04-06 12.773146 2013-04-07 12.780774 2013-04-08 12.786835</code></p> <p>I have this piece of code for <code>decomposition</code> `</p> <pre><code>from statsmodels.tsa.seasonal import seasonal_decompose decomposition = seasonal_decompose(ts_log) trend = decomposition.trend seasonal = decomposition.seasonal residual = decomposition.resid </code></pre> <p>but in the line <code>decomposition = seasonal_decompose(ts_log)</code> i got this error :</p> <pre><code>ValueError: You must specify a freq or x must be a pandas object with a timeseries index </code></pre> <p>Where is the problem?</p>
0debug
yuv2yuvX16_c_template(const int16_t *lumFilter, const int32_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int32_t **chrUSrc, const int32_t **chrVSrc, int chrFilterSize, const int32_t **alpSrc, uint16_t *dest[4], int dstW, int chrDstW, int big_endian, int output_bits) { int i; int dword= output_bits == 16; uint16_t *yDest = dest[0], *uDest = dest[1], *vDest = dest[2], *aDest = CONFIG_SWSCALE_ALPHA ? dest[3] : NULL; int shift = 11 + 4*dword + 16 - output_bits; #define output_pixel(pos, val) \ if (big_endian) { \ if (output_bits == 16) { \ AV_WB16(pos, av_clip_uint16(val >> shift)); \ } else { \ AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \ } \ } else { \ if (output_bits == 16) { \ AV_WL16(pos, av_clip_uint16(val >> shift)); \ } else { \ AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \ } \ } for (i = 0; i < dstW; i++) { int val = 1 << (26-output_bits + 4*dword); int j; for (j = 0; j < lumFilterSize; j++) val += (dword ? lumSrc[j][i] : ((int16_t**)lumSrc)[j][i]) * lumFilter[j]; output_pixel(&yDest[i], val); } if (uDest) { for (i = 0; i < chrDstW; i++) { int u = 1 << (26-output_bits + 4*dword); int v = 1 << (26-output_bits + 4*dword); int j; for (j = 0; j < chrFilterSize; j++) { u += (dword ? chrUSrc[j][i] : ((int16_t**)chrUSrc)[j][i]) * chrFilter[j]; v += (dword ? chrVSrc[j][i] : ((int16_t**)chrVSrc)[j][i]) * chrFilter[j]; } output_pixel(&uDest[i], u); output_pixel(&vDest[i], v); } } if (CONFIG_SWSCALE_ALPHA && aDest) { for (i = 0; i < dstW; i++) { int val = 1 << (26-output_bits + 4*dword); int j; for (j = 0; j < lumFilterSize; j++) val += (dword ? alpSrc[j][i] : ((int16_t**)alpSrc)[j][i]) * lumFilter[j]; output_pixel(&aDest[i], val); } } #undef output_pixel }
1threat
static void cirrus_bitblt_fill_nop(CirrusVGAState *s, uint8_t *dst, int dstpitch, int bltwidth,int bltheight) { }
1threat
document.getElementById('input').innerHTML = user_input;
1threat
Change css property using jquery : <p>Please check the code bellow. I want to change a css property after click on 'switch' button. Whats wrong i am doing here? Also please help me to do this with any other way if possible. Thanks all </p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;test&lt;/title&gt; &lt;script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"&gt;&lt;/script&gt; &lt;link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"&gt; &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;button id="myButton"&gt;switch&lt;/button&gt; &lt;p class="foo"&gt;Some text&lt;/p&gt; &lt;script type="text/javascript"&gt; $("#myButton").click(function() { $(".foo").attr("background", "red"); }); &lt;/script&gt; &lt;style&gt; .foo { background: gray; } &lt;/style&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
0debug
Kubernetes: --image-pull-policy always does not work : <p>I have a Kubernetes deployment which uses image: <code>test:latest</code> (not real image name but it's the latest tag). This image is on docker hub. I have just pushed a new version of <code>test:latest</code> to dockerhub. I was expecting a new deployment of my pod in Kubernetes but nothing happends.</p> <p>I've created my deployment like this:</p> <pre><code>kubectl run sample-app --image=`test:latest` --namespace=sample-app --image-pull-policy Always </code></pre> <p>Why isn't there a new deployment triggered after the push of a new image?</p>
0debug
Array scope issue with jQuery : These scope issues is driving me crazy. I have var foo = ["apples", "bananas", "grapes"]; $(document).ready(function(){ $(select).change(function(){ console.log(foo); }) }); The array within console log won't be exist. How can I bring it there ? Hanks
0debug
sonarqube + lombok = false positives : <pre><code>import lombok.Data; @Data public class Filter { private Operator operator; private Object value; private String property; private PropertyType propertyType; } </code></pre> <p>For code above there are 4 squid:S1068 reports about unused private fields. (even they are used by lombok generated getters). I've seen that some fixes related to support of "lombok.Data" annotation have been pushed, but still having these annoying false positives.</p> <p>Versions: SonarQube 6.4.0.25310<br> SonarJava 4.13.0.11627<br> SonarQube scanner for Jenkins (2.6.1)</p>
0debug
How to set up the Twitter gem in rails app? please help me please : i have installed ruby rails on my computer. i would like to create twitter API with ruby rails. [i downloaded this gem zip file also ][1] [1]: http://i.stack.imgur.com/eMNsJ.jpg i have twitter API token and key. i don't know how to move up so please help.
0debug
Livy Server on Amazon EMR hangs on Connecting to ResourceManager : <p>I'm trying to deploy a Livy Server on Amazon EMR. First I built the Livy master branch</p> <pre><code>mvn clean package -Pscala-2.11 -Pspark-2.0 </code></pre> <p>Then, I uploaded it to the EMR cluster master. I set the following configurations:</p> <p><strong>livy-env.sh</strong></p> <pre><code>SPARK_HOME=/usr/lib/spark HADOOP_CONF_DIR=/etc/hadoop/conf </code></pre> <p><strong>livy.conf</strong></p> <pre><code>livy.spark.master = yarn livy.spark.deployMode = cluster </code></pre> <p>When I start Livy, it hangs indefinitely while connecting to YARN Resource manager (XX.XX.XXX.XX is the IP address)</p> <pre><code>16/10/28 17:56:23 INFO RMProxy: Connecting to ResourceManager at /XX.XX.XXX.XX:8032 </code></pre> <p>However when I netcat the port 8032, it connects successfully</p> <pre><code>nc -zv XX.XX.XXX.XX 8032 Connection to XX.XX.XXX.XX 8032 port [tcp/pro-ed] succeeded! </code></pre> <p>I think I'm probably missing some step. Anyone has any idea of what this step might be?</p>
0debug
static int h264_init_context(AVCodecContext *avctx, H264Context *h) { int i; h->avctx = avctx; h->picture_structure = PICT_FRAME; h->workaround_bugs = avctx->workaround_bugs; h->flags = avctx->flags; h->poc.prev_poc_msb = 1 << 16; h->recovery_frame = -1; h->frame_recovered = 0; h->next_outputed_poc = INT_MIN; for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++) h->last_pocs[i] = INT_MIN; ff_h264_sei_uninit(&h->sei); avctx->chroma_sample_location = AVCHROMA_LOC_LEFT; h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? avctx->thread_count : 1; h->slice_ctx = av_mallocz_array(h->nb_slice_ctx, sizeof(*h->slice_ctx)); if (!h->slice_ctx) { h->nb_slice_ctx = 0; return AVERROR(ENOMEM); } for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) { h->DPB[i].f = av_frame_alloc(); if (!h->DPB[i].f) return AVERROR(ENOMEM); } h->cur_pic.f = av_frame_alloc(); if (!h->cur_pic.f) return AVERROR(ENOMEM); h->output_frame = av_frame_alloc(); if (!h->output_frame) return AVERROR(ENOMEM); for (i = 0; i < h->nb_slice_ctx; i++) h->slice_ctx[i].h264 = h; return 0; }
1threat
static int mpc8_decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MPCContext *c = avctx->priv_data; GetBitContext gb2, *gb = &gb2; int i, j, k, ch, cnt, res, t; Band *bands = c->bands; int off; int maxband, keyframe; int last[2]; c->frame.nb_samples = MPC_FRAME_SIZE; if ((res = avctx->get_buffer(avctx, &c->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return res; } keyframe = c->cur_frame == 0; if(keyframe){ memset(c->Q, 0, sizeof(c->Q)); c->last_bits_used = 0; } init_get_bits(gb, buf, buf_size * 8); skip_bits(gb, c->last_bits_used & 7); if(keyframe) maxband = mpc8_get_mod_golomb(gb, c->maxbands + 1); else{ maxband = c->last_max_band + get_vlc2(gb, band_vlc.table, MPC8_BANDS_BITS, 2); if(maxband > 32) maxband -= 33; } if(maxband > c->maxbands + 1 || maxband >= BANDS) { av_log(avctx, AV_LOG_ERROR, "maxband %d too large\n",maxband); return AVERROR_INVALIDDATA; } c->last_max_band = maxband; if(maxband){ last[0] = last[1] = 0; for(i = maxband - 1; i >= 0; i--){ for(ch = 0; ch < 2; ch++){ last[ch] = get_vlc2(gb, res_vlc[last[ch] > 2].table, MPC8_RES_BITS, 2) + last[ch]; if(last[ch] > 15) last[ch] -= 17; bands[i].res[ch] = last[ch]; } } if(c->MSS){ int mask; cnt = 0; for(i = 0; i < maxband; i++) if(bands[i].res[0] || bands[i].res[1]) cnt++; t = mpc8_get_mod_golomb(gb, cnt); mask = mpc8_get_mask(gb, cnt, t); for(i = maxband - 1; i >= 0; i--) if(bands[i].res[0] || bands[i].res[1]){ bands[i].msf = mask & 1; mask >>= 1; } } } for(i = maxband; i < c->maxbands; i++) bands[i].res[0] = bands[i].res[1] = 0; if(keyframe){ for(i = 0; i < 32; i++) c->oldDSCF[0][i] = c->oldDSCF[1][i] = 1; } for(i = 0; i < maxband; i++){ if(bands[i].res[0] || bands[i].res[1]){ cnt = !!bands[i].res[0] + !!bands[i].res[1] - 1; if(cnt >= 0){ t = get_vlc2(gb, scfi_vlc[cnt].table, scfi_vlc[cnt].bits, 1); if(bands[i].res[0]) bands[i].scfi[0] = t >> (2 * cnt); if(bands[i].res[1]) bands[i].scfi[1] = t & 3; } } } for(i = 0; i < maxband; i++){ for(ch = 0; ch < 2; ch++){ if(!bands[i].res[ch]) continue; if(c->oldDSCF[ch][i]){ bands[i].scf_idx[ch][0] = get_bits(gb, 7) - 6; c->oldDSCF[ch][i] = 0; }else{ t = get_vlc2(gb, dscf_vlc[1].table, MPC8_DSCF1_BITS, 2); if(t == 64) t += get_bits(gb, 6); bands[i].scf_idx[ch][0] = ((bands[i].scf_idx[ch][2] + t - 25) & 0x7F) - 6; } for(j = 0; j < 2; j++){ if((bands[i].scfi[ch] << j) & 2) bands[i].scf_idx[ch][j + 1] = bands[i].scf_idx[ch][j]; else{ t = get_vlc2(gb, dscf_vlc[0].table, MPC8_DSCF0_BITS, 2); if(t == 31) t = 64 + get_bits(gb, 6); bands[i].scf_idx[ch][j + 1] = ((bands[i].scf_idx[ch][j] + t - 25) & 0x7F) - 6; } } } } for(i = 0, off = 0; i < maxband; i++, off += SAMPLES_PER_BAND){ for(ch = 0; ch < 2; ch++){ res = bands[i].res[ch]; switch(res){ case -1: for(j = 0; j < SAMPLES_PER_BAND; j++) c->Q[ch][off + j] = (av_lfg_get(&c->rnd) & 0x3FC) - 510; break; case 0: break; case 1: for(j = 0; j < SAMPLES_PER_BAND; j += SAMPLES_PER_BAND / 2){ cnt = get_vlc2(gb, q1_vlc.table, MPC8_Q1_BITS, 2); t = mpc8_get_mask(gb, 18, cnt); for(k = 0; k < SAMPLES_PER_BAND / 2; k++, t <<= 1) c->Q[ch][off + j + k] = (t & 0x20000) ? (get_bits1(gb) << 1) - 1 : 0; } break; case 2: cnt = 6; for(j = 0; j < SAMPLES_PER_BAND; j += 3){ t = get_vlc2(gb, q2_vlc[cnt > 3].table, MPC8_Q2_BITS, 2); c->Q[ch][off + j + 0] = mpc8_idx50[t]; c->Q[ch][off + j + 1] = mpc8_idx51[t]; c->Q[ch][off + j + 2] = mpc8_idx52[t]; cnt = (cnt >> 1) + mpc8_huffq2[t]; } break; case 3: case 4: for(j = 0; j < SAMPLES_PER_BAND; j += 2){ t = get_vlc2(gb, q3_vlc[res - 3].table, MPC8_Q3_BITS, 2) + q3_offsets[res - 3]; c->Q[ch][off + j + 1] = t >> 4; c->Q[ch][off + j + 0] = (t & 8) ? (t & 0xF) - 16 : (t & 0xF); } break; case 5: case 6: case 7: case 8: cnt = 2 * mpc8_thres[res]; for(j = 0; j < SAMPLES_PER_BAND; j++){ t = get_vlc2(gb, quant_vlc[res - 5][cnt > mpc8_thres[res]].table, quant_vlc[res - 5][cnt > mpc8_thres[res]].bits, 2) + quant_offsets[res - 5]; c->Q[ch][off + j] = t; cnt = (cnt >> 1) + FFABS(c->Q[ch][off + j]); } break; default: for(j = 0; j < SAMPLES_PER_BAND; j++){ c->Q[ch][off + j] = get_vlc2(gb, q9up_vlc.table, MPC8_Q9UP_BITS, 2); if(res != 9){ c->Q[ch][off + j] <<= res - 9; c->Q[ch][off + j] |= get_bits(gb, res - 9); } c->Q[ch][off + j] -= (1 << (res - 2)) - 1; } } } } ff_mpc_dequantize_and_synth(c, maxband - 1, c->frame.data[0], avctx->channels); c->cur_frame++; c->last_bits_used = get_bits_count(gb); if(c->cur_frame >= c->frames) c->cur_frame = 0; *got_frame_ptr = 1; *(AVFrame *)data = c->frame; return c->cur_frame ? c->last_bits_used >> 3 : buf_size; }
1threat
Oracle : SUM of columns duplicates : I have table as below DATE | JOB_ID |Name | Count --------------------|-----------|-----------|-------- 01-JAN-18 01:02:41 | JOB_1 | weight | 200 01-JAN-18 01:02:41 | JOB_1 | weight | 200 01-JAN-18 01:02:42 | JOB_1 | weight | 200 01-JAN-18 01:02:43 | JOB_1 | weight | 200 01-JAN-18 01:02:43 | JOB_1 | weight | 200 02-JAN-18 01:02:44 | JOB_2 | weight | 200 02-JAN-18 01:02:45 | JOB_2 | weight | 200 01-JAN-18 01:03:16 | JOB_1 | baseball | 192 01-JAN-18 01:11:15 | JOB_1 | hanescom | 37 01-JAN-18 01:11:15 | JOB_1 | hanescom | 200 01-JAN-18 01:11:16 | JOB_1 | hanescom | 200 01-JAN-18 01:11:17 | JOB_1 | hanescom | 200 01-JAN-18 01:11:17 | JOB_1 | hanescom | 200 01-JAN-18 01:11:18 | JOB_1 | hanescom | 200 03-JAN-18 01:11:25 | JOB_3 | hanescom | 200 03-JAN-18 01:11:26 | JOB_3 | hanescom | 200 03-JAN-18 01:11:26 | JOB_3 | hanescom | 200 01-JAN-18 01:11:27 | JOB_1 | hanescom | 189 01-JAN-18 01:11:28 | JOB_1 | wwbundle | 200 01-JAN-18 01:11:29 | JOB_1 | wwbundle | 200 01-JAN-18 01:11:29 | JOB_1 | wwbundle | 200 01-JAN-18 01:11:30 | JOB_1 | wwbundle | 200 i want to get below results, DATE | JOB_ID |Name | sum(Count) --------------------|-----------|-----------|-------- 01-JAN-18 |JOB_1 |weight | 1000 02-JAN-18 |JOB_2 |weight | 400 01-JAN-18 |JOB_1 |baseball | 192 01-JAN-18 |JOB_1 |hanescom | 1226 03-JAN-18 |JOB_3 |hanescom | 600 01-JAN-18 |JOB_1 |wwbundle | 800
0debug
MockRestServiceServer simulate backend timeout in integration test : <p>I am writing some kind of integration test on my REST controller using MockRestServiceServer to mock backend behaviour. What I am trying to achieve now is to simulate very slow response from backend which would finally lead to timeout in my application. It seems that it can be implemented with WireMock but at the moment I would like to stick to MockRestServiceServer.</p> <p>I am creating server like this:</p> <pre><code>myMock = MockRestServiceServer.createServer(asyncRestTemplate); </code></pre> <p>And then I'm mocking my backend behaviour like:</p> <pre><code>myMock.expect(requestTo("http://myfakeurl.blabla")) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(myJsonResponse, MediaType.APPLICATION_JSON)); </code></pre> <p>Is it possible to add some kind of a delay or timeout or other kind of latency to the response (or maybe whole mocked server or even my asyncRestTemplate)? Or should I just switch to WireMock or maybe Restito?</p>
0debug
compilation error is showing while spliting 1 column into multiple column : while splitting my one column in dataFrame into 2 column using below code , i have tried with two type of code but both the time i got error while running the program.in IteliJ screen its not showing error(means no red mark) but while running it shows error on console. my data frame is: +---------+ |Wrap Time| +---------+ | 19.674| | 11.466| | 263.697| code: 1 val df2= df.withColumn("nested", split(col("Wrap Time"), ".")) .withColumn("Call Completion Code_1", $"nested".getItem(0)) .withColumn("Call Completion Code_2", $"nested".getItem(1)) .withColumn("Call Completion Code_3", $"nested".getItem(2)) .drop("nested") Error:(26, 43) could not find implicit value for parameter impl: breeze.linalg.split.Impl2[org.apache.spark.sql.Column,String,VR] val df2= df.withColumn("nested", split(col("Wrap Time"), ".")) Error:(26, 43) not enough arguments for method apply: (implicit impl: breeze.linalg.split.Impl2[org.apache.spark.sql.Column,String,VR])VR in trait UFunc. Unspecified value parameter impl. val df2= df.withColumn("nested", split(col("Wrap Time"), ".")) code: 2: val df2= df. withColumn("nested", split($"Wrap Time", ".")).select($"nested"(0) as "Call Completion Code_1", $"nested"(1) as "Call Completion Code_2") Error:(23, 33) could not find implicit value for parameter impl: breeze.linalg.split.Impl2[org.apache.spark.sql.ColumnName,String,VR] withColumn("nested", split($"Wrap Time", ".")).select($"nested"(0) as "Call Completion Code_1", $"nested"(1) as "Call Completion Code_2") Error:(23, 33) not enough arguments for method apply: (implicit impl: breeze.linalg.split.Impl2[org.apache.spark.sql.ColumnName,String,VR])VR in trait UFunc. Unspecified value parameter impl. withColumn("nested", split($"Wrap Time", ".")).select($"nested"(0) as "Call Completion Code_1", $"nested"(1) as "Call Completion Code_2") spark version is: spark-2.3.2 scala 2.11.8 jdk1.8.0_20 sbt-1.2.7
0debug
int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries, uint8_t bar_nr) { int ret; char *name; uint32_t bar_size = 4096; uint32_t bar_pba_offset = bar_size / 2; uint32_t bar_pba_size = (nentries / 8 + 1) * 8; if (nentries * PCI_MSIX_ENTRY_SIZE > bar_pba_offset) { bar_pba_offset = nentries * PCI_MSIX_ENTRY_SIZE; } if (bar_pba_offset + bar_pba_size > 4096) { bar_size = bar_pba_offset + bar_pba_size; } if (bar_size & (bar_size - 1)) { bar_size = 1 << qemu_fls(bar_size); } name = g_strdup_printf("%s-msix", dev->name); memory_region_init(&dev->msix_exclusive_bar, OBJECT(dev), name, bar_size); g_free(name); ret = msix_init(dev, nentries, &dev->msix_exclusive_bar, bar_nr, 0, &dev->msix_exclusive_bar, bar_nr, bar_pba_offset, 0); if (ret) { return ret; } pci_register_bar(dev, bar_nr, PCI_BASE_ADDRESS_SPACE_MEMORY, &dev->msix_exclusive_bar); return 0; }
1threat
static void gdb_set_cpu_pc(GDBState *s, target_ulong pc) { #if defined(TARGET_I386) cpu_synchronize_state(s->c_cpu); s->c_cpu->eip = pc; #elif defined (TARGET_PPC) s->c_cpu->nip = pc; #elif defined (TARGET_SPARC) s->c_cpu->pc = pc; s->c_cpu->npc = pc + 4; #elif defined (TARGET_ARM) s->c_cpu->regs[15] = pc; #elif defined (TARGET_SH4) s->c_cpu->pc = pc; #elif defined (TARGET_MIPS) s->c_cpu->active_tc.PC = pc; #elif defined (TARGET_MICROBLAZE) s->c_cpu->sregs[SR_PC] = pc; #elif defined (TARGET_CRIS) s->c_cpu->pc = pc; #elif defined (TARGET_ALPHA) s->c_cpu->pc = pc; #elif defined (TARGET_S390X) cpu_synchronize_state(s->c_cpu); s->c_cpu->psw.addr = pc; #endif }
1threat
static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp) { DeviceState *qdev = DEVICE(ccw_dev); VirtIONetCcw *dev = VIRTIO_NET_CCW(ccw_dev); DeviceState *vdev = DEVICE(&dev->vdev); Error *err = NULL; virtio_net_set_netclient_name(&dev->vdev, qdev->id, object_get_typename(OBJECT(qdev))); qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); object_property_set_bool(OBJECT(vdev), true, "realized", &err); if (err) { error_propagate(errp, err); } }
1threat
I am not able to import able to import my class from one packege to another package : I am having two different package. here is the first package and name of the package is package com.restro.dextrocustomer;... and class name is.. public class FirstPageActivity extends AppCompatActivity Now my second package name is package com.restro.dextrocustomer.Nav_Drawer; and the name of second class is public class MainActivity extends ActionBarActivity implements LocationListener, FragmentDrawer.FragmentDrawerListener, SearchView.OnQueryTextListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener Now I want to import my first package into another package but i cant able to do it
0debug
Division by zero error in a code : <pre><code>public function convert($value, $from, $to) { if ($from == $to) { return $value; } if (isset($this-&gt;lengths[$from])) { $from = $this-&gt;lengths[$from]['value']; } else { $from = 0; } if (isset($this-&gt;lengths[$to])) { $to = $this-&gt;lengths[$to]['value']; } else { $to = 0; } return $value * ($to / $from); } </code></pre> <p>This code is giving division by zero error on the line "return $value * ($to/$from)" . Can any one debug this . </p>
0debug
How to clone object in Kotlin? : <p>The question is that simple. </p> <p>Kotlin documentation <a href="https://kotlinlang.org/docs/reference/?q=clone&amp;p=0" rel="noreferrer">describes cloning only in accessing Java and in enum class</a>. In latter case clone is just throwing an exception.</p> <p>So, how would I / should I clone arbitrary Kotlin object? </p> <p>Should I just use <code>clone()</code> as in Java?</p>
0debug
perl process bring a file with duplicates results : I 'm not sure that this process is the cause, the result is in the file QUERIES_LIST which have duplicates results following each other, can this part of script be in cause, so that it execute the script of copying multiples times or other cause, thanks for your help: my $ok = 0; llog ($DEBUG, 'begin step=['.(defined $step ? $step : 'N/A').']'); if (defined $step and $step eq 'CTL') { hlog ($INFO, 'begin CTL step'); my $MAX_PROCESS_TO_USE; my $queries_to_execute = []; my @team = (); $SIG{CHLD} = \&zombies_killer; $DICTIONARY->{LIST_REQUETE} = $CONFIG->{ExportFiles}->{QUERIES_LIST}; $DICTIONARY->{separator_req} = $CONFIG->{CTLQueriesSeparators}->{separator_req}; $DICTIONARY->{separator_ctl} = $CONFIG->{CTLQueriesSeparators}->{separator_ctl}; $DICTIONARY->{ALL_QUERY_CTRL} = $CONFIG->{ExportFiles}->{QUERY_CTRL_GET}; my $sr; my $msgs; if (can_we_proceed_now ($CONFIG)) { ($ok, $sr, $msgs) = ExecScripts (Scripts => [ $CONFIG->{BTEQScripts}->{query_control} ], Messages => [ 'FILE=Get control queries listEXEC=', ], Files => [ $CONFIG->{ExportFiles}->{QUERIES_LIST} ], NoExec => [ 1 ], ); llog ($DEBUG, "CTL1 ok=[$ok] SR=[".Dumper ($sr).'] msg=['.Dumper ($msgs).']'); if (!$ok) { llog ($INFO, 'an error occured previously, abort'); return CTL_FAIL_GET_CTRL_QUERIES; } if (!-z $CONFIG->{ExportFiles}->{QUERIES_LIST}) { $ok = ctl_clean_exported_file ( INPUT_FILE => $CONFIG->{ExportFiles}->{QUERIES_LIST}, OUTPUT_FILE => $CONFIG->{ExportFiles}->{QUERIES_LIST}.'.tmp', );
0debug
How to QUEUE a new build using VSTS REST API : <p>I have the following script</p> <pre><code>Param( [string]$vstsAccount = "abc, [string]$projectName = "abc", [string]$user = "", [string]$token = "xyz" ) # Base64-encodes the Personal Access Token (PAT) appropriately $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token))) $verb = "POST" $body = @" { "definition": { "id": 20 } } "@ $uri = "https://$($vstsAccount).visualstudio.com/DefaultCollection/$($projectName)/_apis/build/builds?api-version=4.1" $result = Invoke-RestMethod -Uri $uri -Method $verb -ContentType "application/json" -Body (ConvertTo-Json $body) -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} </code></pre> <p>However I get this error</p> <pre><code>Invoke-RestMethod : {"$id":"1","innerException":null,"message":"This request expects an object in the request body, but the supplied data could not be deserialized.","typeName":"Microsoft.TeamFoundation.Build.WebApi.RequestContentException, </code></pre> <p>So I tried to queue a build from the browser and see the payload using developer tools:</p> <pre><code>{"queue":{"id":70},"definition":{"id":20},"project":{"id":"b0e8476e-660a-4254-a100-92ef0ec255e5"},"sourceBranch":"refs/heads/master","sourceVersion":"","reason":1,"demands":[],"parameters":"{\"system.debug\":\"false\"}"} </code></pre> <p>So, I replaced that into my script:</p> <pre><code>$body = @" {"queue":{"id":70},"definition":{"id":20},"project":{"id":"b0e8476e-660a-4254-a100-92ef0ec255e5"},"sourceBranch":"refs/heads/master","sourceVersion":"","reason":1,"demands":[],"parameters":"{\"system.debug\":\"false\"}"} "@ </code></pre> <p>However I keep getting the same error.</p> <p>The official documentation for this endpoint is here, but its not clear <a href="https://docs.microsoft.com/en-us/rest/api/vsts/build/builds/queue?view=vsts-rest-4.1#request-body" rel="noreferrer">https://docs.microsoft.com/en-us/rest/api/vsts/build/builds/queue?view=vsts-rest-4.1#request-body</a></p>
0debug
static void *buffered_file_thread(void *opaque) { MigrationState *s = opaque; int64_t initial_time = qemu_get_clock_ms(rt_clock); int64_t sleep_time = 0; int64_t max_size = 0; bool last_round = false; int ret; qemu_mutex_lock_iothread(); DPRINTF("beginning savevm\n"); ret = qemu_savevm_state_begin(s->file, &s->params); qemu_mutex_unlock_iothread(); while (ret >= 0) { int64_t current_time; uint64_t pending_size; qemu_mutex_lock_iothread(); if (s->state != MIG_STATE_ACTIVE) { DPRINTF("put_ready returning because of non-active state\n"); qemu_mutex_unlock_iothread(); break; } if (s->complete) { qemu_mutex_unlock_iothread(); break; } if (s->bytes_xfer < s->xfer_limit) { DPRINTF("iterate\n"); pending_size = qemu_savevm_state_pending(s->file, max_size); DPRINTF("pending size %lu max %lu\n", pending_size, max_size); if (pending_size && pending_size >= max_size) { ret = qemu_savevm_state_iterate(s->file); if (ret < 0) { qemu_mutex_unlock_iothread(); break; } } else { int old_vm_running = runstate_is_running(); int64_t start_time, end_time; DPRINTF("done iterating\n"); start_time = qemu_get_clock_ms(rt_clock); qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); vm_stop_force_state(RUN_STATE_FINISH_MIGRATE); ret = qemu_savevm_state_complete(s->file); if (ret < 0) { qemu_mutex_unlock_iothread(); break; } else { migrate_fd_completed(s); } end_time = qemu_get_clock_ms(rt_clock); s->total_time = end_time - s->total_time; s->downtime = end_time - start_time; if (s->state != MIG_STATE_COMPLETED) { if (old_vm_running) { vm_start(); } } last_round = true; } } qemu_mutex_unlock_iothread(); current_time = qemu_get_clock_ms(rt_clock); if (current_time >= initial_time + BUFFER_DELAY) { uint64_t transferred_bytes = s->bytes_xfer; uint64_t time_spent = current_time - initial_time - sleep_time; double bandwidth = transferred_bytes / time_spent; max_size = bandwidth * migrate_max_downtime() / 1000000; DPRINTF("transferred %" PRIu64 " time_spent %" PRIu64 " bandwidth %g max_size %" PRId64 "\n", transferred_bytes, time_spent, bandwidth, max_size); if (s->dirty_bytes_rate && transferred_bytes > 10000) { s->expected_downtime = s->dirty_bytes_rate / bandwidth; } s->bytes_xfer = 0; sleep_time = 0; initial_time = current_time; } if (!last_round && (s->bytes_xfer >= s->xfer_limit)) { g_usleep((initial_time + BUFFER_DELAY - current_time)*1000); sleep_time += qemu_get_clock_ms(rt_clock) - current_time; } buffered_flush(s); ret = qemu_file_get_error(s->file); } if (ret < 0) { migrate_fd_error(s); } g_free(s->buffer); return NULL; }
1threat
static void slavio_timer_get_out(SLAVIO_TIMERState *s) { int out; int64_t diff, ticks, count; uint32_t limit; if (s->mode == 1 && s->stopped) ticks = s->stop_time; else ticks = qemu_get_clock(vm_clock) - s->tick_offset; out = (ticks > s->expire_time); if (out) s->reached = 0x80000000; if (!s->limit) limit = 0x7fffffff; else limit = s->limit; limit = limit >> 9; diff = muldiv64(ticks - s->count_load_time, CNT_FREQ, ticks_per_sec); count = diff % limit; s->count = count << 9; s->counthigh = count >> 22; s->expire_time = ticks + muldiv64(limit - count, ticks_per_sec, CNT_FREQ); DPRINTF("irq %d limit %d reached %d d %" PRId64 " count %d s->c %x diff %" PRId64 " stopped %d mode %d\n", s->irq, limit, s->reached?1:0, (ticks-s->count_load_time), count, s->count, s->expire_time - ticks, s->stopped, s->mode); if (s->mode != 1) pic_set_irq_cpu(s->intctl, s->irq, out, s->cpu); }
1threat
Swift4 How to check if object not exists in array : I should compare MenuArray array, SavedArray array. If MenuArray does not contain SavedArray's object, should remove SavedArray's object so I did. for i in 0..<savedArr.count { let savedDic = savedArr[i] let containIndex = menuArray.index(where: { (dic) -> Bool in if dic[Keys.KEY_DISPETT_SEQ] as! Int == savedDic[Keys.KEY_DISPETT_SEQ] as! Int { return true }else{ return false } }) if containIndex == nil { savedArr.filter({ (dic) -> Bool in return true }) } } But it's not working. How can I do? Thank you!
0debug
How do I compile using javac in command line this small code snippet : <p>I am learning springframework and I don't want to use any IDE, and I want to work in java in pure command line in bash. I already have downloaded lots of jar I can see them in /root/.m2/repository as well as in /usr/share/maven/ref/repository/ too. The <code>AppConfig.java</code> i want to compile has the below content: </p> <pre><code>@Configuration public class AppConfig { // this is all there is } </code></pre> <p>It compiles fine without the <code>@Configuration</code> annotation. At the top of my head, I know that I need to pull-in the correct jar. To be systematic in future dealings of these things, I want to know how to:</p> <ul> <li>Identify the correct jar and location of jar needed for a keyword</li> </ul> <p>I accept maven pom.xml way of doing things if needed, but if possible I want to work in the most minimal way.</p>
0debug
static void replay_save_event(Event *event, int checkpoint) { if (replay_mode != REPLAY_MODE_PLAY) { replay_put_event(EVENT_ASYNC); replay_put_byte(checkpoint); replay_put_byte(event->event_kind); switch (event->event_kind) { case REPLAY_ASYNC_EVENT_BH: replay_put_qword(event->id); break; case REPLAY_ASYNC_EVENT_INPUT: replay_save_input_event(event->opaque); break; case REPLAY_ASYNC_EVENT_INPUT_SYNC: break; case REPLAY_ASYNC_EVENT_CHAR_READ: replay_event_char_read_save(event->opaque); break; default: error_report("Unknown ID %d of replay event", read_event_kind); exit(1); } } }
1threat
Package 'EntityFramework 6.2.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0' : <p>I have made .net core 2.0 web app. I have added Entity Framework 6.2.0 using NUGET and then I get this error</p> <blockquote> <p>Package 'EntityFramework 6.2.0' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.</p> </blockquote> <p>How do I fix this? </p>
0debug
void kvm_arch_pre_run(CPUState *env, struct kvm_run *run) { if (env->interrupt_request & CPU_INTERRUPT_NMI) { env->interrupt_request &= ~CPU_INTERRUPT_NMI; DPRINTF("injected NMI\n"); kvm_vcpu_ioctl(env, KVM_NMI); } if (!kvm_irqchip_in_kernel()) { if (env->interrupt_request & CPU_INTERRUPT_INIT) { env->exit_request = 1; } if (run->ready_for_interrupt_injection && (env->interrupt_request & CPU_INTERRUPT_HARD) && (env->eflags & IF_MASK)) { int irq; env->interrupt_request &= ~CPU_INTERRUPT_HARD; irq = cpu_get_pic_interrupt(env); if (irq >= 0) { struct kvm_interrupt intr; intr.irq = irq; DPRINTF("injected interrupt %d\n", irq); kvm_vcpu_ioctl(env, KVM_INTERRUPT, &intr); } } if ((env->interrupt_request & CPU_INTERRUPT_HARD)) { run->request_interrupt_window = 1; } else { run->request_interrupt_window = 0; } DPRINTF("setting tpr\n"); run->cr8 = cpu_get_apic_tpr(env->apic_state); } }
1threat
search keyword not found any result : I want to search **keyword like %$keyword%** than the resulting black . not show result missing PHP code. I have one table 'ads_post' and use field cat_name, city_name please check it and help me... **search-result.php** <?php if(isset($_GET['submit'])){ $keyword = $_GET['keywoed']; $query = "select * from ads_post where cat_name like '%$keywoed%' or city_name like '%$keywoed%'"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { echo "cat Name: " . $row["cat_name"]. "<br>"; } } else { echo "0 results"; } mysqli_close($conn); } ?> **html form here** <form action="search-result.php" method="get" > <input class="form-control" name="keyword" placeholder="Search any keyword..?"> <input type="submit" value="search"> </form>
0debug
How can make three legends and colors of the legends same as the bars colors in matplotlib,. following is my code : 'import numpy as np import matplotlib.pyplot as plt x=[1,2,3] y=[399,499,100] LABELS = ["node0", "node1", "failed"] cr = ['g','r','b'] fig,ax = plt.subplots() ax.bar(x,y,align='center',color=cr, Label='txed, rxed, failed') plt.xticks(x, LABELS) plt.legend() plt.show()
0debug
How can I add up all the Values of a List<Integer> if its a value in a map? : <p>So, basically I have a map that looks like :</p> <p><code>Map&lt;String, List&lt;Integer&gt;&gt; map = new HashMap&lt;&gt;();</code></p> <p>I also have a method that needs to add up all those values for a certain key:</p> <p><code>public Integer getTotalPointsForStudent(String student) { }</code></p> <p>How can I add up all the Values of the List assigned to a certain "student"?</p> <p>Thanks in advance.</p>
0debug
Android Bottom Sheet smooth expanding, like Google Maps : <p>I want to recreate Bottom Sheet Behavior provided in the Google Maps app: <br><br> <a href="https://media.giphy.com/media/1syNHM25tZ1Sw/giphy.gif" rel="noreferrer">Link to expected behavior.</a> <br><br> I have tried using <a href="https://developer.android.com/reference/android/support/design/widget/BottomSheetBehavior.html" rel="noreferrer">BottomSheetBehavior</a> and couple of other 3rd party libs like umano AndroidSlidingUpPanel but the problem I was unable to avoid is they are all snapping the Bottom Sheet in between states (collapsed and expanded). <br><br> I would like to have a Bottom Sheet which can be smoothly expanded by sliding up, without it snapping to the closest state but instead to remain where the user stopped with the sliding.</p>
0debug
void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data, BIOSLinker *linker, AcpiNVDIMMState *state, uint32_t ram_slots) { nvdimm_build_nfit(state, table_offsets, table_data, linker); if (ram_slots) { nvdimm_build_ssdt(table_offsets, table_data, linker, state->dsm_mem, ram_slots); } }
1threat
Creating Excel Macro : <p>I'm trying to create a macro that basically does:</p> <p>If cell A contains exact date from cell C, then ask "if you want to transfer data from cell C to A"</p> <p>Not sure how complicated creating such macro. I'm new to Excel and macros.</p> <p>Any help?</p>
0debug
How to redirect a web page using HTML, CSS and JavaScript with help of buttons : <div class="navbar"> <a> <div class="grid__item theme-1"> <button class="action"></button> <button class="particles-button">Home</button> </div> </a> // In this Effect applied how to redirect it after the effect completed
0debug
static void rtce_init(VIOsPAPRDevice *dev) { size_t size = (dev->rtce_window_size >> SPAPR_VIO_TCE_PAGE_SHIFT) * sizeof(VIOsPAPR_RTCE); if (size) { dev->rtce_table = g_malloc0(size); } }
1threat
static int mov_text_decode_frame(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *avpkt) { AVSubtitle *sub = data; int ret, ts_start, ts_end; AVBPrint buf; char *ptr = avpkt->data; char *end; int text_length, tsmb_type, style_entries, tsmb_size; int **style_start = {0,}; int **style_end = {0,}; int **style_flags = {0,}; const uint8_t *tsmb; int index, i; int *flag; int *style_pos; if (!ptr || avpkt->size < 2) return AVERROR_INVALIDDATA; if (avpkt->size == 2) return AV_RB16(ptr) == 0 ? 0 : AVERROR_INVALIDDATA; text_length = AV_RB16(ptr); end = ptr + FFMIN(2 + text_length, avpkt->size); ptr += 2; ts_start = av_rescale_q(avpkt->pts, avctx->time_base, (AVRational){1,100}); ts_end = av_rescale_q(avpkt->pts + avpkt->duration, avctx->time_base, (AVRational){1,100}); tsmb_size = 0; av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED); if (text_length + 2 != avpkt->size) { while (text_length + 2 + tsmb_size < avpkt->size) { tsmb = ptr + text_length + tsmb_size; tsmb_size = AV_RB32(tsmb); tsmb += 4; tsmb_type = AV_RB32(tsmb); tsmb += 4; if (tsmb_type == MKBETAG('s','t','y','l')) { style_entries = AV_RB16(tsmb); tsmb += 2; for(i = 0; i < style_entries; i++) { style_pos = av_malloc(4); *style_pos = AV_RB16(tsmb); index = i; av_dynarray_add(&style_start, &index, style_pos); tsmb += 2; style_pos = av_malloc(4); *style_pos = AV_RB16(tsmb); index = i; av_dynarray_add(&style_end, &index, style_pos); tsmb += 2; tsmb += 2; flag = av_malloc(4); *flag = AV_RB8(tsmb); index = i; av_dynarray_add(&style_flags, &index, flag); tsmb += 2; tsmb += 4; } text_to_ass(&buf, ptr, end, style_start, style_end, style_flags, style_entries); av_freep(&style_start); av_freep(&style_end); av_freep(&style_flags); } } } else text_to_ass(&buf, ptr, end, NULL, NULL, 0, 0); ret = ff_ass_add_rect_bprint(sub, &buf, ts_start, ts_end - ts_start); av_bprint_finalize(&buf, NULL); if (ret < 0) return ret; *got_sub_ptr = sub->num_rects > 0; return avpkt->size; }
1threat
PPC_OP(subfze) { T1 = ~T0; T0 = T1 + xer_ca; if (T0 < T1) { xer_ca = 1; } else { xer_ca = 0; } RETURN(); }
1threat
static CharDriverState *qmp_chardev_open_file(ChardevFile *file, Error **errp) { int flags, in = -1, out = -1; flags = O_WRONLY | O_TRUNC | O_CREAT | O_BINARY; out = qmp_chardev_open_file_source(file->out, flags, errp); if (error_is_set(errp)) { return NULL; } if (file->has_in) { flags = O_RDONLY; in = qmp_chardev_open_file_source(file->in, flags, errp); if (error_is_set(errp)) { qemu_close(out); return NULL; } } return qemu_chr_open_fd(in, out); }
1threat
static UserDefNested *nested_struct_create(void) { UserDefNested *udnp = g_malloc0(sizeof(*udnp)); udnp->string0 = strdup("test_string0"); udnp->dict1.string1 = strdup("test_string1"); udnp->dict1.dict2.userdef1 = g_malloc0(sizeof(UserDefOne)); udnp->dict1.dict2.userdef1->base = g_new0(UserDefZero, 1); udnp->dict1.dict2.userdef1->base->integer = 42; udnp->dict1.dict2.userdef1->string = strdup("test_string"); udnp->dict1.dict2.string2 = strdup("test_string2"); udnp->dict1.has_dict3 = true; udnp->dict1.dict3.userdef2 = g_malloc0(sizeof(UserDefOne)); udnp->dict1.dict3.userdef2->base = g_new0(UserDefZero, 1); udnp->dict1.dict3.userdef2->base->integer = 43; udnp->dict1.dict3.userdef2->string = strdup("test_string"); udnp->dict1.dict3.string3 = strdup("test_string3"); return udnp; }
1threat
struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev) { struct XenDevice *xendev; TAILQ_FOREACH(xendev, &xendevs, next) { if (xendev->dom != dom) continue; if (xendev->dev != dev) continue; if (strcmp(xendev->type, type) != 0) continue; return xendev; } return NULL; }
1threat
Window not defined? : <p>I am running a local server as shown and when I load it, it says "window not defined" what could be the problem here? I am waiting till it loads my index.html file and calling a callback to it.</p> <pre><code>module.exports=function(){ //require the express module to use it in the app var express=require('express'); //create an express app, fire the express function //to be able to use the methods in express var app=express(); app.listen(3000); app.get('/', function(req,res){ res.sendFile(__dirname+'/index.html',function(){ window.onload=function(){ alert('webpage loaded'); } }); }); } </code></pre>
0debug
long target_mmap(target_ulong start, target_ulong len, int prot, int flags, int fd, target_ulong offset) { target_ulong ret, end, real_start, real_end, retaddr, host_offset, host_len; long host_start; #if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \ defined(__ia64) || defined(__mips__) static target_ulong last_start = 0x40000000; #elif defined(__CYGWIN__) static target_ulong last_start = 0x18000000; #endif #ifdef DEBUG_MMAP { printf("mmap: start=0x%lx len=0x%lx prot=%c%c%c flags=", start, len, prot & PROT_READ ? 'r' : '-', prot & PROT_WRITE ? 'w' : '-', prot & PROT_EXEC ? 'x' : '-'); if (flags & MAP_FIXED) printf("MAP_FIXED "); if (flags & MAP_ANONYMOUS) printf("MAP_ANON "); switch(flags & MAP_TYPE) { case MAP_PRIVATE: printf("MAP_PRIVATE "); break; case MAP_SHARED: printf("MAP_SHARED "); break; default: printf("[MAP_TYPE=0x%x] ", flags & MAP_TYPE); break; } printf("fd=%d offset=%lx\n", fd, offset); } #endif if (offset & ~TARGET_PAGE_MASK) { errno = EINVAL; return -1; } len = TARGET_PAGE_ALIGN(len); if (len == 0) return start; real_start = start & qemu_host_page_mask; if (!(flags & MAP_FIXED)) { #if defined(__alpha__) || defined(__sparc__) || defined(__x86_64__) || \ defined(__ia64) || defined(__mips__) || defined(__CYGWIN__) if (real_start == 0) { real_start = last_start; last_start += HOST_PAGE_ALIGN(len); } #endif if (0 && qemu_host_page_size != qemu_real_host_page_size) { abort(); host_len = HOST_PAGE_ALIGN(len) + qemu_host_page_size - TARGET_PAGE_SIZE; real_start = (long)mmap(g2h(real_start), host_len, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (real_start == -1) return real_start; real_end = real_start + host_len; start = HOST_PAGE_ALIGN(real_start); end = start + HOST_PAGE_ALIGN(len); if (start > real_start) munmap((void *)real_start, start - real_start); if (end < real_end) munmap((void *)end, real_end - end); flags |= MAP_FIXED; } else { host_offset = offset & qemu_host_page_mask; host_len = len + offset - host_offset; host_start = (long)mmap(real_start ? g2h(real_start) : NULL, host_len, prot, flags, fd, host_offset); if (host_start == -1) return host_start; if (!(flags & MAP_ANONYMOUS)) host_start += offset - host_offset; start = h2g(host_start); goto the_end1; } } if (start & ~TARGET_PAGE_MASK) { errno = EINVAL; return -1; } end = start + len; real_end = HOST_PAGE_ALIGN(end); if (!(flags & MAP_ANONYMOUS) && (offset & ~qemu_host_page_mask) != (start & ~qemu_host_page_mask)) { if ((flags & MAP_TYPE) == MAP_SHARED && (prot & PROT_WRITE)) { errno = EINVAL; return -1; } retaddr = target_mmap(start, len, prot | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); if (retaddr == -1) return retaddr; pread(fd, g2h(start), len, offset); if (!(prot & PROT_WRITE)) { ret = target_mprotect(start, len, prot); if (ret != 0) return ret; } goto the_end; } if (start > real_start) { if (real_end == real_start + qemu_host_page_size) { ret = mmap_frag(real_start, start, end, prot, flags, fd, offset); if (ret == -1) return ret; goto the_end1; } ret = mmap_frag(real_start, start, real_start + qemu_host_page_size, prot, flags, fd, offset); if (ret == -1) return ret; real_start += qemu_host_page_size; } if (end < real_end) { ret = mmap_frag(real_end - qemu_host_page_size, real_end - qemu_host_page_size, real_end, prot, flags, fd, offset + real_end - qemu_host_page_size - start); if (ret == -1) return ret; real_end -= qemu_host_page_size; } if (real_start < real_end) { unsigned long offset1; if (flags & MAP_ANONYMOUS) offset1 = 0; else offset1 = offset + real_start - start; ret = (long)mmap(g2h(real_start), real_end - real_start, prot, flags, fd, offset1); if (ret == -1) return ret; } the_end1: page_set_flags(start, start + len, prot | PAGE_VALID); the_end: #ifdef DEBUG_MMAP printf("ret=0x%lx\n", (long)start); page_dump(stdout); printf("\n"); #endif return start; }
1threat
How to work with numbers of the order 10^100 in C & java? : <p>How to work with numbers of the order 10^100?Like iterating upto a number of that order,getting sum of squares of their digits;then checking if the sum matches the square of a certain number,if yes sum up those numbers and finally display the sum of those numbers.</p>
0debug
static void virtio_net_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->init = virtio_net_init_pci; k->exit = virtio_net_exit_pci; k->romfile = "pxe-virtio.rom"; k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; k->device_id = PCI_DEVICE_ID_VIRTIO_NET; k->revision = VIRTIO_PCI_ABI_VERSION; k->class_id = PCI_CLASS_NETWORK_ETHERNET; dc->alias = "virtio-net"; dc->reset = virtio_pci_reset; dc->props = virtio_net_properties; }
1threat
static inline int target_rt_restore_ucontext(CPUM68KState *env, struct target_ucontext *uc, int *pd0) { int temp; target_greg_t *gregs = uc->tuc_mcontext.gregs; __get_user(temp, &uc->tuc_mcontext.version); if (temp != TARGET_MCONTEXT_VERSION) goto badframe; __get_user(env->dregs[0], &gregs[0]); __get_user(env->dregs[1], &gregs[1]); __get_user(env->dregs[2], &gregs[2]); __get_user(env->dregs[3], &gregs[3]); __get_user(env->dregs[4], &gregs[4]); __get_user(env->dregs[5], &gregs[5]); __get_user(env->dregs[6], &gregs[6]); __get_user(env->dregs[7], &gregs[7]); __get_user(env->aregs[0], &gregs[8]); __get_user(env->aregs[1], &gregs[9]); __get_user(env->aregs[2], &gregs[10]); __get_user(env->aregs[3], &gregs[11]); __get_user(env->aregs[4], &gregs[12]); __get_user(env->aregs[5], &gregs[13]); __get_user(env->aregs[6], &gregs[14]); __get_user(env->aregs[7], &gregs[15]); __get_user(env->pc, &gregs[16]); __get_user(temp, &gregs[17]); env->sr = (env->sr & 0xff00) | (temp & 0xff); *pd0 = env->dregs[0]; return 0; badframe: return 1; }
1threat
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *cur_buf) { AlphaExtractContext *extract = inlink->dst->priv; AVFilterLink *outlink = inlink->dst->outputs[0]; AVFilterBufferRef *out_buf = ff_get_video_buffer(outlink, AV_PERM_WRITE, outlink->w, outlink->h); int ret; if (!out_buf) { ret = AVERROR(ENOMEM); goto end; } avfilter_copy_buffer_ref_props(out_buf, cur_buf); if (extract->is_packed_rgb) { int x, y; uint8_t *pin, *pout; for (y = 0; y < out_buf->video->h; y++) { pin = cur_buf->data[0] + y * cur_buf->linesize[0] + extract->rgba_map[A]; pout = out_buf->data[0] + y * out_buf->linesize[0]; for (x = 0; x < out_buf->video->w; x++) { *pout = *pin; pout += 1; pin += 4; } } } else { const int linesize = FFMIN(out_buf->linesize[Y], cur_buf->linesize[A]); int y; for (y = 0; y < out_buf->video->h; y++) { memcpy(out_buf->data[Y] + y * out_buf->linesize[Y], cur_buf->data[A] + y * cur_buf->linesize[A], linesize); } } ret = ff_filter_frame(outlink, out_buf); end: avfilter_unref_buffer(cur_buf); return ret; }
1threat