problem
stringlengths
26
131k
labels
class label
2 classes
trying to add numbers in javascript : <p>I am trying to write a program to decrypt a encrypted message. The encrypted message is a very long set of numbers ".296.294.255.268.313.278.311.270.290.305.322.252.276.286.301.305.264.301.251.269.274.311.304. 230.280.264.327.301.301.265.287.285.306.265.282.319.235.262.278.249.239.284.237.249.289.250. 282.240.256.287.303.310.314.242.302.289.268.315.264.293.261.298.310.242.253.299.278.272.333. 272.295.306.276.317.286.250.272.272.274.282.308.262.285.326.321.285.270.270.241.283.305.319. 246.263.311.299.295.315.263.304.279.286.286.299.282.285.289.298.277.292.296.282.267.245.....ect". Each character of the message is transformed into three different numbers (eg.first character of message is '230 .280 .264' second character is '.327.301.265' ect). so i am trying to use javascript to add the groups of three numbers and then save them as their own variable. thanks </p>
0debug
static void test_source_notify(void) { while (g_main_context_iteration(NULL, false)); aio_notify(ctx); g_assert(g_main_context_iteration(NULL, true)); g_assert(!g_main_context_iteration(NULL, false)); }
1threat
static av_cold int nvenc_setup_device(AVCodecContext *avctx) { NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; CUresult cu_res; CUcontext cu_context_curr; switch (avctx->codec->id) { case AV_CODEC_ID_H264: ctx->init_encode_params.encodeGUID = NV_ENC_CODEC_H264_GUID; break; case AV_CODEC_ID_HEVC: ctx->init_encode_params.encodeGUID = NV_ENC_CODEC_HEVC_GUID; break; default: return AVERROR_BUG; } ctx->data_pix_fmt = avctx->pix_fmt; #if CONFIG_CUDA if (avctx->pix_fmt == AV_PIX_FMT_CUDA) { AVHWFramesContext *frames_ctx; AVCUDADeviceContext *device_hwctx; if (!avctx->hw_frames_ctx) { av_log(avctx, AV_LOG_ERROR, "hw_frames_ctx must be set when using GPU frames as input\n"); return AVERROR(EINVAL); } frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data; device_hwctx = frames_ctx->device_ctx->hwctx; ctx->cu_context = device_hwctx->cuda_ctx; ctx->data_pix_fmt = frames_ctx->sw_format; return 0; } #endif if (ctx->gpu >= dl_fn->nvenc_device_count) { av_log(avctx, AV_LOG_FATAL, "Requested GPU %d, but only %d GPUs are available!\n", ctx->gpu, dl_fn->nvenc_device_count); return AVERROR(EINVAL); } ctx->cu_context = NULL; cu_res = dl_fn->cu_ctx_create(&ctx->cu_context_internal, 4, dl_fn->nvenc_devices[ctx->gpu]); if (cu_res != CUDA_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "Failed creating CUDA context for NVENC: 0x%x\n", (int)cu_res); return AVERROR_EXTERNAL; } cu_res = dl_fn->cu_ctx_pop_current(&cu_context_curr); if (cu_res != CUDA_SUCCESS) { av_log(avctx, AV_LOG_FATAL, "Failed popping CUDA context: 0x%x\n", (int)cu_res); return AVERROR_EXTERNAL; } ctx->cu_context = ctx->cu_context_internal; return 0; }
1threat
int spapr_h_cas_compose_response(sPAPRMachineState *spapr, target_ulong addr, target_ulong size, sPAPROptionVector *ov5_updates) { void *fdt, *fdt_skel; sPAPRDeviceTreeUpdateHeader hdr = { .version_id = 1 }; size -= sizeof(hdr); fdt_skel = g_malloc0(size); _FDT((fdt_create(fdt_skel, size))); _FDT((fdt_begin_node(fdt_skel, ""))); _FDT((fdt_end_node(fdt_skel))); _FDT((fdt_finish(fdt_skel))); fdt = g_malloc0(size); _FDT((fdt_open_into(fdt_skel, fdt, size))); g_free(fdt_skel); _FDT((spapr_fixup_cpu_dt(fdt, spapr))); if (spapr_dt_cas_updates(spapr, fdt, ov5_updates)) { return -1; } _FDT((fdt_pack(fdt))); if (fdt_totalsize(fdt) + sizeof(hdr) > size) { trace_spapr_cas_failed(size); return -1; } cpu_physical_memory_write(addr, &hdr, sizeof(hdr)); cpu_physical_memory_write(addr + sizeof(hdr), fdt, fdt_totalsize(fdt)); trace_spapr_cas_continue(fdt_totalsize(fdt) + sizeof(hdr)); g_free(fdt); return 0; }
1threat
Javascript can't change html scr : <p>So im creating an automatic slide show, but for some reason, I can get js to change my img scr to the images in the array I have. </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>&lt;script&gt; var i= 0; // starting image var images= []; //image array empty-array var time= 2000; //2 sec time interval //image list for image array images[0] = 'image_1.png'; //image array starting image images[1] = 'image_2.png'; images[2] = 'image_3.png'; //change image function function changeImg(){ document.getElementById("imagess").scr = images[i]; //changes image on html side if(i &lt; images.length-1){ //if var i is less then the length of the array add one, length -1 because array list start with 0 and ends with 2. i++; } else{ // if var is more the array length set it back to 0 to start the slide again i = 0; } setTimeout("changeImg()", time);// the amount of time before the function run if statment } window.onload = changeImg; //when sites loads run script &lt;/script&gt;</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;div class="image"&gt; &lt;!--main image --&gt; &lt;img id="imagess" src="#" alt="HAL Phone Icon" &gt; &lt;/div&gt; &lt;!--closing image --&gt;</code></pre> </div> </div> </p>
0debug
Can't show a model info in template : <p>I would like to show my model in template, but I've a problem :</p> <pre><code>Uncaught ReferenceError: title is not defined </code></pre> <p>There's my code:</p> <pre><code> var NewsView2 = Backbone.View.extend({ NewsView: _.template(NewsView), initialize: function () { console.log(this); this.$el.html(this.NewsView()); this.render(); }, render: function () { this.$el.html(this.NewsView()); var html = this.NewsView(this.model.toJSON()); this.$el.append(html); return this; } }); </code></pre> <p>initialize:</p> <pre><code> var news2 = new News({ author: "costam", }); var widok2 = new NewsView2({model: news2}); </code></pre> <p>and code in my template:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;/head&gt; &lt;body&gt; &lt;%= title %&gt; &lt;/body&gt; </code></pre> <p></p> <p>Someone could help me with that? I don't have any idea to do it.</p>
0debug
Using BoxLayout to resize JPanels in GUI : <p>I currently have this code I am working with:</p> <pre><code>this.getContentPane().add(wwjPanel, BorderLayout.EAST); if (includeLayerPanel) { this.controlPanel = new JPanel(); controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.Y_AXIS)); this.layerPanel = new LayerPanel(this.getWwd()); this.controlPanel.add(new FlatWorldPanel(this.getWwd()),Box.createRigidArea(new Dimension(1000, 1000))); //This is the top pan this.controlPanel.add(this.getStates(), Box.createRigidArea(new Dimension(0, 100))); this.controlPanel.add(this.getPanelAlerts(), Box.createRigidArea(new Dimension(0,100))); this.getContentPane().add(this.controlPanel, BorderLayout.WEST);//This is the whole panel on the left } </code></pre> <p>I am trying to resize the JPanels, called controlPanel here, to each have their own unique size in my GUI. I am new to building GUIs with java, and the majority of the code I have is pulled from another file. The code I am trying to incorporate are these new panels as described in my code, and trying to resize them. Is BoxLayout what I want to be using to get my desired effect?</p> <p>Also, when I use the createRigidArea it seems to work, but if I continue to change the x and y values you pass to it nothing seems to happen. What I mean by this is, that I don't see any visual difference by changing the values, and I have used values ranging from 0-1000.</p> <p>Thanks.</p>
0debug
static int pte_check_hash32(struct mmu_ctx_hash32 *ctx, target_ulong pte0, target_ulong pte1, int h, int rw, int type) { target_ulong mmask; int access, ret, pp; ret = -1; if ((pte0 & HPTE32_V_VALID) && (h == !!(pte0 & HPTE32_V_SECONDARY))) { mmask = PTE_CHECK_MASK; pp = pte1 & HPTE32_R_PP; if (HPTE32_V_COMPARE(pte0, ctx->ptem)) { if (ctx->raddr != (hwaddr)-1ULL) { if ((ctx->raddr & mmask) != (pte1 & mmask)) { qemu_log("Bad RPN/WIMG/PP\n"); return -3; } } access = ppc_hash32_pp_check(ctx->key, pp, ctx->nx); ctx->raddr = pte1; ctx->prot = access; ret = ppc_hash32_check_prot(ctx->prot, rw, type); if (ret == 0) { LOG_MMU("PTE access granted !\n"); } else { LOG_MMU("PTE access rejected\n"); } } } return ret; }
1threat
static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt) { struct SAPState *sap = s->priv_data; int fd = url_get_file_handle(sap->ann_fd); int n, ret; fd_set rfds; struct timeval tv; uint8_t recvbuf[1500]; if (sap->eof) return AVERROR_EOF; while (1) { FD_ZERO(&rfds); FD_SET(fd, &rfds); tv.tv_sec = tv.tv_usec = 0; n = select(fd + 1, &rfds, NULL, NULL, &tv); if (n <= 0 || !FD_ISSET(fd, &rfds)) break; ret = url_read(sap->ann_fd, recvbuf, sizeof(recvbuf)); if (ret >= 8) { uint16_t hash = AV_RB16(&recvbuf[2]); if (recvbuf[0] & 0x04 && hash == sap->hash) { sap->eof = 1; return AVERROR_EOF; } } } ret = av_read_frame(sap->sdp_ctx, pkt); if (ret < 0) return ret; if (s->ctx_flags & AVFMTCTX_NOHEADER) { while (sap->sdp_ctx->nb_streams > s->nb_streams) { int i = s->nb_streams; AVStream *st = av_new_stream(s, i); if (!st) { av_free_packet(pkt); return AVERROR(ENOMEM); } avcodec_copy_context(st->codec, sap->sdp_ctx->streams[i]->codec); st->time_base = sap->sdp_ctx->streams[i]->time_base; } } return ret; }
1threat
Alternate to match function in R that returns list of indexes : <p>I am using <code>R 3.5</code><br> I want to get all indexes that contain zero in my list</p> <pre><code>a = c(1,2,3,0,5,7,0) </code></pre> <p>result should be</p> <pre><code>[1] 4 7 </code></pre> <p>should return the indexes as <code>match</code> will only return the first index in this case <code>4</code></p>
0debug
How to add and retrieve from array list? : <p>I'm creating a mock banking program and want to use arraylists to keep track of things like first, last name, account balance, etc. then I want to display these values later with print statements. How do I do this?</p>
0debug
Navigation Arrow Not updating: Navigation arrow not rotating at high speed navigation : <p><a href="https://i.stack.imgur.com/WxCcZ.png" rel="nofollow noreferrer">enter image description here</a></p> <p>In the image above as you can see my navigation arrow is not pointing in the correct direction in which i am driving. This issue always occurs when i am driving at high speed.What can be done to remove this issue. Thanks.</p>
0debug
How to license C++ software : <p>I would like to start selling some software I have developed in C++. The first line of protection will be the fact that C++ produces an executable. Within that, I will also apply algorithmic and manual obfuscation techniques to make it very hard to understand even once cracked.</p> <p>With regards to licensing, my plan is to create an API you can send a request to. The data will include your license key and your device fingerprint. Upon receiving this data, the API will check for the license key in the database, and ensure the device fingerprint matches the fingerprint stored. If it does, it will reply with some sort of cryptographic response that must match a certain pattern. The client will then check if that response matches the pre-determined pattern, and if it does the software will be allowed to be used. If it does not, the user will be locked out. And this response will be empty if the API check failed, so that will also cause the user to be locked out.</p> <p>I am aware that this is not unbreakable, but I would like to make it as difficult to break as possible without investing a ridiculous amount of time. The reason I wanted to add some cryptographic response is so the user can't just spoof the response from my server. Although I will also be using HTTPS on top of that. If this is a good idea, what sort of cryptographic check would you recommend?</p> <p>The idea of the fingerprint is to prevent users from using the software on multiple computers at a time. I'm not quite sure what to use for this, but I was thinking of hashing a combination of the MAC address, computer name and something else. Any suggestions?</p> <p>Is there anything else I should be doing to protect my software?</p> <p>Thanks.</p>
0debug
How to Remove the numbers after the dot.? : i have a drop function to get the value and show in an input field but i just need it as decimal number . events: { drop: function() { document.getElementById('point-temp').value = this.y; } } html: <input placeholder="new Temperature" id="point-temp" type="text" class="field" value="">
0debug
static int tcg_match_xori(TCGType type, tcg_target_long val) { if ((s390_facilities & FACILITY_EXT_IMM) == 0) { return 0; } if (type == TCG_TYPE_I32) { return 1; } if (val < 0 && val == (int32_t)val) { return 0; } return 1; }
1threat
Integer fractorization in C language : I am making a program with C language to make the output look like this. 2 = 2 3 = 3 4 = 2 x 2 5 = 5 6 = 2 x 3 .... 102 = 2 x 3 x 17 103 = 103 104 = 2 x 2 x 2 x 13 I wrote the integer fractorization code in this way. #include <stdio.h> #define MAXNUM 1000 int main(){ int num,numfordiv; int div = 2; for (num=2;num<MAXNUM;num++){ printf("%d=", num); numfordiv = num; if(num%div != 0){ div = div+1; } else{ numfordiv = numfordiv / div; printf("%d x ",div); if(numfordiv == 1){ div = 2; } } } return 0; } However, this does not work for unknown reason. Is there anything wrong with the loop?
0debug
Include path with constant and variable : <p>I'm trying to include a file to current php page but the name of the file depens on the lang.</p> <p>This line does not work:</p> <pre><code>include_once PATH.'lang/'.$_SESSION['lang'].'.php'; </code></pre> <p>How can I achieve that?</p>
0debug
Error with Flowable's onErrorResumeNext, networkOnMainThread : <p>I have the following rxJava chain:</p> <pre><code> override fun combineLocationToPlace(req: Flowable&lt;Place&gt;): Flowable&lt;Place&gt; { var combinedFlowable = Flowable .combineLatest( req, getLastLocation().lastOrError().toFlowable(), BiFunction&lt;Place, Location, Place&gt; { t1, location -&gt; Timber.w("FIRSTINIT - Retrieved location $location") var placeLocation = Location(t1.placeName) placeLocation.latitude = t1.latitude placeLocation.longitude = t1.longitude t1.distance = location.distanceTo(placeLocation) t1 }) return combinedFlowable .onErrorResumeNext { t: Throwable -&gt; Timber.w(t, "FIRSTINIT - Could not retrieve location for place (${t.message}) returning original request") req } .doOnError { Timber.w("FIRSTINIT - did detect the error here...") } return combinedFlowable } </code></pre> <p>In short, I am retrieving some data from the local database (a place) and I want to combine it with the latest location from the GPS:</p> <pre><code> override fun getLastLocation(requestIfEmpty: Boolean): Observable&lt;Location&gt; { var lastLocation = locationProvider.lastKnownLocation .doOnNext { Timber.w("Got location $it from last one") } .doOnComplete { Timber.w("did i get a location?") } if (requestIfEmpty) { Timber.w("Switching to request of location") lastLocation = lastLocation.switchIfEmpty(requestLocation()) } return lastLocation.doOnNext { Timber.w("Got something!") location = it } } </code></pre> <p>But I want to account for the scneario where the user does not have a last location, and thus the line:</p> <pre><code>return combinedFlowable .onErrorResumeNext { t: Throwable -&gt; Timber.w(t, "FIRSTINIT - Could not retrieve location for place (${t.message}) returning original request") req } .doOnError { Timber.w("FIRSTINIT - did detect the error here...") } </code></pre> <p>Which is trying to catch any error and retry just with the original request without combining it with anything. I am calling this code like this:</p> <pre><code>fun getPlace(placeId: String) { locationManager.combineLocationToPlace(placesRepository.getPlace(placeId)) .onErrorResumeNext { t: Throwable -&gt; Timber.e(t, "Error resuming next! ") placesRepository.getPlace(placeId) }.subscribeOn(schedulerProvider.io()).observeOn(schedulerProvider.ui()) .subscribeBy( onNext = { place.value = Result.success(it) }, onError = { Timber.e("ERROR! $it") place.value = Result.failure(it) } ) .addTo(disposables) } </code></pre> <p>However, when there is no location a <code>NoSuchElementException</code> is thrown, my flowable switches to the original request, and then upon executing it I get a <code>NetworkOnMainThread</code> exception. Shouldn't this request be executed on the <code>scheduler.io()</code> that I put in there (since I put the code before that)?</p> <p>In case you are wondering, <code>schedulerProvider.io()</code> translates to:</p> <pre><code>Schedulers.io() </code></pre> <p>GetPlace:</p> <pre><code> /** * Retrieves a single place from database */ override fun getPlace(id: String): Flowable&lt;Place&gt; { return Flowable.merge(placesDao.getPlace(id), refreshPlace(id).toFlowable()) } /** * Triggers a refreshPlace update on the db, useful when changing stuff associated with the place * itself indirectly (e.g. an experience) */ private fun refreshPlace(id: String): Single&lt;Place&gt; { return from(placesApi.getPlace(id)) .doOnSuccess { placesDao.savePlace(it) } } </code></pre>
0debug
void rdma_start_incoming_migration(const char *host_port, Error **errp) { int ret; RDMAContext *rdma; Error *local_err = NULL; DPRINTF("Starting RDMA-based incoming migration\n"); rdma = qemu_rdma_data_init(host_port, &local_err); if (rdma == NULL) { goto err; } ret = qemu_rdma_dest_init(rdma, &local_err); if (ret) { goto err; } DPRINTF("qemu_rdma_dest_init success\n"); ret = rdma_listen(rdma->listen_id, 5); if (ret) { ERROR(errp, "listening on socket!"); goto err; } DPRINTF("rdma_listen success\n"); qemu_set_fd_handler2(rdma->channel->fd, NULL, rdma_accept_incoming_migration, NULL, (void *)(intptr_t) rdma); return; err: error_propagate(errp, local_err); g_free(rdma); }
1threat
Run all unit tests in Android Studio : <p>I have this project in Android Studio :</p> <p><a href="https://i.stack.imgur.com/L5llk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/L5llk.png" alt="enter image description here"></a></p> <p>I wish to run all unit tests in all project with one click.</p> <p>How i can do it ?</p>
0debug
Branching Systems Differences : <p>There are 3 different branching systems <em>Feature Branch, Release Branch,</em> and <em>Hotfix Branch</em></p> <p>What is the difference between them and what are they used for?</p>
0debug
split strings and add them as new row : <p>I have the following dataset: </p> <pre><code>df&lt;-data.frame (fact= c("a,b,c,d","f,g,h,v"), value = c("0,1,0,1" , "0,0,1,0")) </code></pre> <p>This is the data:</p> <pre><code> fact value 1 a,b,c,d 0,1,0,1 2 f,g,h,v 0,0,1,0 </code></pre> <p>I wish to split it when the <strong>value is 1</strong>. So, my ideal output is: </p> <pre><code> fact value 1: a,b 0,1 2: c,d 0,1 3: f,g,h 0,0,1 4: v 0 </code></pre> <p>Firstly, I thought I might find a way by using <code>cut</code> like: </p> <pre><code>cut(as.numeric(strsplit(as.character(df$value), split = ",")), breaks =1) </code></pre> <p>But none of my attempts get close. </p>
0debug
JQuery returns false after return true? : <p>I'm little confused by behaviour of my functions in <code>JQuery</code>. The thing is that <code>is_airport</code> function decides, whether the location is an airport using JSON of airports. </p> <p>Everything seems to work correctly, JSON is correctly parsed etc. As you can see there is a loop which is used for detecting, whether the <code>destination_id</code> is in airports JSON keys. It is. <strong>It alerts 'OK'</strong> but returns <code>false</code> instead of <code>true</code>. </p> <p>If there was an <code>AJAX</code> instead of <code>each</code> function, I would expect this behaviour because of async. But why it happens here?</p> <pre><code>function is_airport(destination_id){ var json_storage = $("#locations-json"); var airports = JSON.parse(json_storage.attr("data-airports")); $.each(airports,function(id,name){ console.log(id,destination_id,name); if (id==destination_id){ alert('ok'); return true } }); return false } $(document).ready(function () { console.log(is_airport(5));)} </code></pre> <p>Do you know where is the problem?</p>
0debug
uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function, uint32_t index, int reg) { struct kvm_cpuid2 *cpuid; uint32_t ret = 0; uint32_t cpuid_1_edx; bool found = false; cpuid = get_supported_cpuid(s); struct kvm_cpuid_entry2 *entry = cpuid_find_entry(cpuid, function, index); if (entry) { found = true; ret = cpuid_entry_get_reg(entry, reg); if (function == 1 && reg == R_EDX) { ret |= CPUID_MTRR | CPUID_PAT | CPUID_MCE | CPUID_MCA; } else if (function == 1 && reg == R_ECX) { if ((function == KVM_CPUID_FEATURES) && !found) { ret = get_para_features(s); return ret;
1threat
aspnetcore.dll failed to load : <p>I usually dev on a windows 7 desktop, using visual studio 2015 update 3. I have the same vs2015.3 on my windows 10 laptop. I copied an asp mvc 5 app I am working on to the laptop but it wont run when I try to launch it from VS. I get the "aspnetcore.dll failed to load" error. I looked around and most solutions are to repair the asp net core install, but my laptop does not have asp net core installed on it, because I don't use core yet. My project is targeting .Net 4.6.</p> <p>My desktop does have Core on it. So do I have to install .net core just because? Or is there some other solution? I am using the default IIS 10.</p>
0debug
Problem with my program to scrap data can u check it? : I have to make a code in order to scrap datafrom a website and then analyse them for university My problem is that I made this code in order to get some datas for all products but when I run it it only shows 1 response for each variable. Can u help me see my error ? from bs4 import BeautifulSoup as soup import urllib from urllib.request import urlopen as uReq import requests myurl='https://boutique.orange.fr/mobile/choisir-un-mobile' Uclient=uReq(myurl) page=Uclient.read() Uclient.close() pagesoup=soup(page,'html.parser') containers=pagesoup.findAll('div',{'class':'box-prod pointer'}) container=containers[0] produit=container.img['alt'] price=container.findAll('span',{'class':'price'}) price2=container.findAll('div',{'class':'prix-seul'}) avis=container.footer.div.a.img['alt'] file="orange.csv" f=open(file,'w') headers='produit,prix avec abonnement, prix seul, avis\n' f.write(headers) for container in containers: produit=container.img['alt'] price=container.findAll('span',{'class':'price'}) price2=container.findAll('div',{'class':'prix-seul'}) avis=container.footer.div.a.img['alt']
0debug
Inline eslint comment in JSX : <p>I'm getting an error <code>(eslint): Line 199 exceeds maximum line length of 120. (max-len)</code></p> <p>Why doesn't this inline comment work?</p> <pre><code>{/* eslint-disable-next-line max-len */} &lt;Chip ref="code" style={styles.chip}backgroundColor={this.state.filterSelected['School Code'] &amp;&amp; blue300}onTouchTap={this.handleTouchTap} &gt; &lt;Avatar size={32}&gt;C&lt;/Avatar&gt; School Code &lt;/Chip&gt; </code></pre>
0debug
Run node.js on cpanel hosting server : <p>It is a simple node.js code.</p> <pre><code>var http = require('http'); http.createServer(function(req, res) { res.writeHead(200, { 'Content-Type' : 'text/plain'}); res.end('Hello World!'); }).listen(8080); </code></pre> <p>I uploaded it on cpanel hosting server and installed node.js and run it. If a server is normal server I can check script result by accessing 'http://{serverip}:8080'. But on cpanel is hosting domain and sub domain and every domain is matched by every sites. Even http://{serverip} is not valid url. How can I access my node.js result? Kindly teach me. Thanks. bingbing.</p>
0debug
static int pty_chr_write(CharDriverState *chr, const uint8_t *buf, int len) { PtyCharDriver *s = chr->opaque; if (!s->connected) { pty_chr_update_read_handler_locked(chr); return 0; } return io_channel_send(s->fd, buf, len); }
1threat
static int qpa_init_out (HWVoiceOut *hw, struct audsettings *as) { int error; static pa_sample_spec ss; static pa_buffer_attr ba; struct audsettings obt_as = *as; PAVoiceOut *pa = (PAVoiceOut *) hw; ss.format = audfmt_to_pa (as->fmt, as->endianness); ss.channels = as->nchannels; ss.rate = as->freq; ba.tlength = pa_usec_to_bytes (4 * 1000, &ss); ba.minreq = pa_usec_to_bytes (2 * 1000, &ss); ba.maxlength = -1; ba.prebuf = -1; obt_as.fmt = pa_to_audfmt (ss.format, &obt_as.endianness); pa->s = pa_simple_new ( conf.server, "qemu", PA_STREAM_PLAYBACK, conf.sink, "pcm.playback", &ss, NULL, &ba, &error ); if (!pa->s) { qpa_logerr (error, "pa_simple_new for playback failed\n"); goto fail1; } audio_pcm_init_info (&hw->info, &obt_as); hw->samples = conf.samples; pa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift); pa->rpos = hw->rpos; if (!pa->pcm_buf) { dolog ("Could not allocate buffer (%d bytes)\n", hw->samples << hw->info.shift); goto fail2; } if (audio_pt_init (&pa->pt, qpa_thread_out, hw, AUDIO_CAP, AUDIO_FUNC)) { goto fail3; } return 0; fail3: g_free (pa->pcm_buf); pa->pcm_buf = NULL; fail2: pa_simple_free (pa->s); pa->s = NULL; fail1: return -1; }
1threat
static void blkverify_verify_readv(BlkverifyAIOCB *acb) { ssize_t offset = qemu_iovec_compare(acb->qiov, &acb->raw_qiov); if (offset != -1) { blkverify_err(acb, "contents mismatch in sector %" PRId64, acb->sector_num + (int64_t)(offset / BDRV_SECTOR_SIZE)); } }
1threat
USBBus *usb_bus_find(int busnr) { USBBus *bus; if (-1 == busnr) return TAILQ_FIRST(&busses); TAILQ_FOREACH(bus, &busses, next) { if (bus->busnr == busnr) return bus; } return NULL; }
1threat
Mapbox-GL setStyle removes layers : <p>I'm building a mapping web application using Mapbox-GL. It has a lot of cool features. I've set up the buttons to switch base maps (ie. satellite, terrain, etc) following the example on the <a href="https://www.mapbox.com/mapbox-gl-js/example/setstyle/" rel="noreferrer">Mapbox website</a>.</p> <p>The problem that I am having is that when I change the style it removes my polygons that are loaded as layers and reloads the map. I load in polygons from a Mongo database as layers based on user queries. I want to be able to change the base map and keep those layers.</p> <p>Is there a way to change the style without reloading the map, or at least not droping the layers?</p> <p>Here is my code for the switcher, its the same as the example but I added a condition for a custom style:</p> <pre><code> var layerList = document.getElementById('menu'); var inputs = layerList.getElementsByTagName('input'); function switchLayer(layer) { var layerId = layer.target.id; if (layerId === 'outdoors') { map.setStyle('/outdoors-v8.json'); } else { map.setStyle('mapbox://styles/mapbox/' + layerId + '-v8'); } } for (var i = 0; i &lt; inputs.length; i++) { inputs[i].onclick = switchLayer; } </code></pre>
0debug
jQuery animation bug : <p>I have a really annoying bug with my menu tab, jQuery hover effect.</p> <p>Here is the link ( <a href="http://pavilioncreative.com" rel="nofollow">http://pavilioncreative.com</a> )</p> <p>If you refresh your page and quickly place your mouse curser over the menu tab and then move out the jQuery animation will work back to front.</p> <p>If you click on the menu tab and then click of the menu tab the same thing will happen again as the jQuery animation will work back to front!</p> <p>Can any one help with this ? its really frustrating!!</p> <p>Thanks</p>
0debug
using background image size contain or cover property how to set background image fit(full width) to web page but with certain height : hey guys i have one question using background image size contain or cover property how do i set background image fit(full width) to web page but with certain height. i'm trying to do this layout. it is given in the comment box please take a reference of that. so anyone know how to do that and also i want add two images on the background image like what is in image:- "two ktm images on one blue Lamborghini background image"? please give me example i'm new in this. also i have provided my code link what i have tried.
0debug
static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) { MOVContext *mov = s->priv_data; ByteIOContext *pb = s->pb; MOVTrack *trk = &mov->tracks[pkt->stream_index]; AVCodecContext *enc = trk->enc; unsigned int samplesInChunk = 0; int size= pkt->size; if (url_is_streamed(s->pb)) return 0; if (!size) return 0; if (enc->codec_id == CODEC_ID_AMR_NB) { static uint16_t packed_size[16] = {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 0}; int len = 0; while (len < size && samplesInChunk < 100) { len += packed_size[(pkt->data[len] >> 3) & 0x0F]; samplesInChunk++; } if(samplesInChunk > 1){ av_log(s, AV_LOG_ERROR, "fatal error, input is not a single packet, implement a AVParser for it\n"); return -1; } } else if (trk->sampleSize) samplesInChunk = size/trk->sampleSize; else samplesInChunk = 1; if (trk->vosLen == 0 && enc->extradata_size > 0) { trk->vosLen = enc->extradata_size; trk->vosData = av_malloc(trk->vosLen); memcpy(trk->vosData, enc->extradata, trk->vosLen); } if (enc->codec_id == CODEC_ID_H264 && trk->vosLen > 0 && *(uint8_t *)trk->vosData != 1) { int ret = ff_avc_parse_nal_units(pkt->data, &pkt->data, &pkt->size); if (ret < 0) return ret; assert(pkt->size); size = pkt->size; } else if (enc->codec_id == CODEC_ID_DNXHD && !trk->vosLen) { if (size < 640) return -1; trk->vosLen = 640; trk->vosData = av_malloc(trk->vosLen); memcpy(trk->vosData, pkt->data, 640); } if (!(trk->entry % MOV_INDEX_CLUSTER_SIZE)) { trk->cluster = av_realloc(trk->cluster, (trk->entry + MOV_INDEX_CLUSTER_SIZE) * sizeof(*trk->cluster)); if (!trk->cluster) return -1; } trk->cluster[trk->entry].pos = url_ftell(pb); trk->cluster[trk->entry].samplesInChunk = samplesInChunk; trk->cluster[trk->entry].size = size; trk->cluster[trk->entry].entries = samplesInChunk; trk->cluster[trk->entry].dts = pkt->dts; trk->trackDuration = pkt->dts - trk->cluster[0].dts + pkt->duration; if(enc->codec_type == CODEC_TYPE_VIDEO) { if (pkt->dts != pkt->pts) trk->hasBframes = 1; trk->cluster[trk->entry].cts = pkt->pts - pkt->dts; trk->cluster[trk->entry].key_frame = !!(pkt->flags & PKT_FLAG_KEY); if(trk->cluster[trk->entry].key_frame) trk->hasKeyframes++; } trk->entry++; trk->sampleCount += samplesInChunk; mov->mdat_size += size; put_buffer(pb, pkt->data, size); put_flush_packet(pb); return 0; }
1threat
Creating Archive Button : I have a weekly schedule for work. I want to create a macro and link to a "button" (not even sure if that is possible), that would basically cut cells from one sheet and move it to a new workbook. Basically archiving that week to a new archive workbook. I'm so used to excel and recording macros that I'm basically at a loss. I appreciate all input
0debug
How to update core-js to core-js@3 dependency? : <p>While I was trying to install and setup react native, the precaution observed about the core-js version as update your core-js@... to core-js@3 But don't know how to update my core-js.</p> <pre><code>$ sudo react-native init AwesomeProject121 Password: This will walk you through creating a new React Native project in /Users/amarnr1989/AwesomeProject121 Using yarn v1.13.0 Installing react-native... yarn add v1.13.0 info No lockfile found. [1/4] 🔍 Resolving packages... warning react-native &gt; create-react-class &gt; fbjs &gt; core-js@1.2.7: core-js@&lt;2.6.5 is no longer maintained. Please, upgrade to core-js@3 or at least to actual version of core-js@2. [2/4] 🚚 Fetching packages... [----------------------------------------------------------------------------------------------------------------------------------------------------------] 0/601internal/modules/cjs/loader.js:584 throw err; ^ Error: Cannot find module '/Users/amarnr1989/AwesomeProject121/node_modules/react-native/package.json' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15) at Function.Module._load (internal/modules/cjs/loader.js:508:25) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:22:18) at checkNodeVersion (/usr/local/lib/node_modules/react-native-cli/index.js:306:21) at run (/usr/local/lib/node_modules/react-native-cli/index.js:300:3) at createProject (/usr/local/lib/node_modules/react-native-cli/index.js:249:3) at init (/usr/local/lib/node_modules/react-native-cli/index.js:200:5) at Object.&lt;anonymous&gt; (/usr/local/lib/node_modules/react-native-cli/index.js:153:7) at Module._compile (internal/modules/cjs/loader.js:701:30) </code></pre> <p>Please Suggest </p>
0debug
int64_t cpu_get_clock(void) { int64_t ti; if (!timers_state.cpu_ticks_enabled) { return timers_state.cpu_clock_offset; } else { ti = get_clock(); return ti + timers_state.cpu_clock_offset; } }
1threat
Can't print a long long double output : <p>My question is simple, How to print a long long double output?. I know how to print a long double i.e</p> <pre><code>printf("%Lf",output); </code></pre>
0debug
PHP match phrase, but not if phrase contains more words : I want to prevent some words to be saved as username. Following is list of unacceptable words: - love - hug - kiss but if the words contain following, then it becomes acceptable: - loveyou - huggy - kisses I can check first if condition with following, but I'm not sure if it would be write thing to do, since word can contain `lovekisses` and love should not be acceptable. preg_match('[love|hug|kiss]', $data) // this is unacceptable words, but how can I put acceptable words with this, since they are very close to each other.
0debug
Programmatically disable app power saving mode on Samsung : <p>I am the developer of a messaging application. My application get put on an automatic power save mode which prevents messages from getting through.</p> <p>When I go to the App Power Saving option on a Samsung phone (Settings->Battery->App Power Saving option), I can see that this option is "Disabled" for certain apps (like WhatsApp and Facebook messenger).</p> <p>When I do a clean install of the WhatsApp application, the power saving mode gets disabled by default before I even open the app.</p> <p>This seems to be specific to Samsung devices Android version 6.0.1 and higher.</p> <p>Is it possible to disable power saving by default for my application?</p>
0debug
How to create HTTP server inside my app that will feed the .m3u8 data to AVPlayer? : How to create HTTP server inside my app to stream & play file .m3u8 file - http://ccbprnrush-vh.akamaihd.net/i/PRN/premiereradionetworks/The-Rush-Limbaugh-Show/102617/80407_1509037716.12_RUSHMP320171026_,48,.mp4.csmil/master.m3u8
0debug
Answer from Function is incorrect : <p>The answer of this function is returned into the main function of the program, and that works fine. The issue is that any value where the cosine should be 0, it turns out to give a weird irrational number (something like 1.30431912*10^-13). So, 90, 450, and so on, all turn out irrational answers. What's the matter?</p> <pre><code> float cosineDegrees() { string i; double iDouble; cout &lt;&lt; "Give me a number to find the value of degrees in. "; getline(cin, i); iDouble = stod(i); double PI = 3.14159265359; float answer = cos((PI/180)*iDouble); return answer; } </code></pre>
0debug
c++ farenheit or celsius converter : Hi Just wondering why this is not working, as of right now it prints out just the farenehit one no matter if i select c or f. plz help #include <iostream> using namespace std; int main() { char unit; float degrees = 0.0; float Farenheit, Celsius; cout << "Enter the temperature unit you are currently in (f or c): "; cin >> unit; cout << "Enter the temperature in degrees: "; cin >> degrees; if ( unit == 'c' || 'C') { Farenheit = (degrees - 32) / 9 * 5.0; cout << "The degrees in Farenheit are: " << Farenheit << endl; } else if ( unit == 'f' || 'F') { Celsius = (degrees - 32) * 5.0/9; cout << "The degrees in Celsius is: " << Celsius << endl; } return 0; }
0debug
What is the proper way to build this code on Windows 10? : <p>I need some help with building this C code on Windows 10. Trouble is, the methods I have so far used don't seem to work (MinGW, Visual Studio Developer Tools etc.). Unfortunately, I only have a very limited understanding of how makefiles should be handles in operating systems other than Linux. Can you please take a look at the files (see the link below) and check whether the code can be compiled using Windows. If so, how can I do that? Thank you! <a href="https://github.com/embeddedartistry/embedded-resources/tree/master/examples/c" rel="nofollow noreferrer">https://github.com/embeddedartistry/embedded-resources/tree/master/examples/c</a></p>
0debug
how to find a array is almost increasing Sequence by omitting only one element in java : I am trying to solve some code in codefights.com. I have given the following problem where I am stuck right now. If I want to see the hint there I have to spent 5000 points which I don't want to. Can anybody help me for this please? I am not having the perfect logic for this. Here is the problem below : Given a sequence of integers as an array, determine whether it is possible to obtain a strictly increasing sequence by removing no more than one element from the array. Example : For sequence = [1, 3, 2, 1], the output should be almostIncreasingSequence(sequence) = false; There is no one element in this array that can be removed in order to get a strictly increasing sequence. For sequence = [1, 3, 2], the output should be almostIncreasingSequence(sequence) = true. You can remove 3 from the array to get the strictly increasing sequence [1, 2]. Alternately, you can remove 2 to get the strictly increasing sequence [1, 3]. [output] boolean Return true if it is possible to remove one element from the array in order to get a strictly increasing sequence, otherwise return false. I have tried as follows : boolean almostIncreasingSequence(int[] sequence) { ArrayList<Integer> list = new ArrayList<Integer>(); for(int i=0; i<sequence.length;i++) { list.add(sequence[i]); } int omittedCounter = 0; boolean status = true; for(int i=1; i<list.size();i++) { if(list.get(i-1) >= list.get(i)) { omittedCounter ++; list.remove(i-1); break; } } if (omittedCounter > 0) { for(int i=1; i<list.size();i++) { if(list.get(i-1) >= list.get(i)) { omittedCounter ++; list.remove(i-1); break; } } } if (omittedCounter > 1) { status = false; } return status; } But I am having trouble when I am given this sequence >>> Input: sequence: [1, 2, 3, 4, 3, 6] Output: false Expected Output: true
0debug
static int X264_frame(AVCodecContext *ctx, uint8_t *buf, int bufsize, void *data) { X264Context *x4 = ctx->priv_data; AVFrame *frame = data; x264_nal_t *nal; int nnal, i; x264_picture_t pic_out; x4->pic.img.i_csp = X264_CSP_I420; x4->pic.img.i_plane = 3; if (frame) { for (i = 0; i < 3; i++) { x4->pic.img.plane[i] = frame->data[i]; x4->pic.img.i_stride[i] = frame->linesize[i]; } x4->pic.i_pts = frame->pts; x4->pic.i_type = X264_TYPE_AUTO; } if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0) return -1; bufsize = encode_nals(ctx, buf, bufsize, nal, nnal, 0); if (bufsize < 0) return -1; x4->out_pic.pts = pic_out.i_pts; switch (pic_out.i_type) { case X264_TYPE_IDR: case X264_TYPE_I: x4->out_pic.pict_type = FF_I_TYPE; break; case X264_TYPE_P: x4->out_pic.pict_type = FF_P_TYPE; break; case X264_TYPE_B: case X264_TYPE_BREF: x4->out_pic.pict_type = FF_B_TYPE; break; } x4->out_pic.key_frame = pic_out.i_type == X264_TYPE_IDR; x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA; return bufsize; }
1threat
void esp_reg_write(ESPState *s, uint32_t saddr, uint64_t val) { trace_esp_mem_writeb(saddr, s->wregs[saddr], val); switch (saddr) { case ESP_TCHI: s->tchi_written = true; case ESP_TCLO: case ESP_TCMID: s->rregs[ESP_RSTAT] &= ~STAT_TC; break; case ESP_FIFO: if (s->do_cmd) { if (s->cmdlen < TI_BUFSZ) { s->cmdbuf[s->cmdlen++] = val & 0xff; } else { trace_esp_error_fifo_overrun(); } } else if (s->ti_size == TI_BUFSZ - 1) { trace_esp_error_fifo_overrun(); } else { s->ti_size++; s->ti_buf[s->ti_wptr++] = val & 0xff; } break; case ESP_CMD: s->rregs[saddr] = val; if (val & CMD_DMA) { s->dma = 1; s->rregs[ESP_TCLO] = s->wregs[ESP_TCLO]; s->rregs[ESP_TCMID] = s->wregs[ESP_TCMID]; s->rregs[ESP_TCHI] = s->wregs[ESP_TCHI]; } else { s->dma = 0; } switch(val & CMD_CMD) { case CMD_NOP: trace_esp_mem_writeb_cmd_nop(val); break; case CMD_FLUSH: trace_esp_mem_writeb_cmd_flush(val); s->rregs[ESP_RINTR] = INTR_FC; s->rregs[ESP_RSEQ] = 0; s->rregs[ESP_RFLAGS] = 0; break; case CMD_RESET: trace_esp_mem_writeb_cmd_reset(val); esp_soft_reset(s); break; case CMD_BUSRESET: trace_esp_mem_writeb_cmd_bus_reset(val); s->rregs[ESP_RINTR] = INTR_RST; if (!(s->wregs[ESP_CFG1] & CFG1_RESREPT)) { esp_raise_irq(s); } break; case CMD_TI: handle_ti(s); break; case CMD_ICCS: trace_esp_mem_writeb_cmd_iccs(val); write_response(s); s->rregs[ESP_RINTR] = INTR_FC; s->rregs[ESP_RSTAT] |= STAT_MI; break; case CMD_MSGACC: trace_esp_mem_writeb_cmd_msgacc(val); s->rregs[ESP_RINTR] = INTR_DC; s->rregs[ESP_RSEQ] = 0; s->rregs[ESP_RFLAGS] = 0; esp_raise_irq(s); break; case CMD_PAD: trace_esp_mem_writeb_cmd_pad(val); s->rregs[ESP_RSTAT] = STAT_TC; s->rregs[ESP_RINTR] = INTR_FC; s->rregs[ESP_RSEQ] = 0; break; case CMD_SATN: trace_esp_mem_writeb_cmd_satn(val); break; case CMD_RSTATN: trace_esp_mem_writeb_cmd_rstatn(val); break; case CMD_SEL: trace_esp_mem_writeb_cmd_sel(val); handle_s_without_atn(s); break; case CMD_SELATN: trace_esp_mem_writeb_cmd_selatn(val); handle_satn(s); break; case CMD_SELATNS: trace_esp_mem_writeb_cmd_selatns(val); handle_satn_stop(s); break; case CMD_ENSEL: trace_esp_mem_writeb_cmd_ensel(val); s->rregs[ESP_RINTR] = 0; break; case CMD_DISSEL: trace_esp_mem_writeb_cmd_dissel(val); s->rregs[ESP_RINTR] = 0; esp_raise_irq(s); break; default: trace_esp_error_unhandled_command(val); break; } break; case ESP_WBUSID ... ESP_WSYNO: break; case ESP_CFG1: case ESP_CFG2: case ESP_CFG3: case ESP_RES3: case ESP_RES4: s->rregs[saddr] = val; break; case ESP_WCCF ... ESP_WTEST: break; default: trace_esp_error_invalid_write(val, saddr); return; } s->wregs[saddr] = val; }
1threat
Is there a way to disallow runtime errors to crash app on background thread? : <p>I'm running a method in this way</p> <pre><code>dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), { () -&gt; Void in ... }) </code></pre> <p>I want this logic to avoid crashing app if something goes wrong inside. Is there any way to do so?</p> <p>Please don't answer fix the bug if any, I'm talking about any potencial bug I haven't found. This runs on a timer to process data from server, if crashes, it will make app unusable since it will crash at start up. </p> <p>App can live without this data processing in worst case, but crashing app on start up is much more worse since app can't be used at all.</p> <p>I know Swift doesn't have a catch for unexpected exceptions but maybe there is a way to avoid background threads to crash app if things goes wrong</p>
0debug
int ff_img_read_header(AVFormatContext *s1) { VideoDemuxData *s = s1->priv_data; int first_index = 1, last_index = 1; AVStream *st; enum AVPixelFormat pix_fmt = AV_PIX_FMT_NONE; s1->ctx_flags |= AVFMTCTX_NOHEADER; st = avformat_new_stream(s1, NULL); if (!st) { return AVERROR(ENOMEM); } if (s->pixel_format && (pix_fmt = av_get_pix_fmt(s->pixel_format)) == AV_PIX_FMT_NONE) { av_log(s1, AV_LOG_ERROR, "No such pixel format: %s.\n", s->pixel_format); return AVERROR(EINVAL); } av_strlcpy(s->path, s1->filename, sizeof(s->path)); s->img_number = 0; s->img_count = 0; if (s1->iformat->flags & AVFMT_NOFILE) s->is_pipe = 0; else { s->is_pipe = 1; st->need_parsing = AVSTREAM_PARSE_FULL; } if (s->ts_from_file == 2) { #if !HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC av_log(s1, AV_LOG_ERROR, "POSIX.1-2008 not supported, nanosecond file timestamps unavailable\n"); return AVERROR(ENOSYS); #endif avpriv_set_pts_info(st, 64, 1, 1000000000); } else if (s->ts_from_file) avpriv_set_pts_info(st, 64, 1, 1); else avpriv_set_pts_info(st, 64, s->framerate.den, s->framerate.num); if (s->width && s->height) { st->codec->width = s->width; st->codec->height = s->height; } if (!s->is_pipe) { if (s->pattern_type == PT_GLOB_SEQUENCE) { s->use_glob = is_glob(s->path); if (s->use_glob) { #if HAVE_GLOB char *p = s->path, *q, *dup; int gerr; #endif av_log(s1, AV_LOG_WARNING, "Pattern type 'glob_sequence' is deprecated: " "use pattern_type 'glob' instead\n"); #if HAVE_GLOB dup = q = av_strdup(p); while (*q) { if ((p - s->path) >= (sizeof(s->path) - 2)) break; if (*q == '%' && strspn(q + 1, "%*?[]{}")) ++q; else if (strspn(q, "\\*?[]{}")) *p++ = '\\'; *p++ = *q++; } *p = 0; av_free(dup); gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate); if (gerr != 0) { return AVERROR(ENOENT); } first_index = 0; last_index = s->globstate.gl_pathc - 1; #endif } } if ((s->pattern_type == PT_GLOB_SEQUENCE && !s->use_glob) || s->pattern_type == PT_SEQUENCE) { if (find_image_range(&first_index, &last_index, s->path, s->start_number, s->start_number_range) < 0) { av_log(s1, AV_LOG_ERROR, "Could find no file with path '%s' and index in the range %d-%d\n", s->path, s->start_number, s->start_number + s->start_number_range - 1); return AVERROR(ENOENT); } } else if (s->pattern_type == PT_GLOB) { #if HAVE_GLOB int gerr; gerr = glob(s->path, GLOB_NOCHECK|GLOB_BRACE|GLOB_NOMAGIC, NULL, &s->globstate); if (gerr != 0) { return AVERROR(ENOENT); } first_index = 0; last_index = s->globstate.gl_pathc - 1; s->use_glob = 1; #else av_log(s1, AV_LOG_ERROR, "Pattern type 'glob' was selected but globbing " "is not supported by this libavformat build\n"); return AVERROR(ENOSYS); #endif } else if (s->pattern_type != PT_GLOB_SEQUENCE && s->pattern_type != PT_NONE) { av_log(s1, AV_LOG_ERROR, "Unknown value '%d' for pattern_type option\n", s->pattern_type); return AVERROR(EINVAL); } s->img_first = first_index; s->img_last = last_index; s->img_number = first_index; if (!s->ts_from_file) { st->start_time = 0; st->duration = last_index - first_index + 1; } } if (s1->video_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = s1->video_codec_id; } else if (s1->audio_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = s1->audio_codec_id; } else if (s1->iformat->raw_codec_id) { st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = s1->iformat->raw_codec_id; } else { const char *str = strrchr(s->path, '.'); s->split_planes = str && !av_strcasecmp(str + 1, "y"); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; if (s1->pb) { int probe_buffer_size = 2048; uint8_t *probe_buffer = av_realloc(NULL, probe_buffer_size + AVPROBE_PADDING_SIZE); AVInputFormat *fmt = NULL; AVProbeData pd = { 0 }; if (!probe_buffer) return AVERROR(ENOMEM); probe_buffer_size = avio_read(s1->pb, probe_buffer, probe_buffer_size); if (probe_buffer_size < 0) { av_free(probe_buffer); return probe_buffer_size; } memset(probe_buffer + probe_buffer_size, 0, AVPROBE_PADDING_SIZE); pd.buf = probe_buffer; pd.buf_size = probe_buffer_size; pd.filename = s1->filename; while ((fmt = av_iformat_next(fmt))) { if (fmt->read_header != ff_img_read_header || !fmt->read_probe || (fmt->flags & AVFMT_NOFILE) || !fmt->raw_codec_id) continue; if (fmt->read_probe(&pd) > 0) { st->codec->codec_id = fmt->raw_codec_id; break; } } if (s1->flags & AVFMT_FLAG_CUSTOM_IO) { avio_seek(s1->pb, 0, SEEK_SET); } else ffio_rewind_with_probe_data(s1->pb, &probe_buffer, probe_buffer_size); } if (st->codec->codec_id == AV_CODEC_ID_NONE) st->codec->codec_id = ff_guess_image2_codec(s->path); if (st->codec->codec_id == AV_CODEC_ID_LJPEG) st->codec->codec_id = AV_CODEC_ID_MJPEG; if (st->codec->codec_id == AV_CODEC_ID_ALIAS_PIX) st->codec->codec_id = AV_CODEC_ID_NONE; } if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pix_fmt != AV_PIX_FMT_NONE) st->codec->pix_fmt = pix_fmt; return 0; }
1threat
I wanna make smth like this :( if time " now " = 5:50 pm) do // Somthing Android Studio : <p>I wanna do just like Alarm in time , but as I said in the question I wanna make smth like this :( if time " now " = 5:50 pm) do // Something i tried this but it's take all my battery life time : what I've Done is Set int Hours and int minutes and then </p> <pre><code>enter code here while (true){ if (Hours==x &amp;minutes==y ) //do somethin } so any better way ? </code></pre>
0debug
r - How to make this loop faster? : <p>I am reading the <code>.csv</code> file named <code>cleanequityreturns.csv</code> which looks like this:</p> <p><a href="https://i.stack.imgur.com/c2BR1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c2BR1.png" alt="enter image description here"></a></p> <p>It goes from <code>r1</code> to <code>r299</code> and has 4,166 rows. The following code then creates a new file for each column, compute the approximate entropy using the <code>approx_entropy</code> function, and prints the value. I know creating a new file for each column is very tedious but I could not find another to do it.</p> <pre><code> equityreturn &lt;- read.csv("cleanequityreturns.csv", header=T) for(i in 1:299) { file2 = paste(i, "equityret.csv", sep="") file5 = paste("r", i, sep="") file1 = subset(equityreturn, select=file5) write.table(file1, file2, sep="\t", row.names=FALSE, col.names=FALSE) file3 = paste("equity", i, sep="") file3 = matrix(scan(file = file2), nrow=4166, byrow=TRUE) print(approx_entropy(file3, edim = 4, r=0.441*sd(file3), elag = 1)) } </code></pre> <p>My problem is the following: it takes a long time for the code to perform these tasks. I tried running it for 10 columns and it took about 20 min, which translates in about 10h for all of the 299 columns. Also, this code prints each approximate entropy values, so I still have to copy and paste them in Excel to use them.</p> <p>How could I make this code run faster and write the output in a <code>.csv</code> file?</p>
0debug
solution to turtle concept in python : This is my piece of code: import turtle def draw_square(some_turtle): for i in range(1,5): some_turtle.forward(100) some_turtle.right(90) def draw_art(): window = turtle.screen() window.bgcolor("red") brad = turtle.Turtle() brad.shape("turtle") brad.color("yellow") brad.speed(2) for i in range(1,5): draw_square(brad) brad.right(10) window.exitonclick() And as output it is showing this message below: C:\Users\adc\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/adc/PycharmProjects/untitled/tur.py Process finished with exit code 0
0debug
How to make only part of text on top of colored div white? : <p>How could I make only the part of the text on the red div white? (so top stays dark grey, but bottom part white)</p> <p><a href="https://i.stack.imgur.com/QWEfc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QWEfc.png" alt="image"></a></p>
0debug
How to comment out content in Hugo : <p>How do I comment out content in Hugo? </p> <p>If I have notes, unfinished thoughts, I'd like to leave them in the <code>.md</code> file but not have them appear in the <code>html</code>. </p> <p><code>&lt;!--</code> tags don't seem to work -- it doesn't even become a html comment, it remains visible text on the page.</p>
0debug
build_mcfg_q35(GArray *table_data, GArray *linker, AcpiMcfgInfo *info) { AcpiTableMcfg *mcfg; const char *sig; int len = sizeof(*mcfg) + 1 * sizeof(mcfg->allocation[0]); mcfg = acpi_data_push(table_data, len); mcfg->allocation[0].address = cpu_to_le64(info->mcfg_base); mcfg->allocation[0].pci_segment = cpu_to_le16(0); mcfg->allocation[0].start_bus_number = 0; mcfg->allocation[0].end_bus_number = PCIE_MMCFG_BUS(info->mcfg_size - 1); if (info->mcfg_base == PCIE_BASE_ADDR_UNMAPPED) { sig = "QEMU"; } else { sig = "MCFG"; } build_header(linker, table_data, (void *)mcfg, sig, len, 1, NULL, NULL); }
1threat
static int qemu_rdma_block_for_wrid(RDMAContext *rdma, int wrid_requested, uint32_t *byte_len) { int num_cq_events = 0, ret = 0; struct ibv_cq *cq; void *cq_ctx; uint64_t wr_id = RDMA_WRID_NONE, wr_id_in; if (ibv_req_notify_cq(rdma->cq, 0)) { return -1; } while (wr_id != wrid_requested) { ret = qemu_rdma_poll(rdma, &wr_id_in, byte_len); if (ret < 0) { return ret; } wr_id = wr_id_in & RDMA_WRID_TYPE_MASK; if (wr_id == RDMA_WRID_NONE) { break; } if (wr_id != wrid_requested) { trace_qemu_rdma_block_for_wrid_miss(print_wrid(wrid_requested), wrid_requested, print_wrid(wr_id), wr_id); } } if (wr_id == wrid_requested) { return 0; } while (1) { if (rdma->migration_started_on_destination) { yield_until_fd_readable(rdma->comp_channel->fd); } ret = ibv_get_cq_event(rdma->comp_channel, &cq, &cq_ctx); if (ret) { perror("ibv_get_cq_event"); goto err_block_for_wrid; } num_cq_events++; ret = -ibv_req_notify_cq(cq, 0); if (ret) { goto err_block_for_wrid; } while (wr_id != wrid_requested) { ret = qemu_rdma_poll(rdma, &wr_id_in, byte_len); if (ret < 0) { goto err_block_for_wrid; } wr_id = wr_id_in & RDMA_WRID_TYPE_MASK; if (wr_id == RDMA_WRID_NONE) { break; } if (wr_id != wrid_requested) { trace_qemu_rdma_block_for_wrid_miss(print_wrid(wrid_requested), wrid_requested, print_wrid(wr_id), wr_id); } } if (wr_id == wrid_requested) { goto success_block_for_wrid; } } success_block_for_wrid: if (num_cq_events) { ibv_ack_cq_events(cq, num_cq_events); } return 0; err_block_for_wrid: if (num_cq_events) { ibv_ack_cq_events(cq, num_cq_events); } rdma->error_state = ret; return ret; }
1threat
How to dynamic load android strings.xml easily? : I'm working on android i18n now. There are some strings.xml files in so many values-xxxx directories, but the product manager want to put these hole strings.xml files into the server, app get strings.xml file from network by a language-parameter dynamicly.But strings.xml is used in these ways: @string/xx, Widget.setText(R.string.xx), getString(R.string.xx), Toast.make(x, R.string.x, x) and so on... How to dynamic load android strings.xml easily? Or do you got a easier way to solve my problem? Thanks!
0debug
Error while Installing the python package? : [Error while installing dedupe package :][1] [1]: https://i.stack.imgur.com/QzcAv.png Please help me to solve this error...
0debug
static void smbios_encode_uuid(struct smbios_uuid *uuid, const uint8_t *buf) { memcpy(uuid, buf, 16); if (smbios_uuid_encoded) { uuid->time_low = bswap32(uuid->time_low); uuid->time_mid = bswap16(uuid->time_mid); uuid->time_hi_and_version = bswap16(uuid->time_hi_and_version); } }
1threat
What is the use of WHERE 1=0 in SQL : <p>Why do we write WHERE 1=0 or 1=1 in SQL query under WHERE clause?</p>
0debug
static int aac_adtstoasc_init(AVBSFContext *ctx) { av_freep(&ctx->par_out->extradata); ctx->par_out->extradata_size = 0; return 0; }
1threat
How to integrate two different template in Angular 4 : I am a beginner in angular 4. I try to integrate **admin template** and **frontend template** in the same application. so I can't achieve. If it's possible how can I do. My folder Structure ------------------- Admin Module ------------ [![enter image description here][1]][1] Frontend Module --------------- [![enter image description here][2]][2] [1]: https://i.stack.imgur.com/PKBaA.png [2]: https://i.stack.imgur.com/U8Utm.png
0debug
static void omap_os_timer_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { struct omap_32khz_timer_s *s = (struct omap_32khz_timer_s *) opaque; int offset = addr & OMAP_MPUI_REG_MASK; if (size != 4) { return omap_badwidth_write32(opaque, addr, value); } switch (offset) { case 0x00: s->timer.reset_val = value & 0x00ffffff; break; case 0x04: OMAP_RO_REG(addr); break; case 0x08: s->timer.ar = (value >> 3) & 1; s->timer.it_ena = (value >> 2) & 1; if (s->timer.st != (value & 1) || (value & 2)) { omap_timer_sync(&s->timer); s->timer.enable = value & 1; s->timer.st = value & 1; omap_timer_update(&s->timer); } break; default: OMAP_BAD_REG(addr); } }
1threat
How to add image/ads to the sides of main content : <p>Let's say that I got a div called <code>container</code> that is 1000px wide and aligned to the center of the screen. I would like to add images/ads to the blank space that is left over the the left and right side of that div. It should be fixed and should not move into the <code>content</code> div if the screen is smaller but should instead disappear to the sides when zooming in on the website or having smaller screen.</p> <p>I am pretty much trying to accomplish what probuilds.net did: <a href="https://i.gyazo.com/746c89429d9ca0e23016469120f2b607.jpg" rel="nofollow">https://i.gyazo.com/746c89429d9ca0e23016469120f2b607.jpg</a></p> <p>How could that be done? Each side should have individual ad/image code.</p>
0debug
Angular4 Application running issues in IE11 : <p>I am building a Angular4 project using Angular CLI (1.1.2). It runs perfectly in Chrome (Version 59.0.3071.115) and firefox(54.0.1) but when I tried to use IE11 (Verison 11.0.9600.18738) nothings shows up and when I open the develper mode in IE, it shows me the following Error:</p> <pre><code>SCRIPT5022: Exception thrown and not caught File: polyfills.bundle.js, Line: 829, Column: 34 </code></pre> <p>And the detailed Error message is following:</p> <p><a href="https://i.stack.imgur.com/O2L2B.png" rel="noreferrer"><img src="https://i.stack.imgur.com/O2L2B.png" alt="enter image description here"></a></p> <p>Anyone knows how to solve this problem?</p> <p>Thanks!</p>
0debug
running total wih constant numbers TSQL : I have data looks like this ' MILEAGE January February ........December 0 ` 0 0 2 0.066 0.052 3 0.081 0 5 0 0.062 6 0.080 0 ......... 813 0 0 and so on ' I want the data to look like this Mileage January February ..... December 0 (Total of Mileage less and equal to zero for each month) 2000 Total of Mileage upto 2000 for each month 4000 Total of Mileage upto 4000 for each month 6000 Total of Mileage upto 6000 for each month 8000 and so on.... 10000 12000 14000 2 thousand increment up till 50000 ' Thank you very much for your help.I am using sql 2008 R2 and not sure how to achieve this
0debug
Is a data member of a temporary object an xvalue in C++11? : <pre><code>#include &lt;vector&gt; using namespace std; struct A { vector&lt;int&gt; coll; }; void f(const vector&lt;int&gt;&amp;){} void f(vector&lt;int&gt;&amp;&amp;){} int main() { f(A().coll); // Is "A().coll" an xvalue? } </code></pre> <p><strong>Does C++11 guarantee <code>f(A().coll)</code> will call <code>void f(vector&lt;int&gt;&amp;&amp;)</code>?</strong></p>
0debug
Is there a Python equivalent to the C# ?. and ?? operators? : <p>For instance, in C# (starting with v6) I can say:</p> <pre><code>mass = (vehicle?.Mass / 10) ?? 150; </code></pre> <p>to set mass to a tenth of the vehicle's mass if there is a vehicle, but 150 if the vehicle is null (or has a null mass, if the Mass property is of a nullable type).</p> <p>Is there an equivalent construction in Python (specifically IronPython) that I can use in scripts for my C# app?</p> <p>This would be particularly useful for displaying defaults for values that can be modified by other values - for instance, I might have an armor component defined in script for my starship that is always consumes 10% of the space available on the ship it's installed on, and its other attributes scale as well, but I want to display defaults for the armor's size, hitpoints, cost, etc. so you can compare it with other ship components. Otherwise I might have to write a convoluted expression that does a null check or two, like I had to in C# before v6.</p>
0debug
python numpy ndarray element-wise mean : <p>I'd like to calculate element-wise average of numpy ndarray.</p> <pre><code>In [56]: a = np.array([10, 20, 30]) In [57]: b = np.array([30, 20, 20]) In [58]: c = np.array([50, 20, 40]) </code></pre> <p>What I want:</p> <pre><code>[30, 20, 30] </code></pre> <p>Is there any in-built function for this operation, other than vectorized sum and dividing? </p>
0debug
Angular 2 (keydown.enter) can not preventDefault() : <p>the <code>event.preventDefault()</code> doesn't work when I use <code>(keydown.enter)</code> in template. <br> This is demo: <a href="https://plnkr.co/edit/GZrVt7l6BEO2uHfWFoTQ?p=preview" rel="noreferrer">https://plnkr.co/edit/GZrVt7l6BEO2uHfWFoTQ?p=preview</a> Please help me.</p>
0debug
python 2.7 string conversion by inserting another string or character after particular counts : send data on serial in hex format i have data in string format on 1st line which converted to hex string on 2nd line but while sending python - serial it should be in format on 3rd line. I want to insert '\x' initially and after every 2 count. please help for the same 1st line - string ='s00123' 2nd line - "01733030313233" 3rd lline - `x01\x73\x30\x30\x31\x32\x33`
0debug
static void memory_region_read_accessor(MemoryRegion *mr, hwaddr addr, uint64_t *value, unsigned size, unsigned shift, uint64_t mask) { uint64_t tmp; if (mr->flush_coalesced_mmio) { qemu_flush_coalesced_mmio_buffer(); } tmp = mr->ops->read(mr->opaque, addr, size); trace_memory_region_ops_read(mr, addr, tmp, size); *value |= (tmp & mask) << shift; }
1threat
Using jQuery to manipulate entire HTML DOM : <p>Is this a good practice? I mean is it good if all of my codes(behavior,presentation,structure) are inside on my .js(for example, since I'm making a website) file? Why? Sorry for my bad english.</p>
0debug
static void test_visitor_out_struct_errors(TestOutputVisitorData *data, const void *unused) { EnumOne bad_values[] = { ENUM_ONE_MAX, -1 }; UserDefZero b; UserDefOne u = { .base = &b }, *pu = &u; Error *err; int i; for (i = 0; i < ARRAY_SIZE(bad_values) ; i++) { err = NULL; u.has_enum1 = true; u.enum1 = bad_values[i]; visit_type_UserDefOne(data->ov, &pu, "unused", &err); g_assert(err); error_free(err); } }
1threat
unable to add path for image in phpmyadmin : *hello,i was just working on my php website and i need database for that ,so i was tryin to insert image path to phpmyadmin but i am unable to add path becouse i dnt know the exact syntax for iamge path and also when i am trying to insert image path i cant see empty column instead of that i am watching somethng lik binary and choose file., as you can see in image...so please help urgernt.,thx* [enter image description here][1] [1]: https://i.stack.imgur.com/0AzJX.png
0debug
HTTP Status code for preflight request : <p>this question was asked in some online test on some website but i did not found the correct answer. Can anyone help me to get the right answer.</p> <p>Ques: What is the HTTP Status code for pre-flight request?</p>
0debug
C# Deserialize Multi-Dimentional JSON array : I am having an issue deserializing and defining this JSON structure would be great to get some assistance. I have reverted this back to last known working position because I am just going off the rails here. my JSON stucture is: [ { "name": "Name1", "description": "Description of this process", "Location": "ANY", "SubItems": [ { "name": "sub1", "required": true, "description": "This is a short description" }, { "name": "sub2", "required": true, "description": "This is a short description" }, { "name": "sub3", "required": true, "description": "This is a short description" } ], "outputs": [ { "name": "out1", "required": false }, { "name": "exit code", "required": false } ] }, { "name": "Name2", "description": "This is a short description", "Location": "ANY", "SubItems": [ { "name": "sub1", "required": false, "description": "This is a short description" }] }, ] } ] Here are my C# Json definitions that were last working. public class JsonObject { [JsonProperty("name")] public string ProcessName { get; set; } [JsonProperty("description")] public string ProcessDescription { get; set; } [JsonProperty("Location")] public string KnownLocation { get; set; } } I am only capturing a couple of definitions at the moment for testing. Here is my deserializing object var Object = JsonConvert.DeserializeObject <List<JsonObject>>(txt); foreach (JsonObject JsonObject in Object) { Console.WriteLine("Name: " + JsonObject.ProcessName); Console.WriteLine(); Console.WriteLine("Description: " +JsonObject.ProcessDescription); Console.WriteLine(); } So as I had stated, I can get at least the first 3 top-most level JSON elements in the output. The problem starts when I start trying to get the "SubItems" and "outputs" I followed the structure of the below linked post and tried very hard to understand it, but after a while I realized that solution is not for this issue. I simply have a multi-dimentional array JSON object. Literally has a top tier, and 2 sub tiers I attempted to try and do... List<List<JsonObject>>Object = JsonConvert.DeserializeObject <List<List<JsonObject>>>(txt); and tried to have 2 lists of the same with different names with 3 sets of JSON Definitions. and implemented the tiered foreach loops, but then I wasn't able to access the definitions for the top most JSON, and nothing was writing for the actual elements for "SubItems" What I need is to get to each object, really. http://stackoverflow.com/questions/32896228/how-to-deserialize-a-json-file-with-multidimensional-array-to-convert-it-to-obje Related Issue
0debug
Serve multiple Angular apps from the same server with Nginx : <p>I'm serving multiple <code>angular</code> apps from the same <code>server</code> block in <code>Nginx</code>. So in order to let the user browse directly to certain custom <code>Angular</code> routes I've declared without having to go through the home page (and avoid the 404 page), I'm forwarding these routes from nginx to each angular app's <code>index.html</code>, I've added a <code>try_files</code> to each <code>location</code>:</p> <pre><code>server { listen 80; server_name website.com; # project1 location / { alias /home/hakim/project1/dist/; try_files $uri /index.html; } # project2 location /project2/ { alias /home/hakim/project2/dist/; try_files $uri /index.html; } # project3 location /project3/ { alias /home/hakim/project3/dist/; try_files $uri /index.html; } } </code></pre> <p>This solution avoids the 404 error when going to an Angular route, but the problem is that when I browse to <code>/project2/</code> or <code>/project3/</code> it redirects to the <code>/project1/</code>. That's obviously not what is expected, since I want to have each location to forward to the <code>/project-i/index.html</code> of the adequate project.</p>
0debug
static int epaf_read_header(AVFormatContext *s) { int le, sample_rate, codec, channels; AVStream *st; avio_skip(s->pb, 4); if (avio_rl32(s->pb)) return AVERROR_INVALIDDATA; le = avio_rl32(s->pb); if (le && le != 1) return AVERROR_INVALIDDATA; if (le) { sample_rate = avio_rl32(s->pb); codec = avio_rl32(s->pb); channels = avio_rl32(s->pb); } else { sample_rate = avio_rb32(s->pb); codec = avio_rb32(s->pb); channels = avio_rb32(s->pb); } if (!channels || !sample_rate) return AVERROR_INVALIDDATA; st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->channels = channels; st->codecpar->sample_rate = sample_rate; switch (codec) { case 0: st->codecpar->codec_id = le ? AV_CODEC_ID_PCM_S16LE : AV_CODEC_ID_PCM_S16BE; break; case 2: st->codecpar->codec_id = AV_CODEC_ID_PCM_S8; break; case 1: avpriv_request_sample(s, "24-bit Paris PCM format"); default: return AVERROR_INVALIDDATA; } st->codecpar->bits_per_coded_sample = av_get_bits_per_sample(st->codecpar->codec_id); st->codecpar->block_align = st->codecpar->bits_per_coded_sample * st->codecpar->channels / 8; avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate); if (avio_skip(s->pb, 2024) < 0) return AVERROR_INVALIDDATA; return 0; }
1threat
Rails 5: Load lib files in production : <p>I've upgraded one of my apps from Rails 4.2.6 to Rails 5.0.0. The <a href="http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#autoloading-is-disabled-after-booting-in-the-production-environment" rel="noreferrer">Upgrade Guide</a> says, that the Autoload feature is now disabled in production by default.</p> <p>Now I always get an error on my production server since I load all lib files with autoload in the <code>application.rb</code> file.</p> <pre><code>module MyApp class Application &lt; Rails::Application config.autoload_paths += %W( lib/ ) end end </code></pre> <p>For now, I've set the <code>config.enable_dependency_loading</code> to <code>true</code> but I wonder if there is a better solution to this. There must be a reason that Autoloading is disabled in production by default.</p>
0debug
hwaddr mips_cpu_get_phys_page_debug(CPUState *cs, vaddr addr) { MIPSCPU *cpu = MIPS_CPU(cs); hwaddr phys_addr; int prot; if (get_physical_address(&cpu->env, &phys_addr, &prot, addr, 0, ACCESS_INT) != 0) { return -1; } return phys_addr; }
1threat
re-numbering list members in python : <p>How can re-numbering list members respectively from zero to n in Python ?</p> <p>for example :</p> <pre><code>In : [4, 10, 12, 40, 4, 12, 20, 21] Out : [0, 1, 2, 3, 0, 2, 4, 5] </code></pre>
0debug
Moment last day of month parsing issue : <p>Why is this not working? I'm going crazy here trying to find where I might have gone wrong but nothing comes to mind. Tested only in Chrome.</p> <pre><code>var startString = "30.01.2017"; var endString = "31.01.2017"; // is OK var startDate = moment(startString, "DD.MM.YYYY", 'bs',true).clone().toDate(); // breaks down var endDate = moment(endtString, "DD.MM.YYYY", 'bs',true).clone().toDate(); // console dump Uncaught ReferenceError: endtString is not defined at HTMLDocument.&lt;anonymous&gt; (Kreiraj:1062) at j (jquery.js:3094) at Object.fireWith [as resolveWith] (jquery.js:3206) at Function.ready (jquery.js:3412) at HTMLDocument.I (jquery.js:3428) </code></pre> <p>What did I do wrong?</p>
0debug
strptime format - Python : <p>I'm currently working with an API that returns date in the following format:</p> <pre><code>d1 = '2015-06-25T18:45:24' d2 = '2015-07-11T18:45:35' </code></pre> <p>So, to find the difference between two times, in days, I'm doing the following:</p> <pre><code>import datetime d1 = datetime.datetime.strptime(d1, "%Y-%m-%d %H:%M:%S.%f") d2 = datetime.datetime.strptime(d2, "%Y-%m-%d %H:%M:%S.%f") print abs((d2-d1).days) </code></pre> <p>However, I'm getting the following error:</p> <pre><code>ValueError: time data '2015-06-25T18:45:24' does not match format '%Y-%m-%dT%H:%M:%S.%f' </code></pre> <p>I know I could just simply split the string in <code>'T'</code> and then convert, however is there an easy way to convert to such format to datetime object?</p>
0debug
S390PCIBusDevice *s390_pci_find_next_avail_dev(S390PCIBusDevice *pbdev) { int idx = 0; S390PCIBusDevice *dev = NULL; S390pciState *s = s390_get_phb(); if (pbdev) { idx = (pbdev->fh & FH_MASK_INDEX) + 1; } for (; idx < PCI_SLOT_MAX; idx++) { dev = s->pbdev[idx]; if (dev && dev->state != ZPCI_FS_RESERVED) { return dev; } } return NULL; }
1threat
Change Xml Color to Drawable : this is my first question, here I want to ask about xml, I want to change the color of the following xml into images. so the point I want mebubah color to the picture. how do I do? thank you this xml code : < color name="spring_loaded_panel_color" >#50e602ee < / color >
0debug
What wrong with my IDEA? : I cant understand whats wrong with my IDEA. In this code i getting errors like this when im trying to assign a value to a variable within a class. Also System.out.println doesnt work in this classes: 1.Identifier expected 2.Unexpected token 3.Unknown class "windows" public static void main(String[] args) { } class building{ int apart_num; apart_num = 3; } class apartments{ double area; int lightbulb; int windows; windows = 4; } interface construct_building{ } interface construct_apartments{ }
0debug
Replace quotes after double quotes in string : <p>I have following string:</p> <pre><code>&lt;something=""Some" random string" somethingelse="Another "random" string"&gt; </code></pre> <p>I need to change it to this</p> <pre><code>&lt;something="&amp;quot;Some&amp;quot; random string" somethingelse="Another &amp;quot;random&amp;quot; string"&gt; </code></pre> <p>Basically leaving the 'outer' quotes and changing the quotes inside them to <code>&amp;quot;</code></p> <p>I thought some regex might be used to do this, but I'm not sure what the logic should be. Any idea?</p>
0debug
NanoTime in java 8 : I am a beginner in java I want compute the execution time of my methods with System.nanoTime and pass this time as stream argument to comparison method and put them in an Long array from [2] to [5], and return this array my problem is i do not know how can i do, because i tried different ways but i had error and i did not have any answer please help me how can i do this in java 8 my code is: import java.util.stream.Stream; import java.io.*; import java.nio.file.*; import java.util.Arrays; import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.LongStream; import java.lang.Object; import java.util.stream.IntStream; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author user */ public class WinneropsDB implements Winner{ private int getYear; private int getWinnerAge; private String getWinnerName; private String getFilmTitle; public WinneropsDB(String s) { String[] Data = s.split(",",5); getYear = Integer.parseInt(Data[1]); getWinnerAge = Integer.parseInt(Data[2]); getWinnerName = Data[3].substring(1,Data[3].length()-1); getFilmTitle = Data[4].substring(1,Data[4].length()-1); } @Override public String toString(){ return getYear+", "+getWinnerAge+", "+getWinnerName+", "+getFilmTitle; } public static Stream<Winner> loadData(String[] fileName) { return Arrays.stream(fileName).flatMap(f -> { try { return Files.lines(Paths.get(f)) .filter(first -> !first.startsWith("#")) .map(WinneropsDB:: new); } catch (IOException e) { System.out.println("file not found"); return null; } }); } /** * * @param young * @return */ public static Stream<Winner> youngWinners(Stream<Winner> young) { return young.filter(w -> w.getWinnerAge() < 35) .sorted(Comparator.comparing(Winner :: getWinnerName)); } public static Stream<Winner> extreamWinners (Stream<Winner> mix){ long startTime = System.nanoTime(); Comparator<Winner> comparator = Comparator.comparing(Winner -> Winner.getWinnerName()); Stream<Winner> m = mix.sorted(comparator); // Winner[] g = (Winner[]) m.toArray(); //System.out.println(g[0]); Comparator<Winner> comparator1 = Comparator.comparing(Winner -> Winner.getWinnerAge()); Stream<Winner> m1 = m.sorted(comparator1); Winner[] lis = m1.toArray(s -> new Winner[s]); Winner youngest = lis[0]; Winner oldest = lis[lis.length - 1]; Arrays.stream(lis).forEach(System.out::println); System.out.println("youngest: " + youngest + " oldest: " + oldest); long finishTime = System.nanoTime(); long timeWinner = finishTime - startTime; System.out.println("timeWinner: " + timeWinner); comparison(Stream.of(timeWinner)); return m1; } public static Stream<String> multiAwardedPerson(Stream<Winner> m){ long startTime = System.nanoTime(); Comparator<Winner> comprator = Comparator.comparing(Winner -> Winner.getWinnerName()); Map<String,List<Winner>> c1 = m.collect(Collectors.groupingBy(Winner::getWinnerName)); //, Collectors.counting())); long finishTime = System.nanoTime(); long timePerson = finishTime - startTime; System.out.println("timePerson: " + timePerson); comparison(Stream.of(timePerson)); return c1.values().stream().filter(s -> s.size()>= 2).map(e -> e.get(0)).sorted(comprator).map(f -> f.getWinnerName()); } public static Stream<String> multiAwardedFilm(Stream<Winner> d){ long startTime = System.nanoTime(); Comparator<Winner> comprator = Comparator.comparing(Winner -> Winner.getYear()); Map<Integer,List<Winner>> c1 = d.collect(Collectors.groupingBy(Winner::getYear)); long finishTime = System.nanoTime(); long timeFilm = finishTime - startTime; System.out.println(" timeFilm: " + timeFilm); comparison(Stream.of(timeFilm)); return c1.values().stream().filter(f -> f.size() == 2).map(t -> t.get(0)).sorted(comprator).map(y -> y.getFilmTitle()); } public static <T, U> long measure(Function<Stream<T>,Stream<U>> f , Stream<T> s1){ long startTime = System.nanoTime(); Stream<U> s2 = f.apply(s1); List<U> collect = s2.collect(Collectors.toList()); long endTime = System.nanoTime(); long time = endTime - startTime; return time; } public static long[] comparison(Stream<Winner> e){ long [] arrayTime = LongStream.of(e).toArray(); return null; } /** * @param args the command line arguments * @throws java.io.FileNotFoundException */ public static void main(String[] args) throws FileNotFoundException { String[] fileName = {"G:\\path\\oscar_age_female.csv" , "G:\\path\\oscar_age_male.csv"}; // TODO code application logic here Stream<Winner> loadData = loadData(fileName); //loadData.forEach(x -> System.out.println(x)); // Stream<Winner> young = youngWinners(loadData); // young.forEach(a -> System.out.println(a)); Stream<Winner> mix1 = extreamWinners(loadData); Stream<String> winner = multiAwardedPerson(loadData); // winner.forEach(q -> System.out.println(q)); Stream<String> date = multiAwardedFilm(loadData); // date.forEach(l -> System.out.println(l)); } @Override public int getYear() { return getYear; } @Override public int getWinnerAge() { return getWinnerAge; } @Override public String getWinnerName() { return getWinnerName; } @Override public String getFilmTitle() { return getFilmTitle; } }
0debug
gnu make - Ignore clean command in Makefile : I have a project to compile with a lot of makefiles including a clean command. That's why i always have to start over again if there is an error. Question: Is there any possibility to tell make to ignore the clean command? I would have to touch > 100 Makefiles otherwise. I would like make to start on the last error, not compiling all done stuff again
0debug
void decode_mb_coeffs(VP8Context *s, VP8ThreadData *td, VP56RangeCoder *c, VP8Macroblock *mb, uint8_t t_nnz[9], uint8_t l_nnz[9]) { int i, x, y, luma_start = 0, luma_ctx = 3; int nnz_pred, nnz, nnz_total = 0; int segment = mb->segment; int block_dc = 0; if (mb->mode != MODE_I4x4 && mb->mode != VP8_MVMODE_SPLIT) { nnz_pred = t_nnz[8] + l_nnz[8]; nnz = decode_block_coeffs(c, td->block_dc, s->prob->token[1], 0, nnz_pred, s->qmat[segment].luma_dc_qmul); l_nnz[8] = t_nnz[8] = !!nnz; if (nnz) { nnz_total += nnz; block_dc = 1; if (nnz == 1) s->vp8dsp.vp8_luma_dc_wht_dc(td->block, td->block_dc); else s->vp8dsp.vp8_luma_dc_wht(td->block, td->block_dc); } luma_start = 1; luma_ctx = 0; } for (y = 0; y < 4; y++) for (x = 0; x < 4; x++) { nnz_pred = l_nnz[y] + t_nnz[x]; nnz = decode_block_coeffs(c, td->block[y][x], s->prob->token[luma_ctx], luma_start, nnz_pred, s->qmat[segment].luma_qmul); td->non_zero_count_cache[y][x] = nnz + block_dc; t_nnz[x] = l_nnz[y] = !!nnz; nnz_total += nnz; } for (i = 4; i < 6; i++) for (y = 0; y < 2; y++) for (x = 0; x < 2; x++) { nnz_pred = l_nnz[i + 2 * y] + t_nnz[i + 2 * x]; nnz = decode_block_coeffs(c, td->block[i][(y << 1) + x], s->prob->token[2], 0, nnz_pred, s->qmat[segment].chroma_qmul); td->non_zero_count_cache[i][(y << 1) + x] = nnz; t_nnz[i + 2 * x] = l_nnz[i + 2 * y] = !!nnz; nnz_total += nnz; } if (!nnz_total) mb->skip = 1; }
1threat
What does character "^" do in Excel? : <p>I have a formula in Excel like this <code>D484/(1+$J$6)^B484</code>.</p> <p>What is <code>^</code> doing in this formula?</p>
0debug
static uint32_t dp8393x_readl(void *opaque, target_phys_addr_t addr) { uint32_t v; v = dp8393x_readw(opaque, addr); v |= dp8393x_readw(opaque, addr + 2) << 16; return v; }
1threat
void qemu_add_balloon_handler(QEMUBalloonEvent *func, void *opaque) { balloon_event_fn = func; balloon_opaque = opaque; }
1threat
def check(arr,n): g = 0 for i in range(1,n): if (arr[i] - arr[i - 1] > 0 and g == 1): return False if (arr[i] - arr[i] < 0): g = 1 return True
0debug
Does GraphQL obviate Data Transfer Objects? : <p>To my understanding, <a href="https://martinfowler.com/eaaCatalog/dataTransferObject.html" rel="noreferrer">Data Transfer Objects</a> (DTOs) are typically smallish, flattish, behavior-less, serializable objects whose main advantage is ease of transport across networks. </p> <p>GraphQL has the following facets: </p> <ul> <li>encourages serving <a href="https://graphql.org/learn/thinking-in-graphs/" rel="noreferrer">rich object graphs</a>, which (in my head anyway) contradicts the "flattish" portion of DTOs, </li> <li>lets clients <a href="https://graphql.org/learn/queries/" rel="noreferrer">choose exactly the data they want</a>, which addresses the "smallish" portion,</li> <li>returns <a href="http://graphql.org/learn/schema/" rel="noreferrer">JSON-esque objects</a>, which addresses the "behavior-less" and "serializable" portions</li> </ul> <p><strong>Do GraphQL and the DTO pattern mutually exclude one another?</strong></p> <p>Here's what led to this question: We envision a microservices architecture with a gateway. I'm designing one API to fit into that architecture that will serve (among other things) <a href="https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.types.sqlgeometry.aspx" rel="noreferrer">geometries</a>. In many (likely most) cases the geometries will not be useful to client applications, but they'll be critical in others so they must be served. However they're serialized, geometries can be big so giving clients the option to decline them can save lots of bandwidth. RESTful APIs that I've seen handling geometries do that by providing a <a href="https://developers.arcgis.com/rest/services-reference/query-feature-service-.htm" rel="noreferrer">"returnGeometry" parameter</a> in the query string. I never felt entirely comfortable with that approach, and I initially envisioned serving a reasonably deep set of related/nested return objects many of which clients will elect to decline. All of that led me to consider a GraphQL interface. As the design has progressed, I've started considering flattening the output (either entirely or partially), which led me to consider the DTO pattern. So now I'm wondering if it would be best to flatten everything into DTOs and skip GraphQL (in favor of REST, I suppose?). I've considered a middle ground with DTOs served using GraphQL to let clients pick and choose the attributes they want on them, but I'm wondering if that's mixing patterns &amp; technologies inappropriately.</p>
0debug
C# asp.net5 make a link to download PDF file : I make a link that download the PDF file When click on the Link. Here is my .cshtml: <html> <body> <h1>Hello Shuainan</h1> <a href="/Account/PdfDownload">download</a> <input type="button" value="Download" onClick="download('test.pdf')" /> <script> function download(file) { window.location = file; } </script> </body> </html> and the download function is : public void PdfDownload(string path, string fileName) { var myPDF = System.IO.File.ReadAllBytes(@"C:\Program Files\wkhtmltopdf\bin\myPDF.pdf"); Response.ContentType = "Application/pdf"; Response.Headers.Add("Content-Disposition", "attachment; filename=testPDF.pdf"); Response.Body.Write(myPDF, 0, 2048); } And the I cant LOAD the PDF file when finish the download , PLS help me with that. Ty for advance.
0debug
How to import data from a JSON into a Discord Bot Embed message? : I'm a complete dummy, trying to code a Discord.js bot without any prior coding knowledge. I'm trying to learn as I go. So, the project we are trying to make is a bot that will reply with a discord embed message. It's discord for an online game, where there are multiple different characters. Each of them have unique stats, skills and type. So the idea is to fill a JSON with all the information on all units, then have people use .unitname and have the bot reply with an embed will all information about that unit. This is how it should look like: https://i.imgur.com/Uc4F3En.png (sorry, I can't post images). First of all, adding dozens of different commands for every single unit doesn't seem right, so I'm having the bot check every single message for a potential unit request. This does sounds pretty unoptimized for me, but will it slow down the bot in practice? And how would I code it to recognize something as .OneOfDozensOfPossibleUnits? Maybe I could have a separate list with all unit names, and have it trigger at .AnyOfThose, but is that the optimal way to do it? Let's say the bot recognizes .Lucius as a unit request. He will have to look into the JSON file with dozens of units and gather data from Lucius specifically. How do I do that? Then I would have data saved, like stats, for example. Those would have to go in the places I called "variable" (check the code), but what's the syntax for that? I would also like to add some extra "if"s (for example, if unit type = "defense", make the color blue). This one I can probably search and find the syntax for, but I'd be really glad if you could include it. Sorry, this is such a "do the work for me, please" post, but it can't be helped, haha. I would usually take my time and learn everything bit by bit, but since this is a community project, I'm going blind into a lot of areas. Please let me know if you have any other tips or if you found potential flaws in the program. Thank you in advance! ``` client.on('message', message => { if (message.content === '.' + "unit") { const embed = new Discord.RichEmbed() .setAuthor("Author", "https://lh3.googleusercontent.com/rA0lKRGI_-bP-Jj4nkVc5lm6WJfO3nYlAz089otvQnLeevIoao1CTvaU0l0dqnnWIvLZTSOTaEwj6W04IZSRHQz3NYWiePtJnW3bANh54aI=w120") .setColor(0xFF0000) .addField("<:stats:545991150486421514> Stats", "⧫ ATK: " + "variable" + "\r\n ⧫ HP: " + "variable" + "\r\n ⧫ DEF: " + "variable", true) .addField("\u200B", "⧫ CRIT RATE: " + "variable" + "\r\n ⧫ CRIT DMG: " + "variable" + "\r\n ⧫ AGI: " + "variable", true) .addField("<:skills:545991578355761152> Skills", "Skill descriptions") .setImage("https://lh3.googleusercontent.com/rA0lKRGI_-bP-Jj4nkVc5lm6WJfO3nYlAz089otvQnLeevIoao1CTvaU0l0dqnnWIvLZTSOTaEwj6W04IZSRHQz3NYWiePtJnW3bANh54aI=w120", 2, 2) .setThumbnail("https://lh3.googleusercontent.com/rA0lKRGI_-bP-Jj4nkVc5lm6WJfO3nYlAz089otvQnLeevIoao1CTvaU0l0dqnnWIvLZTSOTaEwj6W04IZSRHQz3NYWiePtJnW3bANh54aI=w120") .setFooter("Footer", "https://lh3.googleusercontent.com/rA0lKRGI_-bP-Jj4nkVc5lm6WJfO3nYlAz089otvQnLeevIoao1CTvaU0l0dqnnWIvLZTSOTaEwj6W04IZSRHQz3NYWiePtJnW3bANh54aI=w120"); message.channel.send(embed); ```
0debug