problem
stringlengths
26
131k
labels
class label
2 classes
PHP array merge values from one array into another : <p>Sorry I have read so many posts to make sense of this and have finally confused myself!</p> <p>I have 2 arrays:</p> <p>Array 1:</p> <pre><code>Array ( [0] =&gt; Array ( [ID] =&gt; SI012348 [Date] =&gt; 06/01/2016 [Month] =&gt; 1 [Tier1] =&gt; 2.188875 [Tier2] =&gt; [Tier3] =&gt; [Tier4] =&gt; [Delivery] =&gt; 0 ) [1] =&gt; Array ( [ID] =&gt; SI012351 [Date] =&gt; 06/01/2016 [Month] =&gt; 1 [Tier1] =&gt; 2.139 [Tier2] =&gt; 0 [Tier3] =&gt; 0 [Tier4] =&gt; 0 [Delivery] =&gt; 0 ) [2] =&gt; Array ( [ID] =&gt; SI012387 [Date] =&gt; 14/01/2016 [Month] =&gt; 1 [Tier1] =&gt; 0.201 [Tier2] =&gt; 0 [Tier3] =&gt; 0 [Tier4] =&gt; 0 [Delivery] =&gt; 0 ) ) </code></pre> <p>Array 2: (Contains all invoices with Delivery charges)</p> <pre><code>Array ( [SI000005] =&gt; 25 [SI000010] =&gt; 15 [SI000054] =&gt; 20 [SI000069] =&gt; 0 [SI000074] =&gt; 20 [SI000076] =&gt; 16 ) </code></pre> <p>I need to update Array 1 where SI00000x matches and push the value from Array 2 into the [Delivery] value in Array 1.</p> <p>I am sure this is straightforward but everything I try either takes an age or crashes!</p> <p>Please help! </p>
0debug
bool qemu_signalfd_available(void) { #ifdef CONFIG_SIGNALFD errno = 0; syscall(SYS_signalfd, -1, NULL, _NSIG / 8); return errno != ENOSYS; #else return false; #endif }
1threat
static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW) { int i; for(i=0; i<dstW; i++) { int val=1<<18; int j; for(j=0; j<lumFilterSize; j++) val += lumSrc[j][i] * lumFilter[j]; dest[i]= av_clip_uint8(val>>19); } if(uDest != NULL) for(i=0; i<chrDstW; i++) { int u=1<<18; int v=1<<18; int j; for(j=0; j<chrFilterSize; j++) { u += chrSrc[j][i] * chrFilter[j]; v += chrSrc[j][i + 2048] * chrFilter[j]; } uDest[i]= av_clip_uint8(u>>19); vDest[i]= av_clip_uint8(v>>19); } }
1threat
Java: How to make a 2D array of a particular object : <p>I have the following class in Java:</p> <pre><code>public class Cell { private int x; private int y; private int g; private int h; public Cell(int x, int y, int g, int h) { this.x = x; this.y = y; this.g = g; this.h = h; } } </code></pre> <p>I want to make a 2D array with each element of the array being of type Cell. However, I am not sure what is the best way to go about doing this. Any insights are appreciated.</p>
0debug
need help to solve stock market puzzle in java for max profit : need max profit. what i can modify to get the max profit if i can only buy once and sell once. means if i buy at 5 and sell at 150 then its max profit. Currently what is have done is buy when price is less than next day ,and sell if price is more than next day. as obvious We have to keep in mind we can sell only after we buy, means sell index can not be before buy index. what i have done so far is : package com; public class Stock { public static void main(String[] args) { int[] prices = {20,10,70,80,5,150,67}; int length = prices.length-2; int buy=0; int sell=0; int buyIndex=-1; int sellIndex=-1; int i=0; for (i =0 ; i<=length ;i++ ){ // buy logic start if(prices[i]<prices[i+1]){ if(i>buyIndex){ buy= prices[i]; buyIndex=i; System.out.println("buy"+buy); System.out.println("buyIndex"+buyIndex); } } // buy logic finish // sell logic start if(buy!=0 && i>buyIndex ){ System.out.println("inside sell logic"); if(prices[i]>prices[i+1]){ sell = prices[i]; sellIndex = i; System.out.println("sell"+sell); System.out.println("sellIndex"+sellIndex); } } // sell logic end } // for loop end } // main end } out put is buy10 buyIndex1 buy70 buyIndex2 inside sell logic sell80 sellIndex3 buy5 buyIndex4 inside sell logic sell150 sellIndex5 Please help.
0debug
How to get the value of a Django Model Field object : <p>I got a model field object using <code>field_object = MyModel._meta.get_field(field_name)</code>. How can I get the value (content) of the field object?</p>
0debug
void do_mullwo (void) { int64_t res = (int64_t)Ts0 * (int64_t)Ts1; if (likely((int32_t)res == res)) { xer_ov = 0; } else { xer_ov = 1; xer_so = 1; } T0 = (int32_t)res; }
1threat
static int aasc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AascContext *s = avctx->priv_data; int compr, i, stride, ret; if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } compr = AV_RL32(buf); buf += 4; buf_size -= 4; switch (compr) { case 0: stride = (avctx->width * 3 + 3) & ~3; if (buf_size < stride * avctx->height) for (i = avctx->height - 1; i >= 0; i--) { memcpy(s->frame->data[0] + i * s->frame->linesize[0], buf, avctx->width * 3); buf += stride; } break; case 1: bytestream2_init(&s->gb, buf, buf_size); ff_msrle_decode(avctx, (AVPicture*)s->frame, 8, &s->gb); break; default: av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr); } *got_frame = 1; if ((ret = av_frame_ref(data, s->frame)) < 0) return ret; return buf_size; }
1threat
I am not able to access this filename [{"filename":"54526108_1946746692102415_4003062236024143872_n.jpg"}] : <p>I have tried console.log(filename.filename); but it is not working.</p> <p>[{"filename":"54526108_1946746692102415_4003062236024143872_n.jpg"}]</p>
0debug
How can i solve align mistakes? : Here i have a my website, in the specific this is the user page. Now, the problem is that the header elements and other, are not align in the same row. Here is what i mean: https://www.dropbox.com/s/oigfuevo9thf8cn/Immagine.png?dl=0 how can i solve? here is the html and css code: html: <?php session_start(); if(!isset($_SESSION['user'])){ header('Location: TESlogin.php'); } else{ ?> <!DOCTYPE html> <html> <head> <title>myTES</title> <link href="myTES_style.css" rel="stylesheet" type="text/css"> <link rel="shortcut icon" href="tes-ico(1).ico" /> </head> <body> <div id="mySidenav" class="sidenav"> <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">& times;</a> <a href="#">Home</a> <a href="#">I miei consumi</a> <a href="#">Il mio conto</a><br> <a href="logout.php">Esci</a> </div> <div id = "main"> <div class="header"> <p id = "p1">My<b>TES</b></p> &nbsp; &nbsp; <p id = "p-left" ><span style="font-size:20px; cursor:pointer;" onclick="openNav()">&#9776; </span></p> </div> <div id="pmain"> &nbsp; &nbsp; Ciao <b><?= $_SESSION['nome'] ?></b> &nbsp; <i class="right"></i> </div> <hr> <p align = "center"> il mio abbonamento &nbsp; <i class="down"></i></p> <hr> </div> <!----- script in javascript per effetto comparsa laterale menu -----> <script> function openNav() { document.getElementById("mySidenav").style.width = "250px"; document.getElementById("main").style.marginLeft = "250px"; } function closeNav() { document.getElementById("mySidenav").style.width = "0"; document.getElementById("main").style.marginLeft= "0"; } </script> </body> </html> <?php } ?> CSS: @font-face{ src: url(font/Montserrat-ExtraLight.ttf); font-family: montserratblack; } html, body{ display: inline-block; /* Serve a far collassare i magini dei contenuti adiacenti ai limiti del body, i quali influirebbero altrimenti sullo stesso body */ position: relative; /* Blocca il riferimento dei contenuti con position absolute anche durante lo scroll della pagina */ width: 100%; /* Con inline-block la larghezza è relativa ai contenuti, quindi è necessario estenderla per l'intera larghezza della finestra */ min-height: 100%; /* Estende l'altezza del body per tutta la finestra anche se ci sono pochi contenuti, evitando che in tal caso il .footer si porti in mezzo alla pagina */ margin: 0; /* Rimuove i margini di default per ottenere un corretto dimensionamento */ padding: 0; font-family: montserratblack; font-size: 20px; } .header{ width: 100%; background-color: grey; overflow: hidden; } #pmain{ display: inline-block; } #p-left{ float: left; display: inline; margin: 0 0 0 20px; } #p1{ text-align: center; color: white; font-size: 20px; } #p2{ float: right; } i { border: solid black; border-width: 0 2px 2px 0; display: inline-block; padding: 3px; } .down { transform: rotate(45deg); -webkit-transform: rotate(45deg); } /* barra a comparsa dal lato sinistro */ .sidenav { height: 100%; width: 0; position: fixed; z-index: 1; top: 0; left: 0; background-color: #111; overflow-x: hidden; transition: 0.5s; padding-top: 60px; } .sidenav a { padding: 8px 8px 8px 32px; text-decoration: none; font-size: 25px; color: #818181; display: block; transition: 0.3s; } .sidenav a:hover { color: #f1f1f1; } .sidenav .closebtn { position: absolute; top: 0; right: 25px; font-size: 36px; margin-left: 50px; } #main { transition: margin-left .5s; /*padding: 16px;*/ } @media screen and (max-height: 450px) { .sidenav {padding-top: 15px;} .sidenav a {font-size: 18px;} } i try in every way, but nothing. What can i do? thanks.
0debug
static int movie_push_frame(AVFilterContext *ctx, unsigned out_id) { MovieContext *movie = ctx->priv; AVPacket *pkt = &movie->pkt; enum AVMediaType frame_type; MovieStream *st; int ret, got_frame = 0, pkt_out_id; AVFilterLink *outlink; if (!pkt->size) { if (movie->eof) { if (movie->st[out_id].done) { if (movie->loop_count != 1) { ret = rewind_file(ctx); if (ret < 0) return ret; movie->loop_count -= movie->loop_count > 1; av_log(ctx, AV_LOG_VERBOSE, "Stream finished, looping.\n"); return 0; } return AVERROR_EOF; } pkt->stream_index = movie->st[out_id].st->index; } else { ret = av_read_frame(movie->format_ctx, &movie->pkt0); if (ret < 0) { av_init_packet(&movie->pkt0); *pkt = movie->pkt0; if (ret == AVERROR_EOF) { movie->eof = 1; return 0; } return ret; } *pkt = movie->pkt0; } } pkt_out_id = pkt->stream_index > movie->max_stream_index ? -1 : movie->out_index[pkt->stream_index]; if (pkt_out_id < 0) { av_free_packet(&movie->pkt0); pkt->size = 0; pkt->data = NULL; return 0; } st = &movie->st[pkt_out_id]; outlink = ctx->outputs[pkt_out_id]; movie->frame = av_frame_alloc(); if (!movie->frame) return AVERROR(ENOMEM); frame_type = st->st->codec->codec_type; switch (frame_type) { case AVMEDIA_TYPE_VIDEO: ret = avcodec_decode_video2(st->st->codec, movie->frame, &got_frame, pkt); break; case AVMEDIA_TYPE_AUDIO: ret = avcodec_decode_audio4(st->st->codec, movie->frame, &got_frame, pkt); break; default: ret = AVERROR(ENOSYS); break; } if (ret < 0) { av_log(ctx, AV_LOG_WARNING, "Decode error: %s\n", av_err2str(ret)); av_frame_free(&movie->frame); av_free_packet(&movie->pkt0); movie->pkt.size = 0; movie->pkt.data = NULL; return 0; } if (!ret || st->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) ret = pkt->size; pkt->data += ret; pkt->size -= ret; if (pkt->size <= 0) { av_free_packet(&movie->pkt0); pkt->size = 0; pkt->data = NULL; } if (!got_frame) { if (!ret) st->done = 1; av_frame_free(&movie->frame); return 0; } movie->frame->pts = av_frame_get_best_effort_timestamp(movie->frame); av_dlog(ctx, "movie_push_frame(): file:'%s' %s\n", movie->file_name, describe_frame_to_str((char[1024]){0}, 1024, movie->frame, frame_type, outlink)); if (st->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (movie->frame->format != outlink->format) { av_log(ctx, AV_LOG_ERROR, "Format changed %s -> %s, discarding frame\n", av_get_pix_fmt_name(outlink->format), av_get_pix_fmt_name(movie->frame->format) ); av_frame_free(&movie->frame); return 0; } } ret = ff_filter_frame(outlink, movie->frame); movie->frame = NULL; if (ret < 0) return ret; return pkt_out_id == out_id; }
1threat
How do you jump to the first commit in git? : <p>How can I jump to the first every commit in a git repository? Also, is there a way to do it on Github through the website?</p>
0debug
Tag for dynamic view of UIButtons : I found this example of a dynamic view of UIButtons at: http://helpmecodeswift.com/advanced-functions/generating-uibuttons-loop I insert this code into my app but unfortunately I can't find a way to set a tag for each Button. <br/>My target is to know which button is tapped, count the amount of clicks for each button and save this information into my DB. override func viewDidLoad() { super.viewDidLoad() var arrayOfVillains = ["santa", "bugs", "superman", "batman"] var buttonY: CGFloat = 20 for villain in arrayOfVillains { let villainButton = UIButton(frame: CGRect(x: 50, y: buttonY, width: 250, height: 30)) buttonY = buttonY + 50 // we are going to space these UIButtons 50px apart villainButton.layer.cornerRadius = 10 // get some fancy pantsy rounding villainButton.backgroundColor = UIColor.darkGrayColor() villainButton.setTitle("Button for Villain: \(villain)", forState: UIControlState.Normal) // We are going to use the item name as the Button Title here. villainButton.titleLabel?.text = "\(villain)" villainButton.addTarget(self, action: "villainButtonPressed:", forControlEvents: UIControlEvents.TouchUpInside) self.view.addSubview(villainButton) // myView in this case is the view you want these buttons added } } func villainButtonPressed(sender:UIButton!) { if sender.titleLabel?.text != nil { println("You have chosen Villain: \(sender.titleLabel?.text)") } else { println("Nowhere to go :/") } } } So how it is possible to set and get the tag for/from each button in code(in this example)? Thank you in advance!
0debug
SKErrorDomain Code=0 "Cannot connect to iTunes Store" in IAP iOS Objective c : <p>when i tested IAP for my app, it throws following error</p> <pre><code>Error Domain=SKErrorDomain Code=0 "Cannot connect to iTunes Store" UserInfo={NSLocalizedDescription=Cannot connect to iTunes Store} </code></pre> <p>i have tried many links related to this problem but nothing helped. Moreover the "Product Identifier" are also correct and i also created new sandbox user, but no output. Any help would be great.</p>
0debug
My js script is not working properly : <p>I want to have a result based on grading set by my script. But it's not giving me the result as expected. It's not doing anything in fact. </p> <p>Below is the code:</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; function rateMe() { var a = ""; var x = document.getElementById("id1").value; if (x &lt; 10) {a = "Bad";} if (x &lt; 50) {a = "Average";} if (x &lt; 75) {a = "Good";} if (x &lt; 100) {a = "Best";} var y = document.getElementById("id2") + a; } y; &lt;/script&gt;</code></pre> </div> </div> </p>
0debug
Using basic Flask vs Flask-RESTful for API development : <p>I'm about to develop a REST API for our upcoming application. I have decided to use Python Flask for it. But at this point, I don't know which option to use. Should I be using the basic Flask package or Flask with Flask-RESTful extension. I've found some advantages and disadvantages in both. </p> <p>Below is an example of two APIs doing the same thing but in Flask and Flask-RESTful:</p> <p><strong>Flask version</strong>:</p> <pre><code>from flask import Flask, jsonify app = Flask(__name__) usersList = ['Aaron', 'Bianca', 'Cat', 'Danny', 'Elena'] @app.route('/users', methods=['GET']) def users(): return jsonify({ 'users': [user for user in usersList] }) @app.route('/user/&lt;int:id&gt;', methods=['GET']) def userById(id): return jsonify({ 'username': usersList[id] }) @app.route('/user/&lt;string:name&gt;', methods=['GET']) def getUserByName(name): # Show some user information return "Some info" @app.route('/user/&lt;string:name&gt;', methods=['POST']) def addUserByName(name): usersList.append(name) return jsonify({ 'message': 'New user added' }) app.run() </code></pre> <p><strong>Flask-RESTful version</strong>:</p> <pre><code>from flask import Flask from flask_restful import Resource, Api app = Flask(__name__) api = Api(app) usersList = ['Aaron', 'Bianca', 'Cat', 'Danny', 'Elena'] class UsersList(Resource): def get(self): return { 'users' : [ user for user in usersList ] }, 200 class UserById(Resource): def get(self, id): return { 'username': usersList[id] } class UserByName(Resource): def post(self, name): usersList.append(name) return { 'message': 'New user added'} api.add_resource(UsersList, '/users') api.add_resource(UserById, '/user/&lt;int:id&gt;') api.add_resource(UserByName, '/user/&lt;string:name&gt;') app.run() </code></pre> <p>Using Flask-RESTful, I cannot get a single resource to serve multiple related endpoints like <code>GET /user/&lt;int:id&gt;</code>, <code>GET /user/&lt;string:name&gt;</code>, <code>GET /user/&lt;int:id&gt;/friends</code> etc. And I don't know if creating new classes for simple sub-resources is a good practice because I'll probably end up with many classes. Due to this reason, I'm more inclined towards using just Flask since only functions are defined and the endpoints can be freely defined as per my needs. </p> <p>Keeping the above in mind, is it okay to create many classes for sub-resources in Flask-RESTful? Or am I better of using Flask? Or Flask-RESTful provides some really good advantages over Flask?</p>
0debug
Python - How to convert JSON File to Dataframe : <p>How can I convert a JSON File as such into a dataframe to do some transformations.</p> <p>For Example if the JSON file reads:</p> <pre><code>{"FirstName":"John", "LastName":"Mark", "MiddleName":"Lewis", "username":"johnlewis2", "password":"2910"} </code></pre> <p>How can I convert it to a table like such</p> <pre><code>Column -&gt; FirstName | LastName | MiddleName | username | password Row -----&gt; John | Mark |Lewis | johnlewis2 |2910 </code></pre>
0debug
static int ppc_hash32_get_physical_address(CPUPPCState *env, struct mmu_ctx_hash32 *ctx, target_ulong eaddr, int rw, int access_type) { bool real_mode = (access_type == ACCESS_CODE && msr_ir == 0) || (access_type != ACCESS_CODE && msr_dr == 0); if (real_mode) { ctx->raddr = eaddr; ctx->prot = PAGE_READ | PAGE_EXEC | PAGE_WRITE; return 0; } else { int ret = -1; if (env->nb_BATs != 0) { ret = ppc_hash32_get_bat(env, ctx, eaddr, rw, access_type); } if (ret < 0) { ret = get_segment32(env, ctx, eaddr, rw, access_type); } return ret; } }
1threat
target_ulong helper_evpe(target_ulong arg1) { arg1 = 0; return arg1; }
1threat
Special characters in GraphQL schema : <p>Is there any way of enabling special characters in GraphQL schema (e.g., <code>/</code>, <code>:</code>, <code>@</code> in the field names)? </p> <p>And if there isn't (which I suspect is the case) do you have an idea what would be relatively easiest way to modify the node.js code (<a href="https://github.com/graphql/graphql-js" rel="noreferrer">https://github.com/graphql/graphql-js</a>) to achieve such functionality? </p>
0debug
static int sd_open(BlockDriverState *bs, const char *filename, int flags) { int ret, fd; uint32_t vid = 0; BDRVSheepdogState *s = bs->opaque; char vdi[SD_MAX_VDI_LEN], tag[SD_MAX_VDI_TAG_LEN]; uint32_t snapid; char *buf = NULL; strstart(filename, "sheepdog:", (const char **)&filename); QLIST_INIT(&s->inflight_aio_head); QLIST_INIT(&s->pending_aio_head); s->fd = -1; memset(vdi, 0, sizeof(vdi)); memset(tag, 0, sizeof(tag)); if (parse_vdiname(s, filename, vdi, &snapid, tag) < 0) { ret = -EINVAL; goto out; } s->fd = get_sheep_fd(s); if (s->fd < 0) { ret = s->fd; goto out; } ret = find_vdi_name(s, vdi, snapid, tag, &vid, 0); if (ret) { goto out; } s->cache_enabled = 1; s->flush_fd = connect_to_sdog(s->addr, s->port); if (s->flush_fd < 0) { error_report("failed to connect"); ret = s->flush_fd; goto out; } if (snapid || tag[0] != '\0') { dprintf("%" PRIx32 " snapshot inode was open.\n", vid); s->is_snapshot = 1; } fd = connect_to_sdog(s->addr, s->port); if (fd < 0) { error_report("failed to connect"); ret = fd; goto out; } buf = g_malloc(SD_INODE_SIZE); ret = read_object(fd, buf, vid_to_vdi_oid(vid), 0, SD_INODE_SIZE, 0, s->cache_enabled); closesocket(fd); if (ret) { goto out; } memcpy(&s->inode, buf, sizeof(s->inode)); s->min_dirty_data_idx = UINT32_MAX; s->max_dirty_data_idx = 0; bs->total_sectors = s->inode.vdi_size / SECTOR_SIZE; strncpy(s->name, vdi, sizeof(s->name)); qemu_co_mutex_init(&s->lock); g_free(buf); return 0; out: qemu_aio_set_fd_handler(s->fd, NULL, NULL, NULL, NULL); if (s->fd >= 0) { closesocket(s->fd); } g_free(buf); return ret; }
1threat
Eliminate the white body border : <p><a href="http://i.stack.imgur.com/dixSV.png" rel="nofollow">Web Page</a></p> <p>In the above web page photo I have taken a <code>&lt;div&gt;</code> with <code>height : 100vh;</code> and <code>width : 100%;</code></p> <p>I don't want the white body border.</p> <p>Someone please help !!!</p>
0debug
How to get assembly instructions or mnemonics from the opcode/machine code? : <p>I have a binary file compiled using gcc of a simple c program. I'm writing my own dis-assembler, I able to read ELF header and other header from ELF files.</p> <p>I'm reading ".text"section from ELF binary file. And trying to convert the opecode into mnemonics/assembly instruction.</p> <p>How to convert raw opcode/machine code into mnemonics/assembly instruction?? C source code is: </p> <pre><code>#include &lt;stdio.h&gt; int main() { int i = 10; int j = 22 + i; return 0; } </code></pre> <p>Following is the example of raw opcode i have received after reading ELF file:</p> <pre><code>55 ffffff89 ffffffe5 ffffff83 ffffffec 20 ffffffc7 45 ffffffec 3 ffffffc7 45 fffffff0 41 ffffffc7 45 fffffff4 8 ffffffc7 45 fffffff8 21 ffffff8b 45 ffffffec ffffff83 ffffffc0 16 ffffff89 45 fffffffc ffffffb8 ffffffc9 ffffffc3 </code></pre>
0debug
in androidx.fragment.app.Fragment,setUserVisibleHint()is Deprecated,and not executed,why? : <pre><code>@Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); if (getUserVisibleHint()) { isVisible = true; onVisible(); } else { isVisible = false; onInVisible(); } } </code></pre> <p>I found that this part of the code is not executed.</p>
0debug
int ff_h264_decode_ref_pic_list_reordering(H264Context *h){ int list, index, pic_structure, i; print_short_term(h); print_long_term(h); for(list=0; list<h->list_count; list++){ for (i = 0; i < h->ref_count[list]; i++) COPY_PICTURE(&h->ref_list[list][i], &h->default_ref_list[list][i]); if(get_bits1(&h->gb)){ int pred= h->curr_pic_num; for(index=0; ; index++){ unsigned int reordering_of_pic_nums_idc= get_ue_golomb_31(&h->gb); unsigned int pic_id; int i; Picture *ref = NULL; if(reordering_of_pic_nums_idc==3) break; if(index >= h->ref_count[list]){ av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n"); return -1; } if(reordering_of_pic_nums_idc<3){ if(reordering_of_pic_nums_idc<2){ const unsigned int abs_diff_pic_num= get_ue_golomb(&h->gb) + 1; int frame_num; if(abs_diff_pic_num > h->max_pic_num){ av_log(h->avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n"); return -1; } if(reordering_of_pic_nums_idc == 0) pred-= abs_diff_pic_num; else pred+= abs_diff_pic_num; pred &= h->max_pic_num - 1; frame_num = pic_num_extract(h, pred, &pic_structure); for(i= h->short_ref_count-1; i>=0; i--){ ref = h->short_ref[i]; assert(ref->reference); assert(!ref->long_ref); if( ref->frame_num == frame_num && (ref->reference & pic_structure) ) break; } if(i>=0) ref->pic_id= pred; }else{ int long_idx; pic_id= get_ue_golomb(&h->gb); long_idx= pic_num_extract(h, pic_id, &pic_structure); if(long_idx>31){ av_log(h->avctx, AV_LOG_ERROR, "long_term_pic_idx overflow\n"); return -1; } ref = h->long_ref[long_idx]; assert(!(ref && !ref->reference)); if (ref && (ref->reference & pic_structure)) { ref->pic_id= pic_id; assert(ref->long_ref); i=0; }else{ i=-1; } } if (i < 0) { av_log(h->avctx, AV_LOG_ERROR, "reference picture missing during reorder\n"); memset(&h->ref_list[list][index], 0, sizeof(Picture)); } else { for(i=index; i+1<h->ref_count[list]; i++){ if(ref->long_ref == h->ref_list[list][i].long_ref && ref->pic_id == h->ref_list[list][i].pic_id) break; } for(; i > index; i--){ COPY_PICTURE(&h->ref_list[list][i], &h->ref_list[list][i - 1]); } COPY_PICTURE(&h->ref_list[list][index], ref); if (FIELD_PICTURE){ pic_as_field(&h->ref_list[list][index], pic_structure); } } }else{ av_log(h->avctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc\n"); return -1; } } } } for(list=0; list<h->list_count; list++){ for(index= 0; index < h->ref_count[list]; index++){ if (!h->ref_list[list][index].f.data[0]) { int i; av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc); for (i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++) h->last_pocs[i] = INT_MIN; if (h->default_ref_list[list][0].f.data[0]) COPY_PICTURE(&h->ref_list[list][index], &h->default_ref_list[list][0]); else return -1; } } } return 0; }
1threat
Laravel - Lock wait timeout exceeded : <p>I have a lot of transactions in my code, and if an error occurs in executing in one of these transactions that doesn't trigger commit or rollback, then the database is locked and any subsequent attempts to access the database results in this:</p> <p><code>production.ERROR: PDOException: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction in /home/forge/default/vendor/laravel/framework/src/Illuminate/Database/Connection.php:390 </code></p> <p>In the Controller:</p> <pre><code>DB::beginTransaction(); try { //Code that uses exec() to process some images. &lt;-- If code breaks here, then the above error appears on subsequent requests. //Code that accesses the database } catch(\Exception $e){ DB::rollback(); throw $e; } DB::commit(); </code></pre> <p>So even php artisan migrate:refresh or php artisan migrate:reset stops working as well. How should I go about fixing this?</p>
0debug
Send HTTP POST message in ASP.NET Core using HttpClient PostAsJsonAsync : <p>I want to send dynamic object like</p> <pre><code>new { x = 1, y = 2 }; </code></pre> <p>as body of HTTP POST message. So I try to write</p> <pre><code>var client = new HttpClient(); </code></pre> <p>but I can't find method </p> <pre><code>client.PostAsJsonAsync() </code></pre> <p>So I tried to add Microsoft.AspNetCore.Http.Extensions package to project.json and add </p> <pre><code>using Microsoft.AspNetCore.Http.Extensions; </code></pre> <p>to uses clause. However It didn't help me.</p> <p>So what is the easiest way to send POST request with JSON body in ASP.NET Core?</p>
0debug
i m try to make the date to be concise,but i m try so many method,it doesn't work : **i m try many method to solve this data,but it can't work ,strip() and replace method looks like the picture one,it doesn't work,please help me ,online waiting** import requests from lxml import html,etree from selenium import webdriver import time, json file_name = 'dubanxinlixue.json' driver = webdriver.Chrome() url_string = [] name_data, price_data = [], [] jd_goods_data = {} page = 0 while True: url = 'https://book.douban.com/tag/%E5%BF%83%E7%90%86%E5%AD%A6?start={page}&type=S'.format(page=page) url_string.append(url) page += 20 if page > 980: break for i in url_string: driver.get(i) base_html = driver.page_source selctor = etree.HTML(base_html) j = 1 for j in range(20): j += 1 name = '//*[@id="subject_list"]/ul/li[%d]/div[2]/h2/a[1]/@title'%(j) get_name =selctor.xpath(name)[0] describe = '//*[@id="subject_list"]/ul/li[%d]/div[2]/div[1]/text()'%(j) get_describe = selctor.xpath(describe)[0] describe.replace('\t\r\n\f', '') print(get_describe) with open(file_name, 'w') as f: json.dump(jd_goods_data, f) the get_describe looks like this ,[the result of get_describe][1] [1]: https://i.stack.imgur.com/f3O2F.png
0debug
Font-Awesome 5 - CSS Pseudo-elements, how to mirror/rotate icon : <p>I am using css pseudo elements to render icons (<a href="http://jsfiddle.net/4Rakx/4633/" rel="nofollow noreferrer">jsfiddle</a>)</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-css lang-css prettyprint-override"><code>body { font-family: Arial; font-size: 13px; } a { text-decoration: none; color: #515151; } a:before { font-family: "Font Awesome 5 Free"; content: "\f07a"; display: inline-block; padding-right: 3px; vertical-align: middle; font-weight:900; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://use.fontawesome.com/releases/v5.4.1/css/all.css" rel="stylesheet"/&gt; &lt;a href="#"&gt;This is a link&lt;/a&gt;</code></pre> </div> </div> </p> <p>Is there a way to rotate or mirror a icon?</p>
0debug
Unexpected T_STRING, but where? : <p>I'm doing a module of prestashop (I posted other question yesterday). Now I'm having a problem with PHP, I think. Everytime it's says me that the line <code>if($same_puente === false OR $same_patilla === false)...</code> Parse error: syntax error, unexpected T_STRING in that line.</p> <pre><code>&lt;?php if (!defined('_PS_VERSION_')) exit; class glassOptics extends Module { /* @var boolean error */ protected $_errors = false; /* @var boolean puente */ public $same_puente = false; /* @var boolean patilla */ public $same_patilla = false; /* @var boolean altura cristal */ public $same_altura_cristal = false; /* @var boolean ancho cristal */ public $same_ancho_cristal = false; public function __construct() { $this-&gt;name = 'glassOptics'; $this-&gt;tab = 'front_office_features'; $this-&gt;version = '1.0'; $this-&gt;author = 'Víctor Martín'; $this-&gt;need_instance = 0; parent::__construct(); $this-&gt;displayName = $this-&gt;l('glassOptics'); $this-&gt;description = $this-&gt;l('Módulo para Ópticas, de filtrado de gafas compatibles para cada cliente.'); } public function install() { if (!parent::install() OR !$this-&gt;glopticasCustomerDB('add') OR !$this-&gt;glopticasProductDB('add') OR !$this-&gt;glopticasProductLangDB('modify') OR !$this-&gt;registerHook('hookActionProductListOverride') OR !$this-&gt;registerHook('DisplayAdminProductsExtra') OR !$this-&gt;registerHook('ActionProductUpdate')) return false; return true; } public function uninstall() { if (!parent::uninstall() OR !$this-&gt;glopticasCustomerDB('remove') OR !$this-&gt;glopticasProductDB('remove')) return false; return true; } public function glopticasCustomerDB($method) { switch ($method) { case 'add': $decimal_zero = '0.000000'; $decimal_zero = mysql_real_escape_string($decimal_zero); $sql = 'CREATE TABLE IF EXISTS `'._DB_PREFIX_.'customer_optics_data` ( `id_customer` int(10) UNSIGNED NOT NULL, `dioptrias_izquierdo` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', `dioptrias_derecho` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', `puente` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', `patilla` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', `altura_cristal` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', `ancho_cristal` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.' ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'; break; case 'remove': $sql = 'DROP TABLE IF EXISTS `'._DB_PREFIX_ . 'customer_optics_data`'; break; } if(!Db::getInstance()-&gt;Execute($sql)) return false; return true; } public function glopticasProductDB($method) { switch ($method) { case 'add': $decimal_zero = '0.000000'; $decimal_zero = mysql_real_escape_string($decimal_zero); $sql = 'CREATE TABLE IF EXISTS `'._DB_PREFIX_.'product_optics_data` ( `id_product` int(10) UNSIGNED NOT NULL, `dioptrias_izquierdo` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', `dioptrias_derecho` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', `puente` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', `patilla` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', `altura_cristal` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.', `ancho_cristal` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.' ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'; break; case 'remove': $sql = 'DROP TABLE IF EXISTS `'._DB_PREFIX_ . 'product_optics_data`'; break; } if(!Db::getInstance()-&gt;Execute($sql)) return false; return true; } public function glopticasProductLangDB($method) { switch ($method) { case 'modify': $decimal_zero = '0.000000'; $decimal_zero = mysql_real_escape_string($decimal_zero); $sql = 'ALTER TABLE ' . _DB_PREFIX_ . 'product_lang ' .'ADD `dioptrias_izquierdo` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' .'ADD `dioptrias_derecho` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' .'ADD `puente` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' .'ADD `patilla` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' .'ADD `altura_cristal` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.',' .'ADD `ancho_cristal` decimal(20,6) NOT NULL DEFAULT '.$decimal_zero.'' .') ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'; break; } if(!Db::getInstance()-&gt;Execute($sql)) return false; return true; } public function hookActionProductListOverride($params) { $customer_settings = glassOpticsHelperClass::getCustomerSettings($this-&gt;context-&gt;customer); if (!is_null($customer_settings)) { // Inform the hook was executed $params['hookExecuted'] = true; // Filter products here, you are now overriding the default // functionality of CategoryController class. // You can see blocklayered module for more details. if ((isset($this-&gt;context-&gt;controller-&gt;display_column_left) &amp;&amp; !$this-&gt;context-&gt;controller-&gt;display_column_left) &amp;&amp; (isset($this-&gt;context-&gt;controller-&gt;display_column_right) &amp;&amp; !$this-&gt;context-&gt;controller-&gt;display_column_right)) return false; global $smarty; if (!Configuration::getGlobalValue('PS_LAYERED_INDEXED')) return; $sql_cat = 'SELECT COUNT(*) FROM '._DB_PREFIX_.'layered_category WHERE id_category = '.(int)Tools::getValue('id_category', Tools::getValue('id_category_layered', Configuration::get('PS_HOME_CATEGORY'))).' AND id_shop = '.(int) Context::getContext()-&gt;shop-&gt;id; $categories_count = Db::getInstance()-&gt;getValue($sql_cat); if ($categories_count == 0) return; // List of product to overrride categoryController $params['catProducts'] = array(); $selected_filters = $this-&gt;getSelectedFilters(); $filter_block = $this-&gt;getFilterBlock($selected_filters); $title = ''; if (is_array($filter_block['title_values'])) foreach ($filter_block['title_values'] as $key =&gt; $val) $title .= ' &gt; '.$key.' '.implode('/', $val); $smarty-&gt;assign('categoryNameComplement', $title); $this-&gt;getProducts($selected_filters, $params['catProducts'], $params['nbProducts'], $p, $n, $pages_nb, $start, $stop, $range); // Need a nofollow on the pagination links? $smarty-&gt;assign('no_follow', $filter_block['no_follow']); filterProductsByConditions($customer_settings, $params['nbProducts']); } } private static function filterProductsByConditions($customer_settings, $product_collection) { if(!is_null($product_collection)){ foreach ($product_collection as $product){ $product_settings = glassOpticsHelperClass::getProductSettings($product); if(!is_null($product_settings)){ if(!is_null($product_settings-&gt;puente) AND !is_null($customer_settings-&gt;puente)){ $same_puente = (($product_settings-&gt;puente == $customer_settings-&gt;puente) ? true : false); }else{ $same_puente = false; } if(!is_null($product_settings-&gt;patilla) AND !is_null($customer_settings-&gt;patilla)){ $same_patilla = (($product_settings-&gt;patilla == $customer_settings-&gt;patilla) ? true : false); }else{ $same_patilla = false; } if(!is_null($product_settings-&gt;altura_cristal) AND !is_null($customer_settings-&gt;altura_cristal)){ $same_altura_cristal = (($product_settings-&gt;altura_cristal == $customer_settings-&gt;altura_cristal) ? true : false); }else{ $same_altura_cristal = false; } if(!is_null($product_settings-&gt;ancho_cristal) AND !is_null($customer_settings-&gt;ancho_cristal)){ $same_ancho_cristal = (($product_settings-&gt;ancho_cristal == $customer_settings-&gt;ancho_cristal) ? true : false); }else{ $same_ancho_cristal = false; } if($same_puente === false OR $same_patilla === false){ unset($product_collection[$product]); } } } return $product_collection; }else{ return $product_collection; } } } </code></pre> <p>What I'm doing wrong? Thank you.</p>
0debug
static void RENAME(yadif_filter_line)(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, int w, int prefs, int mrefs, int parity, int mode) { DECLARE_ALIGNED(16, uint8_t, tmp0)[16]; DECLARE_ALIGNED(16, uint8_t, tmp1)[16]; DECLARE_ALIGNED(16, uint8_t, tmp2)[16]; DECLARE_ALIGNED(16, uint8_t, tmp3)[16]; int x; #define FILTER\ for(x=0; x<w; x+=STEP){\ __asm__ volatile(\ "pxor "MM"7, "MM"7 \n\t"\ LOAD("(%[cur],%[mrefs])", MM"0") \ LOAD("(%[cur],%[prefs])", MM"1") \ LOAD("(%["prev2"])", MM"2") \ LOAD("(%["next2"])", MM"3") \ MOVQ" "MM"3, "MM"4 \n\t"\ "paddw "MM"2, "MM"3 \n\t"\ "psraw $1, "MM"3 \n\t" \ MOVQ" "MM"0, %[tmp0] \n\t" \ MOVQ" "MM"3, %[tmp1] \n\t" \ MOVQ" "MM"1, %[tmp2] \n\t" \ "psubw "MM"4, "MM"2 \n\t"\ PABS( MM"4", MM"2") \ LOAD("(%[prev],%[mrefs])", MM"3") \ LOAD("(%[prev],%[prefs])", MM"4") \ "psubw "MM"0, "MM"3 \n\t"\ "psubw "MM"1, "MM"4 \n\t"\ PABS( MM"5", MM"3")\ PABS( MM"5", MM"4")\ "paddw "MM"4, "MM"3 \n\t" \ "psrlw $1, "MM"2 \n\t"\ "psrlw $1, "MM"3 \n\t"\ "pmaxsw "MM"3, "MM"2 \n\t"\ LOAD("(%[next],%[mrefs])", MM"3") \ LOAD("(%[next],%[prefs])", MM"4") \ "psubw "MM"0, "MM"3 \n\t"\ "psubw "MM"1, "MM"4 \n\t"\ PABS( MM"5", MM"3")\ PABS( MM"5", MM"4")\ "paddw "MM"4, "MM"3 \n\t" \ "psrlw $1, "MM"3 \n\t"\ "pmaxsw "MM"3, "MM"2 \n\t"\ MOVQ" "MM"2, %[tmp3] \n\t" \ \ "paddw "MM"0, "MM"1 \n\t"\ "paddw "MM"0, "MM"0 \n\t"\ "psubw "MM"1, "MM"0 \n\t"\ "psrlw $1, "MM"1 \n\t" \ PABS( MM"2", MM"0") \ \ MOVQU" -1(%[cur],%[mrefs]), "MM"2 \n\t" \ MOVQU" -1(%[cur],%[prefs]), "MM"3 \n\t" \ MOVQ" "MM"2, "MM"4 \n\t"\ "psubusb "MM"3, "MM"2 \n\t"\ "psubusb "MM"4, "MM"3 \n\t"\ "pmaxub "MM"3, "MM"2 \n\t"\ PSHUF(MM"3", MM"2") \ "punpcklbw "MM"7, "MM"2 \n\t" \ "punpcklbw "MM"7, "MM"3 \n\t" \ "paddw "MM"2, "MM"0 \n\t"\ "paddw "MM"3, "MM"0 \n\t"\ "psubw "MANGLE(pw_1)", "MM"0 \n\t" \ \ CHECK(-2,0)\ CHECK1\ CHECK(-3,1)\ CHECK2\ CHECK(0,-2)\ CHECK1\ CHECK(1,-3)\ CHECK2\ \ \ MOVQ" %[tmp3], "MM"6 \n\t" \ "cmpl $2, %[mode] \n\t"\ "jge 1f \n\t"\ LOAD("(%["prev2"],%[mrefs],2)", MM"2") \ LOAD("(%["next2"],%[mrefs],2)", MM"4") \ LOAD("(%["prev2"],%[prefs],2)", MM"3") \ LOAD("(%["next2"],%[prefs],2)", MM"5") \ "paddw "MM"4, "MM"2 \n\t"\ "paddw "MM"5, "MM"3 \n\t"\ "psrlw $1, "MM"2 \n\t" \ "psrlw $1, "MM"3 \n\t" \ MOVQ" %[tmp0], "MM"4 \n\t" \ MOVQ" %[tmp1], "MM"5 \n\t" \ MOVQ" %[tmp2], "MM"7 \n\t" \ "psubw "MM"4, "MM"2 \n\t" \ "psubw "MM"7, "MM"3 \n\t" \ MOVQ" "MM"5, "MM"0 \n\t"\ "psubw "MM"4, "MM"5 \n\t" \ "psubw "MM"7, "MM"0 \n\t" \ MOVQ" "MM"2, "MM"4 \n\t"\ "pminsw "MM"3, "MM"2 \n\t"\ "pmaxsw "MM"4, "MM"3 \n\t"\ "pmaxsw "MM"5, "MM"2 \n\t"\ "pminsw "MM"5, "MM"3 \n\t"\ "pmaxsw "MM"0, "MM"2 \n\t" \ "pminsw "MM"0, "MM"3 \n\t" \ "pxor "MM"4, "MM"4 \n\t"\ "pmaxsw "MM"3, "MM"6 \n\t"\ "psubw "MM"2, "MM"4 \n\t" \ "pmaxsw "MM"4, "MM"6 \n\t" \ "1: \n\t"\ \ MOVQ" %[tmp1], "MM"2 \n\t" \ MOVQ" "MM"2, "MM"3 \n\t"\ "psubw "MM"6, "MM"2 \n\t" \ "paddw "MM"6, "MM"3 \n\t" \ "pmaxsw "MM"2, "MM"1 \n\t"\ "pminsw "MM"3, "MM"1 \n\t" \ "packuswb "MM"1, "MM"1 \n\t"\ \ :[tmp0]"=m"(tmp0),\ [tmp1]"=m"(tmp1),\ [tmp2]"=m"(tmp2),\ [tmp3]"=m"(tmp3)\ :[prev] "r"(prev),\ [cur] "r"(cur),\ [next] "r"(next),\ [prefs]"r"((x86_reg)prefs),\ [mrefs]"r"((x86_reg)mrefs),\ [mode] "g"(mode)\ );\ __asm__ volatile(MOV" "MM"1, %0" :"=m"(*dst));\ dst += STEP;\ prev+= STEP;\ cur += STEP;\ next+= STEP;\ } if (parity) { #define prev2 "prev" #define next2 "cur" FILTER #undef prev2 #undef next2 } else { #define prev2 "cur" #define next2 "next" FILTER #undef prev2 #undef next2 } }
1threat
The newline characters '/n' is getting printed instead of splitting to a newline : <p>To clarify, I understand I could use:</p> <pre><code>Console.WriteLine("sample text") </code></pre> <p>to get the desired effect, nevertheless, the code I'm using should work, and I want to know why it isn't.</p> <p>The code sample:</p> <pre><code>Console.Write("You have chosen {0}, the game will now begin.{1} Newline.", x_or_o, "/n"); </code></pre> <p>And the output I am receiving in the console is:</p> <pre><code>You have chosen x, the game will now begin./n Newline. </code></pre> <p>Whereas my desired output is:</p> <pre><code>You have chosen x, the game will now begin. Newline. </code></pre> <p>Sorry if I'm missing something fundamental or obvious, but my SO and google searches have resulted in no solutions.</p> <p>All answers are appreciated in advance, thank you for your time.</p>
0debug
im trying 2 implement a queue using 2 stacks but my code isnt functioning can u pls spot the error : `enter code here` #include <stdio.h> `enter code here` #include<stdlib.h> `enter code here` #define MAX 5 `enter code here` typedef struct stack `enter code here` { `enter code here` int top; `enter code here` int arr[MAX]; `enter code here` }stack; `enter code here` void enque(stack*s1,int ele) `enter code here` { `enter code here` printf("entering"); `enter code here` push(&s1,ele); `enter code here` printf("what a pain"); `enter code here` } `enter code here` void push(stack*s,int ele) `enter code here` { `enter code here` if(s->top==MAX-1) `enter code here` { `enter code here` printf("OVERFLOW"); `enter code here` } `enter code here` else `enter code here` { `enter code here` s->arr[++s->top]=ele; `enter code here` } `enter code here` } `enter code here` int deq(stack*s1,stack*s2) `enter code here` { `enter code here` int x; `enter code here` if(s1->top==-1&&s2->top==-1) `enter code here` { `enter code here` printf("empty"); `enter code here` } `enter code here` else `enter code here` { `enter code here` if(s2->top==-1) `enter code here` {while(s1->top!=-1) `enter code here` { `enter code here` push(&s2,pop(&s1)); `enter code here` } `enter code here` } `enter code here` x=pop(&s2); `enter code here` return x; `enter code here` } `enter code here` } `enter code here` int pop(stack *s) `enter code here` { `enter code here` if(s->top==-1) `enter code here` { `enter code here` printf("UNDERFLOW"); `enter code here` } `enter code here` else `enter code here` { `enter code here` return s->arr[s->top--]; `enter code here` } `enter code here` } `enter code here` void display(stack*s) `enter code here` { `enter code here` printf("entered display"); `enter code here` int i; `enter code here` for (i = 0;i <= s->top;i++) `enter code here` { `enter code here` printf(" %d",s->arr[i]); `enter code here` } `enter code here` } `enter code here` int main() `enter code here` { `enter code here` int ch,ele,c; `enter code here` stack s1,s2; `enter code here` s1.top=-1,s2.top=-1; `enter code here` do{ `enter code here` printf("1 - Enqueue2-deq3-display4-exit\n"); `enter code here` printf("Enter choice"); `enter code here` scanf("%d", &ch); `enter code here` switch (ch) `enter code here` { `enter code here` case 1:printf("enter ele of ur choice"); `enter code here` scanf("%d",&ele); `enter code here` enque(&s1,ele); `enter code here` break; `enter code here` case 2: `enter code here` c=deq(&s1,&s2); `enter code here` printf("%d",c); `enter code here` break; `enter code here` case 3: `enter code here` display(&s1); `enter code here` break; `enter code here` case 4: `enter code here` exit(0); `enter code here` default: `enter code here` printf("Wrong choice"); `enter code here` } `enter code here` }while(ch!=5); `enter code here` }
0debug
static inline int vmsvga_fifo_length(struct vmsvga_state_s *s) { int num; if (!s->config || !s->enable) return 0; num = CMD(next_cmd) - CMD(stop); if (num < 0) num += CMD(max) - CMD(min); return num >> 2; }
1threat
document.getElementById('input').innerHTML = user_input;
1threat
opts_end_list(Visitor *v) { OptsVisitor *ov = to_ov(v); assert(ov->list_mode == LM_STARTED || ov->list_mode == LM_IN_PROGRESS || ov->list_mode == LM_SIGNED_INTERVAL || ov->list_mode == LM_UNSIGNED_INTERVAL); ov->repeated_opts = NULL; ov->list_mode = LM_NONE; }
1threat
jQuery Array Difference : <p>This is isn't really a question, it's a solution but I wanted to post it because I've seen it come up frequently. Feel free to suggest improvements though. I'll update my <a href="https://jsfiddle.net/difster/qvbs6ps4/" rel="nofollow noreferrer">Fiddle</a> with the results.</p> <p>Using jQuery, this compares 2 arrays and outputs the differences in the two.</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>var array1 = [1, 2, 3, 4, 5, 6]; var array2 = [1, 2, 3, 4, 5, 6, 7, 8, 9]; var foo = []; var i = 0; jQuery.grep(array2, function(el) { if (jQuery.inArray(el, array1) == -1) foo.push(el); i++; }); alert(" the difference is " + foo);</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre> </div> </div> </p>
0debug
Aspnet Core Decimal binding not working on non English Culture : <p>I have an aspnet core app that runs with a non english configuration (spanish):</p> <pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { ...... app.UseRequestLocalization(new RequestLocalizationOptions { DefaultRequestCulture = new RequestCulture(new CultureInfo("es-AR")) ,SupportedCultures = new List&lt;CultureInfo&gt; { new CultureInfo("es-AR") } ,SupportedUICultures = new List&lt;CultureInfo&gt; { new CultureInfo("es") } }); ......... } </code></pre> <p>In english a decimal number has its decimal part delimited with a dot, but in spanish a comma is used:</p> <ul> <li>10256.35 english </li> <li>10256,35 spanish</li> </ul> <p>I have this action in a controller:</p> <pre><code> [HttpPost] public decimal Test(decimal val) { return val; } </code></pre> <p>If I use postman and send to that action a json like this {val: 15.30}, then val in the action recives a 0 (binding not working because of the culture). If I send a json like this {val: 15,30} then in the action I recive 15.30 The problem I have is, I need the action to accept decimals with commas, because that is the format that comes from inputs type text in the app's forms. But i also need to accept decimal with a dot that comes from request in json format. There is no way to specify a decimal/float in json that accepts a comma (send it as string is not an option). How can I do this??? I'm driving my self crazy with this.</p> <p>Thanks!!</p>
0debug
static int64_t coroutine_fn bdrv_co_get_block_status_above(BlockDriverState *bs, BlockDriverState *base, bool want_zero, int64_t sector_num, int nb_sectors, int *pnum, BlockDriverState **file) { BlockDriverState *p; int64_t ret = 0; bool first = true; assert(bs != base); for (p = bs; p != base; p = backing_bs(p)) { ret = bdrv_co_get_block_status(p, want_zero, sector_num, nb_sectors, pnum, file); if (ret < 0) { break; } if (ret & BDRV_BLOCK_ZERO && ret & BDRV_BLOCK_EOF && !first) { *pnum = nb_sectors; } if (ret & (BDRV_BLOCK_ZERO | BDRV_BLOCK_DATA)) { break; } nb_sectors = MIN(nb_sectors, *pnum); first = false; } return ret; }
1threat
React fade in element : <p>I have a <code>Basket</code> component which needs to toggle a <code>BasketContents</code> component when clicked on. This works:</p> <pre><code>constructor() { super(); this.state = { open: false } this.handleDropDown = this.handleDropDown.bind(this); } handleDropDown() { this.setState({ open: !this.state.open }) } render() { return( &lt;div className="basket"&gt; &lt;button className="basketBtn" onClick={this.handleDropDown}&gt; Open &lt;/button&gt; { this.state.open ? &lt;BasketContents /&gt; : null } &lt;/div&gt; ) } </code></pre> <p>It uses a conditional to either display the <code>BasketContents</code> component or not. I now want it to fade in. I tried adding a <code>ComponentDidMount</code> hook to <code>BasketContents</code> to transition the opacity but that doesn't work. Is there a simple way to do this?</p>
0debug
Promise in the if statement (Javascript) : <p>I want to use promise results in the if statements, however when I try to, I get something like this:</p> <pre><code>const promise = new Promise((resolve, reject) =&gt; { setTimeout(() =&gt; { resolve(5 * 2) }, 1000) }) console.log(promise.then(i =&gt; i) === 10) //false </code></pre> <p>Is it possible to somehow wait for the extraction of the promise result in this case?</p>
0debug
Definition of "atomic object" : <p>In standard jargon of C and C++, the phrase "<strong>atomic object</strong>" means "<em>object</em> of <em>atomic type,</em>" does it not?</p> <p>No standard will explicitly define every two-word phrase, so one does not fault the C and C++ standards for omitting explicit definition of this one. Nevertheless, when I read in the C++17 standard (draft <a href="http://open-std.org/JTC1/SC22/WG21/docs/papers/2017/n4659.pdf" rel="noreferrer">here</a>), sect. 4.7.1(4), that "all modifications to a particular atomic object <em>M</em> occur in some particular total order, called the <em>modification order</em> of <em>M</em>"&mdash;and when the standard repeatedly employs similar language to delimit ever more precise logic for concurrency&mdash;I would like to be sure that I am not inadvertently misunderstanding.</p> <p>Do I assume correctly that the phrase "atomic object" means</p> <ul> <li><em>object</em> of <em>atomic type</em>?</li> </ul> <p>The only plausible alternative I can imagine would be that the phrase instead meant</p> <ul> <li>properly aligned <em>object</em> small enough that hardware could handle it atomically.</li> </ul> <p>Which is it, please?</p> <p>(Note: I tag this question both C and C++ because, when it comes to atomics, the two standards use almost identical language. For this reason, an expert in either language can answer as far as I know. If for some reason I am mistaken, then please remove the C tag and retain the C++.)</p> <p>Reference: see also <a href="https://stackoverflow.com/q/52606524/1275653">this question,</a> for which my question is preliminary.</p>
0debug
Flutter textfield expand as user types : <p>I have a textfield and need to have multi-line as below so that the text wraps, however it takes up the space of all the lines that is defined in maxLines. I want to be able to have it look like 1 line and expand as the text wraps. Any ideas of how to do this is flutter?</p> <pre><code>new TextField( decoration: const InputDecoration( hintText: 'Reply', labelText: 'Reply:', ), autofocus: false, focusNode: _focusnode, maxLines: 1, controller: _newreplycontroller, keyboardType: TextInputType.text, ), </code></pre>
0debug
static int wsvqa_read_packet(AVFormatContext *s, AVPacket *pkt) { WsVqaDemuxContext *wsvqa = s->priv_data; AVIOContext *pb = s->pb; int ret = -1; unsigned char preamble[VQA_PREAMBLE_SIZE]; unsigned int chunk_type; unsigned int chunk_size; int skip_byte; while (avio_read(pb, preamble, VQA_PREAMBLE_SIZE) == VQA_PREAMBLE_SIZE) { chunk_type = AV_RB32(&preamble[0]); chunk_size = AV_RB32(&preamble[4]); skip_byte = chunk_size & 0x01; if ((chunk_type == SND0_TAG) || (chunk_type == SND1_TAG) || (chunk_type == SND2_TAG) || (chunk_type == VQFR_TAG)) { ret= av_get_packet(pb, pkt, chunk_size); if (ret<0) return AVERROR(EIO); switch (chunk_type) { case SND0_TAG: case SND1_TAG: case SND2_TAG: if (wsvqa->audio_stream_index == -1) { AVStream *st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); wsvqa->audio_stream_index = st->index; if (!wsvqa->sample_rate) wsvqa->sample_rate = 22050; if (!wsvqa->channels) wsvqa->channels = 1; if (!wsvqa->bps) wsvqa->bps = 8; st->codec->sample_rate = wsvqa->sample_rate; st->codec->bits_per_coded_sample = wsvqa->bps; st->codec->channels = wsvqa->channels; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); switch (chunk_type) { case SND0_TAG: if (wsvqa->bps == 16) st->codec->codec_id = AV_CODEC_ID_PCM_S16LE; else st->codec->codec_id = AV_CODEC_ID_PCM_U8; break; case SND1_TAG: st->codec->codec_id = AV_CODEC_ID_WESTWOOD_SND1; break; case SND2_TAG: st->codec->codec_id = AV_CODEC_ID_ADPCM_IMA_WS; st->codec->extradata_size = 2; st->codec->extradata = av_mallocz(2 + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); AV_WL16(st->codec->extradata, wsvqa->version); break; } } pkt->stream_index = wsvqa->audio_stream_index; switch (chunk_type) { case SND1_TAG: pkt->duration = AV_RL16(pkt->data) / wsvqa->channels; break; case SND2_TAG: pkt->duration = (chunk_size * 2) / wsvqa->channels; break; } break; case VQFR_TAG: pkt->stream_index = wsvqa->video_stream_index; pkt->duration = 1; break; } if (skip_byte) avio_skip(pb, 1); return ret; } else { switch(chunk_type){ case CMDS_TAG: break; default: av_log(s, AV_LOG_INFO, "Skipping unknown chunk 0x%08X\n", chunk_type); } avio_skip(pb, chunk_size + skip_byte); } } return ret; }
1threat
static int GLZWDecode(GifState * s, uint8_t * buf, int len) { int l, c, code, oc, fc; uint8_t *sp; if (s->end_code < 0) return 0; l = len; sp = s->sp; oc = s->oc; fc = s->fc; while (sp > s->stack) { *buf++ = *(--sp); if ((--l) == 0) goto the_end; } for (;;) { c = GetCode(s); if (c == s->end_code) { s->end_code = -1; break; } else if (c == s->clear_code) { s->cursize = s->codesize + 1; s->curmask = mask[s->cursize]; s->slot = s->newcodes; s->top_slot = 1 << s->cursize; while ((c = GetCode(s)) == s->clear_code); if (c == s->end_code) { s->end_code = -1; break; } if (c >= s->slot) c = 0; fc = oc = c; *buf++ = c; if ((--l) == 0) break; } else { code = c; if (code >= s->slot) { *sp++ = fc; code = oc; } while (code >= s->newcodes) { *sp++ = s->suffix[code]; code = s->prefix[code]; } *sp++ = code; if (s->slot < s->top_slot) { s->suffix[s->slot] = fc = code; s->prefix[s->slot++] = oc; oc = c; } if (s->slot >= s->top_slot) { if (s->cursize < MAXBITS) { s->top_slot <<= 1; s->curmask = mask[++s->cursize]; } } while (sp > s->stack) { *buf++ = *(--sp); if ((--l) == 0) goto the_end; } } } the_end: s->sp = sp; s->oc = oc; s->fc = fc; return len - l; }
1threat
static int nbd_errno_to_system_errno(int err) { switch (err) { case NBD_SUCCESS: return 0; case NBD_EPERM: return EPERM; case NBD_EIO: return EIO; case NBD_ENOMEM: return ENOMEM; case NBD_ENOSPC: return ENOSPC; default: TRACE("Squashing unexpected error %d to EINVAL", err); case NBD_EINVAL: return EINVAL; } }
1threat
Bash LS formatting size, filename and type : I'm a complete newbie at bash and I'm looking for some help. I'm looking to output a list of contents formatted by size, type of each file and the file name without the extension. I've tried using ls grep and awk but to no avail. I'm not sure how else this could be done, could someone help me? thanks.
0debug
Disable autocomplete in chrome 66 : <p>Is there any way to disable autocomplete on a text field in chrome 66? I have tried a number of options like :</p> <ol> <li>autocomplete="off"</li> <li>autocomplete="false"</li> <li>autocomplete="disabled"</li> <li>autocomplete="something-new" etc.</li> </ol> <p>Can anyone help me with this?</p> <p>Also, one more thing does chrome automatically enables autocomplete for a username if it has a password type field below it?</p>
0debug
Android ExoPlayer Play .m3u8 from Android Resources : I am able to play .m3u8 file from a web server like http://example.com/file.m3u8 I have added the play list file in android resource but it not playing. How to play same file from local resources. Thanks,
0debug
EXCEL DATA LETTERS BETWEEN SPACE HOW TO REMOVE? : [MY DATA EXCEL FORMAT][1] HI please look my data first field , my output required second field data format without space in letters [1]: https://i.stack.imgur.com/Sh0Xn.jpg
0debug
SystemError: error return without exception set, when using requests and debugger : <p>Environment: Python 3.6.3 Requests 2.18.4 PyCharm 2018.1</p> <p>When using the above configuration in normal run everything is fine. However,when using PyCharm debugger my output is constantly giving me two kinds of exceptions:</p> <pre><code>Exception ignored in: &lt;generator object urlsplit.&lt;locals&gt;.&lt;genexpr&gt; at 0x7f69803940a0&gt; Traceback (most recent call last): File "/usr/lib/python3.6/urllib/parse.py", line 433, in &lt;genexpr&gt; if not rest or any(c not in '0123456789' for c in rest): </code></pre> <p>or </p> <pre><code>SystemError: error return without exception set Exception ignored in: &lt;generator object iter_slices at 0x7f69803940f8&gt; Traceback (most recent call last): File "/home/damian/workspace/DofusV2/venv/lib/python3.6/site-packages/requests/utils.py", line 449, in iter_slices def iter_slices(string, slice_length): ` </code></pre> <p>This is not an issue in a single project, I had this issue in numerous projects countless times. However, every project was multi-threaded ( I do not know if this makes any difference) The thing is I do not have this problem when not using the debugger plus it doesn't really do anything the application is stable and works fine. My question is why is this happening and can I at least suppress it so it won't pollute my log?</p>
0debug
void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp) { #if HAVE_YASM int mm_flags = av_get_cpu_flags(); if (mm_flags & AV_CPU_FLAG_SSE && HAVE_SSE) { fdsp->vector_fmul = ff_vector_fmul_sse; fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_sse; } if (mm_flags & AV_CPU_FLAG_AVX && HAVE_AVX) { fdsp->vector_fmul = ff_vector_fmul_avx; fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_avx; } #endif }
1threat
How to find all possible combinations from a list with only two elements and no duplicates with Python? : <p>I have the following:</p> <pre><code>list = ["player1", "player2", "player3"] </code></pre> <p>I want to find all possible combinations of two elements of that list, but with no duplicates. I have tried to work with the itertools.combinations() but without the desired result.</p> <p>I'm looking for a result like this:</p> <pre><code>player1, player2 player1, player3 player2, player3 </code></pre> <p>Can someone help me in the right direction?</p> <p>Thanks in advance</p>
0debug
static AVBufferRef *pool_alloc_buffer(AVBufferPool *pool) { BufferPoolEntry *buf; AVBufferRef *ret; ret = pool->alloc(pool->size); if (!ret) return NULL; buf = av_mallocz(sizeof(*buf)); if (!buf) { av_buffer_unref(&ret); return NULL; } buf->data = ret->buffer->data; buf->opaque = ret->buffer->opaque; buf->free = ret->buffer->free; buf->pool = pool; ret->buffer->opaque = buf; ret->buffer->free = pool_release_buffer; avpriv_atomic_int_add_and_fetch(&pool->refcount, 1); return ret; }
1threat
npm - EPERM: operation not permitted on Windows : <p>I ran </p> <pre><code>npm config set prefix /usr/local </code></pre> <p>After running that command, When trying to run any npm commands on Windows OS I keep getting the below. </p> <pre><code>Error: EPERM: operation not permitted, mkdir 'C:\Program Files (x86)\Git\local' at Error (native) </code></pre> <p>Have deleted all files from </p> <pre><code>C:\Users\&lt;your username&gt;\.config\configstore\ </code></pre> <p>It did not work.</p> <p>Any suggestion ?</p>
0debug
static void do_inject_mce(Monitor *mon, const QDict *qdict) { CPUState *cenv; int cpu_index = qdict_get_int(qdict, "cpu_index"); int bank = qdict_get_int(qdict, "bank"); uint64_t status = qdict_get_int(qdict, "status"); uint64_t mcg_status = qdict_get_int(qdict, "mcg_status"); uint64_t addr = qdict_get_int(qdict, "addr"); uint64_t misc = qdict_get_int(qdict, "misc"); for (cenv = first_cpu; cenv != NULL; cenv = cenv->next_cpu) if (cenv->cpu_index == cpu_index && cenv->mcg_cap) { cpu_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc); break; } }
1threat
static void sdhci_do_adma(SDHCIState *s) { unsigned int n, begin, length; const uint16_t block_size = s->blksize & 0x0fff; ADMADescr dscr; int i; for (i = 0; i < SDHC_ADMA_DESCS_PER_DELAY; ++i) { s->admaerr &= ~SDHC_ADMAERR_LENGTH_MISMATCH; get_adma_description(s, &dscr); DPRINT_L2("ADMA loop: addr=" TARGET_FMT_plx ", len=%d, attr=%x\n", dscr.addr, dscr.length, dscr.attr); if ((dscr.attr & SDHC_ADMA_ATTR_VALID) == 0) { s->admaerr &= ~SDHC_ADMAERR_STATE_MASK; s->admaerr |= SDHC_ADMAERR_STATE_ST_FDS; if (s->errintstsen & SDHC_EISEN_ADMAERR) { s->errintsts |= SDHC_EIS_ADMAERR; s->norintsts |= SDHC_NIS_ERR; } sdhci_update_irq(s); return; } length = dscr.length ? dscr.length : 65536; switch (dscr.attr & SDHC_ADMA_ATTR_ACT_MASK) { case SDHC_ADMA_ATTR_ACT_TRAN: if (s->trnmod & SDHC_TRNS_READ) { while (length) { if (s->data_count == 0) { for (n = 0; n < block_size; n++) { s->fifo_buffer[n] = sd_read_data(s->card); } } begin = s->data_count; if ((length + begin) < block_size) { s->data_count = length + begin; length = 0; } else { s->data_count = block_size; length -= block_size - begin; } dma_memory_write(&address_space_memory, dscr.addr, &s->fifo_buffer[begin], s->data_count - begin); dscr.addr += s->data_count - begin; if (s->data_count == block_size) { s->data_count = 0; if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) { s->blkcnt--; if (s->blkcnt == 0) { break; } } } } } else { while (length) { begin = s->data_count; if ((length + begin) < block_size) { s->data_count = length + begin; length = 0; } else { s->data_count = block_size; length -= block_size - begin; } dma_memory_read(&address_space_memory, dscr.addr, &s->fifo_buffer[begin], s->data_count - begin); dscr.addr += s->data_count - begin; if (s->data_count == block_size) { for (n = 0; n < block_size; n++) { sd_write_data(s->card, s->fifo_buffer[n]); } s->data_count = 0; if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) { s->blkcnt--; if (s->blkcnt == 0) { break; } } } } } s->admasysaddr += dscr.incr; break; case SDHC_ADMA_ATTR_ACT_LINK: s->admasysaddr = dscr.addr; DPRINT_L1("ADMA link: admasysaddr=0x%lx\n", s->admasysaddr); break; default: s->admasysaddr += dscr.incr; break; } if (dscr.attr & SDHC_ADMA_ATTR_INT) { DPRINT_L1("ADMA interrupt: admasysaddr=0x%lx\n", s->admasysaddr); if (s->norintstsen & SDHC_NISEN_DMA) { s->norintsts |= SDHC_NIS_DMA; } sdhci_update_irq(s); } if (((s->trnmod & SDHC_TRNS_BLK_CNT_EN) && (s->blkcnt == 0)) || (dscr.attr & SDHC_ADMA_ATTR_END)) { DPRINT_L2("ADMA transfer completed\n"); if (length || ((dscr.attr & SDHC_ADMA_ATTR_END) && (s->trnmod & SDHC_TRNS_BLK_CNT_EN) && s->blkcnt != 0)) { ERRPRINT("SD/MMC host ADMA length mismatch\n"); s->admaerr |= SDHC_ADMAERR_LENGTH_MISMATCH | SDHC_ADMAERR_STATE_ST_TFR; if (s->errintstsen & SDHC_EISEN_ADMAERR) { ERRPRINT("Set ADMA error flag\n"); s->errintsts |= SDHC_EIS_ADMAERR; s->norintsts |= SDHC_NIS_ERR; } sdhci_update_irq(s); } SDHCI_GET_CLASS(s)->end_data_transfer(s); return; } } timer_mod(s->transfer_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + SDHC_TRANSFER_DELAY); }
1threat
static int alloc_audio_output_buf(AVCodecContext *dec, AVCodecContext *enc, int nb_samples, int *buf_linesize) { int64_t audio_buf_samples; int audio_buf_size; audio_buf_samples = ((int64_t)nb_samples * enc->sample_rate + dec->sample_rate) / dec->sample_rate; audio_buf_samples = 4 * audio_buf_samples + 10000; audio_buf_samples = FFMAX(audio_buf_samples, enc->frame_size); if (audio_buf_samples > INT_MAX) return AVERROR(EINVAL); audio_buf_size = av_samples_get_buffer_size(buf_linesize, enc->channels, audio_buf_samples, enc->sample_fmt, 0); if (audio_buf_size < 0) return audio_buf_size; av_fast_malloc(&audio_buf, &allocated_audio_buf_size, audio_buf_size); if (!audio_buf) return AVERROR(ENOMEM); return 0; }
1threat
convert the format into new format javascriopy : 26(5p) => 19005(3p) 6827(3p) => 6939(3p) the arrow gets converted to '-' replace this format to #slices= '5p.26-3p.19005,3p.6827-3p.6939' using JavaScript i tried the below code, too long to execute for(let i=0; i<this.selectedSliceMulti.length; i++) { let replacevalue = this.slicesList[0].replace(/\=>/,''); let replacevalue2 = replacevalue.replace(/ /g,''); let replacevalue3 = replacevalue2.split(/[(\)]/); replacevalue3.splice(4); let halfWayThough = Math.floor(replacevalue3.length / 2) let arrayFirstHalf = replacevalue3.slice(0, halfWayThough); let arraySecondHalf = replacevalue3.slice(halfWayThough, replacevalue3.length); console.log(replacevalue3) //this.slicesList[0].replace('\=>\','-') }
0debug
Could anyone tell me how to add text to speech in this program : I just can't figure it out....I know how python can recognise my voice but I don't know how to make python speak out text :( from time import sleep import sys print("Tell me something...") LOL = input() sleep(2) print("Thinking...") sleep(2) if LOL == 'Hey' or LOL == 'Hello': ??? #I want it to say Hello too! else: print("ERROR") sys.exit()
0debug
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { SheerVideoContext *s = avctx->priv_data; ThreadFrame frame = { .f = data }; AVFrame *p = data; GetBitContext gb; unsigned format; int ret; if (avpkt->size <= 20) if (AV_RL32(avpkt->data) != MKTAG('S','h','i','r') && AV_RL32(avpkt->data) != MKTAG('Z','w','a','k')) s->alt = 0; format = AV_RL32(avpkt->data + 16); av_log(avctx, AV_LOG_DEBUG, "format: %s\n", av_fourcc2str(format)); switch (format) { case MKTAG(' ', 'R', 'G', 'B'): avctx->pix_fmt = AV_PIX_FMT_RGB0; s->decode_frame = decode_rgb; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_r_rgb, 256); ret |= build_vlc(&s->vlc[1], l_g_rgb, 256); break; case MKTAG(' ', 'r', 'G', 'B'): avctx->pix_fmt = AV_PIX_FMT_RGB0; s->decode_frame = decode_rgbi; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_r_rgbi, 256); ret |= build_vlc(&s->vlc[1], l_g_rgbi, 256); break; case MKTAG('A', 'R', 'G', 'X'): avctx->pix_fmt = AV_PIX_FMT_GBRAP10; s->decode_frame = decode_argx; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_r_rgbx, 1024); ret |= build_vlc(&s->vlc[1], l_g_rgbx, 1024); break; case MKTAG('A', 'r', 'G', 'X'): avctx->pix_fmt = AV_PIX_FMT_GBRAP10; s->decode_frame = decode_argxi; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_r_rgbxi, 1024); ret |= build_vlc(&s->vlc[1], l_g_rgbxi, 1024); break; case MKTAG('R', 'G', 'B', 'X'): avctx->pix_fmt = AV_PIX_FMT_GBRP10; s->decode_frame = decode_rgbx; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_r_rgbx, 1024); ret |= build_vlc(&s->vlc[1], l_g_rgbx, 1024); break; case MKTAG('r', 'G', 'B', 'X'): avctx->pix_fmt = AV_PIX_FMT_GBRP10; s->decode_frame = decode_rgbxi; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_r_rgbxi, 1024); ret |= build_vlc(&s->vlc[1], l_g_rgbxi, 1024); break; case MKTAG('A', 'R', 'G', 'B'): avctx->pix_fmt = AV_PIX_FMT_ARGB; s->decode_frame = decode_argb; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_r_rgb, 256); ret |= build_vlc(&s->vlc[1], l_g_rgb, 256); break; case MKTAG('A', 'r', 'G', 'B'): avctx->pix_fmt = AV_PIX_FMT_ARGB; s->decode_frame = decode_argbi; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_r_rgbi, 256); ret |= build_vlc(&s->vlc[1], l_g_rgbi, 256); break; case MKTAG('A', 'Y', 'B', 'R'): s->alt = 1; case MKTAG('A', 'Y', 'b', 'R'): avctx->pix_fmt = AV_PIX_FMT_YUVA444P; s->decode_frame = decode_aybr; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_ybr, 256); ret |= build_vlc(&s->vlc[1], l_u_ybr, 256); break; case MKTAG('A', 'y', 'B', 'R'): s->alt = 1; case MKTAG('A', 'y', 'b', 'R'): avctx->pix_fmt = AV_PIX_FMT_YUVA444P; s->decode_frame = decode_aybri; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_ybri, 256); ret |= build_vlc(&s->vlc[1], l_u_ybri, 256); break; case MKTAG(' ', 'Y', 'B', 'R'): s->alt = 1; case MKTAG(' ', 'Y', 'b', 'R'): avctx->pix_fmt = AV_PIX_FMT_YUV444P; s->decode_frame = decode_ybr; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_ybr, 256); ret |= build_vlc(&s->vlc[1], l_u_ybr, 256); break; case MKTAG(' ', 'y', 'B', 'R'): s->alt = 1; case MKTAG(' ', 'y', 'b', 'R'): avctx->pix_fmt = AV_PIX_FMT_YUV444P; s->decode_frame = decode_ybri; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_ybri, 256); ret |= build_vlc(&s->vlc[1], l_u_ybri, 256); break; case MKTAG('Y', 'B', 'R', 0x0a): avctx->pix_fmt = AV_PIX_FMT_YUV444P10; s->decode_frame = decode_ybr10; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_ybr10, 1024); ret |= build_vlc(&s->vlc[1], l_u_ybr10, 1024); break; case MKTAG('y', 'B', 'R', 0x0a): avctx->pix_fmt = AV_PIX_FMT_YUV444P10; s->decode_frame = decode_ybr10i; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_ybr10i, 1024); ret |= build_vlc(&s->vlc[1], l_u_ybr10i, 1024); break; case MKTAG('C', 'A', '4', 'p'): avctx->pix_fmt = AV_PIX_FMT_YUVA444P10; s->decode_frame = decode_ca4p; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_ybr10, 1024); ret |= build_vlc(&s->vlc[1], l_u_ybr10, 1024); break; case MKTAG('C', 'A', '4', 'i'): avctx->pix_fmt = AV_PIX_FMT_YUVA444P10; s->decode_frame = decode_ca4i; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_ybr10i, 1024); ret |= build_vlc(&s->vlc[1], l_u_ybr10i, 1024); break; case MKTAG('B', 'Y', 'R', 'Y'): avctx->pix_fmt = AV_PIX_FMT_YUV422P; s->decode_frame = decode_byry; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_byry, 256); ret |= build_vlc(&s->vlc[1], l_u_byry, 256); break; case MKTAG('B', 'Y', 'R', 'y'): avctx->pix_fmt = AV_PIX_FMT_YUV422P; s->decode_frame = decode_byryi; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_byryi, 256); ret |= build_vlc(&s->vlc[1], l_u_byryi, 256); break; case MKTAG('Y', 'b', 'Y', 'r'): avctx->pix_fmt = AV_PIX_FMT_YUV422P; s->decode_frame = decode_ybyr; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_ybyr, 256); ret |= build_vlc(&s->vlc[1], l_u_ybyr, 256); break; case MKTAG('C', '8', '2', 'p'): avctx->pix_fmt = AV_PIX_FMT_YUVA422P; s->decode_frame = decode_c82p; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_byry, 256); ret |= build_vlc(&s->vlc[1], l_u_byry, 256); break; case MKTAG('C', '8', '2', 'i'): avctx->pix_fmt = AV_PIX_FMT_YUVA422P; s->decode_frame = decode_c82i; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_byryi, 256); ret |= build_vlc(&s->vlc[1], l_u_byryi, 256); break; case MKTAG(0xa2, 'Y', 'R', 'Y'): avctx->pix_fmt = AV_PIX_FMT_YUV422P10; s->decode_frame = decode_yry10; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_yry10, 1024); ret |= build_vlc(&s->vlc[1], l_u_yry10, 1024); break; case MKTAG(0xa2, 'Y', 'R', 'y'): avctx->pix_fmt = AV_PIX_FMT_YUV422P10; s->decode_frame = decode_yry10i; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_yry10i, 1024); ret |= build_vlc(&s->vlc[1], l_u_yry10i, 1024); break; case MKTAG('C', 'A', '2', 'p'): avctx->pix_fmt = AV_PIX_FMT_YUVA422P10; s->decode_frame = decode_ca2p; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_yry10, 1024); ret |= build_vlc(&s->vlc[1], l_u_yry10, 1024); break; case MKTAG('C', 'A', '2', 'i'): avctx->pix_fmt = AV_PIX_FMT_YUVA422P10; s->decode_frame = decode_ca2i; if (s->format != format) { ret = build_vlc(&s->vlc[0], l_y_yry10i, 1024); ret |= build_vlc(&s->vlc[1], l_u_yry10i, 1024); break; default: avpriv_request_sample(avctx, "unsupported format: 0x%X", format); return AVERROR_PATCHWELCOME; if (s->format != format) { if (ret < 0) return ret; s->format = format; p->pict_type = AV_PICTURE_TYPE_I; p->key_frame = 1; if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0) return ret; if ((ret = init_get_bits8(&gb, avpkt->data + 20, avpkt->size - 20)) < 0) return ret; s->decode_frame(avctx, p, &gb); *got_frame = 1; return avpkt->size;
1threat
int vhost_backend_update_device_iotlb(struct vhost_dev *dev, uint64_t iova, uint64_t uaddr, uint64_t len, IOMMUAccessFlags perm) { struct vhost_iotlb_msg imsg; imsg.iova = iova; imsg.uaddr = uaddr; imsg.size = len; imsg.type = VHOST_IOTLB_UPDATE; switch (perm) { case IOMMU_RO: imsg.perm = VHOST_ACCESS_RO; break; case IOMMU_WO: imsg.perm = VHOST_ACCESS_WO; break; case IOMMU_RW: imsg.perm = VHOST_ACCESS_RW; break; default: return -EINVAL; } return dev->vhost_ops->vhost_send_device_iotlb_msg(dev, &imsg); }
1threat
having difficulties on understanding java script toggle class : i want to change glyphicon-plus into glyphicon-minus when clicked on it. here is my code <pre><code>` <?php foreach (get_categories() as $category){ ?> <div class = "sidebar_menu" > <li class="<?php echo $active = ($i==1)?"active":""; ?>"><a href="<?php echo get_category_link(get_cat_ID( $category->name )); ?>" ><strong><?php echo $category->name;?> </strong></a></li> <div class = "floatright"> <li id="cool"> <a role="button" data-toggle="collapse" data-parent="#accordion" href="#collapseOne<?php echo $i; ?>" aria-expanded="true" aria-controls="collapseOne<?php echo $i; ?>"> <i class="glyphicon glyphicon-plus" aria-hidden="true"></i> </a> </li> </div> </div>` and the js. <pre><code>`$('#cool').click(function(){ $(this).find('i').toggleClass('glyphicon-plus').toggleClass('glyphicon-minus'); });` problem is that the glyphicon changes for the first list item only. it should be changed for all list item. Any help will be highly appreciated.
0debug
int ff_tls_open_underlying(TLSShared *c, URLContext *parent, const char *uri, AVDictionary **options) { int port; const char *p; char buf[200], opts[50] = ""; struct addrinfo hints = { 0 }, *ai = NULL; const char *proxy_path; int use_proxy; set_options(c, uri); if (c->listen) snprintf(opts, sizeof(opts), "?listen=1"); av_url_split(NULL, 0, NULL, 0, c->host, sizeof(c->host), &port, NULL, 0, uri); p = strchr(uri, '?'); if (!p) { p = opts; } else { if (av_find_info_tag(opts, sizeof(opts), "listen", p)) c->listen = 1; } ff_url_join(buf, sizeof(buf), "tcp", NULL, c->host, port, "%s", p); hints.ai_flags = AI_NUMERICHOST; if (!getaddrinfo(c->host, NULL, &hints, &ai)) { c->numerichost = 1; freeaddrinfo(ai); } proxy_path = getenv("http_proxy"); use_proxy = !ff_http_match_no_proxy(getenv("no_proxy"), c->host) && proxy_path && av_strstart(proxy_path, "http: if (use_proxy) { char proxy_host[200], proxy_auth[200], dest[200]; int proxy_port; av_url_split(NULL, 0, proxy_auth, sizeof(proxy_auth), proxy_host, sizeof(proxy_host), &proxy_port, NULL, 0, proxy_path); ff_url_join(dest, sizeof(dest), NULL, NULL, c->host, port, NULL); ff_url_join(buf, sizeof(buf), "httpproxy", proxy_auth, proxy_host, proxy_port, "/%s", dest); } return ffurl_open(&c->tcp, buf, AVIO_FLAG_READ_WRITE, &parent->interrupt_callback, options); }
1threat
Characters not showing up [C] : <p>I'm making a fun little text-based game for fun and for some reason some text aren't showing up for the username.</p> <p>Here's my code:</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; /* Forward declarations -- Prototypes */ void askCharacterName(char *name); void printMainMessage(char* name); int main(char* username) { askCharacterName(username); char* temp; temp = &amp;username; printMainMessage(temp); return (0); } void askCharacterName(char *name) { char username[20]; printf("What is your desired username?"); scanf("%s", &amp;username); return *username; } void printMainMessage(char *name) { printf("Hello %s. Welcome to Lamescape!\n", name); } </code></pre> <p>Here is my output:</p> <pre><code>Welcome []. Welcome to Lamescape! </code></pre>
0debug
Why is my jQuery code doesn't work : <textarea>This is very, very long preloading text, I mean vvveeerrryyy, vvveeerrryyy long one!</textarea> $(function () { $('textarea').setAttribute('style', 'height:' + ($('textarea').scrollHeight) + 'px;'); }); What am I doing wrong, please? I double checked it, but can't find anything wrong
0debug
Determine if more true or falses in an array : Given an array with only odd counts: [1,nil,nil] [1,nil,nil,nil,2] [1,4,nil] [] I would like to determine if there are nils or more non-nils. So far, I converted the truthy and false values to true or false and then to determine if there are more true or false values: [ 1,nil,nil,nil,2,3].collect {|val| !!!val }.max ArgumentError: comparison of TrueClass with false failed The max method does not want to play nice with booleans. How can I accomplish this?
0debug
int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter *iter) { return hbitmap_iter_next(&iter->hbi); }
1threat
void object_unparent(Object *obj) { object_ref(obj); if (obj->parent) { object_property_del_child(obj->parent, obj, NULL); } if (obj->class->unparent) { (obj->class->unparent)(obj); } object_unref(obj); }
1threat
I cant find the files I save in vim : <p>I am trying to learn code using a vim editor as I hear I can get superior long term benefits when I start making long codes and documents. I am a pretty big fan of keyboard shortcuts so I do not mind taking the long road to superior editing abilities. Any way the Linux book I am reading has recommended it and even has many exercises that require typing and saving in vim. The problem is that I cannot find the files I save in vim. I enter the escape mode hit the colon key and use the w option. The vim tells me that the file is saved but when later try to find it in my Linux directory I can find nothing. I have tried using the type, file, find, and locate commands as well as whereis even though this is for commands. Thank you for help in advance.</p>
0debug
document.getElementById('input').innerHTML = user_input;
1threat
Pattern-based substitution in the txt via bash : I have a long text file where somewhere near the end there are 1 line, where the 3 column == OXT. ATOM 2439 O LEU 300 -4.699 34.599 65.335 1.00 83.23 O ATOM 2440 N LEU 301 -6.822 33.898 65.057 1.00 19.70 N ATOM 2441 CA LEU 301 -7.080 34.965 64.138 1.00 19.70 C ATOM 2442 CB LEU 301 -8.165 34.630 63.101 1.00 19.70 C ATOM 2443 CG LEU 301 -7.762 33.478 62.162 1.00 19.70 C ATOM 2444 CD1 LEU 301 -8.849 33.207 61.110 1.00 19.70 C ATOM 2445 CD2 LEU 301 -6.376 33.719 61.543 1.00 19.70 C ATOM 2446 C LEU 301 -7.556 36.168 64.946 1.00 19.70 C ATOM 2447 O LEU 301 -8.657 36.695 64.633 1.00 19.70 O ATOM 2448 OXT LEU 301 -6.821 36.580 65.884 1.00 19.70 O TER 2449 LEU 301 HETATM 2450 NA NA 302 -13.016 13.036 54.214 1.00 44.33 NA HETATM 2451 O WAT 303 -18.411 13.587 59.094 1.00 27.41 O HETATM 2452 O WAT 304 -11.894 17.279 58.575 1.00 18.35 O HETATM 2453 O WAT 305 -15.811 12.728 54.157 1.00 39.81 O I need to modify a line with the pattern OXT (see example below) in a third column and the next one from it (substitute it just with TERM) keeping the spacing between each of the lines as in the original doc. ATOM 2439 O LEU 300 -4.699 34.599 65.335 1.00 83.23 O ATOM 2440 N LEU 301 -6.822 33.898 65.057 1.00 19.70 N ATOM 2441 CA LEU 301 -7.080 34.965 64.138 1.00 19.70 C ATOM 2442 CB LEU 301 -8.165 34.630 63.101 1.00 19.70 C ATOM 2443 CG LEU 301 -7.762 33.478 62.162 1.00 19.70 C ATOM 2444 CD1 LEU 301 -8.849 33.207 61.110 1.00 19.70 C ATOM 2445 CD2 LEU 301 -6.376 33.719 61.543 1.00 19.70 C ATOM 2446 C LEU 301 -7.556 36.168 64.946 1.00 19.70 C ATOM 2447 O LEU 301 -8.657 36.695 64.633 1.00 19.70 O ATOM 2448 N NHE 301 -6.821 36.580 65.884 1.00 19.70 N TER HETATM 2450 NA NA 302 -13.016 13.036 54.214 1.00 44.33 NA HETATM 2451 O WAT 303 -18.411 13.587 59.094 1.00 27.41 O HETATM 2452 O WAT 304 -11.894 17.279 58.575 1.00 18.35 O HETATM 2453 O WAT 305 -15.811 12.728 54.157 1.00 39.81 O I have tried to use awk '$3=="OXT"{ f=1; rn=NR; $3=$NF="N"; $4="NHE" }/TER/ && f && NR-rn == 1{ $0=$1 }1' file It has produced right job but on a new string I had 1 space between each columns which is wrong. ATOM 2410 N NHE 299 -17.563 -15.711 -15.915 1.00 76.42 N I need to keep the original format ATOM 2448 N NHE 301 -6.821 36.580 65.884 1.00 19.70 N Thanks for help! J.
0debug
JS find multiple values in array : <p>I have an array which the values are : </p> <pre><code>1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26 </code></pre> <p>then i want to check this <strong>values</strong> to the array : </p> <pre><code>14,15,16,17 </code></pre> <p>i tried with this but didn't work :</p> <pre><code>function contains(a, toFind) { for (var i = 0; i &lt; a.length; i++) { if (equalArray(a[i], toFind)) { return true; } } return false; } function equalArray(a, b) { if (a.length === b.length) { for (var i = 0; i &lt; a.length; i++) { if (a[i] !== b[i]) { return false; } } return true; } else { return false; } } </code></pre> <p>Anyone can help me out ? </p>
0debug
static int openpic_init(SysBusDevice *dev) { OpenPICState *opp = FROM_SYSBUS(typeof (*opp), dev); int i, j; MemReg list_le[] = { {"glb", &openpic_glb_ops_le, true, OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE}, {"tmr", &openpic_tmr_ops_le, true, OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE}, {"msi", &openpic_msi_ops_le, true, OPENPIC_MSI_REG_START, OPENPIC_MSI_REG_SIZE}, {"src", &openpic_src_ops_le, true, OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE}, {"cpu", &openpic_cpu_ops_le, true, OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE}, }; MemReg list_be[] = { {"glb", &openpic_glb_ops_be, true, OPENPIC_GLB_REG_START, OPENPIC_GLB_REG_SIZE}, {"tmr", &openpic_tmr_ops_be, true, OPENPIC_TMR_REG_START, OPENPIC_TMR_REG_SIZE}, {"msi", &openpic_msi_ops_be, true, OPENPIC_MSI_REG_START, OPENPIC_MSI_REG_SIZE}, {"src", &openpic_src_ops_be, true, OPENPIC_SRC_REG_START, OPENPIC_SRC_REG_SIZE}, {"cpu", &openpic_cpu_ops_be, true, OPENPIC_CPU_REG_START, OPENPIC_CPU_REG_SIZE}, }; MemReg *list; switch (opp->model) { case OPENPIC_MODEL_FSL_MPIC_20: default: opp->flags |= OPENPIC_FLAG_IDR_CRIT; opp->nb_irqs = 80; opp->vid = VID_REVISION_1_2; opp->vir = VIR_GENERIC; opp->vector_mask = 0xFFFF; opp->tfrr_reset = 0; opp->ivpr_reset = IVPR_MASK_MASK; opp->idr_reset = 1 << 0; opp->max_irq = FSL_MPIC_20_MAX_IRQ; opp->irq_ipi0 = FSL_MPIC_20_IPI_IRQ; opp->irq_tim0 = FSL_MPIC_20_TMR_IRQ; opp->irq_msi = FSL_MPIC_20_MSI_IRQ; opp->brr1 = FSL_BRR1_IPID | FSL_BRR1_IPMJ | FSL_BRR1_IPMN; opp->mpic_mode_mask = GCR_MODE_PROXY; msi_supported = true; list = list_be; for (i = 0; i < FSL_MPIC_20_MAX_EXT; i++) { opp->src[i].level = false; } for (i = 16; i < MAX_SRC; i++) { opp->src[i].type = IRQ_TYPE_FSLINT; opp->src[i].level = true; } for (i = MAX_SRC; i < MAX_IRQ; i++) { opp->src[i].type = IRQ_TYPE_FSLSPECIAL; opp->src[i].level = false; } break; case OPENPIC_MODEL_RAVEN: opp->nb_irqs = RAVEN_MAX_EXT; opp->vid = VID_REVISION_1_3; opp->vir = VIR_GENERIC; opp->vector_mask = 0xFF; opp->tfrr_reset = 4160000; opp->ivpr_reset = IVPR_MASK_MASK | IVPR_MODE_MASK; opp->idr_reset = 0; opp->max_irq = RAVEN_MAX_IRQ; opp->irq_ipi0 = RAVEN_IPI_IRQ; opp->irq_tim0 = RAVEN_TMR_IRQ; opp->brr1 = -1; opp->mpic_mode_mask = GCR_MODE_MIXED; list = list_le; list[2].map = false; if (opp->nb_cpus != 1) { return -EINVAL; } break; } memory_region_init(&opp->mem, "openpic", 0x40000); for (i = 0; i < ARRAY_SIZE(list_le); i++) { if (!list[i].map) { continue; } memory_region_init_io(&opp->sub_io_mem[i], list[i].ops, opp, list[i].name, list[i].size); memory_region_add_subregion(&opp->mem, list[i].start_addr, &opp->sub_io_mem[i]); } for (i = 0; i < opp->nb_cpus; i++) { opp->dst[i].irqs = g_new(qemu_irq, OPENPIC_OUTPUT_NB); for (j = 0; j < OPENPIC_OUTPUT_NB; j++) { sysbus_init_irq(dev, &opp->dst[i].irqs[j]); } } register_savevm(&opp->busdev.qdev, "openpic", 0, 2, openpic_save, openpic_load, opp); sysbus_init_mmio(dev, &opp->mem); qdev_init_gpio_in(&dev->qdev, openpic_set_irq, opp->max_irq); return 0; }
1threat
static CharDriverState *qemu_chr_open_stdio(QemuOpts *opts) { CharDriverState *chr; if (stdio_nb_clients >= STDIO_MAX_CLIENTS) { if (stdio_nb_clients == 0) { old_fd0_flags = fcntl(0, F_GETFL); tcgetattr (0, &oldtty); fcntl(0, F_SETFL, O_NONBLOCK); atexit(term_exit); chr = qemu_chr_open_fd(0, 1); chr->chr_close = qemu_chr_close_stdio; chr->chr_set_echo = qemu_chr_set_echo_stdio; qemu_set_fd_handler2(0, stdio_read_poll, stdio_read, NULL, chr); stdio_nb_clients++; stdio_allow_signal = qemu_opt_get_bool(opts, "signal", display_type != DT_NOGRAPHIC); qemu_chr_fe_set_echo(chr, false); return chr;
1threat
FILE I/O Throwing Compile Error in C : I am trying to write a character to a file in C, but this code: case 4: //If the user types 4 (reset) FILE * fp; FILE *fp; fp = fopen("settings.txt", "w"); fprintf(fp, "a"); int fclose(FILE * fp); break; Throws this error: fileio.c:72:5: error: expected expression FILE * fp; (Yes, I know I used "file * fp" two times but without both it throws even more errors.) How can I fix this? Thank you!
0debug
Matlap Clamped Spline : I need to solve the question on the photo with the help of matlab What am I doing wrong? Are there some who can help? Very important to me. clc; clear; format compact; T=[0 3 5 8 13] V=[0 225 383 623 993] A=[75 77 80 74 72] v_5=interp1(T,V,5); a_5=interp1(T,A,5); t_5=interp1(T,A,5); x=0:3:13; y=interp1(T,A,x,'spline'); plot(T,V,'o',x,y),title('speed vs distance ') [exp][1] [1]: https://i.stack.imgur.com/iqS4n.png
0debug
How does this C code work but the other says L-value required? : <p>This code works fine when b is incremented and a is printed upon increment</p> <pre><code>#include&lt;stdio.h&gt; int main() { int a[] = {10,20,30,40,50}, *p, j; int *b = a; for(j=0;j&lt;5;j++) { printf("%d\n",*b); b++; } return 0; } </code></pre> <p>What happens here? What effect does a++ have here to suggest <code>lvalue</code> is required. Does a++ move to a point after all the elements of the array a?</p> <pre><code>#include&lt;stdio.h&gt; int main() { int a[] = {10,20,30,40,50}, *p, j; for(j=0;j&lt;5;j++) { printf("%d\n",*a); a++; } return 0; } </code></pre>
0debug
static int qcow2_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVQcowState *s = bs->opaque; int len, i, ret = 0; QCowHeader header; QemuOpts *opts; Error *local_err = NULL; uint64_t ext_end; uint64_t l1_vm_state_index; const char *opt_overlap_check; int overlap_check_template = 0; ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read qcow2 header"); goto fail; } be32_to_cpus(&header.magic); be32_to_cpus(&header.version); be64_to_cpus(&header.backing_file_offset); be32_to_cpus(&header.backing_file_size); be64_to_cpus(&header.size); be32_to_cpus(&header.cluster_bits); be32_to_cpus(&header.crypt_method); be64_to_cpus(&header.l1_table_offset); be32_to_cpus(&header.l1_size); be64_to_cpus(&header.refcount_table_offset); be32_to_cpus(&header.refcount_table_clusters); be64_to_cpus(&header.snapshots_offset); be32_to_cpus(&header.nb_snapshots); if (header.magic != QCOW_MAGIC) { error_setg(errp, "Image is not in qcow2 format"); ret = -EINVAL; goto fail; } if (header.version < 2 || header.version > 3) { report_unsupported(bs, errp, "QCOW version %d", header.version); ret = -ENOTSUP; goto fail; } s->qcow_version = header.version; if (header.version == 2) { header.incompatible_features = 0; header.compatible_features = 0; header.autoclear_features = 0; header.refcount_order = 4; header.header_length = 72; } else { be64_to_cpus(&header.incompatible_features); be64_to_cpus(&header.compatible_features); be64_to_cpus(&header.autoclear_features); be32_to_cpus(&header.refcount_order); be32_to_cpus(&header.header_length); } if (header.header_length > sizeof(header)) { s->unknown_header_fields_size = header.header_length - sizeof(header); s->unknown_header_fields = g_malloc(s->unknown_header_fields_size); ret = bdrv_pread(bs->file, sizeof(header), s->unknown_header_fields, s->unknown_header_fields_size); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read unknown qcow2 header " "fields"); goto fail; } } if (header.backing_file_offset) { ext_end = header.backing_file_offset; } else { ext_end = 1 << header.cluster_bits; } s->incompatible_features = header.incompatible_features; s->compatible_features = header.compatible_features; s->autoclear_features = header.autoclear_features; if (s->incompatible_features & ~QCOW2_INCOMPAT_MASK) { void *feature_table = NULL; qcow2_read_extensions(bs, header.header_length, ext_end, &feature_table, NULL); report_unsupported_feature(bs, errp, feature_table, s->incompatible_features & ~QCOW2_INCOMPAT_MASK); ret = -ENOTSUP; g_free(feature_table); goto fail; } if (s->incompatible_features & QCOW2_INCOMPAT_CORRUPT) { if ((flags & BDRV_O_RDWR) && !(flags & BDRV_O_CHECK)) { error_setg(errp, "qcow2: Image is corrupt; cannot be opened " "read/write"); ret = -EACCES; goto fail; } } if (header.refcount_order != 4) { report_unsupported(bs, errp, "%d bit reference counts", 1 << header.refcount_order); ret = -ENOTSUP; goto fail; } s->refcount_order = header.refcount_order; if (header.cluster_bits < MIN_CLUSTER_BITS || header.cluster_bits > MAX_CLUSTER_BITS) { error_setg(errp, "Unsupported cluster size: 2^%i", header.cluster_bits); ret = -EINVAL; goto fail; } if (header.crypt_method > QCOW_CRYPT_AES) { error_setg(errp, "Unsupported encryption method: %i", header.crypt_method); ret = -EINVAL; goto fail; } s->crypt_method_header = header.crypt_method; if (s->crypt_method_header) { bs->encrypted = 1; } s->cluster_bits = header.cluster_bits; s->cluster_size = 1 << s->cluster_bits; s->cluster_sectors = 1 << (s->cluster_bits - 9); s->l2_bits = s->cluster_bits - 3; s->l2_size = 1 << s->l2_bits; bs->total_sectors = header.size / 512; s->csize_shift = (62 - (s->cluster_bits - 8)); s->csize_mask = (1 << (s->cluster_bits - 8)) - 1; s->cluster_offset_mask = (1LL << s->csize_shift) - 1; s->refcount_table_offset = header.refcount_table_offset; s->refcount_table_size = header.refcount_table_clusters << (s->cluster_bits - 3); s->snapshots_offset = header.snapshots_offset; s->nb_snapshots = header.nb_snapshots; s->l1_size = header.l1_size; l1_vm_state_index = size_to_l1(s, header.size); if (l1_vm_state_index > INT_MAX) { error_setg(errp, "Image is too big"); ret = -EFBIG; goto fail; } s->l1_vm_state_index = l1_vm_state_index; if (s->l1_size < s->l1_vm_state_index) { error_setg(errp, "L1 table is too small"); ret = -EINVAL; goto fail; } s->l1_table_offset = header.l1_table_offset; if (s->l1_size > 0) { s->l1_table = g_malloc0( align_offset(s->l1_size * sizeof(uint64_t), 512)); ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read L1 table"); goto fail; } for(i = 0;i < s->l1_size; i++) { be64_to_cpus(&s->l1_table[i]); } } s->l2_table_cache = qcow2_cache_create(bs, L2_CACHE_SIZE); s->refcount_block_cache = qcow2_cache_create(bs, REFCOUNT_CACHE_SIZE); s->cluster_cache = g_malloc(s->cluster_size); s->cluster_data = qemu_blockalign(bs, QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size + 512); s->cluster_cache_offset = -1; s->flags = flags; ret = qcow2_refcount_init(bs); if (ret != 0) { error_setg_errno(errp, -ret, "Could not initialize refcount handling"); goto fail; } QLIST_INIT(&s->cluster_allocs); QTAILQ_INIT(&s->discards); if (qcow2_read_extensions(bs, header.header_length, ext_end, NULL, &local_err)) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } if (header.backing_file_offset != 0) { len = header.backing_file_size; if (len > 1023) { len = 1023; } ret = bdrv_pread(bs->file, header.backing_file_offset, bs->backing_file, len); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read backing file name"); goto fail; } bs->backing_file[len] = '\0'; } ret = qcow2_read_snapshots(bs); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read snapshots"); goto fail; } if (!bs->read_only && !(flags & BDRV_O_INCOMING) && s->autoclear_features) { s->autoclear_features = 0; ret = qcow2_update_header(bs); if (ret < 0) { error_setg_errno(errp, -ret, "Could not update qcow2 header"); goto fail; } } qemu_co_mutex_init(&s->lock); if (!(flags & (BDRV_O_CHECK | BDRV_O_INCOMING)) && !bs->read_only && (s->incompatible_features & QCOW2_INCOMPAT_DIRTY)) { BdrvCheckResult result = {0}; ret = qcow2_check(bs, &result, BDRV_FIX_ERRORS); if (ret < 0) { error_setg_errno(errp, -ret, "Could not repair dirty image"); goto fail; } } opts = qemu_opts_create(&qcow2_runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto fail; } s->use_lazy_refcounts = qemu_opt_get_bool(opts, QCOW2_OPT_LAZY_REFCOUNTS, (s->compatible_features & QCOW2_COMPAT_LAZY_REFCOUNTS)); s->discard_passthrough[QCOW2_DISCARD_NEVER] = false; s->discard_passthrough[QCOW2_DISCARD_ALWAYS] = true; s->discard_passthrough[QCOW2_DISCARD_REQUEST] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_REQUEST, flags & BDRV_O_UNMAP); s->discard_passthrough[QCOW2_DISCARD_SNAPSHOT] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_SNAPSHOT, true); s->discard_passthrough[QCOW2_DISCARD_OTHER] = qemu_opt_get_bool(opts, QCOW2_OPT_DISCARD_OTHER, false); opt_overlap_check = qemu_opt_get(opts, "overlap-check") ?: "cached"; if (!strcmp(opt_overlap_check, "none")) { overlap_check_template = 0; } else if (!strcmp(opt_overlap_check, "constant")) { overlap_check_template = QCOW2_OL_CONSTANT; } else if (!strcmp(opt_overlap_check, "cached")) { overlap_check_template = QCOW2_OL_CACHED; } else if (!strcmp(opt_overlap_check, "all")) { overlap_check_template = QCOW2_OL_ALL; } else { error_setg(errp, "Unsupported value '%s' for qcow2 option " "'overlap-check'. Allowed are either of the following: " "none, constant, cached, all", opt_overlap_check); qemu_opts_del(opts); ret = -EINVAL; goto fail; } s->overlap_check = 0; for (i = 0; i < QCOW2_OL_MAX_BITNR; i++) { s->overlap_check |= qemu_opt_get_bool(opts, overlap_bool_option_names[i], overlap_check_template & (1 << i)) << i; } qemu_opts_del(opts); if (s->use_lazy_refcounts && s->qcow_version < 3) { error_setg(errp, "Lazy refcounts require a qcow2 image with at least " "qemu 1.1 compatibility level"); ret = -EINVAL; goto fail; } #ifdef DEBUG_ALLOC { BdrvCheckResult result = {0}; qcow2_check_refcounts(bs, &result, 0); } #endif return ret; fail: g_free(s->unknown_header_fields); cleanup_unknown_header_ext(bs); qcow2_free_snapshots(bs); qcow2_refcount_close(bs); g_free(s->l1_table); s->l1_table = NULL; if (s->l2_table_cache) { qcow2_cache_destroy(bs, s->l2_table_cache); } if (s->refcount_block_cache) { qcow2_cache_destroy(bs, s->refcount_block_cache); } g_free(s->cluster_cache); qemu_vfree(s->cluster_data); return ret; }
1threat
URGENT What is wrong with my Lucky name Number python code : name = input("Please enter your name: ") name = name.lower() luckynumb = 0 firstnamenumb = 0 surnamenumb = 0 number = [1, 2, 3, 4, 5, 6, 7, 8, 9] row1 = ["a", "b", "c", "d", "e", "f", "g", "h", "i"] row2 = ["j", "k", "l", "m", "n", "o", "p", "q", "r"] row3 = ["s", "t", "u", "v", "w", "x", "y", "z"] for letter in name: if letter == "a" or letter == "j" or letter == "s=": luckynumb += 1 if letter == "b" or letter == "k"or letter == "t": luckynumb += 2 if letter == "c" or letter == "l"or letter == "u": luckynumb += 3 if letter == "d" or letter == "m"or letter == "v": luckynumb += 4 if letter == "e" or letter == "n"or letter == "w": luckynumb += 5 if letter == "f" or letter == "o"or letter == "x": luckynumb += 6 if letter == "g" or letter == "p"or letter == "y": luckynumb += 7 if letter == "h" or letter == "q"or letter == "z": luckynumb += 8 if letter == "i" or letter == "r": luckynumb += 9 surnamenumb = - luckynumb while int(firstnamenumb) > 9: split = list(str(firstnamenumb)) # it will firstnamenumb = int(split[0]) + int(split[1]) print(firstnamenumb) while int(surnamenumb) > 9: split = list(str(surnamenumb)) # it will surnamenumb = int(split[0]) + int(split[1]) print(surnamenumb) luckynumb = firstnamenumb + surnamenumb for luckynumb in range(1, 5, 9): # print(luckynumb) if int(luckynumb) == 1: print("Natural Leaders") elif int(luckynumb) == 2: print("Natural Peacemakers") elif int(luckynumb) == 3: print("Creative and Optimistic") elif int(luckynumb) == 4: print("Hard Workers") elif int(luckynumb) == 5: print("Value Freedom") elif int(luckynumb) == 6: print("Carers and Providers") elif int(luckynumb) == 7: print("Thinkers") elif int(luckynumb) == 8: print("Have Diplomatic Skills") elif int(luckynumb) == 9: print("Selfless and Generous") else: print("Error. Please try again") What is wrong with this code. no matter what you type in it only give the same 1 answer. no idea how to fix it somone help its urgent need it in the next 4 hours I will now type gibberish as stack overflow isn't allowing me to ask this question until I have more text. udshfauiaesgdiufewhyfiuahfiueyfhuioehyfiuwegfiesjkfaesgukfgeukwgfweurfhewkuafguekwgfEWGFjewgfayguewliaiulwfefhekulwhfukeshfkugsefukewgfuieawgfuwreaghuliewghfiuewfhuwekigfuelskgfugweuaewighifulaegfuilewgaiulfelwgifewgufguewigfuielwlagfuiawegulidsgufkesghfjkadsgdufgtuegfugeugsdayfyuweyuafgewfuiaewghifelrhyflioiewhypoaewyhfuidsgfkdsgadlkjugfukaesfgyugwefyulsegfukseahfuisdhefiawfhyierhfiuoaew;fhyuioeshfilhsfeaio;aehfiouaewyfh;fiuewgfuiaashgcfgtdhyukejsrhgfteyduikfjgvryeuifkgjvhfryeuirfjkgvftryeuijfkgvhfyreu8iofjyru8eirdjfhgydrueiokfdmhyreuikjfhyurdiemfdjduimkvjufidrkmvjdfirkmfcjvfduikfjnvhjfudimfjkemdfnjkdmfcnvjhfdmkfcv I'm sorry for that
0debug
def count_Intgral_Points(x1,y1,x2,y2): return ((y2 - y1 - 1) * (x2 - x1 - 1))
0debug
What to do when Jupyter suddenly hangs? : <p>I'm using Jupyter notebook 4.0.6 on OSX El Capitan. </p> <p>Once in a while I'll start running a notebook and the cell will simply hang, with a <code>[ * ]</code> next to it and no output.</p> <p>When this happens, I find that only killing Jupyter at the command line and restarting it solves the problem. Relaunching the kernel doesn't help. </p> <p>Has anyone else had this problem? If so, any tips?</p>
0debug
static void stellaris_init(const char *kernel_filename, const char *cpu_model, DisplayState *ds, stellaris_board_info *board) { static const int uart_irq[] = {5, 6, 33, 34}; static const int timer_irq[] = {19, 21, 23, 35}; static const uint32_t gpio_addr[7] = { 0x40004000, 0x40005000, 0x40006000, 0x40007000, 0x40024000, 0x40025000, 0x40026000}; static const int gpio_irq[7] = {0, 1, 2, 3, 4, 30, 31}; qemu_irq *pic; qemu_irq *gpio_in[7]; qemu_irq *gpio_out[7]; qemu_irq adc; int sram_size; int flash_size; i2c_bus *i2c; int i; flash_size = ((board->dc0 & 0xffff) + 1) << 1; sram_size = (board->dc0 >> 18) + 1; pic = armv7m_init(flash_size, sram_size, kernel_filename, cpu_model); if (board->dc1 & (1 << 16)) { adc = stellaris_adc_init(0x40038000, pic[14]); } else { adc = NULL; } for (i = 0; i < 4; i++) { if (board->dc2 & (0x10000 << i)) { stellaris_gptm_init(0x40030000 + i * 0x1000, pic[timer_irq[i]], adc); } } stellaris_sys_init(0x400fe000, pic[28], board, nd_table[0].macaddr); for (i = 0; i < 7; i++) { if (board->dc4 & (1 << i)) { gpio_in[i] = pl061_init(gpio_addr[i], pic[gpio_irq[i]], &gpio_out[i]); } } if (board->dc2 & (1 << 12)) { i2c = i2c_init_bus(); stellaris_i2c_init(0x40020000, pic[8], i2c); if (board->peripherals & BP_OLED_I2C) { ssd0303_init(ds, i2c, 0x3d); } } for (i = 0; i < 4; i++) { if (board->dc2 & (1 << i)) { pl011_init(0x4000c000 + i * 0x1000, pic[uart_irq[i]], serial_hds[i], PL011_LUMINARY); } } if (board->dc2 & (1 << 4)) { if (board->peripherals & BP_OLED_SSI) { void * oled; void * sd; void *ssi_bus; int index; oled = ssd0323_init(ds, &gpio_out[GPIO_C][7]); index = drive_get_index(IF_SD, 0, 0); sd = ssi_sd_init(drives_table[index].bdrv); ssi_bus = stellaris_ssi_bus_init(&gpio_out[GPIO_D][0], ssi_sd_xfer, sd, ssd0323_xfer_ssi, oled); pl022_init(0x40008000, pic[7], stellaris_ssi_bus_xfer, ssi_bus); qemu_irq_raise(gpio_out[GPIO_D][0]); } else { pl022_init(0x40008000, pic[7], NULL, NULL); } } if (board->dc4 & (1 << 28)) { stellaris_enet_init(&nd_table[0], 0x40048000, pic[42]); } if (board->peripherals & BP_GAMEPAD) { qemu_irq gpad_irq[5]; static const int gpad_keycode[5] = { 0xc8, 0xd0, 0xcb, 0xcd, 0x1d }; gpad_irq[0] = qemu_irq_invert(gpio_in[GPIO_E][0]); gpad_irq[1] = qemu_irq_invert(gpio_in[GPIO_E][1]); gpad_irq[2] = qemu_irq_invert(gpio_in[GPIO_E][2]); gpad_irq[3] = qemu_irq_invert(gpio_in[GPIO_E][3]); gpad_irq[4] = qemu_irq_invert(gpio_in[GPIO_F][1]); stellaris_gamepad_init(5, gpad_irq, gpad_keycode); } }
1threat
global name 'distance' is not defined : <p>I'm new to python and ros, and I'm having a little issue at the moment. I'm sure it's a simple error on my part, but I can't figure it out.</p> <p>I've searched and found similar situations, but I'm not sure how to implement the solutions given to other answers on my code.</p> <p>Please ignore any 'crappiness' in my code that does not directly contribute to the issue. I just need this project to run as quickly as possible.</p> <pre><code>#!/usr/bin/env python import rospy from geometry_msgs.msg import Twist, Vector3Stamped from math import radians from sensor_msgs.msg import NavSatFix import geometry_msgs.msg import time import numpy global distance global pub global dest_lat global dest_long global move_cmd global turn_cmd global bearing global heading global initial_bearing global cur_lat global prev_lat global cur_long global prev_long bearing = 0 ################################################################################ lat_dest = 30.210406 # DESTINATION COORDINATES long_dest = -92.022914 ################################################################################ move_cmd = Twist() turn_cmd = Twist() def nav_dist(navsat): R = 6373000 # Radius of the earth in m cur_lat = navsat.latitude cur_long = navsat.longitude dLat = cur_lat - lat_dest dLon = cur_long - long_dest x = dLon * numpy.cos((lat_dest+cur_lat)/2) distance = numpy.sqrt(x**2 + dLat**2) * R return distance def bearing(): if (bearing == 0): bearing = initial_bearing return bearing else: bearing = calculate_bearing(cur_lat, prev_lat, cur_long, prev_long) return bearing def calculate_bearing(lat1, lat2, long1, long2): dLon = long2 - long1 y = np.sin(dLon) * np.cos(lat2) x = np.cos(lat1)*np.sin(lat2) - np.sin(lat1)*np.cos(lat2)*np.cos(dLon) bearing = (np.rad2deg(np.arctan2(y, x)) + 360) % 360 return bearing def calculate_nav_angle(lat1, lat_dest, long1, long_dest): dLon = long_dest - long1 y = np.sin(dLon) * np.cos(lat_dest) x = np.cos(lat1)*np.sin(lat_dest) - np.sin(lat1)*np.cos(lat_dest)*np.cos(dLon) heading = (np.rad2deg(np.arctan2(y, x)) + 360) % 360 return heading def navigate(distance, nav_angle): turn_cmd.angular.z = radians(bearing - heading) move_cmd.linear.x = distance pub.publish(turn_cmd) time.sleep(.01) pub.publish(move_cmd) time.sleep(.001) prev_long = cur_long prev_lat = cur_lat ############################################################################################### ################################# callbacks and run ################################# ############################################################################################### def call_nav(navsat): rospy.loginfo("Latitude: %s", navsat.latitude) #Print GPS co-or to terminal rospy.loginfo("Longitude: %s", navsat.longitude) nav_dist(navsat) time.sleep(.001) def call_bear(bearing): rospy.loginfo("Bearing: %s", bearing.vector) #Print mag reading for bearing x = -bearing.vector.y y = bearing.vector.z initial_bearing = numpy.arctan2(y, x) return initial_bearing def run(): pub = rospy.Publisher('/husky_velocity_controller/cmd_vel', Twist) rospy.Subscriber("/imu_um6/mag", Vector3Stamped, call_bear) rospy.Subscriber("/gps/fix", NavSatFix, call_nav) rospy.init_node('navigate_that_husky') rospy.spin() if __name__ == '__main__': run() navigate(distance, nav_angle) </code></pre> <p>and here is the error</p> <pre><code>Traceback (most recent call last): File "NewTest.py", line 111, in &lt;module&gt; navigate(distance, nav_angle) NameError: global name 'distance' is not defined </code></pre> <p>how might I fix this? I appreciate any help.</p>
0debug
creating inteval object in r using lubridate package : <p>hi i have data from uber : <a href="https://i.stack.imgur.com/qZaKs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qZaKs.png" alt="enter image description here"></a></p> <p>about pick ups in NYC . im trying to add a column to the raw data, that indicates for each row, for which time interval (which is represented by a single timepoint at the beginning of thetime interval) it belongs. </p> <p>i want to Create a vector containing all relevant timepoints (i.e. every 15 minutes Use int_diff function from lubridate package on this vector to create an interval object. Run a loop on all the time points in the raw data and for each data point; indicate to which interval (which is represented by a single timepoint at the beginning of the time interval) it belongs. </p> <p>i tried looking for explanations how to use the int_diff function but i dont understand how my vector should look and how the syntax of int_diff works tanks for the help :)</p>
0debug
Trying to understand the new behavior of appsettings.json vs web.config in .NET Core but confused by contradictory information on MSDN : <p>So, I'm reading through all of the .NET Core Fundamentals articles on MSDN while hacking around on a new .NET Core MVC application in Visual Studio 2017. There seem to be some inconsistencies between what I'm reading in the articles and what I'm seeing in my application. I was hoping somebody could help me understand.</p> <p>So, I understand that a new .NET Core project created in Visual Studio, by default, is configured to use the Kestrel web server with an IIS Express web server acting as a reverse proxy when running in development.</p> <p>I also understand that the ASP.NET Core Module hooks into the IIS pipeline and, among other things, redirects traffic to your .NET Core web application.</p> <p>Here's what I'm getting hung up on.</p> <p>From the MSDN article on .NET Core Configuration:</p> <blockquote> <p>The web.config file A web.config file is required when you host the app in IIS >or IIS-Express. web.config turns on the AspNetCoreModule in IIS to launch your >app. Settings in web.config enable >the AspNetCoreModule in IIS to launch your >app and configure other IIS settings and modules. If you are using Visual >Studio and delete web.config, Visual Studio will create a new one.</p> </blockquote> <p>I was under the impression that in .NET Core, application configuration had been moved out of the web.config file, and was instead controlled through a number of different mechanisms, one of which is the appsettings.json file. In fact, creating a new .NET Core MVC application in Visual Studio doesn't even create a web.config file in my solution directory.</p> <p>But from the article quoted above, it sounds like the ASP.NET Core Module is still configured through a web.config file? What's confusing is that the article says Visual Studio will create a web.config file for me if one doesn't exist, but I've run the application a few times and don't see a web.config file created anywhere.</p> <p>What confuses me further is more seemingly contradictory information from the MSDN ASP.NET Core module reference article:</p> <blockquote> <p>The ASP.NET Core Module is configured via a site or application web.config file >and has its own aspNetCore configuration section within system.webServer. >Here's an example web.config file that the Microsoft.NET.Sdk.Web SDK will >provide when the project is published for a framework-dependent deployment with >placeholders for the processPath and arguments:</p> </blockquote> <p>So wait - this says that the act of publishing my application is what creates the web.config file.</p> <p>So is it only full blown IIS that needs a web.config file? Maybe IIS Express and IIS both work with default behavior if no web.config is provided, but I need a web.config file if I want to override the default behavior?</p> <p>Does anybody have a solid understanding of how this all works in .NET Core that is willing to set me straight?</p>
0debug
set_phy_ctrl(E1000State *s, int index, uint16_t val) { if (!(s->compat_flags & E1000_FLAG_AUTONEG)) { return; } if ((val & MII_CR_AUTO_NEG_EN) && (val & MII_CR_RESTART_AUTO_NEG)) { e1000_link_down(s); DBGOUT(PHY, "Start link auto negotiation\n"); timer_mod(s->autoneg_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500); } }
1threat
static av_cold int avs_decode_init(AVCodecContext * avctx) { AvsContext *s = avctx->priv_data; s->frame = av_frame_alloc(); if (!s->frame) return AVERROR(ENOMEM); avctx->pix_fmt = AV_PIX_FMT_PAL8; ff_set_dimensions(avctx, 318, 198); return 0; }
1threat
Python: Test whether a number is within 100 of 1000 or 2000 : <p>After reading the problem I had no clue to solve it, so I read the below solution and still dont have any clue what it means. Can anyone walk me through the objective of the problem and how the below code solves the problem?</p> <p>Below is the sample code to solve the problem:</p> <pre><code>def near_thousand(n): return ((abs(1000 - n) &lt;= 100) or (abs(2000 - n) &lt;= 100)) print(near_thousand(1000)) print(near_thousand(900)) print(near_thousand(800)) print(near_thousand(2200)) </code></pre>
0debug
I need help for open and close action menu using css : I am creating a floating action buttons and here is my code My Code: jsfiddle.net/7zkjas08 Currently in my code when user click the action button the popup appears and user need to click or tap in somewhere in the screen to close the popup. I want functionality like this : jsfiddle.net/r2hxbL5j When user click the button it shows the cross X closing sign. So user can tap/click the cross sign and popup disappears. Please help me how can i do this.
0debug
How to create a function to convert a number into binary form using recursion : ## assuming it is a positive int ## ##[code to convert a number to binary][1]## ##attached is my code, for some it runs correctly but for other numbers it does not ## [1]: https://i.stack.imgur.com/TGab4.png
0debug
static int qemu_rbd_set_keypairs(rados_t cluster, const char *keypairs, Error **errp) { char *p, *buf; char *name; char *value; Error *local_err = NULL; int ret = 0; buf = g_strdup(keypairs); p = buf; while (p) { name = qemu_rbd_next_tok(RBD_MAX_CONF_NAME_SIZE, p, '=', "conf option name", &p, &local_err); if (local_err) { break; } if (!p) { error_setg(errp, "conf option %s has no value", name); ret = -EINVAL; break; } value = qemu_rbd_next_tok(RBD_MAX_CONF_VAL_SIZE, p, ':', "conf option value", &p, &local_err); if (local_err) { break; } ret = rados_conf_set(cluster, name, value); if (ret < 0) { error_setg_errno(errp, -ret, "invalid conf option %s", name); ret = -EINVAL; break; } } if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; } g_free(buf); return ret; }
1threat
void ff_get_guid(AVIOContext *s, ff_asf_guid *g) { assert(sizeof(*g) == 16); avio_read(s, *g, sizeof(*g)); }
1threat
how to know all style options of a ttk widget : <p>This problem nearly makes me craze. I am a new beginner and without knowledge of tck/tk. I have done carefully search on the internet but haven't found a good solution.</p> <p>For example, I created a label frame using</p> <pre><code>import tkinter as tk from tkinter import ttk newBT = ttk.LabelFrame(width=100, height=100) </code></pre> <p>Then I need to set the frame style. There is foreground for <strong>tk.LabelFrame</strong>. However, I didn't find such style option for <strong>ttk.LabelFrame</strong> on <a href="http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/ttk-LabelFrame.html" rel="noreferrer">NMT</a> and <a href="http://www.tcl.tk/man/tcl8.5/TkCmd/ttk_labelframe.htm" rel="noreferrer">tck/tk</a> reference. Then I have to guess, like following</p> <pre><code>s = ttk.Style() s.configure('TLabelframe', foreground='red') </code></pre> <p>But this doesn't work, <a href="https://stackoverflow.com/questions/18755963/set-style-for-checkbutton-or-labelframe-in-python-tkinter">the right thing</a> is</p> <pre><code>s.configure('TLabelframe.Label', foreground='red') </code></pre> <p>So, my question is, how can I find out all the style options a ttk widget has. Is there some function like</p> <pre><code>s.getAllOptions('TLabelframe') </code></pre> <p>and then the output is something like</p> <pre><code>['background', 'foreground', 'padding', 'border', ...] </code></pre> <p>Thanks!</p>
0debug
static int smacker_probe(AVProbeData *p) { if (p->buf_size < 4) return 0; if(p->buf[0] == 'S' && p->buf[1] == 'M' && p->buf[2] == 'K' && (p->buf[3] == '2' || p->buf[3] == '4')) return AVPROBE_SCORE_MAX; else return 0; }
1threat
read_f(int argc, char **argv) { struct timeval t1, t2; int Cflag = 0, pflag = 0, qflag = 0, vflag = 0; int Pflag = 0, sflag = 0, lflag = 0; int c, cnt; char *buf; int64_t offset; int count; int total = 0; int pattern = 0, pattern_offset = 0, pattern_count = 0; while ((c = getopt(argc, argv, "Cl:pP:qs:v")) != EOF) { switch (c) { case 'C': Cflag = 1; break; case 'l': lflag = 1; pattern_count = cvtnum(optarg); if (pattern_count < 0) { printf("non-numeric length argument -- %s\n", optarg); return 0; } break; case 'p': pflag = 1; break; case 'P': Pflag = 1; pattern = atoi(optarg); break; case 'q': qflag = 1; break; case 's': sflag = 1; pattern_offset = cvtnum(optarg); if (pattern_offset < 0) { printf("non-numeric length argument -- %s\n", optarg); return 0; } break; case 'v': vflag = 1; break; default: return command_usage(&read_cmd); } } if (optind != argc - 2) return command_usage(&read_cmd); offset = cvtnum(argv[optind]); if (offset < 0) { printf("non-numeric length argument -- %s\n", argv[optind]); return 0; } optind++; count = cvtnum(argv[optind]); if (count < 0) { printf("non-numeric length argument -- %s\n", argv[optind]); return 0; } if (!Pflag && (lflag || sflag)) { return command_usage(&read_cmd); } if (!lflag) { pattern_count = count - pattern_offset; } if ((pattern_count < 0) || (pattern_count + pattern_offset > count)) { printf("pattern verfication range exceeds end of read data\n"); return 0; } if (!pflag) if (offset & 0x1ff) { printf("offset %lld is not sector aligned\n", (long long)offset); return 0; if (count & 0x1ff) { printf("count %d is not sector aligned\n", count); return 0; } } buf = qemu_io_alloc(count, 0xab); gettimeofday(&t1, NULL); if (pflag) cnt = do_pread(buf, offset, count, &total); else cnt = do_read(buf, offset, count, &total); gettimeofday(&t2, NULL); if (cnt < 0) { printf("read failed: %s\n", strerror(-cnt)); return 0; } if (Pflag) { void* cmp_buf = malloc(pattern_count); memset(cmp_buf, pattern, pattern_count); if (memcmp(buf + pattern_offset, cmp_buf, pattern_count)) { printf("Pattern verification failed at offset %lld, " "%d bytes\n", (long long) offset + pattern_offset, pattern_count); } free(cmp_buf); } if (qflag) return 0; if (vflag) dump_buffer(buf, offset, count); t2 = tsub(t2, t1); print_report("read", &t2, offset, count, total, cnt, Cflag); qemu_io_free(buf); return 0; }
1threat
How to bind raw html in Angular2 : <p>I use Angular 2.0.0-beta.0 and I want to create and bind some simple HTML directly. Is is possible and how?</p> <p>I tried to use</p> <pre><code>{{myField}} </code></pre> <p>but the text in myField will get escaped.</p> <p>For Angular 1.x i found hits for ng-bind-html, but this seems not be supported in 2.x</p> <p>thx Frank </p>
0debug
static USBDevice *usb_serial_init(const char *filename) { USBDevice *dev; CharDriverState *cdrv; uint32_t vendorid = 0, productid = 0; char label[32]; static int index; while (*filename && *filename != ':') { const char *p; char *e; if (strstart(filename, "vendorid=", &p)) { vendorid = strtol(p, &e, 16); if (e == p || (*e && *e != ',' && *e != ':')) { qemu_error("bogus vendor ID %s\n", p); filename = e; } else if (strstart(filename, "productid=", &p)) { productid = strtol(p, &e, 16); if (e == p || (*e && *e != ',' && *e != ':')) { qemu_error("bogus product ID %s\n", p); filename = e; } else { qemu_error("unrecognized serial USB option %s\n", filename); while(*filename == ',') filename++; if (!*filename) { qemu_error("character device specification needed\n"); filename++; snprintf(label, sizeof(label), "usbserial%d", index++); cdrv = qemu_chr_open(label, filename, NULL); if (!cdrv) dev = usb_create(NULL , "usb-serial"); qdev_prop_set_chr(&dev->qdev, "chardev", cdrv); if (vendorid) qdev_prop_set_uint16(&dev->qdev, "vendorid", vendorid); if (productid) qdev_prop_set_uint16(&dev->qdev, "productid", productid); qdev_init_nofail(&dev->qdev); return dev;
1threat
Java country code. Make the first character always appear : <p>I wanna to make a country code text field. When user click text field, there preset a "+" at the first. Also, that "+" cannot be deleted. How can I make this happen. </p>
0debug
SAP NetWeaver RFC SDK Documentation? : <p>Where can I find the SAP NetWeaver RFC SDK online documentation?</p> <p>A developer told me to download a zip file in this <a href="https://github.com/SAP/PyRFC/issues/89#issuecomment-447299033" rel="nofollow noreferrer">issue</a></p> <p>I can't believe that the docs are not available online. We live in the 21 century :-)</p> <p>Where is the SAP NetWeaver RFC SDK <strong>online</strong> documentation?</p>
0debug