problem
stringlengths
26
131k
labels
class label
2 classes
static void continue_send(IPMIBmcExtern *ibe) { if (ibe->outlen == 0) { goto check_reset; } send: ibe->outpos += qemu_chr_fe_write(ibe->chr, ibe->outbuf + ibe->outpos, ibe->outlen - ibe->outpos); if (ibe->outpos < ibe->outlen) { timer_mod_ns(ibe->extern_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 10000000); } else { ibe->outlen = 0; ibe->outpos = 0; if (!ibe->sending_cmd) { ibe->waiting_rsp = true; } else { ibe->sending_cmd = false; } check_reset: if (ibe->connected && ibe->send_reset) { ibe->outbuf[0] = VM_CMD_RESET; ibe->outbuf[1] = VM_CMD_CHAR; ibe->outlen = 2; ibe->outpos = 0; ibe->send_reset = false; ibe->sending_cmd = true; goto send; } if (ibe->waiting_rsp) { timer_mod_ns(ibe->extern_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 4000000000ULL); } } return; }
1threat
Image in javaFx Listview shows only when is selected : <p>i want to make a listview with an image, some text and a button pro column, but the image is only displayed when the column is selected(clicked). But i want the images/icons to be displayed independ from beeing selected/clicked...</p> <pre><code>todoView.setCellFactory(new Callback&lt;ListView&lt;TodoView&gt;, ListCell&lt;TodoView&gt;&gt;() { @Override public ListCell&lt;TodoView&gt; call(ListView&lt;TodoView&gt; todoViewListView) { ListCell&lt;TodoView&gt; cell = new ListCell&lt;&gt;() { @Override protected void updateItem(TodoView item, boolean empty) { super.updateItem(item, empty); if (item != null) { setGraphic(item); } } }; return cell; } }); </code></pre> <p>(TodoView)item obj is an hbox with imageview, label and button... any ideas?</p>
0debug
AttributeError: 'Figure' object has no attribute 'plot' : <p>My code</p> <pre><code>import matplotlib.pyplot as plt plt.style.use("ggplot") import numpy as np from mtspec import mtspec from mtspec.util import _load_mtdata data = np.loadtxt('262_V01_C00_R000_TEx_BL_4096H.dat') spec,freq,jackknife,f_statistics,degrees_of_f = mtspec(data=data, delta= 4930.0, time_bandwidth=4 ,number_of_tapers=5, nfft= 4194304, statistics=True) fig = plt.figure() ax2 = fig ax2.plot(freq, spec, color='black') ax2.fill_between(freq, jackknife[:, 0], jackknife[:, 1],color="red", alpha=0.3) ax2.set_xlim(freq[0], freq[-1]) ax2.set_ylim(0.1E1, 1E5) ax2.set_xlabel("Frequency $") ax2.set_ylabel("Power Spectral Density $)") plt.tight_layout() plt.show() </code></pre> <p>The problem is with the plotting part of my code.What should I change?I am using Python 2.7 on Ubuntu.</p>
0debug
static int mkv_write_tracks(AVFormatContext *s) { MatroskaMuxContext *mkv = s->priv_data; AVIOContext *pb = s->pb; ebml_master tracks; int i, j, ret; ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TRACKS, avio_tell(pb)); if (ret < 0) return ret; tracks = start_ebml_master(pb, MATROSKA_ID_TRACKS, 0); for (i = 0; i < s->nb_streams; i++) { AVStream *st = s->streams[i]; AVCodecContext *codec = st->codec; ebml_master subinfo, track; int native_id = 0; int qt_id = 0; int bit_depth = av_get_bits_per_sample(codec->codec_id); int sample_rate = codec->sample_rate; int output_sample_rate = 0; AVDictionaryEntry *tag; if (codec->codec_type == AVMEDIA_TYPE_ATTACHMENT) { mkv->have_attachments = 1; continue; } if (!bit_depth) bit_depth = av_get_bytes_per_sample(codec->sample_fmt) << 3; if (codec->codec_id == AV_CODEC_ID_AAC) get_aac_sample_rates(s, codec, &sample_rate, &output_sample_rate); track = start_ebml_master(pb, MATROSKA_ID_TRACKENTRY, 0); put_ebml_uint (pb, MATROSKA_ID_TRACKNUMBER , i + 1); put_ebml_uint (pb, MATROSKA_ID_TRACKUID , i + 1); put_ebml_uint (pb, MATROSKA_ID_TRACKFLAGLACING , 0); if ((tag = av_dict_get(st->metadata, "title", NULL, 0))) put_ebml_string(pb, MATROSKA_ID_TRACKNAME, tag->value); tag = av_dict_get(st->metadata, "language", NULL, 0); put_ebml_string(pb, MATROSKA_ID_TRACKLANGUAGE, tag ? tag->value:"und"); if (st->disposition) put_ebml_uint(pb, MATROSKA_ID_TRACKFLAGDEFAULT, !!(st->disposition & AV_DISPOSITION_DEFAULT)); for (j = 0; ff_mkv_codec_tags[j].id != AV_CODEC_ID_NONE; j++) { if (ff_mkv_codec_tags[j].id == codec->codec_id) { put_ebml_string(pb, MATROSKA_ID_CODECID, ff_mkv_codec_tags[j].str); native_id = 1; break; } } if (mkv->mode == MODE_WEBM && !(codec->codec_id == AV_CODEC_ID_VP8 || codec->codec_id == AV_CODEC_ID_VORBIS)) { av_log(s, AV_LOG_ERROR, "Only VP8 video and Vorbis audio are supported for WebM.\n"); return AVERROR(EINVAL); } switch (codec->codec_type) { case AVMEDIA_TYPE_VIDEO: put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_VIDEO); if(st->avg_frame_rate.num && st->avg_frame_rate.den && 1.0/av_q2d(st->avg_frame_rate) > av_q2d(codec->time_base)) put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, 1E9/av_q2d(st->avg_frame_rate)); else put_ebml_uint(pb, MATROSKA_ID_TRACKDEFAULTDURATION, av_q2d(codec->time_base)*1E9); if (!native_id && ff_codec_get_tag(ff_codec_movvideo_tags, codec->codec_id) && (!ff_codec_get_tag(ff_codec_bmp_tags, codec->codec_id) || codec->codec_id == AV_CODEC_ID_SVQ1 || codec->codec_id == AV_CODEC_ID_SVQ3 || codec->codec_id == AV_CODEC_ID_CINEPAK)) qt_id = 1; if (qt_id) put_ebml_string(pb, MATROSKA_ID_CODECID, "V_QUICKTIME"); else if (!native_id) { put_ebml_string(pb, MATROSKA_ID_CODECID, "V_MS/VFW/FOURCC"); mkv->tracks[i].write_dts = 1; } subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKVIDEO, 0); put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELWIDTH , codec->width); put_ebml_uint (pb, MATROSKA_ID_VIDEOPIXELHEIGHT, codec->height); if ((tag = av_dict_get(st->metadata, "stereo_mode", NULL, 0)) || (tag = av_dict_get( s->metadata, "stereo_mode", NULL, 0))) { uint64_t st_mode = MATROSKA_VIDEO_STEREO_MODE_COUNT; for (j=0; j<MATROSKA_VIDEO_STEREO_MODE_COUNT; j++) if (!strcmp(tag->value, ff_matroska_video_stereo_mode[j])){ st_mode = j; break; } if ((mkv->mode == MODE_WEBM && st_mode > 3 && st_mode != 11) || st_mode >= MATROSKA_VIDEO_STEREO_MODE_COUNT) { av_log(s, AV_LOG_ERROR, "The specified stereo mode is not valid.\n"); return AVERROR(EINVAL); } else put_ebml_uint(pb, MATROSKA_ID_VIDEOSTEREOMODE, st_mode); } if (st->sample_aspect_ratio.num) { int d_width = av_rescale(codec->width, st->sample_aspect_ratio.num, st->sample_aspect_ratio.den); put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYWIDTH , d_width); put_ebml_uint(pb, MATROSKA_ID_VIDEODISPLAYHEIGHT, codec->height); } if (codec->codec_id == AV_CODEC_ID_RAWVIDEO) { uint32_t color_space = av_le2ne32(codec->codec_tag); put_ebml_binary(pb, MATROSKA_ID_VIDEOCOLORSPACE, &color_space, sizeof(color_space)); } end_ebml_master(pb, subinfo); break; case AVMEDIA_TYPE_AUDIO: put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_AUDIO); if (!native_id) put_ebml_string(pb, MATROSKA_ID_CODECID, "A_MS/ACM"); subinfo = start_ebml_master(pb, MATROSKA_ID_TRACKAUDIO, 0); put_ebml_uint (pb, MATROSKA_ID_AUDIOCHANNELS , codec->channels); put_ebml_float (pb, MATROSKA_ID_AUDIOSAMPLINGFREQ, sample_rate); if (output_sample_rate) put_ebml_float(pb, MATROSKA_ID_AUDIOOUTSAMPLINGFREQ, output_sample_rate); if (bit_depth) put_ebml_uint(pb, MATROSKA_ID_AUDIOBITDEPTH, bit_depth); end_ebml_master(pb, subinfo); break; case AVMEDIA_TYPE_SUBTITLE: put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_SUBTITLE); if (!native_id) { av_log(s, AV_LOG_ERROR, "Subtitle codec %d is not supported.\n", codec->codec_id); return AVERROR(ENOSYS); } break; default: av_log(s, AV_LOG_ERROR, "Only audio, video, and subtitles are supported for Matroska.\n"); break; } ret = mkv_write_codecprivate(s, pb, codec, native_id, qt_id); if (ret < 0) return ret; end_ebml_master(pb, track); avpriv_set_pts_info(st, 64, 1, 1000); } end_ebml_master(pb, tracks); return 0; }
1threat
Why Event Listener Not Changing? : **HTML** < div id="q">< /div> **Style** #q { width:40px; height:40px; background-color:blue; } **Javascript** window.onload = function () { var a = document.getElementById("q"); var b = 1; function tri() { a.style.width = "100px"; b++ if(b == 3) { b-- } return b; } function un() { a.style.width = "40px" if(b == 2) { b-- } }; if(b == 1) { a.addEventListener("click",tri); }; if(b == 2) { a.addEventListener("click",un) }; }; I Don't Know Why But My Code Is Not Working Is it Possible To Add To EVENT Listeners In one Element If Yes Then Please Explain How I Tried Lot But It's Not Working
0debug
table row highlights a picture area : I have a table with four rows that highlight on mouse over. I also have a picture with 4 areas that correspond to the rows in the table. I need the areas in the picture get highlighted as well as the table rows. This pictures illustrates my problem: http://projekty.freshynek.cz/table-roll-over-picture-highlight.jpg Thank you for your help. [1]: https://i.stack.imgur.com/17b2d.jpg
0debug
In spacy, how to use your own word2vec model created in gensim? : <p>I have trained my own word2vec model in gensim and I am trying to load that model in spacy. First, I need to save it in my disk and then try to load an init-model in spacy but unable to figure out exactly how.</p> <pre><code>gensimmodel Out[252]: &lt;gensim.models.word2vec.Word2Vec at 0x110b24b70&gt; import spacy spacy.load(gensimmodel) OSError: [E050] Can't find model 'Word2Vec(vocab=250, size=1000, alpha=0.025)'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory. </code></pre>
0debug
how to set color to button group by focus on one of buttons : <p>I have one button group with 5 button, I need to set color to button group with focus on one of theme, for example if I hover on third button I need change first there will be change color, I try to do it with this button group code : </p> <pre><code>&lt;div class="btn-group"&gt; &lt;button type="button" class="btn btn-default"&gt;&lt;i class="far fa-star"&gt;&lt;/i&gt;&lt;/button&gt; &lt;button type="button" class="btn btn-default"&gt;&lt;i class="far fa-star"&gt;&lt;/i&gt;&lt;/button&gt; &lt;button type="button" class="btn btn-default"&gt;&lt;i class="far fa-star"&gt;&lt;/i&gt;&lt;/button&gt; &lt;button type="button" class="btn btn-default"&gt;&lt;i class="far fa-star"&gt;&lt;/i&gt;&lt;/button&gt; &lt;button type="button" class="btn btn-default"&gt;&lt;i class="far fa-star"&gt;&lt;/i&gt;&lt;/button&gt; &lt;/div&gt; </code></pre>
0debug
installing amqp on mac with brew : <p>I wanted to install <code>amqp</code> with pecl for my mac sierra. </p> <p>I installed php with brew, with <code>pecl install amqp</code> I receive an error: <code>checking for amqp using pkg-config... configure: error: librabbitmq not found</code></p> <p>I installed with brew the <code>librabbitmq-c</code> package but I still get this error. I think it's somehow not synced with the pkg-config. </p> <p>Does someone have an idea what to do here?</p>
0debug
why multiple condition in python while loop are not working? : <p>I can't seem to find the problem in code...<br></p> <pre><code>user_decision = "" while not user_decision == "yes" or not user_decision == "no": user_decision = input("You want to Join?: Please answer (yes/no): ") else: if user_decision == "yes": print("test") else: print("test") </code></pre> <p>Thanks....</p>
0debug
Helm _helpers.tpl: Calling defined templates in other template definitions : <h1>Helm _helpers.tpl?</h1> <p>Helm allows for the use of <a href="https://golang.org/pkg/text/template/" rel="noreferrer">Go templating</a> in resource files for Kubernetes. </p> <p>A file named <code>_helpers.tpl</code> is usually used to define Go template helpers with this syntax:</p> <pre><code>{{- define "yourFnName" -}} {{- printf "%s-%s" .Values.name .Values.version | trunc 63 -}} {{- end -}} </code></pre> <p>Which you can then use in your <code>*.yaml</code> resource files like so:</p> <pre><code>{{ template "yourFnName" . }} </code></pre> <h1>The Question</h1> <p>How can I use the helpers I define, in other helper definitions? </p> <p>For example, what if I have a helper for the application name, and want to use that in the definition for a helper which determines the ingress host name? </p> <p>I have tried calling helpers in other definitions a couple different ways. Given this basic helper function:</p> <pre><code>{{- define "host" -}} {{- printf "%.example.com" &lt;Somehow get result of "name" helper here&gt; -}} {{- end -}} </code></pre> <p>I have tried the following:</p> <pre><code>{{- printf "%.example.com" {{ template "name" . }} -}} {{- printf "%.example.com" {{- template "name" . -}} -}} {{- printf "%.example.com" ( template "name" . ) -}} {{- printf "%.example.com" template "name" . -}} # Separator {{- $name := {{ template "environment" . }} -}} {{- printf "%.example.com" $name -}} # Separator {{- $name := template "environment" . -}} {{- printf "%.example.com" $name -}} # Separator {{- $name := environment -}} {{- printf "%.example.com" $name -}} </code></pre> <p>Is it possible to even do this? If so, how?</p>
0debug
Angular 2 Load CSS background-image from assets folder : <p>My folder structure looks like</p> <pre><code>-myapp -assets -home-page-img -header-bg.jpg -src -app -home-page -home-page.component.css -home-page.component.html -home-page.component.ts </code></pre> <p>Inside my home-page.component.css, I have the following</p> <pre><code>header { width: 200px; height: 200px; background-image: url('/src/assets/home-page-img/header-bg.jpg'); } My angular-cli.json "assets": [ "assets", "favicon.ico" ] </code></pre> <p>When I run the code, I get</p> <pre><code>GET http://localhost:4200/src/assets/home-page-img/header-bg.jpg 404 (Not Found) </code></pre> <p>For demonstrating purpose, If I change background-image to the following, I get a whole different error</p> <pre><code>background-image: url('assets/home-page-img/header-bg.jpg'); ./src/app/home-page/home-page.component.css Module not found: Error: Can't resolve './assets/home-page-img/header-bg.jpg' in '/Users/JohnSmith/Desktop/my-app/src/app/home-page' </code></pre> <p>How can I get that image to load?</p>
0debug
Default values for Laravel 5.4+ blades new components? : <p>Laravel 5.4+ allows for components of the following structure:</p> <pre><code>&lt;div class="alert alert-{{ $type }}"&gt; &lt;div class="alert-title"&gt;{{ $title }}&lt;/div&gt; {{ $slot }} &lt;/div&gt; </code></pre> <p>Which are called like:</p> <pre><code>@component('alert', ['type' =&gt; 'danger']) @slot('title') oh no @endslot Foo @endcomponent </code></pre> <p>Is there a shorthand or blade marker to set default values for the variables passed in?</p> <p>For example, in the above, if I don't pass in "type" I get a <code>undefined variable</code> error. I could do something like:</p> <pre><code>&lt;div class="alert alert-{{ isset($type) ? $type : 'default' }}"&gt; </code></pre> <p>But the above feels verbose, especially if the variable is used in multiple spots. </p>
0debug
aio_ctx_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { AioContext *ctx = (AioContext *) source; assert(callback == NULL); aio_dispatch(ctx, true); return true; }
1threat
static void gen_rfdi(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } gen_helper_rfdi(cpu_env); gen_sync_exception(ctx); #endif }
1threat
static void check_watchpoint(int offset, int len, int flags) { CPUState *cpu = current_cpu; CPUArchState *env = cpu->env_ptr; target_ulong pc, cs_base; target_ulong vaddr; CPUWatchpoint *wp; int cpu_flags; if (cpu->watchpoint_hit) { cpu_interrupt(cpu, CPU_INTERRUPT_DEBUG); return; } vaddr = (cpu->mem_io_vaddr & TARGET_PAGE_MASK) + offset; QTAILQ_FOREACH(wp, &cpu->watchpoints, entry) { if (cpu_watchpoint_address_matches(wp, vaddr, len) && (wp->flags & flags)) { if (flags == BP_MEM_READ) { wp->flags |= BP_WATCHPOINT_HIT_READ; } else { wp->flags |= BP_WATCHPOINT_HIT_WRITE; } wp->hitaddr = vaddr; if (!cpu->watchpoint_hit) { cpu->watchpoint_hit = wp; tb_check_watchpoint(cpu); if (wp->flags & BP_STOP_BEFORE_ACCESS) { cpu->exception_index = EXCP_DEBUG; cpu_loop_exit(cpu); } else { cpu_get_tb_cpu_state(env, &pc, &cs_base, &cpu_flags); tb_gen_code(cpu, pc, cs_base, cpu_flags, 1); cpu_resume_from_signal(cpu, NULL); } } } else { wp->flags &= ~BP_WATCHPOINT_HIT; } } }
1threat
Replacing RegExp to another RegExp (JQuery, JavaScript) : **Problem**<hr/> I have a String var str = "string"; I want it will be catched with this Expression `/(^[a-z])/` and will be replaced by This Expression `/([A-Z])/` > It means it will make the first `LowerCase` Letter to `UpperCase` **I have tried**<hr/> > I have tried it my self but got an unexpected result. My code was like that. "string".replace(/(^[a-z])/, /([A-Z])/); > But the results of it is `/([A-Z])/` . It catches the first `Charecter` and Replace it to /([A-Z])/ as a text
0debug
c# delet a item form a listbox using double click : I need help I don't know I do to delete an item from the listbox by double click the item I have just started like 1 hour ago so I don't have code that can help. I didn't find anything on interned that could help me. if you know how to do this or a tutorial pleas comment that
0debug
When use setState in Flutter? : <p>As newbie in flutter it's very confusing for me when use <code>setState</code> in <code>Flutter</code> application. In below code boolean <code>searching</code> and var <code>resBody</code> used inside <code>setState</code>. My question is why only <code>searching</code> and <code>resBody</code> inside setState? Why not others veriable?</p> <pre><code>var resBody; bool searching = false,api_no_limit = false; String user = null; Future _getUser(String text) async{ setState(() { searching = true; }); user = text; _textController.clear(); String url = "https://api.github.com/users/"+text; var res = await http .get(Uri.encodeFull(url), headers: {"Accept": "application/json"}); setState(() { resBody = json.decode(res.body); }); } </code></pre>
0debug
RockerSwitch *qmp_query_rocker(const char *name, Error **errp) { RockerSwitch *rocker = g_malloc0(sizeof(*rocker)); Rocker *r; r = rocker_find(name); if (!r) { error_set(errp, ERROR_CLASS_GENERIC_ERROR, "rocker %s not found", name); return NULL; } rocker->name = g_strdup(r->name); rocker->id = r->switch_id; rocker->ports = r->fp_ports; return rocker; }
1threat
static int v210_read_packet(AVFormatContext *s, AVPacket *pkt) { int packet_size, ret, width, height; AVStream *st = s->streams[0]; width = st->codec->width; height = st->codec->height; packet_size = GET_PACKET_SIZE(width, height); if (packet_size < 0) return -1; ret = av_get_packet(s->pb, pkt, packet_size); pkt->pts = pkt->dts = pkt->pos / packet_size; pkt->stream_index = 0; if (ret < 0) return ret; return 0; }
1threat
Flutter onClosing callback for showModalBottomSheet : <p>I have a <code>showModalBottomSheet</code> like the below, which I understand to inherit from <code>BottomSheet</code> (right?)</p> <pre><code> showModalBottomSheet&lt;void&gt;( context: context, builder: (BuildContext context) { return Container( height: 260.0, child: Text('I am text') ); }, ); </code></pre> <p>What I want to do:</p> <p>I want to know (listen) when the modal is being closed, and act on it.</p> <p>I've seen this <code>onClosing</code> callback: <a href="https://docs.flutter.io/flutter/material/BottomSheet/onClosing.html" rel="noreferrer">https://docs.flutter.io/flutter/material/BottomSheet/onClosing.html</a></p> <p>How can I have a listener attached to the <code>showModalBottomSheet</code>, and then act accordingly when it fires?</p>
0debug
static int pcnet_can_receive(void *opaque) { PCNetState *s = opaque; if (CSR_STOP(s) || CSR_SPND(s)) return 0; if (s->recv_pos > 0) return 0; return sizeof(s->buffer)-16; }
1threat
where should I put docker-compose.yml : <p>When I pull the images from docker hub. Sometimes, I would like to run the images in a multi-container way. So I choose to use docker-compose. For example, I would run the <a href="https://hub.docker.com/_/zookeeper/" rel="noreferrer">zookeeper</a> in <a href="http://zookeeper.apache.org/doc/current/zookeeperStarted.html#sc_RunningReplicatedZooKeeper" rel="noreferrer">replicated mode</a>. I will new a file named docker-compose.yml, and run docker-compose up and wait for it to initialize completely. </p> <p>My question is what is proper directory I should put docker-compose.yml file into?</p>
0debug
Remove li from a dynamic list using blade and jquery : I have a dynamically populated list. On clicking on the Approve/reject button, an ajax call happens. If the response is 1, the div should be hidden from the UI. Below is my code. The remove() option doesn't seem to work. Can't figure out a way. Approve.blade.php <ul> @foreach($pendlist as $pend) <li id="{{$pend->id}}"> <div class="list-box-listing"> <div class="list-box-listing-img"><a href="#"><img src="images/listing-item-01.jpg" alt=""></a></div> <div class="list-box-listing-content"> <div class="inner"> <h3><a href="#">{{$pend->title}}</a></h3> <span>{{$pend->address}}, {{$pend->locality}}, {{$pend->city}}</span> <div class="star-rating" data-rating="3.5"> <div class="rating-counter">(12 reviews)</div> <input type="hidden" value="{{$pend->id}}" id="propid"> </div> </div> </div> </div> <div class="buttons-to-right"> <a href="#" class="button gray reject" id="reject"><i class="sl sl-icon-close"></i> Reject</a> <a href="#" class="button gray approve" id="approve"><i class="sl sl-icon-check"></i> Approve</a> </div> </li> @endforeach </ul> the jquery: $('#approve').click(function(){ $.ajax({ type: "POST", url: "{{ url('/api/approve') }}", async: true, data: { id: $('#propid').val(), status: 1 }, success: function(result){ let id = $('#propid').val(); if(result == 1){ $(this).remove(); } },error: function(XMLHttpRequest, textStatus, errorThrown) { alert(errorThrown); $("#loader").hide(); } }); I have tried $(this).closest('li').remove() But that also doesn't seem to work. Any help highly appreciated.
0debug
static int ohci_bus_start(OHCIState *ohci) { ohci->eof_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, ohci_frame_boundary, ohci); if (ohci->eof_timer == NULL) { trace_usb_ohci_bus_eof_timer_failed(ohci->name); ohci_die(ohci); return 0; } trace_usb_ohci_start(ohci->name); ohci_sof(ohci); return 1; }
1threat
static uint32_t pxa2xx_rtc_read(void *opaque, target_phys_addr_t addr) { PXA2xxRTCState *s = (PXA2xxRTCState *) opaque; switch (addr) { case RTTR: return s->rttr; case RTSR: return s->rtsr; case RTAR: return s->rtar; case RDAR1: return s->rdar1; case RDAR2: return s->rdar2; case RYAR1: return s->ryar1; case RYAR2: return s->ryar2; case SWAR1: return s->swar1; case SWAR2: return s->swar2; case PIAR: return s->piar; case RCNR: return s->last_rcnr + ((qemu_get_clock(rt_clock) - s->last_hz) << 15) / (1000 * ((s->rttr & 0xffff) + 1)); case RDCR: return s->last_rdcr + ((qemu_get_clock(rt_clock) - s->last_hz) << 15) / (1000 * ((s->rttr & 0xffff) + 1)); case RYCR: return s->last_rycr; case SWCR: if (s->rtsr & (1 << 12)) return s->last_swcr + (qemu_get_clock(rt_clock) - s->last_sw) / 10; else return s->last_swcr; default: printf("%s: Bad register " REG_FMT "\n", __FUNCTION__, addr); break; } return 0; }
1threat
Send multipart/form-data files with angular using $http : <p>I know there are a lot of questions about this, but I can't get this to work:</p> <p>I want to upload a file from input to a server in multipart/form-data</p> <p>I've tried two approaches. First:</p> <pre><code>headers: { 'Content-Type': undefined }, </code></pre> <p>Which results in e.g. for an image</p> <pre><code>Content-Type:image/png </code></pre> <p>while it should be multipart/form-data</p> <p>and the other: </p> <pre><code>headers: { 'Content-Type': multipart/form-data }, </code></pre> <p>But this asks for a boundry header, which I believe should not be manually inserted... </p> <p>What is a clean way to solve this problem? I've read that you can do </p> <pre><code>$httpProvider.defaults.headers.post['Content-Type'] = 'multipart/form-data; charset=utf-8'; </code></pre> <p>But I don't want all my posts to be multipart/form-data. The default should be JSON</p>
0debug
Displaying the result in the page - Angular 4 : I am trying to extract data from database (arangodb) and display it on the page or even push it to next page. As of now I am able to display the data in console by clicking button. But how can I display the result in same page ? Can someone help with this ? **app.component.html** <li> <button type="submit" (click)="client_wsdl_get()">test GET data</button> </li> I want this result to be displayed in the page. [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/Bem1F.png
0debug
How to add menu to right button : [![enter image description here][1]][1] I want to add a menu on the left click. Where to read about how to do this? [1]: https://i.stack.imgur.com/d3m1U.jpg
0debug
static uint64_t hb_count_between(HBitmap *hb, uint64_t start, uint64_t last) { HBitmapIter hbi; uint64_t count = 0; uint64_t end = last + 1; unsigned long cur; size_t pos; hbitmap_iter_init(&hbi, hb, start << hb->granularity); for (;;) { pos = hbitmap_iter_next_word(&hbi, &cur); if (pos >= (end >> BITS_PER_LEVEL)) { break; } count += popcountl(cur); } if (pos == (end >> BITS_PER_LEVEL)) { int bit = end & (BITS_PER_LONG - 1); cur &= (1UL << bit) - 1; count += popcountl(cur); } return count; }
1threat
Python 2.7 function imports : <p>When I say <code>import numpy as np</code>, I can access all the modules and submodules in numpy from np. I do not have to say <code>np.matrixlib.matrix</code>. What is this feature called? How do I implement this in my package.</p>
0debug
What mean of 0x0000000000000000? : I have a view, and remove when there is a situation. if (self.superview) { [self removeFromSuperview]; // breakpoint point here } I `lldb` it : (lldb) po self.superview 0x0000000000000000 How to juedge the `superview` equals to `0x0000000000000000`?
0debug
static int mp_user_removexattr(FsContext *ctx, const char *path, const char *name) { char *buffer; int ret; if (strncmp(name, "user.virtfs.", 12) == 0) { errno = EACCES; return -1; } buffer = rpath(ctx, path); ret = lremovexattr(buffer, name); g_free(buffer); return ret; }
1threat
def position_min(list1): min_val = min(list1) min_result = [i for i, j in enumerate(list1) if j == min_val] return min_result
0debug
Espresso Tests in Library Module 'com.android.library' : <p>I have a library module that is used by two android applications and I want to add espresso tests to the Library module so that both apps can run common set of tests. Is there an example available where espresso tests are added in library module?</p>
0debug
I want to print a string multiple time but in a new line : print('python'*5,sep='\n') [][1] [1]: https://i.stack.imgur.com/zB3HT.png how to print it in new line Ex: python python python
0debug
Locatio Based Android Development : In android once we get the current location's latitude and longitude then after how we can able to get the list of my places which are all marked in Google My Maps within the 10kms radius of current location , i.e if my current location latitude and longitudes are 23.00 & 72.50 respectively so on base of that how can i get the list of my places marked in Google My Maps nearby this location address within the 10 kms radius?
0debug
Cannot use import statement outside a module : <p>I'm trying to use classes in pure JavaScript, so I'm facing the error "Uncaught SyntaxError: Cannot use import statement outside a module" and can't solve it.</p> <p>File1.js - Main file</p> <pre><code>import example from "./file2"; var test = new example(); </code></pre> <p>File2.js - Class file</p> <pre><code>export default class example { constructor() { console.log("hello world"); } } </code></pre>
0debug
ionic 2 - Remove Border Footer : <p>I have a blue footer like this</p> <pre><code>&lt;ion-footer align="center"&gt; &lt;ion-toolbar&gt; &lt;ion-title&gt; ... </code></pre> <p>But it is showing a shadow style border at the top. How can I remove it. I tried to inspect it but did not find anything.</p>
0debug
static void t_gen_lsl(TCGv d, TCGv a, TCGv b) { TCGv t0, t_31; t0 = tcg_temp_new(TCG_TYPE_TL); t_31 = tcg_const_tl(31); tcg_gen_shl_tl(d, a, b); tcg_gen_sub_tl(t0, t_31, b); tcg_gen_sar_tl(t0, t0, t_31); tcg_gen_and_tl(t0, t0, d); tcg_gen_xor_tl(d, d, t0); tcg_temp_free(t0); tcg_temp_free(t_31); }
1threat
Convert a simple Object to a Complex array : <p>I have been trying to map the following object to the following array, I am quite new to map/sort and reduce. Is it even possible to do acquire the wanted result?</p> <p><strong>From:</strong></p> <pre><code>{ boxer: Array [] brabancon: Array [] briard: Array [] bulldog: Array [ "boston", "french" ] } </code></pre> <p><strong>To:</strong></p> <pre><code>[ {dogBreed: 'boxer'}, {dogBree: 'brabancon'}, {dogBree: 'briard'}, {dogBree: 'bulldog (boston)'}, {dogBree: 'bulldog (french)'} ] </code></pre>
0debug
static inline void RENAME(rgb16to15)(const uint8_t *src, uint8_t *dst, int src_size) { register const uint8_t* s=src; register uint8_t* d=dst; register const uint8_t *end; const uint8_t *mm_end; end = s + src_size; __asm__ volatile(PREFETCH" %0"::"m"(*s)); __asm__ volatile("movq %0, %%mm7"::"m"(mask15rg)); __asm__ volatile("movq %0, %%mm6"::"m"(mask15b)); mm_end = end - 15; while (s<mm_end) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movq %1, %%mm0 \n\t" "movq 8%1, %%mm2 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "psrlq $1, %%mm0 \n\t" "psrlq $1, %%mm2 \n\t" "pand %%mm7, %%mm0 \n\t" "pand %%mm7, %%mm2 \n\t" "pand %%mm6, %%mm1 \n\t" "pand %%mm6, %%mm3 \n\t" "por %%mm1, %%mm0 \n\t" "por %%mm3, %%mm2 \n\t" MOVNTQ" %%mm0, %0 \n\t" MOVNTQ" %%mm2, 8%0" :"=m"(*d) :"m"(*s) ); d+=16; s+=16; } __asm__ volatile(SFENCE:::"memory"); __asm__ volatile(EMMS:::"memory"); mm_end = end - 3; while (s < mm_end) { register uint32_t x= *((const uint32_t*)s); *((uint32_t *)d) = ((x>>1)&0x7FE07FE0) | (x&0x001F001F); s+=4; d+=4; } if (s < end) { register uint16_t x= *((const uint16_t*)s); *((uint16_t *)d) = ((x>>1)&0x7FE0) | (x&0x001F); } }
1threat
Difference between Notifications API and Push API from Web perspective : <p>What is the difference between <a href="https://developer.chrome.com/apps/notifications" rel="noreferrer">Chrome Notifications API</a> and the <a href="https://developers.google.com/web/updates/2015/03/push-notifications-on-the-open-web?hl=en" rel="noreferrer">Push Notification API</a> when developing Web notifications. When each one should be used and how are they different?</p>
0debug
Python high speed memcpy : <p>I'm trying to do a high speed memcpy in Python. I use the ctypes library which allows me to interact with C programms.</p> <p>I follow this steps:</p> <ol> <li>I get the memory address </li> <li>I get the length of the data</li> <li>I use the ctypes' functions memmove or string_at</li> </ol> <p>The results are correct but I need higher speed. Is there any faster way to do this without using C?</p> <p>Thank you.</p>
0debug
void unregister_savevm(DeviceState *dev, const char *idstr, void *opaque) { SaveStateEntry *se, *new_se; char id[256] = ""; if (dev && dev->parent_bus && dev->parent_bus->info->get_dev_path) { char *path = dev->parent_bus->info->get_dev_path(dev); if (path) { pstrcpy(id, sizeof(id), path); pstrcat(id, sizeof(id), "/"); qemu_free(path); pstrcat(id, sizeof(id), idstr); QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) { if (strcmp(se->idstr, id) == 0 && se->opaque == opaque) { QTAILQ_REMOVE(&savevm_handlers, se, entry); qemu_free(se);
1threat
static int decode_header(SnowContext *s){ int plane_index, tmp; uint8_t kstate[32]; memset(kstate, MID_STATE, sizeof(kstate)); s->keyframe= get_rac(&s->c, kstate); if(s->keyframe || s->always_reset){ reset_contexts(s); s->spatial_decomposition_type= s->qlog= s->qbias= s->mv_scale= s->block_max_depth= 0; } if(s->keyframe){ s->version= get_symbol(&s->c, s->header_state, 0); if(s->version>0){ av_log(s->avctx, AV_LOG_ERROR, "version %d not supported", s->version); return -1; } s->always_reset= get_rac(&s->c, s->header_state); s->temporal_decomposition_type= get_symbol(&s->c, s->header_state, 0); s->temporal_decomposition_count= get_symbol(&s->c, s->header_state, 0); s->spatial_decomposition_count= get_symbol(&s->c, s->header_state, 0); s->colorspace_type= get_symbol(&s->c, s->header_state, 0); s->chroma_h_shift= get_symbol(&s->c, s->header_state, 0); s->chroma_v_shift= get_symbol(&s->c, s->header_state, 0); s->spatial_scalability= get_rac(&s->c, s->header_state); tmp= get_symbol(&s->c, s->header_state, 0)+1; if(tmp < 1 || tmp > MAX_REF_FRAMES){ av_log(s->avctx, AV_LOG_ERROR, "reference frame count is %d\n", tmp); return -1; } s->max_ref_frames= tmp; decode_qlogs(s); } if(!s->keyframe){ if(get_rac(&s->c, s->header_state)){ for(plane_index=0; plane_index<2; plane_index++){ int htaps, i, sum=0; Plane *p= &s->plane[plane_index]; p->diag_mc= get_rac(&s->c, s->header_state); htaps= get_symbol(&s->c, s->header_state, 0)*2 + 2; if((unsigned)htaps > HTAPS_MAX || htaps==0) return -1; p->htaps= htaps; for(i= htaps/2; i; i--){ p->hcoeff[i]= get_symbol(&s->c, s->header_state, 0) * (1-2*(i&1)); sum += p->hcoeff[i]; } p->hcoeff[0]= 32-sum; } s->plane[2].diag_mc= s->plane[1].diag_mc; s->plane[2].htaps = s->plane[1].htaps; memcpy(s->plane[2].hcoeff, s->plane[1].hcoeff, sizeof(s->plane[1].hcoeff)); } if(get_rac(&s->c, s->header_state)){ s->spatial_decomposition_count= get_symbol(&s->c, s->header_state, 0); decode_qlogs(s); } } s->spatial_decomposition_type+= get_symbol(&s->c, s->header_state, 1); if(s->spatial_decomposition_type > 1){ av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_type %d not supported", s->spatial_decomposition_type); return -1; } s->qlog += get_symbol(&s->c, s->header_state, 1); s->mv_scale += get_symbol(&s->c, s->header_state, 1); s->qbias += get_symbol(&s->c, s->header_state, 1); s->block_max_depth+= get_symbol(&s->c, s->header_state, 1); if(s->block_max_depth > 1 || s->block_max_depth < 0){ av_log(s->avctx, AV_LOG_ERROR, "block_max_depth= %d is too large", s->block_max_depth); s->block_max_depth= 0; return -1; } return 0; }
1threat
When to use ? instead of null : <p>Can someone explain the difference between:</p> <pre><code>if(object?.Count &gt; 0){ //code } </code></pre> <p>and: </p> <pre><code>if(object != null &amp;&amp; object.Count &gt; 0){ //code } </code></pre> <p>Or are they doing the same thing? Thank you.</p>
0debug
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
void virtio_bus_device_plugged(VirtIODevice *vdev, Error **errp) { DeviceState *qdev = DEVICE(vdev); BusState *qbus = BUS(qdev_get_parent_bus(qdev)); VirtioBusState *bus = VIRTIO_BUS(qbus); VirtioBusClass *klass = VIRTIO_BUS_GET_CLASS(bus); VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); DPRINTF("%s: plug device.\n", qbus->name); if (klass->device_plugged != NULL) { klass->device_plugged(qbus->parent, errp); } assert(vdc->get_features != NULL); vdev->host_features = vdc->get_features(vdev, vdev->host_features, errp); if (klass->post_plugged != NULL) { klass->post_plugged(qbus->parent, errp); } }
1threat
void cpu_x86_inject_mce(Monitor *mon, CPUState *cenv, int bank, uint64_t status, uint64_t mcg_status, uint64_t addr, uint64_t misc, int flags) { unsigned bank_num = cenv->mcg_cap & 0xff; CPUState *env; int flag = 0; if (!cenv->mcg_cap) { monitor_printf(mon, "MCE injection not supported\n"); return; } if (bank >= bank_num) { monitor_printf(mon, "Invalid MCE bank number\n"); return; } if (!(status & MCI_STATUS_VAL)) { monitor_printf(mon, "Invalid MCE status code\n"); return; } if ((flags & MCE_INJECT_BROADCAST) && !cpu_x86_support_mca_broadcast(cenv)) { monitor_printf(mon, "Guest CPU does not support MCA broadcast\n"); return; } if (kvm_enabled()) { if (flags & MCE_INJECT_BROADCAST) { flag |= MCE_BROADCAST; } kvm_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc, flag); } else { qemu_inject_x86_mce(mon, cenv, bank, status, mcg_status, addr, misc, flags); if (flags & MCE_INJECT_BROADCAST) { for (env = first_cpu; env != NULL; env = env->next_cpu) { if (cenv == env) { continue; } qemu_inject_x86_mce(mon, env, 1, MCI_STATUS_VAL | MCI_STATUS_UC, MCG_STATUS_MCIP | MCG_STATUS_RIPV, 0, 0, flags); } } } }
1threat
PDF content extractor library for Android : <p>Does anyone know a good Java library (for Android) to extract the text content in a PDF? I have used PDFClown with Java but I cannot use it with Android because Android does not have Java AWT support. Instead it uses android.graphics package. </p> <p>I'm looking for Android library similar to PDFClown but I couldn't find it anywhere in the internet. Please help me. Thanks</p>
0debug
static void filter_mb_edgecv( H264Context *h, uint8_t *pix, int stride, int bS[4], int qp ) { int i, d; const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 ); const int alpha = alpha_table[index_a]; const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )]; for( i = 0; i < 4; i++ ) { if( bS[i] == 0 ) { pix += 2 * stride; continue; } for( d = 0; d < 2; d++ ) { const uint8_t p0 = pix[-1]; const uint8_t p1 = pix[-2]; const uint8_t q0 = pix[0]; const uint8_t q1 = pix[1]; if( abs( p0 - q0 ) >= alpha || abs( p1 - p0 ) >= beta || abs( q1 - q0 ) >= beta ) { pix += stride; continue; } if( bS[i] < 4 ) { const int tc = tc0_table[index_a][bS[i] - 1] + 1; const int i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); pix[-1] = clip( p0 + i_delta, 0, 255 ); pix[0] = clip( q0 - i_delta, 0, 255 ); } else { pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2; pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; } pix += stride; } } }
1threat
Online tool to check/validate css : <p>Is this website <a href="https://codebeautify.org/cssvalidate" rel="nofollow noreferrer">code beautify</a> reliable to check my css codes in details or are there other tools?</p>
0debug
Visual studio community problem in unity 3d, asking to upgrade even i am using free version, what to do ? Please help me someone, Thank you : [enter image description here][1] I am using visual studio community 2017 with unity 3d, but after few days i got this issue, what to do ? [1]: https://i.stack.imgur.com/M9Kxh.jpg
0debug
Regex to remove Entire String from sentence not substring : <p>I am very new to regular expression. I want to replace string from sentence using regular expression in scala or java.</p> <p>Ex.</p> <blockquote> <p>"I am new to scala and scalapark is differnt"</p> </blockquote> <p>I want to remove "scala" string from this statement not "scalapark". </p> <blockquote> <p>"I am new to and scalapark is differnt"</p> </blockquote> <p>How can I perform this using regex.</p> <p>Thanks in advance</p>
0debug
NSFoundationVersionNumber in iOS 11 - How to detect iOS version programmatically : <p>In previous iOS versions I used <code>NSFoundationVersionNumber</code> to detect the iOS version:</p> <pre><code>#define IS_IOS10orHIGHER (floor(NSFoundationVersionNumber) &gt; NSFoundationVersionNumber_iOS_9_x_Max) #define IS_IOS9orHIGHER (floor(NSFoundationVersionNumber) &gt; NSFoundationVersionNumber_iOS_8_3) #define IS_IOS8orHIGHER (floor(NSFoundationVersionNumber) &gt; NSFoundationVersionNumber_iOS_7_1) #define IS_IOS7orHIGHER (floor(NSFoundationVersionNumber) &gt; NSFoundationVersionNumber_iOS_6_1) #define IS_IOS6orHIGHER (floor(NSFoundationVersionNumber) &gt;= NSFoundationVersionNumber_iOS_6_0) ... </code></pre> <p>Now I would to do the same for iOS 11, but I was not able to find the correct <code>NSFoundationVersionNumber</code>. <a href="https://developer.apple.com/documentation/foundation/nsfoundationversionnumber_ios_9_4" rel="noreferrer">The docs</a> show <code>NSFoundationVersionNumber_iOS_9_x_Max</code> to be the latest. </p> <p><strong>So, how is the correct <code>NSFoundationVersionNumber</code> to detect if iOS 11 is used?</strong></p>
0debug
How can i Creating Custom Routes in ASP MVC? : I Want to Send a parametr to a Defult Action in a Defult Controller Just Like This: Domain.com/**parametr** **parametr** it's just an id tha i want to sent to an action
0debug
MigrationCapabilityStatusList *qmp_query_migrate_capabilities(Error **errp) { MigrationCapabilityStatusList *head = NULL; MigrationCapabilityStatusList *caps; MigrationState *s = migrate_get_current(); int i; caps = NULL; for (i = 0; i < MIGRATION_CAPABILITY__MAX; i++) { #ifndef CONFIG_LIVE_BLOCK_MIGRATION if (i == MIGRATION_CAPABILITY_BLOCK) { continue; } #endif if (i == MIGRATION_CAPABILITY_X_COLO && !colo_supported()) { continue; } if (head == NULL) { head = g_malloc0(sizeof(*caps)); caps = head; } else { caps->next = g_malloc0(sizeof(*caps)); caps = caps->next; } caps->value = g_malloc(sizeof(*caps->value)); caps->value->capability = i; caps->value->state = s->enabled_capabilities[i]; } return head; }
1threat
componentWillReceiveProps has been renamed : <p>I'm using Material ui SwipeableViews That use ReactSwipableView package, I'm getting this error on the console</p> <blockquote> <p>react-dom.development.js:12466 Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See for details.</p> <ul> <li>Move data fetching code or side effects to componentDidUpdate.</li> <li>If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: </li> <li>Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run <code>npx react-codemod rename-unsafe-lifecycles</code> in your project source folder.</li> </ul> <p>Please update the following components: ReactSwipableView</p> </blockquote> <p>is there any way to get rid of this error i did try UNSAFE_componentWillReceiveProps but nothing change</p>
0debug
android send data from service to BroadcastReciver : How I can Send data from Service to Broadcast Receiver without using Intent I Know How Intent work but I need another way? `
0debug
How i can print this 2 Variables in the same println "System.out.println" : public class Math1 { public static void main (String args[]) { int abdou1 = 115; double abdou2 = 1122.176876; System.out.println(abdou1, abdou2); } }
0debug
static int local_mkdir(FsContext *fs_ctx, V9fsPath *dir_path, const char *name, FsCred *credp) { char *path; int err = -1; int serrno = 0; V9fsString fullname; char buffer[PATH_MAX]; v9fs_string_init(&fullname); v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name); path = fullname.data; if (fs_ctx->export_flags & V9FS_SM_MAPPED) { err = mkdir(rpath(fs_ctx, path, buffer), SM_LOCAL_DIR_MODE_BITS); if (err == -1) { goto out; } credp->fc_mode = credp->fc_mode|S_IFDIR; err = local_set_xattr(rpath(fs_ctx, path, buffer), credp); if (err == -1) { serrno = errno; goto err_end; } } else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) { err = mkdir(rpath(fs_ctx, path, buffer), SM_LOCAL_DIR_MODE_BITS); if (err == -1) { goto out; } credp->fc_mode = credp->fc_mode|S_IFDIR; err = local_set_mapped_file_attr(fs_ctx, path, credp); if (err == -1) { serrno = errno; goto err_end; } } else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) || (fs_ctx->export_flags & V9FS_SM_NONE)) { err = mkdir(rpath(fs_ctx, path, buffer), credp->fc_mode); if (err == -1) { goto out; } err = local_post_create_passthrough(fs_ctx, path, credp); if (err == -1) { serrno = errno; goto err_end; } } goto out; err_end: remove(rpath(fs_ctx, path, buffer)); errno = serrno; out: v9fs_string_free(&fullname); return err; }
1threat
static int spapr_set_associativity(void *fdt, sPAPREnvironment *spapr) { int ret = 0, offset; CPUPPCState *env; char cpu_model[32]; int smt = kvmppc_smt_threads(); assert(spapr->cpu_model); for (env = first_cpu; env != NULL; env = env->next_cpu) { uint32_t associativity[] = {cpu_to_be32(0x5), cpu_to_be32(0x0), cpu_to_be32(0x0), cpu_to_be32(0x0), cpu_to_be32(env->numa_node), cpu_to_be32(env->cpu_index)}; if ((env->cpu_index % smt) != 0) { continue; } snprintf(cpu_model, 32, "/cpus/%s@%x", spapr->cpu_model, env->cpu_index); offset = fdt_path_offset(fdt, cpu_model); if (offset < 0) { return offset; } ret = fdt_setprop(fdt, offset, "ibm,associativity", associativity, sizeof(associativity)); if (ret < 0) { return ret; } } return ret; }
1threat
What is the benefit of storing data in databases like SQL? : <p>This is very elementary question but why does a framework like Rails use ActiveRecord to run SQL commands to get data from a DB? I heard that you can cached data on the Rails server itself, so why not just store all data on the the server instead of the DB? Is it because space on the server is a lot more expensive/valuable than on the DB? If so, why is that? Also can the reason be that you want a ORM in the DB and that just takes too much code to set up on the Rails server? Sorry if this question sounds dumb but I don't know where else I can go for an answer.</p>
0debug
QuerySelectorAll(input[type=select]) not working : <p>I am able to select every other type of element on the page except:</p> <pre><code>var elems = querySelectorAll("input[type=select]"); </code></pre> <p>Once I have them, I am applying <code>.disabled</code> in a loop:</p> <pre><code>for (var i = 0; i &lt; elems.length; i++) { elems[i].disabled = true; } </code></pre> <p>This works for all inputs except <code>&lt;select&gt;</code>.</p> <p>Forgive me for this stupid question, but my search results, both here in SO, and on google, are flooded with false hits on "select" in "query<strong>SELECT</strong>orAll().</p> <p>Does anyone know the correct syntax to use to select <code>select</code> elements?</p> <p>Or, if my syntax is correct, why it is not working?</p>
0debug
C# int.TryParse and float.TryParse both parsed negative value and returned true : <p>I am working some basic data types. I need to find user input data types.</p> <p>Whenever I use int.TryParse and float.TryParse both parse negative value and returned true.</p> <p>This is bug? or this is the basic functionality which is I did't aware.</p>
0debug
static inline int tcg_temp_new_internal(TCGType type, int temp_local) { TCGContext *s = &tcg_ctx; TCGTemp *ts; int idx, k; k = type; if (temp_local) k += TCG_TYPE_COUNT; idx = s->first_free_temp[k]; if (idx != -1) { ts = &s->temps[idx]; s->first_free_temp[k] = ts->next_free_temp; ts->temp_allocated = 1; assert(ts->temp_local == temp_local); } else { idx = s->nb_temps; #if TCG_TARGET_REG_BITS == 32 if (type == TCG_TYPE_I64) { tcg_temp_alloc(s, s->nb_temps + 2); ts = &s->temps[s->nb_temps]; ts->base_type = type; ts->type = TCG_TYPE_I32; ts->temp_allocated = 1; ts->temp_local = temp_local; ts->name = NULL; ts++; ts->base_type = TCG_TYPE_I32; ts->type = TCG_TYPE_I32; ts->temp_allocated = 1; ts->temp_local = temp_local; ts->name = NULL; s->nb_temps += 2; } else { tcg_temp_alloc(s, s->nb_temps + 1); ts = &s->temps[s->nb_temps]; ts->base_type = type; ts->type = type; ts->temp_allocated = 1; ts->temp_local = temp_local; ts->name = NULL; s->nb_temps++; } } return idx; }
1threat
Perfomance comparison with V8 : I'm currently testing multiple cases for parsing lines. Each lines are formatted like that: "dHdX5jOa7ww9cGsW7jQF=dHdX5jOa7ww9cGsW7jQF=dHdX5jOa7ww9cGsW7jQF=dHdX5jOa7ww9cGsW7jQF" There is a lot of lines of course, and i need to extract the **key**, and the **value**. The **key** is delimited by the first "=" founded. There is never the "=" char in the key. The **value** is the rest of string next to the first "=" sign. So for this exemple the result should be: { key: "dHdX5jOa7ww9cGsW7jQF", value: "dHdX5jOa7ww9cGsW7jQF=dHdX5jOa7ww9cGsW7jQF=dHdX5jOa7ww9cGsW7jQF" } From here we can iterate on multiple solutions: // the first one is not very efficient with split splice join method function first(line) { const lineSplit = line.split('='), key = lineSplit[0], value = lineSplit.splice(1, lineSplit.length).join('='); return { key, value }; } // the second one execute only what i want to do // with built-in String prototype's functions function optimized(line) { const index = line.indexOf("="), key = line.substr(0, index), value = line.substr(index + 1, line.length); return { key, value }; } // i tried to code the logic myself function homemade(line) { const len = line.length; let value = "", key = "", valued = false; for (let i = 0; i < len; ++i) { const char = line[i]; if (valued === false) { if (char !== '=') { key += char; } else { valued = true; } } else { value += char; } } return { key, value }; } // and next recode substr and foreach built-in to implemant the same // function but with homemade substr&foreach String.prototype.substr2 = function(from, to){ let str = ""; for (let i = from; i < to; ++i) { str += this[i]; } return str; }; String.prototype.indexOf2 = function(occ){ const len = this.length; for (let i = 0; i < len; ++i) { if (this[i] === occ) { return i; } } return -1; }; function overload(line) { const index = line.indexOf2("="), key = line.substr2(0, index), value = line.substr2(index + 1, line.length); return { key, value }; } And voila the results with jsBench: [I'm using Google Chrome Version 59.0.3071.104 (Official Build) (64-bit)] [![enter image description here][1]][1] You can checkout the results of these functions with your browser [in this jsBench][2] I don't understand what is going on. I imagined that cannot be possible since i wrote only the code i needed with native for() and other stuffs like this... Can anyone explain these performance gaps? [1]: https://i.stack.imgur.com/DBF36.png [2]: http://jsben.ch/PKqK9
0debug
Multiple Id's in In clause of SQL Query C# : <p>I want to basically use multiple iD's in In clause of my sql query. Now i have two options one is to get the comma separated ID's from a textbox or i can put a list view or grid view to insert id's there and then get the id's to be used in sql statement. Can you please help me with the code, how to do this thing? </p>
0debug
How can I create new Tags in DICOM? : I want to add some specifics tags in my java program that are not in the DICOM library. How can I do it?
0debug
void sm501_init(MemoryRegion *address_space_mem, uint32_t base, uint32_t local_mem_bytes, qemu_irq irq, CharDriverState *chr) { SM501State * s; DeviceState *dev; MemoryRegion *sm501_system_config = g_new(MemoryRegion, 1); MemoryRegion *sm501_disp_ctrl = g_new(MemoryRegion, 1); MemoryRegion *sm501_2d_engine = g_new(MemoryRegion, 1); s = (SM501State *)g_malloc0(sizeof(SM501State)); s->base = base; s->local_mem_size_index = get_local_mem_size_index(local_mem_bytes); SM501_DPRINTF("local mem size=%x. index=%d\n", get_local_mem_size(s), s->local_mem_size_index); s->system_control = 0x00100000; s->misc_control = 0x00001000; s->dc_panel_control = 0x00010000; s->dc_crt_control = 0x00010000; memory_region_init_ram(&s->local_mem_region, NULL, "sm501.local", local_mem_bytes, &error_abort); vmstate_register_ram_global(&s->local_mem_region); memory_region_set_log(&s->local_mem_region, true, DIRTY_MEMORY_VGA); s->local_mem = memory_region_get_ram_ptr(&s->local_mem_region); memory_region_add_subregion(address_space_mem, base, &s->local_mem_region); memory_region_init_io(sm501_system_config, NULL, &sm501_system_config_ops, s, "sm501-system-config", 0x6c); memory_region_add_subregion(address_space_mem, base + MMIO_BASE_OFFSET, sm501_system_config); memory_region_init_io(sm501_disp_ctrl, NULL, &sm501_disp_ctrl_ops, s, "sm501-disp-ctrl", 0x1000); memory_region_add_subregion(address_space_mem, base + MMIO_BASE_OFFSET + SM501_DC, sm501_disp_ctrl); memory_region_init_io(sm501_2d_engine, NULL, &sm501_2d_engine_ops, s, "sm501-2d-engine", 0x54); memory_region_add_subregion(address_space_mem, base + MMIO_BASE_OFFSET + SM501_2D_ENGINE, sm501_2d_engine); dev = qdev_create(NULL, "sysbus-ohci"); qdev_prop_set_uint32(dev, "num-ports", 2); qdev_prop_set_uint64(dev, "dma-offset", base); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base + MMIO_BASE_OFFSET + SM501_USB_HOST); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq); if (chr) { serial_mm_init(address_space_mem, base + MMIO_BASE_OFFSET + SM501_UART0, 2, NULL, 115200, chr, DEVICE_NATIVE_ENDIAN); } s->con = graphic_console_init(DEVICE(dev), 0, &sm501_ops, s); }
1threat
How can I make use of Error boundaries in functional React components? : <p>I can <a href="https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html" rel="noreferrer">make a class an error boundary</a> in React by implementing <code>componentDidCatch</code>.</p> <p>Is there a clean approach to making a functional component into an error boundary without converting it into a class?</p> <p>Or is this a code smell?</p>
0debug
Too many arguments error? yes i am a novice coder : I am building a laser that is to be controlled by a joystick. the joystick uses 2 servo motors to move the laser in the direction i want. i am using an arduino board that uses C++ coding. i keep getting a " too many arguments" error on my outputs and i don't know why. i would appreciate if anyone can help me fix my code. <!-- begin snippet: js hide: false --> <!-- language: lang-css --> #include <Servo.h> const int servo1 = 11; // first servo const int servo2 = 10; // second servo const int joy1 = 5; // switch 1 const int joy2 = 4; // switch 2 const int joy3 = 3; // switch 3 const int joy4 = 2; // switch 4 int servoVal; // variable to read the value from the digital pin Servo myservo1; // create servo object to control a servo Servo myservo2; // create servo object to control a servo void setup() { // Servo myservo1.attach(servo1); // attaches the servo myservo2.attach(servo2); // attaches the servo // Inizialize Serial Serial.begin(9600); } void loop(){ // Display Joystick values using the serial monitor outputJoystick(); // Read the horizontal joystick value (value between 0 and 180) servoVal = digitalRead(joy1, joy2, joy3, joy4); servoVal = map(servoVal, 0, 45, 135, 180); // scale it to use it with the servo (result between 0 and 180) myservo2.write(servoVal); // sets the servo position according to the scaled value // Read the horizontal joystick value (value between 0 and 180) servoVal = digitalRead(joy1, joy2, joy3, joy4); servoVal = map(servoVal, 0, 45, 135, 180); // scale it to use it with the servo (result between 0 and 180) myservo1.write(servoVal); // sets the servo position according to the scaled value delay(15); // waits for the servo to get there } /** * Display joystick values */ void outputJoystick(){ Serial.print(digitalRead(joy1, joy2, joy3, joy4)); Serial.print ("---"); Serial.print(digitalRead(joy1, joy2, joy3, joy4)); Serial.println ("----------------"); } <!-- end snippet -->
0debug
static uint64_t lsi_io_read(void *opaque, target_phys_addr_t addr, unsigned size) { LSIState *s = opaque; return lsi_reg_readb(s, addr & 0xff); }
1threat
static int png_write_row(PNGContext *s, const uint8_t *data, int size) { int ret; s->zstream.avail_in = size; s->zstream.next_in = (uint8_t *)data; while (s->zstream.avail_in > 0) { ret = deflate(&s->zstream, Z_NO_FLUSH); if (ret != Z_OK) return -1; if (s->zstream.avail_out == 0) { png_write_chunk(&s->bytestream, MKTAG('I', 'D', 'A', 'T'), s->buf, IOBUF_SIZE); s->zstream.avail_out = IOBUF_SIZE; s->zstream.next_out = s->buf; } } return 0; }
1threat
What do JSONSerialization options do and how do they change jsonResult? : <p>I am using <code>JSONSerialization</code> quite often in my project. Here is an example of my <code>JSONSerialization</code> code:</p> <pre><code>let json = try JSONSerialization.jsonObject(with: data!, options: []) as? [String: Any] </code></pre> <p><strong>Note</strong>: Options are missing for purpose and I normally have them in my project.</p> <p>My problem is that I am not pretty sure what do these <code>options: []</code> do? </p> <p><strong>What I have found about options:</strong></p> <p><strong>NSJSONReadingMutableContainers:</strong> </p> <blockquote> <p>Specifies that arrays and dictionaries are created as mutable objects.</p> </blockquote> <p><strong>NSJSONReadingMutableLeaves:</strong></p> <blockquote> <p>Specifies that leaf strings in the JSON object graph are created as instances of NSMutableString.</p> </blockquote> <p><strong>NSJSONReadingAllowFragments:</strong></p> <blockquote> <p>Specifies that the parser should allow top-level objects that are not an instance of NSArray or NSDictionary.</p> </blockquote> <p><strong>Note2</strong>: I found those definitions on : <a href="https://developer.apple.com/reference/foundation/nsjsonreadingoptions" rel="noreferrer">https://developer.apple.com/reference/foundation/nsjsonreadingoptions</a></p> <p><strong>My question is</strong>: Can someone please explain me differences between those options , what should I use them for and if you could show me some code example of those options it would be perfect :).</p> <p>Any help appreciated.</p> <p>Thanks.</p>
0debug
Angular2 TypeScript Directive error TS2345 : <p>When I compile my app with tsc I get this error TS2345:</p> <pre><code>error TS2345: Argument of type '{ selector: string; template: string; directives: (typeof Title | any[])[]; providers: typeof Goo...' is not assignable to parameter of type 'ComponentMetadataType'. </code></pre> <p>And here is my code:</p> <pre><code>import { Component, Input } from "@angular/core"; import { Title } from "./components/title"; import { Timeline } from "./components/timeline"; @Component({ selector: "edu", template: ` &lt;div id="Edu" class="Edu content section scrollspy"&gt; &lt;title [icon]="titleIcon" [title]="titleTitle"&gt;&lt;/title&gt; &lt;timeline [data]="edu"&gt;&lt;/timeline&gt; &lt;/div&gt; `, directives: [Title, Timeline] }) export class Edu { private titleIcon = "graduation-cap"; private titleTitle = "Education"; @Input("data") edu: Array&lt;Object&gt;; } </code></pre> <p>I don't see anything wrong in my code, also it used to work. Can anyone see what's wrong with this?</p> <p>Note: I'm using Angular2-rc6 and TypeScript 1.8.10, hope these info helps</p>
0debug
How to use pipes in Angular 5 reactive form input : <p>I am trying to figure out how to use a pipe within a reactive form so that the input is forced into a currency format. I have already created my own pipe for this which I have tested in other areas of the code so I know it works as a simple pipe. My pipe name is 'udpCurrency'</p> <p>The closest answer I could find on stack overflow was this one: <a href="https://stackoverflow.com/questions/39642882/using-pipes-within-ngmodel-on-input-elements-in-angular2-view">Using Pipes within ngModel on INPUT Elements in Angular2-View</a> However this is not working in my case and I suspect it has something to do with the fact that my form is reactive</p> <p>Here is all the relevant code:</p> <p><strong>The Template</strong></p> <pre><code>&lt;form [formGroup]="myForm" #f="ngForm"&gt; &lt;input class="form-control col-md-6" formControlName="amount" [ngModel]="f.value.amount | udpCurrency" (ngModelChange)="f.value.amount=$event" placeholder="Amount"&gt; &lt;/form&gt; </code></pre> <p><strong>The component</strong></p> <pre><code>import { Component, OnInit, HostListener } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; export class MyComponent implements OnInit { myForm: FormGroup; constructor( private builder: FormBuilder ) { this.myForm = builder.group({ amount: ['', Validators.required] }); } } </code></pre> <p><strong>The error:</strong></p> <pre><code>ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'undefined: '. Current value: 'undefined: undefined' </code></pre>
0debug
static int nbd_co_receive_reply(NBDClientSession *s, NBDRequest *request, QEMUIOVector *qiov) { int ret; int i = HANDLE_TO_INDEX(s, request->handle); s->requests[i].receiving = true; qemu_coroutine_yield(); s->requests[i].receiving = false; if (s->reply.handle != request->handle || !s->ioc || s->quit) { ret = -EIO; } else { ret = -s->reply.error; if (qiov && s->reply.error == 0) { assert(request->len == iov_size(qiov->iov, qiov->niov)); if (qio_channel_readv_all(s->ioc, qiov->iov, qiov->niov, NULL) < 0) { ret = -EIO; s->quit = true; } } s->reply.handle = 0; } s->requests[i].coroutine = NULL; if (s->read_reply_co) { aio_co_wake(s->read_reply_co); } qemu_co_mutex_lock(&s->send_mutex); s->in_flight--; qemu_co_queue_next(&s->free_sema); qemu_co_mutex_unlock(&s->send_mutex); return ret; }
1threat
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
Android, Impossible to build app due to a google.gson.JsonSyntaxException (Excepted BEGIN_ARRAY but was STRING at line 1 column 1 path $) : I'm developing in Android Studio. Today I made some fix to my app, save all and than start debbugging it on my connected via usb phone. My pc freezed, so I restarted it, reopened Android Studio, reopened my project, checked if all the fixes was saved and than try again to debug it on my phone. And the Gradle Build gave me an error under "Run Tasks" > ":app:transformClassesWithDexBuilderForDebug" > "Execute transform". I really don't know what the error is, by what it was caused and how to fix it. Anyone can help? Error Log: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $ at com.google.gson.Gson.fromJson(Gson.java:899) at com.google.gson.Gson.fromJson(Gson.java:852) at com.android.build.gradle.internal.pipeline.SubStream.loadSubStreams(SubStream.java:129) at com.android.build.gradle.internal.pipeline.IntermediateFolderUtils.<init>(IntermediateFolderUtils.java:66) at com.android.build.gradle.internal.pipeline.IntermediateStream.init(IntermediateStream.java:191) at com.android.build.gradle.internal.pipeline.IntermediateStream.asOutput(IntermediateStream.java:135) at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:228) at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:217) at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102) at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39) at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70) at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62) at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97) at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87) at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98) at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626) at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalStateException: Expected BEGIN_ARRAY but was STRING at line 1 column 1 path $ at com.google.gson.stream.JsonReader.beginArray(JsonReader.java:350) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:80) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) at com.google.gson.Gson.fromJson(Gson.java:887) ... 56 more
0debug
Trouble in using scanner in java : <p>Scanner class doesn't work how I expected.</p> <pre><code>Scanner in = new Scanner(System.in); // input: total String str = in.nextLine(); // total System.out.println(str); // total System.out.println(str == "total"); // false System.out.println(str != "total"); // true </code></pre> <p>I expected line 5 being true, but the above code is what i got.</p> <p>How should I do for (str == "total") becomes true?</p>
0debug
How can you create a command to run other applications in Windows Batch? : <p>My goal is to run other programs through the command of one in Windows Batch. <a href="https://i.stack.imgur.com/IdkDW.png" rel="nofollow noreferrer">Here are the files I would like to run through a single command if possible.</a> </p> <p>However the code that I have attempted at best is this</p> <pre><code>start "C:\users\excre\OneDrive\Desktop\Coding Files\GTA Chinatown\Terms &amp; Conditions.html" start "C:\users\excre\OneDrive\Desktop\Coding Files\GTA Chinatown\Audio_Synthesis-Program.vbs" start "C:\users\excre\OneDrive\Desktop\Coding Files\GTA Chinatown\test3.bat" </code></pre> <p><a href="https://i.stack.imgur.com/cUcks.png" rel="nofollow noreferrer">This resulted in a simple location CMD tab as shown here</a></p> <hr> <p>If anyone has a potential solution to this please mention below</p>
0debug
int qio_dns_resolver_lookup_sync(QIODNSResolver *resolver, SocketAddress *addr, size_t *naddrs, SocketAddress ***addrs, Error **errp) { switch (addr->type) { case SOCKET_ADDRESS_KIND_INET: return qio_dns_resolver_lookup_sync_inet(resolver, addr, naddrs, addrs, errp); case SOCKET_ADDRESS_KIND_UNIX: case SOCKET_ADDRESS_KIND_VSOCK: case SOCKET_ADDRESS_KIND_FD: return qio_dns_resolver_lookup_sync_nop(resolver, addr, naddrs, addrs, errp); default: abort(); } }
1threat
Changing source branch for PR on Github : <p>I accidentally created a pull request from the master-branch of my fork of a repo.</p> <p>While trying to rebase it I noticed that all of these changes were pushed into that pull request — due to the fact that you can simply <code>Add more commits by pushing to the master branch on username/repo</code></p> <ul> <li><strong>Can you change the source branch of a pull request <em>after</em> the pull request has been submitted?</strong></li> </ul> <p>I see you can edit the base branch, but that's obviously not what I'm after.</p>
0debug
How do i use separate two integers using dot in java? : <p>I want to make a user to enter integers separated with dot like (11.56.98) to use after that x=11 y=56 z=98</p> <pre><code> `Scanner s = new Scanner(System.in); System.out.print("Enter Your number like (36.52.10): "); int x = s.nextInt(); int y = s.nextInt(); int z = s.nextInt();` </code></pre> <p>now how to usedelimiter will change whitespace to dot and how to return to whitespace again</p>
0debug
FTP client in .netcore : <p>Can I download file / list files via FTP protocol using <strong>netcoreapp1.0</strong>?</p> <p>I know, I can use <a href="https://msdn.microsoft.com/en-us/library/system.net.ftpwebrequest(v=vs.110).aspx" rel="noreferrer">FtpWebRequest</a> or <a href="https://www.nuget.org/packages/FluentFTP" rel="noreferrer">FluentFTP</a> if I target full <strong>.net45</strong> framework. </p> <p>My solution, however, is all based on .net standard 1.6 and I don't want to support full framework just to have FTP.</p>
0debug
Unique key generate with digit and letters in php : <p>I need to generate unique key in php. </p> <p>The key must be min 8 digit and 4 letters contain. </p> <p>So any one have idea ?</p> <p>Thanks you</p>
0debug
I want to change the order of a list in C# : I have a list in C# whit 4 items, this list is used to send a response in a web service and i need a specific order for the items, but I'm having a problem, because for any reason the list change the order when I fill it. firs, this is the class of the list using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.Serialization; namespace Mvm.SATWeb.Domain { [Serializable, DataContract] public class puntoDeAtencion { public puntoDeAtencion() { } [DataMember] public string codigoPuntoAtencion { get; set; } [DataMember] public decimal montoIngreso { get; set; } [DataMember] public decimal montoEgreso { get; set; } [DataMember] public decimal ingresoNeto { get; set; } } } I use a SQL server query to fill the list with a dataset List<puntoDeAtencion> valores = new List<puntoDeAtencion>(); DataSet ds; Database baseDatos = DatabaseFactory.CreateDatabase(); DbCommand comandoConsulta = baseDatos.GetStoredProcCommand("USP_RiesgoLiqui"); comandoConsulta.CommandTimeout = 600000; baseDatos.AddInParameter(comandoConsulta, "@pvstrIdAgencia", DbType.String, "-1"); baseDatos.AddInParameter(comandoConsulta, "@pvstrFechaInicial", DbType.String, FechaIni); baseDatos.AddInParameter(comandoConsulta, "@pvstrFechaFinal", DbType.String, FechaFin); comandoConsulta.CommandTimeout = 1000000; // baseDatos.ExecuteDataSet(); ds = baseDatos.ExecuteDataSet(comandoConsulta); if (ds.Tables.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count ; i++) { // valores.Add(s) //valores.Add (new punptoDeAtencion(){} valores.Add(new puntoDeAtencion() { codigoPuntoAtencion = Convert.ToString(ds.Tables[0].Rows[i]["Agencia"]), montoIngreso = Convert.ToDecimal(ds.Tables[0].Rows[i]["INGRESONETO"]), montoEgreso = Convert.ToDecimal(ds.Tables[0].Rows[i]["MONTOEGRESO"]), ingresoNeto = Convert.ToDecimal(0.00) }); // var list1 = (from p in ds.Tables[0].Rows[i] select p).ToList(); } } return valores.ToList<puntoDeAtencion>(); this is the response(Using SOAP UI, but when I debug show the same values in the response object) this is the actual response <b:listaPuntosDeAtencion> <b:puntoDeAtencion> <b:codigoPuntoAtencion>001</b:codigoPuntoAtencion> <b:ingresoNeto>0</b:ingresoNeto> <b:montoEgreso>53266155.0000</b:montoEgreso> <b:montoIngreso>138285187.0000</b:montoIngreso> </b:puntoDeAtencion> and this is how this should be <listaPuntosDeAtencion> <puntoDeAtencion> < codigoPuntoAtencion>00654</codigoPuntoAtencion> <montoIngreso>79000.0</montoIngreso> <montoEgreso>30000.0</montoEgreso> <ingresoNeto>0.0</ingresoNeto> </puntoDeAtencion> Please, I want to order the list or the response, I don't know if LINQ works in this case.
0debug
I get an error running this struct program in c : #include <stdio.h> #include <stdlib.h> struct date { int day; int month; int year; }; struct lottery { int aa; struct date date1; int n1; int n2; int n3; int n4; int n5; int joker; }; void load(struct lottery *array) { FILE *fp; fp=fopen("as.txt","r"); if(fp==NULL) printf("00000\n"); int i; for(i=0; i<1; i++) { fscanf(fp,"%d;%d/%d/%d;%d;%d;%d;%d;%d;%d",&array[i].aa,&array[i].date1.day,&array[i].date1.month,&array[i].date1.year,&array[i].n1,&array[i].n2,&array[i].n3,&array[i].n4,&array[i].n5,&array[i].joker); if(feof(fp)) break; } array=(struct lottery*)realloc(array,i*sizeof(struct lottery)); // printf("%d;%d/%d/%d;%d;%d;%d;%d;%d;%d",array[0].aa,array[0].date1.day,array[0].date1.month,array[0].date1.year,array[0].n1,array[0].n2,array[0].n3,array[0].n4,array[0].n5,array[0].joker); } int main() { struct lottery *array; array=(struct lottery *) malloc(4*sizeof(struct lottery)); // printf("%d",sizeof(struct lottery)); load(struct lottery array); printf("%d",array[0].aa); return 0; } Hello i get an error at the line :load(struct lottery array); in my main function.The error says :Expected expression before struct I googled it and i couldnt unmderstand why would it expect an expression there and i am kinda confused.
0debug
Create your own method inside onCreate() in android : How do I create a method inside onCreate() method? When I am creating its showing error: Syntax error on token void @ expected And if method can not be created inside onCreate method than please tell me how do I create a method outside the onCreate() and pass mContext and mActivity from the onCreate() method. Thanks in Advance
0debug
Random True or false using math.random : <p>How to return true or false, only using Math.random(), without creating a new method or using java.util.random?</p>
0debug
Why is the maximal path length allowed for unix-sockets on linux 108? : <p>When creating a unix socket, the path name (<code>man 7 unix</code>) is allowed to be maximally 108 chars long. For a friend this caused a bug in his program because his path was longer. Now we wonder how exactly that number was determined.</p> <p>I have the suspicion that the number was determined so that <code>sizeof</code> of that struct <code>sockaddr_un</code> is unambiguous compared to the sizeof of other sockaddresses like <code>sockaddr_in</code>. But if they wanted to avoid clashes with other sizeof values, why not use a prime number for example? Can someone please provide an authorative source for that?</p>
0debug
Sum of Digits of the Input from user : <p>I want to create a code that will get the sum of all the digits of the input, <em>sample input: 241 sample output: 7</em> But there are restrictions in in making the program, only the basic operations, functions should be used and no string function is to be used in getting the said sum of the digits only (loop, /, %, *,-,+)are allowed to be used.</p> <p>The program I am thinking should start with this..</p> <pre><code> public class SumOfDigits{ public static void main(String args[]) throws Exception{ Scanner input = new Scanner(System.in); int num = input.nextInt(); while(){ } } } </code></pre>
0debug
BlockDeviceInfo *bdrv_block_device_info(BlockDriverState *bs) { BlockDeviceInfo *info = g_malloc0(sizeof(*info)); info->file = g_strdup(bs->filename); info->ro = bs->read_only; info->drv = g_strdup(bs->drv->format_name); info->encrypted = bs->encrypted; info->encryption_key_missing = bdrv_key_required(bs); info->cache = g_new(BlockdevCacheInfo, 1); *info->cache = (BlockdevCacheInfo) { .writeback = bdrv_enable_write_cache(bs), .direct = !!(bs->open_flags & BDRV_O_NOCACHE), .no_flush = !!(bs->open_flags & BDRV_O_NO_FLUSH), }; if (bs->node_name[0]) { info->has_node_name = true; info->node_name = g_strdup(bs->node_name); } if (bs->backing_file[0]) { info->has_backing_file = true; info->backing_file = g_strdup(bs->backing_file); } info->backing_file_depth = bdrv_get_backing_file_depth(bs); info->detect_zeroes = bs->detect_zeroes; if (bs->io_limits_enabled) { ThrottleConfig cfg; throttle_get_config(&bs->throttle_state, &cfg); info->bps = cfg.buckets[THROTTLE_BPS_TOTAL].avg; info->bps_rd = cfg.buckets[THROTTLE_BPS_READ].avg; info->bps_wr = cfg.buckets[THROTTLE_BPS_WRITE].avg; info->iops = cfg.buckets[THROTTLE_OPS_TOTAL].avg; info->iops_rd = cfg.buckets[THROTTLE_OPS_READ].avg; info->iops_wr = cfg.buckets[THROTTLE_OPS_WRITE].avg; info->has_bps_max = cfg.buckets[THROTTLE_BPS_TOTAL].max; info->bps_max = cfg.buckets[THROTTLE_BPS_TOTAL].max; info->has_bps_rd_max = cfg.buckets[THROTTLE_BPS_READ].max; info->bps_rd_max = cfg.buckets[THROTTLE_BPS_READ].max; info->has_bps_wr_max = cfg.buckets[THROTTLE_BPS_WRITE].max; info->bps_wr_max = cfg.buckets[THROTTLE_BPS_WRITE].max; info->has_iops_max = cfg.buckets[THROTTLE_OPS_TOTAL].max; info->iops_max = cfg.buckets[THROTTLE_OPS_TOTAL].max; info->has_iops_rd_max = cfg.buckets[THROTTLE_OPS_READ].max; info->iops_rd_max = cfg.buckets[THROTTLE_OPS_READ].max; info->has_iops_wr_max = cfg.buckets[THROTTLE_OPS_WRITE].max; info->iops_wr_max = cfg.buckets[THROTTLE_OPS_WRITE].max; info->has_iops_size = cfg.op_size; info->iops_size = cfg.op_size; } info->write_threshold = bdrv_write_threshold_get(bs); return info; }
1threat
How to fix OpenCV assertion failed error? : <p>When I try to run the code below in Visual Studio I getting an error message:</p> <p>Unhandled exception at 0x00007FFC976DA839 in TestOpenCV.exe: Microsoft C++ exception: cv::Exception at memory location 0x0000003DAEEFF360.</p> <p>And the command window show this message:</p> <p>OpenCV(4.1.0-dev) Error: Assertion failed (size.width>0 &amp;&amp; size.height>0) in cv::imshow, file C:\Users\hordon\opencv\modules\highgui\src\window.cpp, line 352</p> <p>I can't figure out whats is wrong. My best guess is that I use a virtual Windows 10 on a Mac with Parallels Desktop and something is wrong with the path. But that would be strange since I copied the image directly next to the EXE. Any idea how to fix this?</p> <pre><code>#include "pch.h" #include &lt;iostream&gt; #include &lt;opencv2/core.hpp&gt; #include &lt;opencv2/highgui.hpp&gt; #include &lt;opencv2/imgproc.hpp&gt; cv::Mat image; void myMouseCallback(int event, int x, int y, int flags, void* userdata) { if (flags &amp; cv::MouseEventFlags::EVENT_FLAG_LBUTTON) { if (flags &amp; cv::MouseEventFlags::EVENT_FLAG_SHIFTKEY) { cv::rectangle(image, { x,y }, { y, x }, CV_RGB(255, (x*y) % 255, (x + y) % 255)); } else if (flags &amp;cv::MouseEventFlags::EVENT_FLAG_ALTKEY) { cv::line(image, { x, y }, { y, x }, CV_RGB((y * x) % 255, (int)(sin((double)x / image.cols) * 255), (x * y * x - y) % 255)); } else { cv::circle(image, { x,y }, (x + y) % 10, 0); } } cv::imshow("Ablak", image); } int main() { image = cv::imread(".\\csillam.jpg"); cv::Mat greyScale(image.rows, image.cols, CV_8UC1); for (int i = 0; i &lt; greyScale.rows; ++i) { for (int j = 0; j &lt; greyScale.cols; j++) { cv::Vec3b pixel = image.at&lt;cv::Vec3b&gt;(i, j); greyScale.at&lt;uint8_t&gt;(i, j) = (pixel[0] + pixel[1] + pixel[2]) / 3; } } cv::imshow("Greyscale", greyScale); cv::imshow("Ablak", image); cv::setMouseCallback("Ablak", myMouseCallback); cv::waitKey(0); } </code></pre>
0debug
I felt my code is not exactly right, but I don't know what's wrong : <p>The question is: Simulate a function to roll a dice. Note that a dice turns up with numbers 1, 2, 3, 4, 5 or 6. The function should do the following: you roll the dice twice, and if both the numbers are the same then return ‘You Win’ otherwise return ‘You Lose’ (hint: use sample()) my code is:</p> <pre><code>s &lt;- function(x) { x = 1:6 s1 &lt;- sample(x, size = 1, replace = TRUE) s2 &lt;- sample(x, size = 1, replace = TRUE) result &lt;- ifelse(s1 == s2, "You Win", "You Lose") return(result) } s(5) </code></pre> <p>Even if the code is right, is there a more effective way to write it? I think it's a little bit tedious.</p>
0debug
Recommendations for presenting about 35 fields for data entry : <p>When the user clicks on a node in a treeview, I'd like to present the user with a way to fill-in about 35 fields. Should I use one form, tab control, etc? Thoughts/Recommendations?</p>
0debug
static void draw_mandelbrot(AVFilterContext *ctx, uint32_t *color, int linesize, int64_t pts) { MBContext *mb = ctx->priv; int x,y,i, in_cidx=0, next_cidx=0, tmp_cidx; double scale= mb->start_scale*pow(mb->end_scale/mb->start_scale, pts/mb->end_pts); int use_zyklus=0; fill_from_cache(ctx, NULL, &in_cidx, NULL, mb->start_y+scale*(-mb->h/2-0.5), scale); tmp_cidx= in_cidx; memset(color, 0, sizeof(*color)*mb->w); for(y=0; y<mb->h; y++){ int y1= y+1; const double ci=mb->start_y+scale*(y-mb->h/2); fill_from_cache(ctx, NULL, &in_cidx, &next_cidx, ci, scale); if(y1<mb->h){ memset(color+linesize*y1, 0, sizeof(*color)*mb->w); fill_from_cache(ctx, color+linesize*y1, &tmp_cidx, NULL, ci + 3*scale/2, scale); } for(x=0; x<mb->w; x++){ float epsilon; const double cr=mb->start_x+scale*(x-mb->w/2); double zr=cr; double zi=ci; uint32_t c=0; double dv= mb->dither / (double)(1LL<<32); mb->dither= mb->dither*1664525+1013904223; if(color[x + y*linesize] & 0xFF000000) continue; if(interpol(mb, color, x, y, linesize)){ if(next_cidx < mb->cache_allocated){ mb->next_cache[next_cidx ].p[0]= cr; mb->next_cache[next_cidx ].p[1]= ci; mb->next_cache[next_cidx++].val = color[x + y*linesize]; } continue; } use_zyklus= (x==0 || mb->inner!=BLACK ||color[x-1 + y*linesize] == 0xFF000000); if(use_zyklus) epsilon= scale*1*sqrt(SQR(x-mb->w/2) + SQR(y-mb->h/2))/mb->w; #define Z_Z2_C(outr,outi,inr,ini)\ outr= inr*inr - ini*ini + cr;\ outi= 2*inr*ini + ci; #define Z_Z2_C_ZYKLUS(outr,outi,inr,ini, Z)\ Z_Z2_C(outr,outi,inr,ini)\ if(use_zyklus){\ if(Z && fabs(mb->zyklus[i>>1][0]-outr)+fabs(mb->zyklus[i>>1][1]-outi) <= epsilon)\ break;\ }\ mb->zyklus[i][0]= outr;\ mb->zyklus[i][1]= outi;\ for(i=0; i<mb->maxiter-8; i++){ double t; Z_Z2_C_ZYKLUS(t, zi, zr, zi, 0) i++; Z_Z2_C_ZYKLUS(zr, zi, t, zi, 1) i++; Z_Z2_C_ZYKLUS(t, zi, zr, zi, 0) i++; Z_Z2_C_ZYKLUS(zr, zi, t, zi, 1) i++; Z_Z2_C_ZYKLUS(t, zi, zr, zi, 0) i++; Z_Z2_C_ZYKLUS(zr, zi, t, zi, 1) i++; Z_Z2_C_ZYKLUS(t, zi, zr, zi, 0) i++; Z_Z2_C_ZYKLUS(zr, zi, t, zi, 1) if(zr*zr + zi*zi > mb->bailout){ i-= FFMIN(7, i); for(; i<mb->maxiter; i++){ zr= mb->zyklus[i][0]; zi= mb->zyklus[i][1]; if(zr*zr + zi*zi > mb->bailout){ switch(mb->outer){ case ITERATION_COUNT: zr = i; break; case NORMALIZED_ITERATION_COUNT: zr= i + log2(log(mb->bailout) / log(zr*zr + zi*zi)); break; } c= lrintf((sin(zr)+1)*127) + lrintf((sin(zr/1.234)+1)*127)*256*256 + lrintf((sin(zr/100)+1)*127)*256; break; } } break; } } if(!c){ if(mb->inner==PERIOD){ int j; for(j=i-1; j; j--) if(SQR(mb->zyklus[j][0]-zr) + SQR(mb->zyklus[j][1]-zi) < epsilon*epsilon*10) break; if(j){ c= i-j; c= ((c<<5)&0xE0) + ((c<<16)&0xE000) + ((c<<27)&0xE00000); } }else if(mb->inner==CONVTIME){ c= floor(i*255.0/mb->maxiter+dv)*0x010101; } else if(mb->inner==MINCOL){ int j; double closest=9999; int closest_index=0; for(j=i-1; j>=0; j--) if(SQR(mb->zyklus[j][0]) + SQR(mb->zyklus[j][1]) < closest){ closest= SQR(mb->zyklus[j][0]) + SQR(mb->zyklus[j][1]); closest_index= j; } closest = sqrt(closest); c= lrintf((mb->zyklus[closest_index][0]/closest+1)*127+dv) + lrintf((mb->zyklus[closest_index][1]/closest+1)*127+dv)*256; } } c |= 0xFF000000; color[x + y*linesize]= c; if(next_cidx < mb->cache_allocated){ mb->next_cache[next_cidx ].p[0]= cr; mb->next_cache[next_cidx ].p[1]= ci; mb->next_cache[next_cidx++].val = c; } } fill_from_cache(ctx, NULL, &in_cidx, &next_cidx, ci + scale/2, scale); } FFSWAP(void*, mb->next_cache, mb->point_cache); mb->cache_used = next_cidx; if(mb->cache_used == mb->cache_allocated) av_log(0, AV_LOG_INFO, "Mandelbrot cache is too small!\n"); }
1threat