problem
stringlengths
26
131k
labels
class label
2 classes
IOS - How to hide a view by touching anywhere outside of it : <p>I'm new to IOS programming, I'm displaying a view when a button is clicked, using the following code inside the button method.</p> <pre><code> @IBAction func moreButton(_ sender: Any) { self.helpView.isHidden = false } </code></pre> <p>initially, the <code>self.helpView.isHidden</code> is set to true in <code>viewDidLoad</code> method to hide the view. Now, how can i dismiss this view by touching anywhere outside the view. From the research, i found that, it can be done by creating a transparent button that fits the whole viewController. So then by clicking on the button, we can make the view to dismiss. Can anyone give me the code in swift 3 to create such button.</p> <p>Or, if there is any other better way to hide a view, it is welcomed.</p> <p>I'm using Xcode 8.2, swift 3.0</p> <p>Thanks in advance.</p>
0debug
Replace last comma in character with " &" : <p>I have many different characters which have the following structure:</p> <pre><code># Example x &lt;- "char1, char2, char3" </code></pre> <p>I want to remove the last comma of this character with " &amp;", i.e. the desired output should look as follows:</p> <pre><code># Desired output "char1, char2 &amp; char3" </code></pre> <p>How could I replace the last comma of a character with " &amp;"?</p>
0debug
missing number with duplicates in the list : I have a list `l = [3,1,2,5,3]`. My goal is to find the repeated number in **O(n)** which is 3 and also the missing number which is 4. Finally, the output should be `[3,4]`. I trying to use a dictionary to find the repeated number but again to find the missing number I am using another loop which results in **O(n^2)** time complexity. Can anyone tell how to find the answer in **O(n)** time complexity?
0debug
dotnet run is not a recognized command line : <p>I have a very simple service. I'm able to start it normally through Visual Studio if I run my service on a debug mode. But I'm trying to run this service while I'm running my project normally locally.</p> <p>If I do a dotnet.run through my command prompt I get this error: dotnet is not a recognized and internal or external command line.</p> <p>I have all the framework installed since there is no issue running this on a debug mode. Any ideas?</p> <p><a href="https://i.stack.imgur.com/TEKxs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TEKxs.png" alt="enter image description here"></a></p>
0debug
void socket_listen_cleanup(int fd, Error **errp) { SocketAddress *addr; addr = socket_local_address(fd, errp); if (addr->type == SOCKET_ADDRESS_TYPE_UNIX && addr->u.q_unix.path) { if (unlink(addr->u.q_unix.path) < 0 && errno != ENOENT) { error_setg_errno(errp, errno, "Failed to unlink socket %s", addr->u.q_unix.path); qapi_free_SocketAddress(addr);
1threat
VirtIODevice *virtio_blk_init(DeviceState *dev, DriveInfo *dinfo) { VirtIOBlock *s; int cylinders, heads, secs; static int virtio_blk_id; char *ps; s = (VirtIOBlock *)virtio_common_init("virtio-blk", VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config), sizeof(VirtIOBlock)); s->vdev.get_config = virtio_blk_update_config; s->vdev.get_features = virtio_blk_get_features; s->vdev.reset = virtio_blk_reset; s->bs = dinfo->bdrv; s->rq = NULL; if (strlen(ps = (char *)drive_get_serial(s->bs))) strncpy(s->serial_str, ps, sizeof(s->serial_str)); else snprintf(s->serial_str, sizeof(s->serial_str), "0"); s->bs->private = dev; bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs); bdrv_set_geometry_hint(s->bs, cylinders, heads, secs); s->vq = virtio_add_queue(&s->vdev, 128, virtio_blk_handle_output); qemu_add_vm_change_state_handler(virtio_blk_dma_restart_cb, s); register_savevm("virtio-blk", virtio_blk_id++, 2, virtio_blk_save, virtio_blk_load, s); return &s->vdev; }
1threat
How to print random values between certain range? : <p>I am writing a basic crypto program using c language. In that i want to get a random numbers form certain range say (97 to 122). I saw this program on some programming website.</p> <pre><code>int main(void) { int c, n; printf("Ten random numbers in [1,100]\n"); for (c = 1; c &lt;= 10; c++) { n = rand() % 100; printf("%d\n", n); } } </code></pre> <p>but it prints random values from 1 to 100. In python we implement it with the help of <code>rand()</code> function eg: <code>r = random.randint(97, 122)</code>. so is there any way to implement like this in c program.</p>
0debug
static int http_receive_data(HTTPContext *c) { HTTPContext *c1; if (c->buffer_end > c->buffer_ptr) { int len; len = recv(c->fd, c->buffer_ptr, c->buffer_end - c->buffer_ptr, 0); if (len < 0) { if (ff_neterrno() != FF_NETERROR(EAGAIN) && ff_neterrno() != FF_NETERROR(EINTR)) goto fail; } else if (len == 0) goto fail; else { c->buffer_ptr += len; c->data_count += len; update_datarate(&c->datarate, c->data_count); } } if (c->buffer_ptr - c->buffer >= 2 && c->data_count > FFM_PACKET_SIZE) { if (c->buffer[0] != 'f' || c->buffer[1] != 'm') { http_log("Feed stream has become desynchronized -- disconnecting\n"); goto fail; } } if (c->buffer_ptr >= c->buffer_end) { FFStream *feed = c->stream; if (c->data_count > FFM_PACKET_SIZE) { lseek(c->feed_fd, feed->feed_write_index, SEEK_SET); if (write(c->feed_fd, c->buffer, FFM_PACKET_SIZE) < 0) { http_log("Error writing to feed file: %s\n", strerror(errno)); goto fail; } feed->feed_write_index += FFM_PACKET_SIZE; if (feed->feed_write_index > c->stream->feed_size) feed->feed_size = feed->feed_write_index; if (c->stream->feed_max_size && feed->feed_write_index >= c->stream->feed_max_size) feed->feed_write_index = FFM_PACKET_SIZE; ffm_write_write_index(c->feed_fd, feed->feed_write_index); for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) { if (c1->state == HTTPSTATE_WAIT_FEED && c1->stream->feed == c->stream->feed) c1->state = HTTPSTATE_SEND_DATA; } } else { AVFormatContext *s = NULL; ByteIOContext *pb; AVInputFormat *fmt_in; int i; url_open_buf(&pb, c->buffer, c->buffer_end - c->buffer, URL_RDONLY); pb->is_streamed = 1; fmt_in = av_find_input_format(feed->fmt->name); if (!fmt_in) goto fail; av_open_input_stream(&s, pb, c->stream->feed_filename, fmt_in, NULL); if (s->nb_streams != feed->nb_streams) { av_close_input_stream(s); av_free(pb); goto fail; } for (i = 0; i < s->nb_streams; i++) memcpy(feed->streams[i]->codec, s->streams[i]->codec, sizeof(AVCodecContext)); av_close_input_stream(s); av_free(pb); } c->buffer_ptr = c->buffer; } return 0; fail: c->stream->feed_opened = 0; close(c->feed_fd); for(c1 = first_http_ctx; c1 != NULL; c1 = c1->next) { if (c1->state == HTTPSTATE_WAIT_FEED && c1->stream->feed == c->stream->feed) c1->state = HTTPSTATE_SEND_DATA_TRAILER; } return -1; }
1threat
static int coroutine_fn sd_co_flush_to_disk(BlockDriverState *bs) { BDRVSheepdogState *s = bs->opaque; SheepdogObjReq hdr = { 0 }; SheepdogObjRsp *rsp = (SheepdogObjRsp *)&hdr; SheepdogInode *inode = &s->inode; int ret; unsigned int wlen = 0, rlen = 0; if (s->cache_flags != SD_FLAG_CMD_CACHE) { return 0; } hdr.opcode = SD_OP_FLUSH_VDI; hdr.oid = vid_to_vdi_oid(inode->vdi_id); ret = do_req(s->flush_fd, (SheepdogReq *)&hdr, NULL, &wlen, &rlen); if (ret) { error_report("failed to send a request to the sheep"); return ret; } if (rsp->result == SD_RES_INVALID_PARMS) { dprintf("disable write cache since the server doesn't support it\n"); s->cache_flags = SD_FLAG_CMD_DIRECT; closesocket(s->flush_fd); return 0; } if (rsp->result != SD_RES_SUCCESS) { error_report("%s", sd_strerror(rsp->result)); return -EIO; } return 0; }
1threat
static void mpeg_decode_sequence_extension(MpegEncContext *s) { int horiz_size_ext, vert_size_ext; int bit_rate_ext; int level, profile; skip_bits(&s->gb, 1); profile= get_bits(&s->gb, 3); level= get_bits(&s->gb, 4); s->progressive_sequence = get_bits1(&s->gb); s->chroma_format = get_bits(&s->gb, 2); horiz_size_ext = get_bits(&s->gb, 2); vert_size_ext = get_bits(&s->gb, 2); s->width |= (horiz_size_ext << 12); s->height |= (vert_size_ext << 12); bit_rate_ext = get_bits(&s->gb, 12); s->bit_rate += (bit_rate_ext << 12) * 400; skip_bits1(&s->gb); s->avctx->rc_buffer_size += get_bits(&s->gb, 8)*1024*16<<10; s->low_delay = get_bits1(&s->gb); if(s->flags & CODEC_FLAG_LOW_DELAY) s->low_delay=1; s->frame_rate_ext_n = get_bits(&s->gb, 2); s->frame_rate_ext_d = get_bits(&s->gb, 5); dprintf("sequence extension\n"); s->codec_id= s->avctx->codec_id= CODEC_ID_MPEG2VIDEO; s->avctx->sub_id = 2; if(s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_DEBUG, "profile: %d, level: %d vbv buffer: %d, bitrate:%d\n", profile, level, s->avctx->rc_buffer_size, s->bit_rate); }
1threat
How to get an OnPropertyChanged event to exectue before the current event continues : <pre><code>private void Build_Button(object sender, RoutedEventArgs e) { T.BuildStatus = "Building..."; BuildSelected(T.ListofTrucks); T.BuildStatus = "Build Complete"; } </code></pre> <p>Currently I have a label binded to T.BuildStatus that I want to display "Building..." while my files are compiled but the label will only update after buildSelected method has finished. How can I get this label to update before continuing with the rest of the event call?</p> <p>Edit: the object T is implementing INotifyPropertyChanged correctly</p>
0debug
static inline void gen_stos(DisasContext *s, int ot) { gen_op_mov_TN_reg(OT_LONG, 0, R_EAX); gen_string_movl_A0_EDI(s); gen_op_st_T0_A0(ot + s->mem_index); gen_op_movl_T0_Dshift[ot](); #ifdef TARGET_X86_64 if (s->aflag == 2) { gen_op_addq_EDI_T0(); } else #endif if (s->aflag) { gen_op_addl_EDI_T0(); } else { gen_op_addw_EDI_T0(); } }
1threat
static void envelope_instant16(WaveformContext *s, AVFrame *out, int plane, int component) { const int dst_linesize = out->linesize[component] / 2; const int bg = s->bg_color[component] * (s->size / 256); const int limit = s->size - 1; const int is_chroma = (component == 1 || component == 2); const int shift_w = (is_chroma ? s->desc->log2_chroma_w : 0); const int shift_h = (is_chroma ? s->desc->log2_chroma_h : 0); const int dst_h = FF_CEIL_RSHIFT(out->height, shift_h); const int dst_w = FF_CEIL_RSHIFT(out->width, shift_w); const int start = s->estart[plane]; const int end = s->eend[plane]; uint16_t *dst; int x, y; if (s->mode) { for (x = 0; x < dst_w; x++) { for (y = start; y < end; y++) { dst = (uint16_t *)out->data[component] + y * dst_linesize + x; if (dst[0] != bg) { dst[0] = limit; break; } } for (y = end - 1; y >= start; y--) { dst = (uint16_t *)out->data[component] + y * dst_linesize + x; if (dst[0] != bg) { dst[0] = limit; break; } } } } else { for (y = 0; y < dst_h; y++) { dst = (uint16_t *)out->data[component] + y * dst_linesize; for (x = start; x < end; x++) { if (dst[x] != bg) { dst[x] = limit; break; } } for (x = end - 1; x >= start; x--) { if (dst[x] != bg) { dst[x] = limit; break; } } } } }
1threat
PDO prepeared statements PHP Call to undefined method PDO::execute() : <p>I am new to php mysqli ect and i have done my best to arrange a prepeared statement function to no avail. All i get is the following Error. </p> <p>Call to undefined method PDO::execute() </p> <p>I donnot understand why this is happening.</p> <p>The values are being passed and echo'd but i still get this error. </p> <p>It does not retrieve data from database either as error is called before doing so.</p> <p>Can anybody see from the code what the problem is.. iv searched about on the net ect. and the closest i got what about checking the Isset of the inputs, but i had allready done this so thats not the issue.</p> <p>im baffled.</p> <p>Thanks for any advice... Its probly really simple. But so am i.</p> <pre><code>&lt;?php //include('conect.php') $dbh = new PDO("mysql:host=localhost;dbname=classifieds", 'root', ''); $type=$_POST['type']; $price=$_POST['price']; if (isset($type) &amp;&amp; isset($price)) { echo $type; echo $price; $dbh-&gt;prepare('SELECT * FROM testdata WHERE type=? AND price=?'); $stm = $dbh-&gt;execute(array($type, $price)); if(($row = $stm-&gt;fetchObject())) { $type=$row['type']; $price=$row['price']; echo $type; echo $price; } else { echo "none recieved"; } } else {echo "invalid"; } ?&gt; </code></pre>
0debug
Voice command in android activity : I have an activity in my app that have a counter for 2 differents teams, now, to add a point to this teams I need to click a button. I want to do this also with a voice command. The thing is that I need: offline voice recognition, add points but not restart the activity, wait continouslly for another voice command, only work in one Activity. And the language will be spanish. Do you know any way of do this? I have been searching and find PocketSphinx, but I don't know if this is the best option.
0debug
Array transformation in JS : <p>I have array transformation required as below in JS.</p> <p>Source Array</p> <pre><code>var numbers = [ [0,0,4], [0,1,9], [0,2,16] , [0,2,7] , [0,2,5] , [1,0,1], [1,1,2], [1,1,4], [1,2,3] ]; </code></pre> <p>Here first value in the source array represents row of target array, second value represents column of target array.</p> <p>So the expected result array looks like</p> <pre><code>var result = [ [4, 9, [16, 7, 5]], [1, [2, 4], 3] ]; </code></pre> <p>Note: 1.Source/Target array can contain N number of rows &amp; columns.</p>
0debug
int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_count, const uint8_t *in_arg [SWR_CH_MAX], int in_count){ AudioData * in= &s->in; AudioData *out= &s->out; if(s->drop_output > 0){ int ret; uint8_t *tmp_arg[SWR_CH_MAX]; if((ret=swri_realloc_audio(&s->drop_temp, s->drop_output))<0) return ret; reversefill_audiodata(&s->drop_temp, tmp_arg); s->drop_output *= -1; ret = swr_convert(s, tmp_arg, -s->drop_output, in_arg, in_count); s->drop_output *= -1; if(ret>0) s->drop_output -= ret; if(s->drop_output || !out_arg) return 0; in_count = 0; } if(!in_arg){ if(s->resample){ if (!s->flushed) s->resampler->flush(s); s->resample_in_constraint = 0; s->flushed = 1; }else if(!s->in_buffer_count){ return 0; } }else fill_audiodata(in , (void*)in_arg); fill_audiodata(out, out_arg); if(s->resample){ int ret = swr_convert_internal(s, out, out_count, in, in_count); if(ret>0 && !s->drop_output) s->outpts += ret * (int64_t)s->in_sample_rate; return ret; }else{ AudioData tmp= *in; int ret2=0; int ret, size; size = FFMIN(out_count, s->in_buffer_count); if(size){ buf_set(&tmp, &s->in_buffer, s->in_buffer_index); ret= swr_convert_internal(s, out, size, &tmp, size); if(ret<0) return ret; ret2= ret; s->in_buffer_count -= ret; s->in_buffer_index += ret; buf_set(out, out, ret); out_count -= ret; if(!s->in_buffer_count) s->in_buffer_index = 0; } if(in_count){ size= s->in_buffer_index + s->in_buffer_count + in_count - out_count; if(in_count > out_count) { if( size > s->in_buffer.count && s->in_buffer_count + in_count - out_count <= s->in_buffer_index){ buf_set(&tmp, &s->in_buffer, s->in_buffer_index); copy(&s->in_buffer, &tmp, s->in_buffer_count); s->in_buffer_index=0; }else if((ret=swri_realloc_audio(&s->in_buffer, size)) < 0) return ret; } if(out_count){ size = FFMIN(in_count, out_count); ret= swr_convert_internal(s, out, size, in, size); if(ret<0) return ret; buf_set(in, in, ret); in_count -= ret; ret2 += ret; } if(in_count){ buf_set(&tmp, &s->in_buffer, s->in_buffer_index + s->in_buffer_count); copy(&tmp, in, in_count); s->in_buffer_count += in_count; } } if(ret2>0 && !s->drop_output) s->outpts += ret2 * (int64_t)s->in_sample_rate; return ret2; } }
1threat
Categorize numbers of an array into different sets and count the occurences : I have a array of numbers. lets say A= [9,12,16,19] I have four sets [8,9,10] , [11,12,13] ,[14,15,16], [17,18,19,20] for each element in A categorize the element into the given sets and count the occurences correspond to each set. what is the efficient way to do this??
0debug
e1000_set_link_status(VLANClientState *nc) { E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque; uint32_t old_status = s->mac_reg[STATUS]; if (nc->link_down) s->mac_reg[STATUS] &= ~E1000_STATUS_LU; else s->mac_reg[STATUS] |= E1000_STATUS_LU; if (s->mac_reg[STATUS] != old_status) set_ics(s, 0, E1000_ICR_LSC); }
1threat
How to convert an RDD[Unit] to a dataframe in Scala? : val sid_df = hiveContext.sql("SELECT a, b, c, d, e FROM my_table") val new_reformatted_rdd = sid_df.map(row => { val t = row.getDouble(0) val f = row.getFloat(1) val s = row.getShort(2) val y = row.getString(3).toShort val originFormat = new java.text.SimpleDateFormat("MM-dd-yyyy") val targetFormat = new java.text.SimpleDateFormat("yyyy-MM-dd") val new_date = targetFormat.format(originFormat.parse(row.getString(4))) }) I need a dataframe from new_reformatted_rdd which is an RDD[Unit]. Kindly suggest me how to do it. Thanks
0debug
Maven Repository Manager - Nexus vs Artifactory for Java Dependencies : <p>We have developed Java based micro services using spring framework where we have dependencies in the form of JAR's. I just wanted to know that which maven repository manager is more useful and efficient. By efficient I mean </p> <ol> <li>Fetching the dependencies from the remote repository at faster rate.</li> <li>Fetching third party dependencies (Rarely used) easily.</li> <li>Taking less deployment time in Docker environment.</li> <li>Good consistency check and self healing mechanism.</li> <li>Pricing.</li> </ol>
0debug
How to convert Pdf file to byte array in php and send? : <p>I have found pdf to byte array and vice-versa in java,dotnet and python. But i want to convert pdf to byte array in php laravel. I am using "IMUIS" which is accounting software solution and need to sending journal entries from laravel lumen to "IMUIS" for processing.But it gives the error after converting.</p> <blockquote> <p>"Foutmelding": "Kan een object van het type System.String niet converteren naar het type System.Byte[]."</p> </blockquote> <p>In english that means </p> <blockquote> <p>"Error message": "Can not convert a System.String object to the System.Byte [] type."</p> </blockquote> <p>The documentation is given here:</p> <p><a href="http://cswdoc.imuisonline.com/?page_id=382" rel="noreferrer">doc link</a></p> <p>Here is the code for it. </p> <pre><code>public function saveJournal($values = '') { //echo "adasd";dd(); $partnerKey = $values-&gt;input('Partnerkey'); $omgevingscode = $values-&gt;input('Environmentcode'); $file = file_get_contents($values-&gt;file('Pdffile')); $str = base64_encode($file); $options = array( \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_URL =&gt; env('IMUIS_URL'), \WsdlToPhp\PackageBase\AbstractSoapClientBase::WSDL_CLASSMAP =&gt; ClassMap::get(), ); $login = new \mysdk\ImuisSDK\ServiceType\Login($options); if ($login-&gt;Login(new \mysdk\ImuisSDK\StructType\Login($partnerKey, $omgevingscode)) !== false) { $sessionid = $login-&gt;getResult()-&gt;SessionId; } $array = [ 'BOE' =&gt; [ 'JR' =&gt; '2018', 'PN' =&gt; '5', 'DAGB' =&gt; 20, 'REK' =&gt; 20032, 'TEGREK' =&gt; '40', 'FACT' =&gt; 0, 'BTW' =&gt; 4, 'BEDRBOEK' =&gt; 123.45, 'DAT' =&gt; '08-05-2018', 'OPM' =&gt; 'Anand testing from wsdl', 'BEDRBTW' =&gt; 21, 'FACT' =&gt; 0, 'OMSCHR' =&gt; 'Testing from wsdl api', 'BOEKSTUK' =&gt; 2018075 ], 'DIGDOS' =&gt; [ 'FILE' =&gt; $str ] ]; $journaalpost = ArrayToXml::convert($array, 'NewDataSet');//convert array to xml string $create = new \mysdk\ImuisSDK\ServiceType\Create($options); if ($create-&gt;CreateJournaalpost(new \mysdk\ImuisSDK\StructType\CreateJournaalpost($partnerKey, $omgevingscode, $sessionid, $journaalpost)) !== false) { $jsonResponse = $create-&gt;getResult(); } else { $jsonResponse = $create-&gt;getLastError(); } return $jsonResponse; } </code></pre> <p>and here is the response as well:</p> <pre><code>{ "success": true, "result": { "CreateJournaalpostResult": false, "Journaalpost": "&lt;?xml version=\"1.0\"?&gt;\n&lt;NewDataSet&gt;&lt;BOE&gt;&lt;JR&gt;2018&lt;/JR&gt;&lt;PN&gt;5&lt;/PN&gt;&lt;DAGB&gt;20&lt;/DAGB&gt;&lt;REK&gt;20032&lt;/REK&gt;&lt;TEGREK&gt;40&lt;/TEGREK&gt;&lt;FACT&gt;0&lt;/FACT&gt;&lt;BTW&gt;4&lt;/BTW&gt;&lt;BEDRBOEK&gt;123.45&lt;/BEDRBOEK&gt;&lt;DAT&gt;08-05-2018&lt;/DAT&gt;&lt;OPM&gt;Anand testing from wsdl&lt;/OPM&gt;&lt;BEDRBTW&gt;21&lt;/BEDRBTW&gt;&lt;OMSCHR&gt;Testing from wsdl api&lt;/OMSCHR&gt;&lt;BOEKSTUK&gt;2018075&lt;/BOEKSTUK&gt;&lt;/BOE&gt;&lt;DIGDOS&gt;&lt;FILE&gt;JVBERi0xLjMKMyAwIG9iago8PC9UeXBlIC9QYWdlCi9QYXJlbnQgMSAwIFIKL1Jlc291cmNlcyAyIDAgUgovQ29udGVudHMgNCAwIFI+PgplbmRvYmoKNCAwIG9iago8PC9GaWx0ZXIgL0ZsYXRlRGVjb2RlIC9MZW5ndGggMzg2Pj4Kc3RyZWFtCniclZNPb9pAEMXvfIp3TA8Zdme93jE3G0xFJWgKJtdolbhICTYU6L9v3zWEGKnUVeST1++9+b2xzfjUU2QdfvayAv2xRkJKofiKvOh9g00ssUCFS0xMzFDNY0uxw2OF/kRjtMGXxms06QSOLUnwP+Fmkd+lyMr9wddP+9r7aoDxfFE8NOfaKqtZO+PoV7X+gOK5mdekSBhg/opJfb0qK+9fDthsB2Cl5VbZWx1D80DZAbtzhiIX2iiSJGBTIoLd6mo1hRXesGMRSuxx3ixNpxjl2aRY5vPX1NDwzcASk1GXjnE6LJbL+Ww5nV51RCykokvHZDZMF5+R5aN5+rF1BJ2xcDoiY1DBSmBT5/s1FqceDPl3D8fEpxmj8schLB/DTbX19e+OJq1Hc+Q6CrTCJBzwFeUrhQ1fTfROitYTs+mAaHVamU4KI8TmnRStJ+Zr0WeKVvefVbBu/prjS6/333e+fiwx9bVflbs9MrqnDpjWq7WRDpoLYSTOUXyxwD9RUucvCmVuZHN0cmVhbQplbmRvYmoKMSAwIG9iago8PC9UeXBlIC9QYWdlcwovS2lkcyBbMyAwIFIgXQovQ291bnQgMQovTWVkaWV5s7I11RFTyPO/t9OL74tl5/das6enN0bXwr//AKZ629kqeo76x9P/AOOs4y+N/wDK6nJuq/7nerWTI6zQrTReVjEVir+fVST/AF1m6Wrf7W+uMQ+o/D744dNdW2I8fKx2Ny8nCOrKu5j18zJOGq/JoeLX9ndp47YfR9t7+zUmmy59IPG9wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABuIAowMDAwMDc2NDgzIDAwMDAwIG4gCjAwMDAwNzY1NTkgMDAwMDAgbiAKdHJhaWxlcgo8PAovU2l6ZSAxMQovUm9vdCAxMCAwIFIKL0luZm8gOSAwIFIKPj4Kc3RhcnR4cmVmCjc2NjA5CiUlRU9GCg0KCiAgICAgIA==&lt;/FILE&gt;&lt;/DIGDOS&gt;&lt;/NewDataSet&gt;\n", "Primarykey": null, "Foutmelding": "Kan een object van het type System.String niet converteren naar het type System.Byte[]." } } </code></pre>
0debug
static size_t v9fs_packunpack(void *addr, struct iovec *sg, int sg_count, size_t offset, size_t size, int pack) { int i = 0; size_t copied = 0; for (i = 0; size && i < sg_count; i++) { size_t len; if (offset >= sg[i].iov_len) { offset -= sg[i].iov_len; continue; } else { len = MIN(sg[i].iov_len - offset, size); if (pack) { memcpy(sg[i].iov_base + offset, addr, len); } else { memcpy(addr, sg[i].iov_base + offset, len); } size -= len; copied += len; addr += len; if (size) { offset = 0; continue; } } } return copied; }
1threat
How to dedupe pair of random numbers in JavaScript : I have a function that generates random numbers given a range I want to make sure I don't re-generate the same pair of numbers. function generateRandomInt(max) { return Math.floor(Math.random() * Math.floor(max)); } let randomInt1 = generateRandomInt(10) + 1; let randomInt2 = generateRandomInt(10) + 1; let numberStore = randomInt1 + "" + randomInt2; console.log(randomInt1); console.log(randomInt2); console.log(parseInt(numberStore)); `numberStore` contains the result of `randomInt1` and `randomInt2` I want to avoid having a pair of numbers that were already generated. https://codepen.io/anon/pen/wRJrrW
0debug
Returning Promises from Vuex actions : <p>I recently started migrating things from jQ to a more structured framework being VueJS, and I love it!</p> <p>Conceptually, Vuex has been a bit of a paradigm shift for me, but I'm confident I know what its all about now, and totally get it! But there exist a few little grey areas, mostly from an implementation standpoint.</p> <p>This one I feel is good by design, but don't know if it contradicts the Vuex <a href="http://vuex.vuejs.org/en/images/vuex.png" rel="noreferrer">cycle</a> of uni-directional data flow.</p> <p>Basically, is it considered good practice to return a promise(-like) object from an action? I treat these as async wrappers, with states of failure and the like, so seems like a good fit to return a promise. Contrarily mutators just change things, and are the pure structures within a store/module.</p>
0debug
static void aspeed_soc_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc); sc->info = (AspeedSoCInfo *) data; dc->realize = aspeed_soc_realize; }
1threat
void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, const char *boot_device, BusState *idebus0, BusState *idebus1, ISADevice *s) { int val, nb, nb_heads, max_track, last_sect, i; FDriveType fd_type[2]; DriveInfo *fd[2]; static pc_cmos_init_late_arg arg; val = 640; rtc_set_memory(s, 0x15, val); rtc_set_memory(s, 0x16, val >> 8); val = (ram_size / 1024) - 1024; if (val > 65535) val = 65535; rtc_set_memory(s, 0x17, val); rtc_set_memory(s, 0x18, val >> 8); rtc_set_memory(s, 0x30, val); rtc_set_memory(s, 0x31, val >> 8); if (above_4g_mem_size) { rtc_set_memory(s, 0x5b, (unsigned int)above_4g_mem_size >> 16); rtc_set_memory(s, 0x5c, (unsigned int)above_4g_mem_size >> 24); rtc_set_memory(s, 0x5d, (uint64_t)above_4g_mem_size >> 32); } if (ram_size > (16 * 1024 * 1024)) val = (ram_size / 65536) - ((16 * 1024 * 1024) / 65536); else val = 0; if (val > 65535) val = 65535; rtc_set_memory(s, 0x34, val); rtc_set_memory(s, 0x35, val >> 8); rtc_set_memory(s, 0x5f, smp_cpus - 1); if (set_boot_dev(s, boot_device, fd_bootchk)) { exit(1); } for (i = 0; i < 2; i++) { fd[i] = drive_get(IF_FLOPPY, 0, i); if (fd[i]) { bdrv_get_floppy_geometry_hint(fd[i]->bdrv, &nb_heads, &max_track, &last_sect, FDRIVE_DRV_NONE, &fd_type[i]); } else { fd_type[i] = FDRIVE_DRV_NONE; } } val = (cmos_get_fd_drive_type(fd_type[0]) << 4) | cmos_get_fd_drive_type(fd_type[1]); rtc_set_memory(s, 0x10, val); val = 0; nb = 0; if (fd_type[0] < FDRIVE_DRV_NONE) { nb++; } if (fd_type[1] < FDRIVE_DRV_NONE) { nb++; } switch (nb) { case 0: break; case 1: val |= 0x01; break; case 2: val |= 0x41; break; } val |= 0x02; val |= 0x04; rtc_set_memory(s, REG_EQUIPMENT_BYTE, val); arg.rtc_state = s; arg.idebus0 = idebus0; arg.idebus1 = idebus1; qemu_register_reset(pc_cmos_init_late, &arg); }
1threat
Difference between lambda and LINQ? : <p>Can someone explain me the difference between lambda and linq?</p> <p>Please don't point me out to other stackexchange answers or trivial explanations, I've checked most of them and they're orribly confusing.</p> <p>I've used a bit of LINQ (I believe?) in these days with expressions like (merely an invented example)</p> <pre><code>var result = object.Where(e =&gt; e.objectParameter &gt; 5).Any() </code></pre> <p>Which, should return in result a boolean which says if there is any element >5.</p> <p>Ok, then, what are LINQ and lambda?</p> <p>Is LINQ just a library, a set of functions, developed by C# team to include with</p> <pre><code>using System.Linq; </code></pre> <p>which gives you a powered "for loop" with many methods to avoid you getting your hands "dirty"? (First, FirstOrDefault, Any.... etc)</p> <p>And what is Lambda? Is the same as above? It's a language on it's own? What is it and how it differs from LINQ? How do I recognize one or another?</p> <p>Thanks</p>
0debug
static int decode_scalefactors(AACContext *ac, float sf[120], GetBitContext *gb, unsigned int global_gain, IndividualChannelStream *ics, enum BandType band_type[120], int band_type_run_end[120]) { int g, i, idx = 0; int offset[3] = { global_gain, global_gain - 90, 0 }; int clipped_offset; int noise_flag = 1; static const char *const sf_str[3] = { "Global gain", "Noise gain", "Intensity stereo position" }; for (g = 0; g < ics->num_window_groups; g++) { for (i = 0; i < ics->max_sfb;) { int run_end = band_type_run_end[idx]; if (band_type[idx] == ZERO_BT) { for (; i < run_end; i++, idx++) sf[idx] = 0.; } else if ((band_type[idx] == INTENSITY_BT) || (band_type[idx] == INTENSITY_BT2)) { for (; i < run_end; i++, idx++) { offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; clipped_offset = av_clip(offset[2], -155, 100); if (offset[2] != clipped_offset) { av_log_ask_for_sample(ac->avctx, "Intensity stereo " "position clipped (%d -> %d).\nIf you heard an " "audible artifact, there may be a bug in the " "decoder. ", offset[2], clipped_offset); } sf[idx] = ff_aac_pow2sf_tab[-clipped_offset + POW_SF2_ZERO]; } } else if (band_type[idx] == NOISE_BT) { for (; i < run_end; i++, idx++) { if (noise_flag-- > 0) offset[1] += get_bits(gb, 9) - 256; else offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; clipped_offset = av_clip(offset[1], -100, 155); if (offset[1] != clipped_offset) { av_log_ask_for_sample(ac->avctx, "Noise gain clipped " "(%d -> %d).\nIf you heard an audible " "artifact, there may be a bug in the decoder. ", offset[1], clipped_offset); } sf[idx] = -ff_aac_pow2sf_tab[clipped_offset + POW_SF2_ZERO]; } } else { for (; i < run_end; i++, idx++) { offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 60; if (offset[0] > 255U) { av_log(ac->avctx, AV_LOG_ERROR, "%s (%d) out of range.\n", sf_str[0], offset[0]); return -1; } sf[idx] = -ff_aac_pow2sf_tab[offset[0] - 100 + POW_SF2_ZERO]; } } } } return 0; }
1threat
function scale() in R doesn't scale the data symmetrically : <p>I apologize if my question is simple. I tried to find the answer but I didn't find much info.</p> <p>I use the scale() function in R to scale my data. What I don't understand is that when I plot my scaled data using matplot() it seems my scaled data aren't symmetric. which means the range of the sacled data is <code>-1,-0.5,0,0.5,1,1.5</code>. As I know, we scale the data to mean zero and standard deviation s. So my data should have a deviation of s from mean but here I have a deviation of 1.5 and a deviation of -1. Why?</p>
0debug
static void term_forward_char(void) { if (term_cmd_buf_index < term_cmd_buf_size) { term_cmd_buf_index++; } }
1threat
Are there sample tables on sqlfiddle : <p>Are there any default tables on SqlFiddle that I can query from?</p> <p>I want to try a basic analytical query on a simple table but I don't want to set up the schema and seed data etc.</p> <p>normally I would do something like <code>select * from all_objects</code></p> <p>( <a href="http://sqlfiddle.com/" rel="noreferrer">http://sqlfiddle.com/</a> )</p>
0debug
static av_cold int pcx_encode_close(AVCodecContext *avctx) { av_frame_free(&avctx->coded_frame); return 0; }
1threat
Trailing and Leading constraints in Swift programmatically (NSLayoutConstraints) : <p>I'm adding from a xib a view into my ViewController. Then I'm putting its constraints to actually fit it </p> <pre><code>override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) ... ... view!.addSubview(gamePreview) gamePreview.translatesAutoresizingMaskIntoConstraints = false if #available(iOS 9.0, *) { // Pin the leading edge of myView to the margin's leading edge gamePreview.leadingAnchor.constraintEqualToAnchor(view.leadingAnchor).active = true //Pin the trailing edge of myView to the margin's trailing edge gamePreview.trailingAnchor.constraintEqualToAnchor(view.trailingAnchor).active = true } else { // Fallback on earlier versions view.addConstraint(NSLayoutConstraint(item: gamePreview, attribute: .TrailingMargin, relatedBy: .Equal, toItem: view, attribute: .TrailingMargin, multiplier: 1, constant: 0)) view.addConstraint(NSLayoutConstraint(item: gamePreview, attribute: .LeadingMargin, relatedBy: .Equal, toItem: view, attribute: .LeadingMargin, multiplier: 1, constant: 0)) } view.addConstraint(NSLayoutConstraint(item: gamePreview, attribute: .Top, relatedBy: .Equal, toItem: self.topLayoutGuide, attribute: .Bottom, multiplier: 1, constant: 0)) view.addConstraint(NSLayoutConstraint(item: gamePreview, attribute: .Height, relatedBy: .Equal, toItem: nil, attribute: .NotAnAttribute,multiplier: 1, constant: 131)) } </code></pre> <p>What i'm trying to do: To actually fit my view constraining it to top, leading, trailing to ViewController's view, and with a prefixed height. The view I'm adding to main view has its own transparent-background view, so no need of margin (the view is meant to be device's width size, so).</p> <p>I've placed 2 couples of lines that would be supposed to be equal (in my attempts), with the if, because the first 2 lines in if are actually available in iOS9> only, while I'm attempting to do the same thing in the else statement, for every device (starting from iOS 8).</p> <p>This is what I get:</p> <p>iOS9+ at left, iOS8+ at right. Transparent background was colored red to show what happens (don't mind at different height in the images, they're equal height in app, instead look at added margins at left and right)</p> <p><img src="https://i.imgur.com/9DwYku4m.png" alt=""> <img src="https://i.imgur.com/bPLYEWWm.png" alt=""></p> <p>I also tried <code>AutoLayoutDSL-Swift</code>, but doesn't help, I'm not expert with it but every attempt made only things worse.</p> <p>How can I write those constraints using classic NSLayoutConstraints methods, and how could I write all in a better way with a framework like AutoLayoutDSL or a fork of it? (or an alternative, though now mostly I'm concerned on official libs)</p>
0debug
trying to make feedback page : <p>I am making feedback page, but it is producing some errors. i don't understand what is wrong. Please help me figure out where i am doing wrong. when i submit the form the errors goes away and produce right result,but when i refresh the page it produces same errors again</p> <pre><code>&lt;?php $name = $_POST['name']; // error undefined index name $suggestion = $_POST['suggest']; // error undefined index suggest $opinion = $_POST['opinion']; // error undefined index opinion $submit = $_POST['submit']; // error undefined index submit if(isset($submit)){ $sql= mysqli_query($con,"insert into feedback (name,suggestion,opinion) values ('$name','$suggestion','$opinion')"); if($sql==true){?&gt; &lt;div class="alert alert-info"&gt; Thankyou for your suggestions. we will notify the admins. &lt;/div&gt; &lt;?php } } ?&gt; &lt;body&gt; &lt;div class="feedback"&gt; &lt;form action="feedback.php" method="post"&gt; &lt;h1&gt; Help us improve our website&lt;/h1&gt; &lt;h2&gt;Please drop your suggestion below&lt;/h2&gt; &lt;div class="form-group"&gt; &lt;label &gt;Your Name:&lt;/label&gt; &lt;input type="text" class="form-control" name="name" required&gt; &lt;/div&gt; &lt;div class="form-group"&gt; &lt;label for="comment"&gt;Your suggestion&lt;/label&gt; &lt;textarea class="form-control" name="suggest" rows="5" id="comment" required &gt;&lt;/textarea&gt; &lt;/div&gt; &lt;p&gt;Were you satisfy with this website?&lt;/p&gt; &lt;label class="checkbox-inline"&gt; &lt;input type="checkbox" name="opinion"value="1"&gt; yes &lt;/label&gt; &lt;label class="checkbox-inline"&gt; &lt;input type="checkbox" name="opinion" value="2"&gt; no &lt;/label&gt; &lt;label class="checkbox-inline"&gt; &lt;input type="checkbox" name="opinion" value="3"&gt; may be &lt;/label&gt; &lt;br /&gt;&lt;br /&gt; &lt;button type="submit" name="submit" class="btn btn-primary"&gt;Submit&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; &lt;/body&gt; </code></pre>
0debug
pass elements of global variable array from keypad in arduino : Currently elements of array a1[2] is initialised in the code but I want to pass this element of global variable array " a1[2] "from keypad as v1. here is my code. #include "Keypad.h" #include <LiquidCrystal.h> unsigned int a1[2]={1,10}; //global variable //unsigned int a1[2] = {1,v1} //not working /.. keypad initialization .../ void setup() { lcd.begin(16, 2); lcd.clear(); lcd.setCursor(1,1); lcd.print("Press # to GO"); lcd.setCursor(0,0); lcd.print("Enter v1: "); v1 = GetNumber(); } void loop() { ... } int GetNumber() { ... .... } return num; } pls help in this code.
0debug
Easy javascript but i cant seem to get it : modify the function to display the names that are 16 and bigger the answer should look like this ['joey', 'jane'] with the code i have i am able to display one name but i cannot get the other name to display but not in the array formate. sorry i am new to javascript when i console log the return statement in the if function i get console.log(people[i].name) -------> 'joey','jane' undefined function getNamesOfLegalDrivers(people) { for(let i = 0; i < people.length; i++){ if(people[i].age >= 16){ return people[i].name; } } } const examplePeopleArray = [ { name: 'John', age: 14 }, { name: 'Joey', age: 16 }, { name: 'Jane', age: 18 } ]; console.log(getNamesOfLegalDrivers(examplePeopleArray), '<-- should be ["Joey", "Jane"]'); my output is: 'Joey' <-- should be ["Joey", "Jane"]' result suppose to be: ["Joey", "Jane"]
0debug
static void gen_ldda_asi(DisasContext *dc, TCGv hi, TCGv addr, int insn, int rd) { TCGv_i32 r_asi, r_rd; r_asi = gen_get_asi(dc, insn); r_rd = tcg_const_i32(rd); gen_helper_ldda_asi(cpu_env, addr, r_asi, r_rd); tcg_temp_free_i32(r_rd); tcg_temp_free_i32(r_asi); }
1threat
cant' Drag and Drop for Design Systems : After update the android studio I am enable to use material designing. but I can't user any UI element in drag and drop mode. mouse curse shows in halfly cutted black circle
0debug
I Want A Countdown That Accepts A Custom Input : <p>So i have tried my absolute hardest to try and get my code to work what i want is a input responsive countdown can anyone help?</p> <pre><code> print ("Would You like To Start A Countdown? Y/N (CASE SENSITIVE)") countdownyn = input (':') if countdownyn == ('Y'): print ("Please Enter Your Designated Time To Countdown From") x = input (':') def countdown(x) : while x&gt; 0: print (x) print ("") time.sleep(1) x = x1 if x ==0: print("BLAST OFF!") countdown(x) </code></pre>
0debug
I am very inexperienced with MySQL and I don't know how to troubleshoot this error. : I'm making a simple website for a class, and I am trying to save information to my database. The error is not very specific and I do not know which part of my code I need to fix. Error message: "check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 2" My PHP code: <?php include 'mysqli.php' ; $result = $con->query("select * from setList s left join songTable t on s.SetList_ID = t.Song_ID left join bands b on s.SetList_ID = b.Band_ID"); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $setList = $_POST['setlist']; $venue = $_POST['venue']; $date = $_POST['dateOfShow']; $band= $_POST['band']; $set = $result->fetch_object(); //error handling and form try { if (empty($setList) || empty($venue) || empty($date) || empty($band)) { throw new Exception( "All Fields Required"); } if (isset($set)) { $id = $set->SetList_ID; $q = "update setList set SetList_Name = '$setList', Venue = '$venue', Show_Date = $date, Band_Name = '$band')"; } else{ $q = "insert setList (SetList_Name, Venue, Show_Date, Band_Name) values ('$setList', '$venue', $date, '$band')"; } $result = $con->query($q); if (!$result) { throw new Exception($con->error); } header('Location:my_set-lists.php'); } catch(Exception $e) { echo '<p class ="error">Error: ' . $e->getMessage() . '</p>'; } } ?>
0debug
Opening a text file with C++ : <p>I'm trying to figure out how to open a text file in a c++ program, I then have to count the white spaces within in the file, which isn't an issue. I just can't figure out to open the text file in c++ </p> <p>Thanks! </p>
0debug
How to color active, wrong and correct words in typing test? Help :( : <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> var hasStarted = false; //strToTest is an array object that holds various strings to be used as the base typing test // - If you update the array, be sure to update the intToTestCnt with the number of ACTIVE testing strings var intToTestCnt = 4; var strToTest = new Array("Innovative Technical Solutions, LLC (ITS) is a Native American owned business that was established in Paducah, Kentucky in April 2000. ITS is a certified and Small Disadvantaged Business by the U.S. Small Business Administration. Our headquarters are in Paducah, Kentucky and we have satellite offices located in Tennessee, Ohio, and Illinois. ITS is a leading edge Information Technology firm that is comprised of professionals with a broad range of experience in software development, high-speed imaging/scanning (TIFF, PDF, Text, and OCR capabilities), document management, records management, relevance management, information security, environmental management, fire services management, fire protection engineering, and protective force expertise.", "The ITS Information Technology (IT) Team are experts in the identification, capture, indexing, microfilming, imaging, disposition, turnover, storage, and retrieval of records, and in the administration of records management databases. The types of records we have extensive experience in managing include waste management, hazardous waste, waste shipment, environmental compliance, environmental monitoring, feasibility studies, environmental work plans, cleanup actions, cemetery records, and various Federal laws such as CERCLA, Paper Reduction, Pollution Prevention, and Clean Water and Air.", "Collectively, the professional background of key ITS personnel demonstrates Fortune 100 Company experience that includes, but is not limited to, DOE, the Department of Defense, EPA, the Tennessee Valley Authority (TVA), Lockheed Martin Utility Services, Lockheed Martin Energy Systems, British Nuclear Fuels Limited, various state and local agencies, and USEC. We consider the depth and magnitude of this experience as a proposition value to both our current and future customers.", "With our years of experience, we completely understand document management and technology. We know the importance of deadlines and we know the importance of production without error. We refuse to over-commit to deadlines that can not be met. Dedication to excellence in providing quality products and services through innovative ideas and processes. Steadfast resolve to a positive working environment that allows for the personal and professional development of all employees, while sustaining project service, and customer satisfaction. Commitment to the highest ethical management practices that recognize client satisfaction as a top priority.") var strToTestType = ""; var checkStatusInt; //General functions to allow for left and right trimming / selection of a string function Left(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else return String(str).substring(0,n); } function Right(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else { var iLen = String(str).length; return String(str).substring(iLen, iLen - n); } } //beginTest Function/Sub initializes the test and starts the timers to determine the WPM and Accuracy function beginTest() { //We're starting the test, so set the variable to true hasStarted = true; //Generate a date value for the current time as a baseline day = new Date(); //Count the number of valid words in the testing baseline string cnt = strToTestType.split(" ").length; //Set the total word count to the number of valid words that need to be typed word = cnt; //Set the exact time of day that the testing has started startType = day.getTime(); //Disable the printing button (if used, in this download it's not included) document.getElementById("printB").disabled = true; calcStat(); //Initialize the testing objects by setting the values of the buttons, what to type, and what is typed document.JobOp.start.value = "-- Typing Test Started --"; document.JobOp.start.disabled = true; document.JobOp.given.value = strToTestType; document.JobOp.typed.value = ""; //Apply focus to the text box the user will type the test into document.JobOp.typed.focus(); document.JobOp.typed.select(); } //User to deter from Copy and Paste, also acting as a testing protection system // Is fired when the user attempts to click or apply focus to the text box containing what needs to be typed function deterCPProtect() { document.JobOp.typed.focus(); } //The final call to end the test -- used when the user has completed their assignment // This function/sub is responsible for calculating the accuracy, and setting post-test variables function endTest() { //Clear the timer that tracks the progress of the test, since it's complete clearTimeout(checkStatusInt); //Initialize an object with the current date/time so we can calculate the difference eDay = new Date(); endType = eDay.getTime(); totalTime = ((endType - startType) / 1000) //Calculate the typing speed by taking the number of valid words typed by the total time taken and multiplying it by one minute in seconds (60) //***** 1A *************************************************************************************************************************** 1A ***** //We also want to disregard if they used a double-space after a period, if we didn't then it would throw everything after the space off //Since we are using the space as the seperator for words; it's the difference between "Hey. This is me." versus "Hey. This is me." and //Having the last three words reporting as wrong/errors due to the double space after the first period, see? //********************************************************************************************************************************************* wpmType = Math.round(((document.JobOp.typed.value.replace(/ /g, " ").split(" ").length)/totalTime) * 60) //Set the start test button label and enabled state document.JobOp.start.value = ">> Re-Start Typing Test <<"; document.JobOp.start.disabled = false; //Flip the starting and stopping buttons around since the test is complete document.JobOp.stop.style.display="none"; document.JobOp.start.style.display="block"; //Declare an array of valid words for what NEEDED to be typed and what WAS typed //Again, refer to the above statement on removing the double spaces globally (1A) var typedValues = document.JobOp.typed.value.replace(/ /g, " "); var neededValues = Left(document.JobOp.given.value, typedValues.length).replace(/ /g, " ").split(" "); typedValues = typedValues.split(" "); //Disable the area where the user types the test input document.JobOp.typed.disabled=true; //Declare variable references to various statistical layers var tErr = document.getElementById("stat_errors"); var tscore = document.getElementById("stat_score"); var tStat = document.getElementById("stat_wpm"); var tTT = document.getElementById("stat_timeleft"); var tArea = document.getElementById("TypeArea"); var aArea = document.getElementById("AfterAction"); var eArea = document.getElementById("expectedArea"); //Initialize the counting variables for the good valid words and the bad valid words var goodWords = 0; var badWords = 0; //Declare a variable to hold the error words we found and also a detailed after action report var errWords = ""; var aftReport = "<b>Detailed Summary:</b><br><font color=\"DarkGreen\">"; //Enable the printing button document.getElementById("printB").disabled = false; //Loop through the valid words that were possible (those in the test baseline of needing to be typed) var str; var i = 0; for (var i = 0; i < word; i++) { //If there is a word the user typed that is in the spot of the expected word, process it if (typedValues.length > i) { //Declare the word we expect, and the word we recieved var neededWord = neededValues[i]; var typedWord = typedValues[i]; //Determine if the user typed the correct word or incorrect if (typedWord != neededWord) { //They typed it incorrectly, so increment the bad words counter badWords = badWords + 1; errWords += typedWord + " = " + neededWord + "\n"; aftReport += "<font color=\"Red\"><u>" + neededWord + "</u></font> "; } else { //They typed it correctly, so increment the good words counter goodWords = goodWords + 1; aftReport += neededWord + " "; } } else { //They didn't even type this word, so increment the bad words counter //Update: We don't want to apply this penalty because they may have chosen to end the test // and we only want to track what they DID type and score off of it. //badWords = badWords + 1; } } //Finalize the after action report variable with the typing summary at the beginning (now that we have the final good and bad word counts) aftReport += "</font>"; aftReport = "<b>Typing Summary:</b><br>You typed " + (document.JobOp.typed.value.replace(/ /g, " ").split(" ").length) + " words in " + totalTime + " seconds, a speed of about " + wpmType + " words per minute.\n\nYou also had " + badWords + " errors, and " + goodWords + " correct words, giving scoring of " + ((goodWords / (goodWords+badWords)) * 100).toFixed(2) + "%.<br><br>" + aftReport; //Set the statistical label variables with what we found (errors, words per minute, time taken, etc) tErr.innerText = badWords + " Errors"; tStat.innerText= (wpmType-badWords) + " WPM / " + wpmType + " WPM"; tTT.innerText = totalTime.toFixed(2) + " sec. elapsed"; //Calculate the accuracy score based on good words typed versus total expected words -- and only show the percentage as ###.## tscore.innerText = ((goodWords / (goodWords+badWords)) * 100).toFixed(2) + "%"; //Flip the display of the typing area and the expected area with the after action display area aArea.style.display = "block"; tArea.style.display = "none"; eArea.style.display = "none"; //Set the after action details report to the summary as we found; and in case there are more words found than typed //Set the undefined areas of the report to a space, otherwise we may get un-needed word holders aArea.innerHTML = aftReport.replace(/undefined/g, " "); //Notify the user of their testing status via a JavaScript Alert //Update: There isn't any need in showing this popup now that we are hiding the typing area and showing a scoring area //alert("You typed " + (document.JobOp.typed.value.split(" ").length) + " words in " + totalTime + " seconds, a speed of about " + wpmType + " words per minute.\n\nYou also had " + badWords + " errors, and " + goodWords + " correct words, giving scoring of " + ((goodWords / (goodWords+badWords)) * 100).toFixed(2) + "%."); } //calcStat is a function called as the user types to dynamically update the statistical information function calcStat() { //If something goes wrong, we don't want to cancel the test -- so fallback error proection (in a way, just standard error handling) try { //Reset the timer to fire the statistical update function again in 250ms //We do this here so that if the test has ended (below) we can cancel and stop it checkStatusInt=setTimeout('calcStat();',250); //Declare reference variables to the statistical information labels var tStat = document.getElementById("stat_wpm"); var tTT = document.getElementById("stat_timeleft"); var tProg = document.getElementById("stProg"); var tProgt = document.getElementById("thisProg"); var tArea = document.getElementById("TypeArea"); var aArea = document.getElementById("AfterAction"); var eArea = document.getElementById("expectedArea"); //Refer to 1A (above) for details on why we are removing the double space var thisTyped = document.JobOp.typed.value.replace(/ /g, " "); //Create a temp variable with the current time of day to calculate the WPM eDay = new Date(); endType = eDay.getTime(); totalTime = ((endType - startType) / 1000) //Calculate the typing speed by taking the number of valid words typed by the total time taken and multiplying it by one minute in seconds (60) wpmType = Math.round(((thisTyped.split(" ").length)/totalTime) * 60) //Set the words per minute variable on the statistical information block tStat.innerText=wpmType + " WPM"; //The test has started apparantly, so disable the stop button document.JobOp.stop.disabled = false; //Flip the stop and start button display status document.JobOp.stop.style.display="block"; document.JobOp.start.style.display="none"; //Calculate and show the time taken to reach this point of the test and also the remaining time left in the test //Colorize it based on the time left (red if less than 5 seconds, orange if less than 15) if (Number(60-totalTime) < 5) { tTT.innerHTML="<font color=\"Red\">" + String(totalTime.toFixed(2)) + " sec. / " + String(Number(60-totalTime).toFixed(2)) + " sec.</font>"; } else { if (Number(60-totalTime) < 15) { tTT.innerHTML="<font color=\"Orange\">" + String(totalTime.toFixed(2)) + " sec. / " + String(Number(60-totalTime).toFixed(2)) + " sec.</font>"; } else { tTT.innerHTML=String(totalTime.toFixed(2)) + " sec. / " + String(Number(60-totalTime).toFixed(2)) + " sec."; } } //Determine if the user has typed all of the words expected if ((((thisTyped.split(" ").length)/word)*100).toFixed(2) >= 100) { tProg.width="100%"; tProgt.innerText = "100%"; } else { //Set the progress bar with the exact percentage of the test completed tProg.width=String((((thisTyped.split(" ").length)/word)*100).toFixed(2))+"%"; tProgt.innerText = tProg.width; } //Determine if the test is complete based on them having typed everything exactly as expected if (thisTyped.value == document.JobOp.given.value) { endTest(); } //Determine if the test is complete based on whether or not they have typed exactly or exceeded the number of valid words (determined by a space) if (word <= (thisTyped.split(" ").length)) { endTest(); } //Check the timer; stop the test if we are at or exceeded 60 seconds if (totalTime >= 60) { endTest(); } //Our handy error handling } catch(e){}; } //Simply does a check on focus to determine if the test has started function doCheck() { if (hasStarted == false) { //The test has not started, but the user is typing already -- maybe we should start? beginTest(); //Yes, we should -- consider it done! } } randNum = Math.floor((Math.random() * 10)) % intToTestCnt; strToTestType = strToTest[randNum]; document.JobOp.given.value = strToTestType; document.JobOp.typed.focus(); <!-- language: lang-html --> <div align="center"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td style="border-bottom: 2px solid #354562; padding: 4px" class="titlec"> <input disabled id="printB" onclick="window.print();" type="button" value="Print Results" name="printB" style="float: right; font-size: 8pt; font-family: Arial"><input onclick="document.getElementById('AfterAction').style.display='none';document.getElementById('expectedArea').style.display='block';document.getElementById('typeArea').style.display='block';document.JobOp.typed.value='';document.JobOp.typed.disabled=false;randNum = Math.floor((Math.random() * 10)) % intToTestCnt;strToTestType = strToTest[randNum];document.JobOp.given.value = strToTestType;" type="button" value="New Test" name="newtest" style="float: right; font-size: 8pt; font-family: Arial">ITS Typing Test System</td> </tr> </table> </div> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td style="border-bottom: 1px dotted #860E36; padding: 4px" class="titlea" background="Images/Lt_Red_Back.gif" width="460"> Accurately and precisely evaluate your typing speed and accuracy.</td> <td style="border-bottom: 1px dotted #860E36; padding: 4px" class="titlea" background="Images/Lt_Red_Back.gif" width="190"> <p align="right">v1.0</td> </tr> <tr> <td style="padding: 4px" class="bodya" colspan="2"> <FORM name="JobOp"> <table border="0" cellpadding="5" width="100%"> <tr> <td> <table border="0" cellpadding="5" width="100%"> <tr> <td align="center" style="border-left: 1px solid #344270; border-right: 2px solid #344270; border-top: 1px solid #344270; border-bottom: 2px solid #344270; padding: 5px; background-color: #CED3E8" background="Images/Blue_Back.gif"> <b><font face="Arial" size="2" color="#FFFFFF">Net / Gross WPM</font></b></td> <td align="center" style="border-left: 1px solid #344270; border-right: 2px solid #344270; border-top: 1px solid #344270; border-bottom: 2px solid #344270; padding: 5px; background-color: #CED3E8" background="Images/Blue_Back.gif"> <b><font face="Arial" size="2" color="#FFFFFF">Entry Errors</font></b></td> <td align="center" style="border-left: 1px solid #344270; border-right: 2px solid #344270; border-top: 1px solid #344270; border-bottom: 2px solid #344270; padding: 5px; background-color: #CED3E8" background="Images/Blue_Back.gif"> <b><font face="Arial" size="2" color="#FFFFFF">Accuracy</font></b></td> <td align="center" style="border-left: 1px solid #344270; border-right: 2px solid #344270; border-top: 1px solid #344270; border-bottom: 2px solid #344270; padding: 5px; background-color: #CED3E8" background="Images/Blue_Back.gif"> <b><font face="Arial" size="2" color="#FFFFFF">Elapsed / Remaining</font></b></td> </tr> <tr> <td align="center"><font size="2" face="Arial"> <div id="stat_wpm">Not Started</div></font></td> <td style="border-left: 1px dotted #8794C7; border-right: 1px dotted #8794C7; border-top-width: 1px; border-bottom-width: 1px" align="center"> <font size="2" face="Arial"><div id="stat_errors">Waiting...</div></font></td> <td style="border-left-width: 1px; border-right: 1px dotted #8794C7; border-top-width: 1px; border-bottom-width: 1px" align="center"> <font size="2" face="Arial"><div id="stat_score">Waiting...</div></font></td> <td align="center"><font size="2" face="Arial"> <div id="stat_timeleft">0:00</div></font></td> </tr> </table> </td> </tr> <tr> <td style="border-left-width: 1px; border-right-width: 1px; border-top: 1px solid #344270; border-bottom-width: 1px"> <div id="expectedArea" style="display:block"> <p style="margin-top: 0; margin-bottom: 0"> <font color="#7A88C0" face="Arial" size="1"> <textarea name="given" cols=53 rows=10 wrap=on onFocus="deterCPProtect();" style="width: 100%; border: 1px solid #344270; padding: 2px; font-family:Arial; font-size:9pt">Click on the button below to start the typing test. What you will be expected to type will appear here.</textarea></font> </div> </td> </tr> <tr> <td> <p align="center" style="margin-top: 0; margin-bottom: 2px"> <input type=button value="&gt;&gt; Start Typing Test &lt;&lt;" name="start" onClick="beginTest()" style="display:block; border-left:1px solid #293358; border-right:2px solid #293358; border-top:1px solid #293358; border-bottom:2px solid #293358; width: 100%; background-color: #9BB892; color:#FFFFFF; background-image:url('Images/Green_Back.gif')"><p align="center" style="margin-top: 0; margin-bottom: 0"> <input disabled type=button value="&gt;&gt; End Typing Test &lt;&lt;" name="stop" onClick="endTest()" style="display:none; border-left:1px solid #293358; border-right:2px solid #293358; border-top:1px solid #293358; border-bottom:2px solid #293358; width: 100%; background-color: #F05959; color:#FFFFFF; background-image:url('Images/Red_Back.gif')"></td> </tr> <tr> <td style="font-family: Arial; font-size: 9pt"> <div id="typeArea" style="display:block"> <table border="0" width="100%" cellspacing="1"> <tr> <td style="border: 1px solid #9CA8D1; background-color: #EAECF4"> <div align="left"> <table id="stProg" border="0" width="0%" cellspacing="1"> <tr> <td style="border: 1px solid #344270; background-color: #8F9BCB; font-family:Arial; font-size:8pt; color:#FFFFFF" align="right" background="Images/Blue_Back.gif"> <div id="thisProg">0%</div></td> </tr> </table> </div> </td> </tr> </table> <p style="margin-top: 0; margin-bottom: 0"> <font color="#7A88C0" face="Arial" size="1"> <textarea onkeypress="doCheck();" onkeydown="//calcStat()" name="typed" cols=53 rows=10 wrap=on style="width: 100%; border: 1px solid #344270; padding: 2px; font-family:Arial; font-size:9pt"></textarea></font> </div> <div id="afterAction" style="display:none"> </div> </td> </tr> </table> </FORM> </td> </tr> </table> <!-- end snippet --> This code is about typing test to check typing speed. I want to highlight an error in typing as red and correct word as green and current word user is typing as brown. I have been trying to achieve this from last three days.I beg you to please help. Whenever I try to modify code, it never run at all. I am new at Javascript. Please suggest ways to achieve this.
0debug
SQL Select when record is 1 then bring back line else bring back the 0 record : I need a little help with a query. I have written a script that brings back an order number and the number of containers needed. (Code Below) SELECT CONI.CONTNO, CONI.ITEMNO, CONI.[WEIGHT], CONI.QTY, STOK.PGROUP, CASE WHEN CPRO.TNTCOL = 1 THEN 1 WHEN CPRO.TNTCOL = 0 THEN 0 WHEN CPRO.TNTCOL IS NULL THEN 0 END AS [TNT], CONI.RECID, CPRO.RECKEY INTO #SUB FROM ContItems CONI LEFT JOIN ContractItemProfiles CPRO ON CONI.RECID = CPRO.RECKEY JOIN Stock STOK ON CONI.ITEMNO = STOK.ITEMNO WHERE STOK.PGROUP LIKE 'FLI%' SELECT #SUB.CONTNO, #SUB.TNT, SUM(#SUB.QTY) AS [Number of flight cases] FROM #SUB WHERE #SUB.CONTNO = '123/321581' GROUP BY #SUB.CONTNO, #SUB.TNT DROP TABLE #SUB Then I get the Result: Contno TNT Number of flight cases 123/321581 0 20.00 123/321581 1 1.00 I need to conditionally bring back the line that has the TNT = 1 Else if there isn't a 1 in the TNT column then bring back the record with 0 I hope this is explained enough.
0debug
"This type of file can harm your computer mac no keep option" - No "Keep" option? macOS HS : <p>I have encountered the usual Chrome "feature" of displaying "this type of file can harm your computer mac no keep option" when trying to download a file from a filehosting website.</p> <p>However, when the warning appears there is only ever a "discard" button and not one to "keep" the file as I have seen when using Windows...</p> <p><a href="https://i.stack.imgur.com/fzTCU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fzTCU.png" alt="enter image description here"></a></p> <p>Can anybody suggest anything?</p>
0debug
static void posix_aio_read(void *opaque) { PosixAioState *s = opaque; RawAIOCB *acb, **pacb; int ret; ssize_t len; for (;;) { char bytes[16]; len = read(s->rfd, bytes, sizeof(bytes)); if (len == -1 && errno == EINTR) continue; if (len == sizeof(bytes)) continue; break; } for(;;) { pacb = &s->first_aio; for(;;) { acb = *pacb; if (!acb) goto the_end; ret = aio_error(&acb->aiocb); if (ret == ECANCELED) { *pacb = acb->next; raw_fd_pool_put(acb); qemu_aio_release(acb); } else if (ret != EINPROGRESS) { if (ret == 0) { ret = aio_return(&acb->aiocb); if (ret == acb->aiocb.aio_nbytes) ret = 0; else ret = -EINVAL; } else { ret = -ret; } *pacb = acb->next; acb->common.cb(acb->common.opaque, ret); raw_fd_pool_put(acb); qemu_aio_release(acb); break; } else { pacb = &acb->next; } } } the_end: ; }
1threat
in JavaScript how can I use the information stored in java arraylist : I use a java class to create a web browser, so I use a local html document to show the mainscreen ,suchas the google map html, but I want to draw some labels on googlemap ,but it is in JavaScript , but the location information such as x,y stored in an arraylist in java . How could I get the information?
0debug
static av_cold int xvid_encode_close(AVCodecContext *avctx) { struct xvid_context *x = avctx->priv_data; if (x->encoder_handle) { xvid_encore(x->encoder_handle, XVID_ENC_DESTROY, NULL, NULL); x->encoder_handle = NULL; } av_frame_free(&avctx->coded_frame); av_freep(&avctx->extradata); if (x->twopassbuffer) { av_free(x->twopassbuffer); av_free(x->old_twopassbuffer); } av_free(x->twopassfile); av_free(x->intra_matrix); av_free(x->inter_matrix); return 0; }
1threat
void OPPROTO op_405_check_satu (void) { if (unlikely(T0 < T2)) { T0 = -1; } RETURN(); }
1threat
void fw_cfg_add_file(FWCfgState *s, const char *filename, uint8_t *data, uint32_t len) { int i, index; if (!s->files) { int dsize = sizeof(uint32_t) + sizeof(FWCfgFile) * FW_CFG_FILE_SLOTS; s->files = g_malloc0(dsize); fw_cfg_add_bytes(s, FW_CFG_FILE_DIR, (uint8_t*)s->files, dsize); } index = be32_to_cpu(s->files->count); assert(index < FW_CFG_FILE_SLOTS); fw_cfg_add_bytes(s, FW_CFG_FILE_FIRST + index, data, len); pstrcpy(s->files->f[index].name, sizeof(s->files->f[index].name), filename); for (i = 0; i < index; i++) { if (strcmp(s->files->f[index].name, s->files->f[i].name) == 0) { trace_fw_cfg_add_file_dupe(s, s->files->f[index].name); return; } } s->files->f[index].size = cpu_to_be32(len); s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index); trace_fw_cfg_add_file(s, index, s->files->f[index].name, len); s->files->count = cpu_to_be32(index+1); }
1threat
Algorithm for joining circles into a polygon : <p>What is the best way of combining overlapping circles into polygons?</p> <p>I am given a list of centre points of circles with a fixed diameter.</p> <p><a href="https://i.stack.imgur.com/LE7b3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LE7b3.png" alt="Rendering of 5 random circles"></a></p> <p>I need to join any overlapping circles together and output a list of points in the resulting polygon. <a href="https://i.stack.imgur.com/bUeY9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bUeY9.png" alt="Rendering of desired output"></a></p> <p>This seems like a fairly common problem (GIS systems, vectors, etc.). This is possible to do through the Google Maps API but I am looking for the actual algorithm.</p> <p>I have tried to solve this problem by calculating points around each circle. <a href="https://i.stack.imgur.com/xwvfU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xwvfU.png" alt="Rendering of 16 points on the circumference of each circle"></a></p> <p>Then removing any points located inside any circle. <a href="https://i.stack.imgur.com/Wor7I.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Wor7I.png" alt="enter image description here"></a></p> <p>This gives me the correct list of points in the desired polygon. <a href="https://i.stack.imgur.com/ww6yp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ww6yp.png" alt="Rendering of points on the desired polygon"></a></p> <p>However, the order of the points is a problem with this solution. Each circle has its points stored in an array. To merge them correctly with 2 overlapping circles is relatively straight forward. However, when dealing with multiple overlapping circles it gets complicated. <a href="https://i.stack.imgur.com/BQcIP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BQcIP.png" alt="enter image description here"></a></p> <p>Hopefully you have some ideas to either make this solution work or of another algorithm that will achieve the desired result.</p> <p>Thanks in advance!</p>
0debug
how to get which statements are missed in python test coverage : <p>I am new to python, I have written test cases for my class , I am using <code>python -m pytest --cov=azuread_api</code> to get code coverage.</p> <p>I am getting coverage on the console as <a href="https://i.stack.imgur.com/iKRNP.png" rel="noreferrer"><img src="https://i.stack.imgur.com/iKRNP.png" alt="enter image description here"></a></p> <p>How do I get which lines are missed by test for e.g in aadadapter.py file</p> <p>Thanks,</p>
0debug
Include an array of 20k zip codes or call MySQL : <p>I have a list of about 20,000 zip codes that I need to check against. Should I store them in an PHP file as an array? How much memory would that occupy?</p> <p>Or should I call MySQL every time to check against its database table to see if it exists? Which way is faster? I assume the first option should be faster? The connection to database alone may slow down the database call option quite significantly? I'm just a bit concerned about that memory problem if I do it by including PHP file on every call.</p>
0debug
use of ELF file in embedded system? : <p>The generation of ELF file (Executable and Linking Format) differs from a native c compiler to a cross compiler. What is use of ELF file in native C compiler and Cross compiler ?</p>
0debug
How to have full screen UITableView (with header) in iPhone X? : <p>I'm updating my app with Xcode 9 for the iPhone X compatibility. I use auto layout and "Use safe Area Layout Guide" is marked.</p> <p>I have a header in my UITableView, and, as you can see in the screenshot below, the header view strictly respects the top safe area. The header doesn't follow my tableview top constraint (which is bigger than the safe area)</p> <p><a href="https://i.stack.imgur.com/9eKI9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9eKI9.png" alt="enter image description here"></a></p> <p>My tableview constraints :</p> <p><a href="https://i.stack.imgur.com/DXMn0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DXMn0.png" alt="enter image description here"></a></p> <p>How can I do to modify my header in order to fill the top of the screen (white area on the screenshot)?</p>
0debug
Using a argument as a property key : <p>Lets say I got this function:</p> <pre><code> vm.setSelectedItem = function(itemName, searchedItems){ vm.selectedItem = _.findWhere(searchedItems, {name: itemName}); }; </code></pre> <p>I need to make the "name" dynamic</p> <pre><code> vm.setSelectedItem = function(itemName, searchedItems, propertyKey){ vm.selectedItem = _.findWhere(searchedItems, {}); //How do I use the arg propertyKey here? }; </code></pre> <p>How do I do this?</p>
0debug
Pandas filter data frame rows by function : <p>I want to filter a data frame by more complex function based on different values in the row.</p> <p>Is there a possibility to filter DF rows by a boolean function like you can do it e.g. in <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter" rel="noreferrer">ES6 filter function</a>?</p> <p>Extreme simplified example to illustrate the problem:</p> <pre><code>import pandas as pd def filter_fn(row): if row['Name'] == 'Alisa' and row['Age'] &gt; 24: return False return row d = { 'Name': ['Alisa', 'Bobby', 'jodha', 'jack', 'raghu', 'Cathrine', 'Alisa', 'Bobby', 'kumar', 'Alisa', 'Alex', 'Cathrine'], 'Age': [26, 24, 23, 22, 23, 24, 26, 24, 22, 23, 24, 24], 'Score': [85, 63, 55, 74, 31, 77, 85, 63, 42, 62, 89, 77]} df = pd.DataFrame(d, columns=['Name', 'Age', 'Score']) df = df.apply(filter_fn, axis=1, broadcast=True) print(df) </code></pre> <p>I found something using apply() bit this actually returns only <code>False</code>/<code>True</code> filled rows using a bool function, which is expected.</p> <p>My workaround would be returning the row itself when the function result would be True and returning False if not. But this would require a additional filtering after that.</p> <pre><code> Name Age Score 0 False False False 1 Bobby 24 63 2 jodha 23 55 3 jack 22 74 4 raghu 23 31 5 Cathrine 24 77 6 False False False 7 Bobby 24 63 8 kumar 22 42 9 Alisa 23 62 10 Alex 24 89 11 Cathrine 24 77 </code></pre>
0debug
python - extract element of a list : I have a list which is like this. [{0: 26}, {0: 36}, {1: 1}, {0: 215}, {1: 63}, {0: 215}] How can I extract another list which has only. [0,0,1,0,1,0]
0debug
static int configure_accelerator(void) { const char *p = NULL; char buf[10]; int i, ret; bool accel_initalised = 0; bool init_failed = 0; QemuOptsList *list = qemu_find_opts("machine"); if (!QTAILQ_EMPTY(&list->head)) { p = qemu_opt_get(QTAILQ_FIRST(&list->head), "accel"); } if (p == NULL) { p = "tcg"; } while (!accel_initalised && *p != '\0') { if (*p == ':') { p++; } p = get_opt_name(buf, sizeof (buf), p, ':'); for (i = 0; i < ARRAY_SIZE(accel_list); i++) { if (strcmp(accel_list[i].opt_name, buf) == 0) { ret = accel_list[i].init(); if (ret < 0) { init_failed = 1; if (!accel_list[i].available()) { printf("%s not supported for this target\n", accel_list[i].name); } else { fprintf(stderr, "failed to initialize %s: %s\n", accel_list[i].name, strerror(-ret)); } } else { accel_initalised = 1; *(accel_list[i].allowed) = 1; } break; } } if (i == ARRAY_SIZE(accel_list)) { fprintf(stderr, "\"%s\" accelerator does not exist.\n", buf); } } if (!accel_initalised) { fprintf(stderr, "No accelerator found!\n"); exit(1); } if (init_failed) { fprintf(stderr, "Back to %s accelerator.\n", accel_list[i].name); } return !accel_initalised; }
1threat
llegalArgumentException : Stack size becomes negative : [java.lang.IllegalArgumentException] Stack size becomes negative after instruction [50] pop in [org/jetbrains/anko/Logging.error(Lorg/jetbrains/anko/AnkoLogger;Lkotlin/jvm/functions/Function0;)V] > 15:38:22.102 [ERROR] [system.err] Unexpected error while inlining > method: 15:38:22.102 [ERROR] [system.err] Target class = > [org/jetbrains/anko/Logging] 15:38:22.103 [ERROR] [system.err] > Target method = > [error(Lorg/jetbrains/anko/AnkoLogger;Lkotlin/jvm/functions/Function0;)V] > 15:38:22.103 [ERROR] [system.err] Exception = > [java.lang.IllegalArgumentException] (Stack size becomes negative > after instruction [50] pop in > [org/jetbrains/anko/Logging.error(Lorg/jetbrains/anko/AnkoLogger;Lkotlin/jvm/functions/Function0;)V]) > 15:38:22.103 [ERROR] [system.err] java.lang.IllegalArgumentException: > Stack size becomes negative after instruction [50] pop in > [org/jetbrains/anko/Logging.error(Lorg/jetbrains/anko/AnkoLogger;Lkotlin/jvm/functions/Function0;)V] > 15:38:22.103 [ERROR] [system.err] at > proguard.classfile.attribute.visitor.StackSizeComputer.evaluateInstructionBlock(StackSizeComputer.java:349) > 15:38:22.103 [ERROR] [system.err] at > proguard.classfile.attribute.visitor.StackSizeComputer.visitBranchInstruction(StackSizeComputer.java:207) > 15:38:22.103 [ERROR] [system.err] at > proguard.classfile.instruction.BranchInstruction.accept(BranchInstruction.java:145) > 15:38:22.103 [ERROR] [system.err] at > proguard.classfile.attribute.visitor.StackSizeComputer.evaluateInstructionBlock(StackSizeComputer.java:366) > 15:38:22.103 [ERROR] [system.err] at > proguard.classfile.attribute.visitor.StackSizeComputer.visitCodeAttribute0(StackSizeComputer.java:163) > 15:38:22.103 [ERROR] [system.err] at > proguard.classfile.attribute.visitor.StackSizeComputer.visitCodeAttribute(StackSizeComputer.java:125) > 15:38:22.103 [ERROR] [system.err] at > proguard.optimize.peephole.MethodInliner.visitCodeAttribute0(MethodInliner.java:220) > 15:38:22.103 [ERROR] [system.err] at > proguard.optimize.peephole.MethodInliner.visitCodeAttribute(MethodInliner.java:172) > 15:38:22.103 [ERROR] [system.err] at > proguard.optimize.info.OptimizationCodeAttributeFilter.visitCodeAttribute(OptimizationCodeAttributeFilter.java:84) > 15:38:22.104 [ERROR] [system.err] at > proguard.classfile.attribute.visitor.DebugAttributeVisitor.visitCodeAttribute(DebugAttributeVisitor.java:302) > 15:38:22.104 [ERROR] [system.err] at > proguard.classfile.attribute.CodeAttribute.accept(CodeAttribute.java:141) > 15:38:22.104 [ERROR] [system.err] at > proguard.classfile.ProgramMethod.attributesAccept(ProgramMethod.java:101) > 15:38:22.104 [ERROR] [system.err] at > proguard.classfile.attribute.visitor.AllAttributeVisitor.visitProgramMember(AllAttributeVisitor.java:95) > 15:38:22.104 [ERROR] [system.err] at > proguard.classfile.util.SimplifiedVisitor.visitProgramMethod(SimplifiedVisitor.java:93) > 15:38:22.104 [ERROR] [system.err] at > proguard.classfile.ProgramMethod.accept(ProgramMethod.java:93) > 15:38:22.104 [ERROR] [system.err] at > proguard.classfile.ProgramClass.methodsAccept(ProgramClass.java:588) > 15:38:22.104 [ERROR] [system.err] at > proguard.classfile.visitor.AllMethodVisitor.visitProgramClass(AllMethodVisitor.java:47) > 15:38:22.104 [ERROR] [system.err] at > proguard.classfile.ProgramClass.accept(ProgramClass.java:430) > 15:38:22.104 [ERROR] [system.err] at > proguard.classfile.ClassPool.classesAccept(ClassPool.java:124) > 15:38:22.104 [ERROR] [system.err] at > proguard.classfile.visitor.AllClassVisitor.visitClassPool(AllClassVisitor.java:45) > 15:38:22.104 [ERROR] [system.err] at > proguard.classfile.ClassPool.accept(ClassPool.java:110) 15:38:22.104 > [ERROR] [system.err] at > proguard.optimize.Optimizer$TimedClassPoolVisitor.visitClassPool(Optimizer.java:1684) > 15:38:22.105 [ERROR] [system.err] at > proguard.classfile.ClassPool.accept(ClassPool.java:110) 15:38:22.105 > [ERROR] [system.err] at > proguard.optimize.Optimizer.execute(Optimizer.java:1194) 15:38:22.105 > [ERROR] [system.err] at > proguard.ProGuard.optimize(ProGuard.java:413) 15:38:22.105 [ERROR] > [system.err] at proguard.ProGuard.execute(ProGuard.java:154) > 15:38:22.105 [ERROR] [system.err] at > com.android.build.gradle.internal.transforms.BaseProguardAction.runProguard(BaseProguardAction.java:66) > 15:38:22.105 [ERROR] [system.err] at > com.android.build.gradle.internal.transforms.ProGuardTransform.doMinification(ProGuardTransform.java:274) > 15:38:22.105 [ERROR] [system.err] at > com.android.build.gradle.internal.transforms.ProGuardTransform.access$000(ProGuardTransform.java:67) > 15:38:22.105 [ERROR] [system.err] at > com.android.build.gradle.internal.transforms.ProGuardTransform$1.run(ProGuardTransform.java:178) > 15:38:22.105 [ERROR] [system.err] at > com.android.builder.tasks.Job.runTask(Job.java:47) 15:38:22.105 > [ERROR] [system.err] at > com.android.build.gradle.tasks.SimpleWorkQueue$EmptyThreadContext.runTask(SimpleWorkQueue.java:41) > 15:38:22.105 [ERROR] [system.err] at > com.android.builder.tasks.WorkQueue.run(WorkQueue.java:282) > 15:38:22.106 [ERROR] [system.err] at > java.lang.Thread.run(Thread.java:745)
0debug
Iterating a hash by comparing it with two separate arrays and arrive with a new hash desired result : <ol> <li>Array 1 = 7 elements</li> <li>Array 2 = 7 elements</li> <li>Hash = 7 elements</li> </ol> <p>My requirement is to iterate through the each element in the hash with each element in array 1 and array 2 and come out with a new hash after applying the desired logic. The comparison is always going to be between the first element in hash against first element in array 1 and first element in array 2 and so on and so forth till I complete the list.</p> <p>I am not even sure where and how to start so any help is appreciated to get me started</p>
0debug
Struts2: How to find missing parameter OR wrong param [No result defined for action and result input] : I have following code snippets **from XML file** <action name="list-process-solution" class="actions.ProcessSolutionAction" method="listProcessSolutions"> <interceptor-ref name="store"> <param name="operationMode">RETRIEVE</param> </interceptor-ref> <interceptor-ref name="defaultStack"/> <result name="success">process_solution_list.jsp</result> <result name="input">process_solution_list.jsp</result> <result name="error">Error.jsp</result> <result name="login">Login.jsp</result> </action> <action name="delete-process-solution" class="actions.ProcessSolutionAction" method="crudProcessSolution"> <interceptor-ref name="store"> <param name="operationMode">STORE</param> </interceptor-ref> <interceptor-ref name="defaultStack"/> <result name="success" type="redirectAction"> <param name="actionName">list-process-solution</param> <param name="nsec">${nsec}</param> </result> <result name="error">Error.jsp</result> <result name="login">Login.jsp</result> </action> After deleting I'm redirecting to List Page ( same again Page ) **But** I'm getting result as `input` don't know where I'm wrong. I have configured this **link for delete** <s:url var="varDeletePS" action="delete-process-solution"> <s:param name="nsec"> <s:property value="nsec"/> </s:param> <s:param name="processId"> <s:property value="processId"/> </s:param> <s:param name="opType"> <s:property value="2" /> </s:param> </s:url> <s:a href="%{varDeletePS}" id="id-delete-PS-link" cssClass="class-delete"> Delete </s:a> In action, I have these fields with **getters and setters** private ProcessSolution processSolution; private short opType; private String nsec; for Model `ProcessSolution` refer this [link][1] My Question is **How to handle result name `input` here ? I don't know which parameter is wrong ?** Thank you. [1]: http://stackoverflow.com/q/40583282/3425489
0debug
How to open different websites in new tabs : I want to write small html/js code that when I open that file.html, 3 different websites open in 3 new tabs right away, can somebody help with the code? Im new in web development...thanks, much love
0debug
create file form text file in java : I write this code to output text file but it doesn't produce any file after running it. String text1="hello word"; try { File file = new File("f0f0f0f.txt"); FileWriter fileWriter = new FileWriter(file); fileWriter.write(text1); fileWriter.flush(); fileWriter.close(); } catch (IOException e) { e.printStackTrace(); } }
0debug
static void mpeg_decode_picture_coding_extension(Mpeg1Context *s1) { MpegEncContext *s= &s1->mpeg_enc_ctx; s->full_pel[0] = s->full_pel[1] = 0; s->mpeg_f_code[0][0] = get_bits(&s->gb, 4); s->mpeg_f_code[0][1] = get_bits(&s->gb, 4); s->mpeg_f_code[1][0] = get_bits(&s->gb, 4); s->mpeg_f_code[1][1] = get_bits(&s->gb, 4); if(!s->pict_type && s1->mpeg_enc_ctx_allocated){ av_log(s->avctx, AV_LOG_ERROR, "Missing picture start code, guessing missing values\n"); if(s->mpeg_f_code[1][0] == 15 && s->mpeg_f_code[1][1]==15){ if(s->mpeg_f_code[0][0] == 15 && s->mpeg_f_code[0][1] == 15) s->pict_type= FF_I_TYPE; else s->pict_type= FF_P_TYPE; }else s->pict_type= FF_B_TYPE; s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == FF_I_TYPE; } s->intra_dc_precision = get_bits(&s->gb, 2); s->picture_structure = get_bits(&s->gb, 2); s->top_field_first = get_bits1(&s->gb); s->frame_pred_frame_dct = get_bits1(&s->gb); s->concealment_motion_vectors = get_bits1(&s->gb); s->q_scale_type = get_bits1(&s->gb); s->intra_vlc_format = get_bits1(&s->gb); s->alternate_scan = get_bits1(&s->gb); s->repeat_first_field = get_bits1(&s->gb); s->chroma_420_type = get_bits1(&s->gb); s->progressive_frame = get_bits1(&s->gb); if(s->progressive_sequence && !s->progressive_frame){ s->progressive_frame= 1; av_log(s->avctx, AV_LOG_ERROR, "interlaced frame in progressive sequence, ignoring\n"); } if(s->picture_structure==0 || (s->progressive_frame && s->picture_structure!=PICT_FRAME)){ av_log(s->avctx, AV_LOG_ERROR, "picture_structure %d invalid, ignoring\n", s->picture_structure); s->picture_structure= PICT_FRAME; } if(s->progressive_frame && !s->frame_pred_frame_dct){ av_log(s->avctx, AV_LOG_ERROR, "invalid frame_pred_frame_dct\n"); s->frame_pred_frame_dct= 1; } if(s->picture_structure == PICT_FRAME){ s->first_field=0; s->v_edge_pos= 16*s->mb_height; }else{ s->first_field ^= 1; s->v_edge_pos= 8*s->mb_height; memset(s->mbskip_table, 0, s->mb_stride*s->mb_height); } if(s->alternate_scan){ ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_alternate_vertical_scan); ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_alternate_vertical_scan); }else{ ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_zigzag_direct); ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_zigzag_direct); } dprintf(s->avctx, "intra_dc_precision=%d\n", s->intra_dc_precision); dprintf(s->avctx, "picture_structure=%d\n", s->picture_structure); dprintf(s->avctx, "top field first=%d\n", s->top_field_first); dprintf(s->avctx, "repeat first field=%d\n", s->repeat_first_field); dprintf(s->avctx, "conceal=%d\n", s->concealment_motion_vectors); dprintf(s->avctx, "intra_vlc_format=%d\n", s->intra_vlc_format); dprintf(s->avctx, "alternate_scan=%d\n", s->alternate_scan); dprintf(s->avctx, "frame_pred_frame_dct=%d\n", s->frame_pred_frame_dct); dprintf(s->avctx, "progressive_frame=%d\n", s->progressive_frame); }
1threat
how to check whether test case has been passed or failed and to know its index value : regarding to the above subject i need to check test cases status like whether it is passed or failed and to know its index value how can i achieve this,i have tried with binary search but that is for key is found or not found,,can u help me out here it is binary search code i have tried with class Array def binary_search(val, low=0, high=(length - 1)) return nil if high < low mid = (low + high) >> 1 case val <=> self[mid] when -1 binary_search(val, low, mid - 1) when 1 binary_search(val, mid + 1, high) else mid end end end ary = [0,1,4,5,6,7,8,9,12,26,45,67,78,90] [0,42,45,24324,99999].each do |val| i = ary.binary_search(val) if i puts "found #{val} at index #{i}: #{ary[i]}" else puts "#{val} not found in array" end end
0debug
static int protocol_client_msg(VncState *vs, char *data, size_t len) { int i; uint16_t limit; switch (data[0]) { case 0: if (len == 1) return 20; set_pixel_format(vs, read_u8(data, 4), read_u8(data, 5), read_u8(data, 6), read_u8(data, 7), read_u16(data, 8), read_u16(data, 10), read_u16(data, 12), read_u8(data, 14), read_u8(data, 15), read_u8(data, 16)); break; case 2: if (len == 1) return 4; if (len == 4) return 4 + (read_u16(data, 2) * 4); limit = read_u16(data, 2); for (i = 0; i < limit; i++) { int32_t val = read_s32(data, 4 + (i * 4)); memcpy(data + 4 + (i * 4), &val, sizeof(val)); } set_encodings(vs, (int32_t *)(data + 4), limit); break; case 3: if (len == 1) return 10; framebuffer_update_request(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4), read_u16(data, 6), read_u16(data, 8)); break; case 4: if (len == 1) return 8; key_event(vs, read_u8(data, 1), read_u32(data, 4)); break; case 5: if (len == 1) return 6; pointer_event(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4)); break; case 6: if (len == 1) return 8; if (len == 8) return 8 + read_u32(data, 4); client_cut_text(vs, read_u32(data, 4), data + 8); break; default: printf("Msg: %d\n", data[0]); vnc_client_error(vs); break; } vnc_read_when(vs, protocol_client_msg, 1); return 0; }
1threat
static void test_tco1_control_bits(void) { TestData d; uint16_t val; d.args = NULL; d.noreboot = true; test_init(&d); val = TCO_LOCK; qpci_io_writew(d.dev, d.tco_io_base + TCO1_CNT, val); val &= ~TCO_LOCK; qpci_io_writew(d.dev, d.tco_io_base + TCO1_CNT, val); g_assert_cmpint(qpci_io_readw(d.dev, d.tco_io_base + TCO1_CNT), ==, TCO_LOCK); qtest_end(); }
1threat
static void virtio_net_handle_tx(VirtIODevice *vdev, VirtQueue *vq) { VirtIONet *n = to_virtio_net(vdev); if (n->tx_waiting) { virtio_queue_set_notification(vq, 1); qemu_del_timer(n->tx_timer); n->tx_waiting = 0; virtio_net_flush_tx(n, vq); } else { qemu_mod_timer(n->tx_timer, qemu_get_clock(vm_clock) + n->tx_timeout); n->tx_waiting = 1; virtio_queue_set_notification(vq, 0); } }
1threat
How to print the Json object in Android using try block : I need to get the json object from mysql database, and to printed as string,Also i need to pass that string to try block to open required class activity.Here, i have attached my code below, check my code and let me know. My json object sample: {"id":"381","task":"user_confirm","message":"New booking details"} My Android Code: public void onMessageReceived(final RemoteMessage remoteMessage) { Intent intent = new Intent(this, Login_Activity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this); notificationBuilder.setContentTitle(getResources().getString(R.string.app_name)); notificationBuilder.setContentText(remoteMessage.getNotification().getBody()); notificationBuilder.setAutoCancel(true); notificationBuilder.setSmallIcon(R.mipmap.main_logo); notificationBuilder.setContentIntent(pendingIntent); Uri path = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.bike_start); notificationBuilder.setSound(path); NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(0,notificationBuilder.build()); if (remoteMessage.getData().size() > 0) { try { JSONObject json = new JSONObject(remoteMessage.getData()); Log.e("JsonOutput", json.toString()); sendNotification(json); } catch (Exception e) { Log.e(TAG, "Exception: " + e.getMessage()); } } if (remoteMessage.getNotification()!=null){ Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody()); } // sendNotification1(String.valueOf(remoteMessage), image); // Log.e("body", body); } private void sendNotification(JSONObject json) { Log.e(TAG, "Notifications JSON1 " + json.toString()); try { JSONObject data = json.getJSONObject("data"); Log.d("data", String.valueOf(data)); //parsing json data id = data.get("id").toString(); message = data.get("message").toString(); task = data.get("task").toString(); Log.d("Id values", id); Log.d("Message", message); } } Output: this is what the output what am getting Notifications JSON1 {"id":"381","task":"user_confirm","message":"New booking details"} Thanks@
0debug
Google Sheets: How can I use REGEX to format phone numbers? : I have 2 phone numbers listed in different formats, but want to just extract the digits only: 17347545296 (734) 754-5296
0debug
static int ftp_store(FTPContext *s) { char command[CONTROL_BUFFER_SIZE]; const int stor_codes[] = {150, 0}; snprintf(command, sizeof(command), "STOR %s\r\n", s->path); if (!ftp_send_command(s, command, stor_codes, NULL)) return AVERROR(EIO); s->state = UPLOADING; return 0; }
1threat
static int decode_spectrum_and_dequant(AACContext * ac, float coef[1024], GetBitContext * gb, float sf[120], int pulse_present, const Pulse * pulse, const IndividualChannelStream * ics, enum BandType band_type[120]) { int i, k, g, idx = 0; const int c = 1024/ics->num_windows; const uint16_t * offsets = ics->swb_offset; float *coef_base = coef; for (g = 0; g < ics->num_windows; g++) memset(coef + g * 128 + offsets[ics->max_sfb], 0, sizeof(float)*(c - offsets[ics->max_sfb])); for (g = 0; g < ics->num_window_groups; g++) { for (i = 0; i < ics->max_sfb; i++, idx++) { const int cur_band_type = band_type[idx]; const int dim = cur_band_type >= FIRST_PAIR_BT ? 2 : 4; const int is_cb_unsigned = IS_CODEBOOK_UNSIGNED(cur_band_type); int group; if (cur_band_type == ZERO_BT) { for (group = 0; group < ics->group_len[g]; group++) { memset(coef + group * 128 + offsets[i], 0, (offsets[i+1] - offsets[i])*sizeof(float)); } }else if (cur_band_type == NOISE_BT) { const float scale = sf[idx] / ((offsets[i+1] - offsets[i]) * PNS_MEAN_ENERGY); for (group = 0; group < ics->group_len[g]; group++) { for (k = offsets[i]; k < offsets[i+1]; k++) { ac->random_state = lcg_random(ac->random_state); coef[group*128+k] = ac->random_state * scale; } } }else if (cur_band_type != INTENSITY_BT2 && cur_band_type != INTENSITY_BT) { for (group = 0; group < ics->group_len[g]; group++) { for (k = offsets[i]; k < offsets[i+1]; k += dim) { const int index = get_vlc2(gb, vlc_spectral[cur_band_type - 1].table, 6, 3); const int coef_tmp_idx = (group << 7) + k; const float *vq_ptr; int j; if(index >= ff_aac_spectral_sizes[cur_band_type - 1]) { av_log(ac->avccontext, AV_LOG_ERROR, "Read beyond end of ff_aac_codebook_vectors[%d][]. index %d >= %d\n", cur_band_type - 1, index, ff_aac_spectral_sizes[cur_band_type - 1]); return -1; } vq_ptr = &ff_aac_codebook_vectors[cur_band_type - 1][index * dim]; if (is_cb_unsigned) { for (j = 0; j < dim; j++) if (vq_ptr[j]) coef[coef_tmp_idx + j] = 1 - 2*(int)get_bits1(gb); }else { for (j = 0; j < dim; j++) coef[coef_tmp_idx + j] = 1.0f; } if (cur_band_type == ESC_BT) { for (j = 0; j < 2; j++) { if (vq_ptr[j] == 64.0f) { int n = 4; while (get_bits1(gb) && n < 15) n++; if(n == 15) { av_log(ac->avccontext, AV_LOG_ERROR, "error in spectral data, ESC overflow\n"); return -1; } n = (1<<n) + get_bits(gb, n); coef[coef_tmp_idx + j] *= cbrtf(fabsf(n)) * n; }else coef[coef_tmp_idx + j] *= vq_ptr[j]; } }else for (j = 0; j < dim; j++) coef[coef_tmp_idx + j] *= vq_ptr[j]; for (j = 0; j < dim; j++) coef[coef_tmp_idx + j] *= sf[idx]; } } } } coef += ics->group_len[g]<<7; } if (pulse_present) { for(i = 0; i < pulse->num_pulse; i++){ float co = coef_base[ pulse->pos[i] ]; float ico = co / sqrtf(sqrtf(fabsf(co))) + pulse->amp[i]; coef_base[ pulse->pos[i] ] = cbrtf(fabsf(ico)) * ico; } } return 0; }
1threat
static inline av_flatten int get_symbol_inline(RangeCoder *c, uint8_t *state, int is_signed) { if (get_rac(c, state + 0)) return 0; else { int i, e, a; e = 0; while (get_rac(c, state + 1 + FFMIN(e, 9))) e++; a = 1; for (i = e - 1; i >= 0; i--) a += a + get_rac(c, state + 22 + FFMIN(i, 9)); e = -(is_signed && get_rac(c, state + 11 + FFMIN(e, 10))); return (a ^ e) - e; } }
1threat
Google photos on iPhone, only upload select photos : <p>I have an iPhone and I want to create an album my friends, many of whom are Android users, can add photos to. I downloaded the app on my phone for this purpose. In order to add any photos the phone first wants to uploade all my photos to Google Photos. I don't want this to happen. I only want to add select photos to the app. Further I don't want to create a situation where I remove a photo from Google Photos which then removes the photos from my phone and other devices. </p>
0debug
static void qpeg_decode_inter(const uint8_t *src, uint8_t *dst, int size, int stride, int width, int height, int delta, const uint8_t *ctable, uint8_t *refdata) { int i, j; int code; int filled = 0; int orig_height; if(!refdata) refdata= dst; for(i = 0; i < height; i++) memcpy(dst + (i * stride), refdata + (i * stride), width); orig_height = height; height--; dst = dst + height * stride; while((size > 0) && (height >= 0)) { code = *src++; size--; if(delta) { while((code & 0xF0) == 0xF0) { if(delta == 1) { int me_idx; int me_w, me_h, me_x, me_y; uint8_t *me_plane; int corr, val; me_idx = code & 0xF; me_w = qpeg_table_w[me_idx]; me_h = qpeg_table_h[me_idx]; corr = *src++; size--; val = corr >> 4; if(val > 7) val -= 16; me_x = val; val = corr & 0xF; if(val > 7) val -= 16; me_y = val; if ((me_x + filled < 0) || (me_x + me_w + filled > width) || (height - me_y - me_h < 0) || (height - me_y > orig_height) || (filled + me_w > width) || (height - me_h < 0)) av_log(NULL, AV_LOG_ERROR, "Bogus motion vector (%i,%i), block size %ix%i at %i,%i\n", me_x, me_y, me_w, me_h, filled, height); else { me_plane = refdata + (filled + me_x) + (height - me_y) * stride; for(j = 0; j < me_h; j++) { for(i = 0; i < me_w; i++) dst[filled + i - (j * stride)] = me_plane[i - (j * stride)]; } } } code = *src++; size--; } } if(code == 0xE0) break; if(code > 0xE0) { int p; code &= 0x1F; p = *src++; size--; for(i = 0; i <= code; i++) { dst[filled++] = p; if(filled >= width) { filled = 0; dst -= stride; height--; if(height < 0) break; } } } else if(code >= 0xC0) { code &= 0x1F; for(i = 0; i <= code; i++) { dst[filled++] = *src++; if(filled >= width) { filled = 0; dst -= stride; height--; if(height < 0) break; } } size -= code + 1; } else if(code >= 0x80) { int skip; code &= 0x3F; if(!code) skip = (*src++) + 64; else if(code == 1) skip = (*src++) + 320; else skip = code; filled += skip; while( filled >= width) { filled -= width; dst -= stride; height--; if(height < 0) break; } } else { if(code) dst[filled++] = ctable[code & 0x7F]; else filled++; if(filled >= width) { filled = 0; dst -= stride; height--; } } } }
1threat
static void test_interface_impl(const char *type) { Object *obj = object_new(type); TestIf *iobj = TEST_IF(obj); TestIfClass *ioc = TEST_IF_GET_CLASS(iobj); g_assert(iobj); g_assert(ioc->test == PATTERN); }
1threat
How can I resolve this problem with "while" : <p>I want to make a timer using while, and when I lunch the code in Chrome, the Chrome don't load.</p> <p>I am making this:</p> <pre><code>var time = 0; while (time &lt; 5) { setTimeout(function(){ tempo[0].innerHTML = time; time++; }, 1000); } </code></pre> <p>I expect when time it gets to 5, javascript will exit the loop and execute the next action</p>
0debug
How do I order fields of my Row objects in Spark (Python) : <p>I'm creating Row objects in Spark. I do not want my fields to be ordered alphabetically. However, if I do the following they are ordered alphabetically.</p> <pre><code>row = Row(foo=1, bar=2) </code></pre> <p>Then it creates an object like the following:</p> <pre><code>Row(bar=2, foo=1) </code></pre> <p>When I then create a dataframe on this object, the column order is going to be bar first, foo second, when I'd prefer to have it the other way around.</p> <p>I know I can use "_1" and "_2" (for "foo" and "bar", respectively) and then assign a schema (with appropriate "foo" and "bar" names). But is there any way to prevent the Row object from ordering them?</p>
0debug
MYSQL Left Join month count from two tables : <p>I want to add columns that represent month base counts from other table.</p> <p>I have 2 tables.</p> <p><b>Leave application</b></p> <pre><code>leaveid Userid 1 3 2 4 3 5 4 1 </code></pre> <p><b>Leave Dates</b></p> <pre><code>dateid leaveid leavedates 1 1 2015-10-06 2 1 2015-10-07 3 2 2015-11-01 4 2 2015-11-02 5 3 2015-01-01 6 4 2015-02-12 </code></pre> <p>I want to end up with total leave count based on months:</p> <pre><code>userid january fabruary march so on... 1 1 3 1 2 2 0 1 2 3 4 1 </code></pre>
0debug
Stubbing window.location.href with Sinon : <p>I am trying to test some client-side code and for that I need to stub the value of <code>window.location.href</code> property using Mocha/Sinon.</p> <p>What I have tried so far (<a href="https://gist.github.com/jouni-kantola/8761980" rel="noreferrer">using this example</a>):</p> <pre><code>describe('Logger', () =&gt; { it('should compose a Log', () =&gt; { var stub = sinon.stub(window.location, 'href', 'http://www.foo.com'); }); }); </code></pre> <p>The runner displays the following error:</p> <blockquote> <p>TypeError: Custom stub should be a function or a property descriptor</p> </blockquote> <p>Changing the test code to: </p> <pre><code>describe('Logger', () =&gt; { it('should compose a Log', () =&gt; { var stub = sinon.stub(window.location, 'href', { value: 'foo' }); }); }); </code></pre> <p>Which yields this error:</p> <blockquote> <p>TypeError: Attempted to wrap string property href as function</p> </blockquote> <p>Passing a function as third argument to <code>sinon.stub</code> doesn't work either.</p> <p>Is there a way to provide a fake <code>window.location.href</code> string, also avoiding redirection (since I'm testing in the browser)?</p>
0debug
Where to put utility functions in a React-Redux application? : <p>In a React-Redux application, I've got a state like this:</p> <pre><code>state = { items: [ { id: 1, first_name: "John", last_name: "Smith", country: "us" }, { id: 2, first_name: "Jinping", last_name: "Xi", country: "cn" }, ] } </code></pre> <p>which I render using a React component.</p> <p>Now I need a function that gives me the "full name" of a person. So it's not just "first_name + last_name" but it depends on the country (for example, it would be "last_name + first_name" in China), so there's some relatively complex logic, which I would like to wrap in a function usable from any React component.</p> <p>In OOP I would create a <code>Person::getFullName()</code> method that would give me this information. However the <code>state</code> object is a "dumb" one where sub-objects don't have any specialized methods.</p> <p>So what is the recommended way to manage this in React-Redux in general? All I can think of is create a global function such as <code>user_getFullName(user)</code> which would take a user and return the full name, but that's not very elegant. Any suggestion?</p>
0debug
def find_Average_Of_Cube(n): sum = 0 for i in range(1, n + 1): sum += i * i * i return round(sum / n, 6)
0debug
Vagrant on mac can't chmod -r 777 . for folders : Using Vagrant on mac with virtual box I try to `sudo chmod -r 777 .' in /vagrant folder, or in the folder project in mac terminal, but in both cases only the files in the sub folders chmod but the folder doesn't chmod. This cause my code to fail with `permission denied` because it cannot write to any folder. If I go to a specific folder and do `sudo chmod 777 <folder name>' than it is working ok, but I have too many folders to do it manually. Please help
0debug
Has Spring-boot changed the way auto-increment of ids works through @GeneratedValue? : <p>Spring-Boot <strong>2.0.0</strong> seems to have modified the way <strong>Hibernate</strong> is auto configured. </p> <p>Let's suppose two simple and independent JPA entities:</p> <pre><code>@Entity class Car { @Id @GeneratedValue private long id; //.... } @Entity class Airplane { @Id @GeneratedValue private long id; //.... } </code></pre> <p>Prior, using Spring-Boot <strong>1.5.10</strong>, I was able to generate separate sequences of auto-increments, meaning that I can get a <code>Car</code> with <strong>1</strong> as primary key and an <code>Airplane</code> with <strong>1</strong> as primary key too. No correlation between them, e.g no shared sequence. </p> <p>Now, with <strong>2.0.0</strong>, when I sequentially create a very first <code>Car</code> then a very first <code>Airplane</code>, the car gets <strong>1</strong> as id and airplane gets <strong>2</strong>. </p> <p>It seems that he has to deal with the <code>GeneratedType.AUTO</code>, that is the "used by default" specified within the <code>@GeneratedValue</code> annotation source.<br> However, my reasoning seems to stop here since <code>GeneratedType.AUTO</code> was also set as default with the <strong>1.5.10</strong>.</p> <p>A simple workaround to fulfil my expectation is to specify the <code>IDENTITY</code> strategy type of generation like so: </p> <pre><code>@Entity class Car { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; //.... } @Entity class Airplane { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private long id; //.... } </code></pre> <p>I can't figure out an explanation of this behavior. </p> <p>What has Spring-boot <strong>2.0.0</strong> changed, explaining this scenario?</p>
0debug
C dynamicall array of pointers with template problem : How to dynamically create an array with this class (this is Teensy Step library for arduino): class StepControl : IPitHandler, IDelayHandler { public: ... StepControl(); template<size_t N> void move(Stepper* (&motors)[N], float relSpeed = 1); ... and then this is usage of this class **that works 100%** but is static: Stepper J1(0, 1), J2(2, 3), J3(4, 5), J4(6, 7), J5(8, 9), J6(10, 11); StepControl <> controller; Stepper *robot[] = {&J1,&J2,&J3,&J4,&J5,&J6}; controller.move(robot); I want to do sth like this but create array dynamically: Stepper J1(0, 1), J2(2, 3), J3(4, 5), J4(6, 7), J5(8, 9), J6(10, 11); StepControl <> controller; int j = 4 Stepper *robot[j]; robot[0]=&J1; robot[1]=&J2; robot[2]=&J2; robot[3]=&J2; controller.move(robot); result: error: no matching function for call to 'StepControl<>::move(Stepper* [j])' How to do this?
0debug
Can't find app in Play Store by name : <p>I've published an app in Play Store week ago and there is a problem with search. I can't find it by searching my app by name in app list with same names, only if I type developer name, I can find it. How I can fix this? Thanks for answers.</p>
0debug
display image and text using division tag rowspan in html : <p>I want to achieve the below format which i could easily do it using TD tags.</p> <p>But if i have to make use of only div tags(rowspan) how is that possible. Below is the format. <a href="https://i.stack.imgur.com/DK8zu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DK8zu.png" alt="enter image description here"></a></p>
0debug
static int decode_bdlt(uint8_t *frame, int width, int height, const uint8_t *src, const uint8_t *src_end) { const uint8_t *frame_end = frame + width * height; uint8_t *line_ptr; int count, lines, segments; count = bytestream_get_le16(&src); if (count >= height || width * count < 0) return -1; frame += width * count; lines = bytestream_get_le16(&src); if (frame + lines * width > frame_end || src >= src_end) return -1; while (lines--) { line_ptr = frame; frame += width; segments = *src++; while (segments--) { if (src_end - src < 3) return -1; line_ptr += *src++; if (line_ptr >= frame) return -1; count = (int8_t)*src++; if (count >= 0) { if (line_ptr + count > frame || src_end - src < count) return -1; bytestream_get_buffer(&src, line_ptr, count); } else { count = -count; if (line_ptr + count > frame || src >= src_end) return -1; memset(line_ptr, *src++, count); } line_ptr += count; } } return 0; }
1threat
def find_equal_tuple(Input, k): flag = 1 for tuple in Input: if len(tuple) != k: flag = 0 break return flag def get_equal(Input, k): if find_equal_tuple(Input, k) == 1: return ("All tuples have same length") else: return ("All tuples do not have same length")
0debug
Java; Txt file of single integer on each line, how can I single out each integer to use in my program? : <p>I have a txt file, each line has a single integer. I need to make a class that singles out each one, so I can then put them in an array in a different class.</p> <p>I understand that it may be weird to want each single integer but I need it this way for my program.</p> <p>Any help would be greatly appreciated.</p>
0debug
static void gen_compute_branch(DisasContext *ctx, uint32_t opc, int r1, int r2 , int32_t constant , int32_t offset) { TCGv temp, temp2; int n; switch (opc) { case OPC1_16_SB_J: case OPC1_32_B_J: gen_goto_tb(ctx, 0, ctx->pc + offset * 2); break; case OPC1_32_B_CALL: case OPC1_16_SB_CALL: gen_helper_1arg(call, ctx->next_pc); gen_goto_tb(ctx, 0, ctx->pc + offset * 2); break; case OPC1_16_SB_JZ: gen_branch_condi(ctx, TCG_COND_EQ, cpu_gpr_d[15], 0, offset); break; case OPC1_16_SB_JNZ: gen_branch_condi(ctx, TCG_COND_NE, cpu_gpr_d[15], 0, offset); break; case OPC1_16_SBC_JEQ: gen_branch_condi(ctx, TCG_COND_EQ, cpu_gpr_d[15], constant, offset); break; case OPC1_16_SBC_JNE: gen_branch_condi(ctx, TCG_COND_NE, cpu_gpr_d[15], constant, offset); break; case OPC1_16_SBRN_JZ_T: temp = tcg_temp_new(); tcg_gen_andi_tl(temp, cpu_gpr_d[15], 0x1u << constant); gen_branch_condi(ctx, TCG_COND_EQ, temp, 0, offset); tcg_temp_free(temp); break; case OPC1_16_SBRN_JNZ_T: temp = tcg_temp_new(); tcg_gen_andi_tl(temp, cpu_gpr_d[15], 0x1u << constant); gen_branch_condi(ctx, TCG_COND_NE, temp, 0, offset); tcg_temp_free(temp); break; case OPC1_16_SBR_JEQ: gen_branch_cond(ctx, TCG_COND_EQ, cpu_gpr_d[r1], cpu_gpr_d[15], offset); break; case OPC1_16_SBR_JNE: gen_branch_cond(ctx, TCG_COND_NE, cpu_gpr_d[r1], cpu_gpr_d[15], offset); break; case OPC1_16_SBR_JNZ: gen_branch_condi(ctx, TCG_COND_NE, cpu_gpr_d[r1], 0, offset); break; case OPC1_16_SBR_JNZ_A: gen_branch_condi(ctx, TCG_COND_NE, cpu_gpr_a[r1], 0, offset); break; case OPC1_16_SBR_JGEZ: gen_branch_condi(ctx, TCG_COND_GE, cpu_gpr_d[r1], 0, offset); break; case OPC1_16_SBR_JGTZ: gen_branch_condi(ctx, TCG_COND_GT, cpu_gpr_d[r1], 0, offset); break; case OPC1_16_SBR_JLEZ: gen_branch_condi(ctx, TCG_COND_LE, cpu_gpr_d[r1], 0, offset); break; case OPC1_16_SBR_JLTZ: gen_branch_condi(ctx, TCG_COND_LT, cpu_gpr_d[r1], 0, offset); break; case OPC1_16_SBR_JZ: gen_branch_condi(ctx, TCG_COND_EQ, cpu_gpr_d[r1], 0, offset); break; case OPC1_16_SBR_JZ_A: gen_branch_condi(ctx, TCG_COND_EQ, cpu_gpr_a[r1], 0, offset); break; case OPC1_16_SBR_LOOP: gen_loop(ctx, r1, offset * 2 - 32); break; case OPC1_16_SR_JI: tcg_gen_andi_tl(cpu_PC, cpu_gpr_a[r1], 0xfffffffe); tcg_gen_exit_tb(0); break; case OPC2_32_SYS_RET: case OPC2_16_SR_RET: gen_helper_ret(cpu_env); tcg_gen_exit_tb(0); break; case OPC1_32_B_CALLA: gen_helper_1arg(call, ctx->next_pc); gen_goto_tb(ctx, 0, EA_B_ABSOLUT(offset)); break; case OPC1_32_B_FCALL: gen_fcall_save_ctx(ctx); gen_goto_tb(ctx, 0, ctx->pc + offset * 2); break; case OPC1_32_B_FCALLA: gen_fcall_save_ctx(ctx); gen_goto_tb(ctx, 0, EA_B_ABSOLUT(offset)); break; case OPC1_32_B_JLA: tcg_gen_movi_tl(cpu_gpr_a[11], ctx->next_pc); case OPC1_32_B_JA: gen_goto_tb(ctx, 0, EA_B_ABSOLUT(offset)); break; case OPC1_32_B_JL: tcg_gen_movi_tl(cpu_gpr_a[11], ctx->next_pc); gen_goto_tb(ctx, 0, ctx->pc + offset * 2); break; case OPCM_32_BRC_EQ_NEQ: if (MASK_OP_BRC_OP2(ctx->opcode) == OPC2_32_BRC_JEQ) { gen_branch_condi(ctx, TCG_COND_EQ, cpu_gpr_d[r1], constant, offset); } else { gen_branch_condi(ctx, TCG_COND_NE, cpu_gpr_d[r1], constant, offset); } break; case OPCM_32_BRC_GE: if (MASK_OP_BRC_OP2(ctx->opcode) == OP2_32_BRC_JGE) { gen_branch_condi(ctx, TCG_COND_GE, cpu_gpr_d[r1], constant, offset); } else { constant = MASK_OP_BRC_CONST4(ctx->opcode); gen_branch_condi(ctx, TCG_COND_GEU, cpu_gpr_d[r1], constant, offset); } break; case OPCM_32_BRC_JLT: if (MASK_OP_BRC_OP2(ctx->opcode) == OPC2_32_BRC_JLT) { gen_branch_condi(ctx, TCG_COND_LT, cpu_gpr_d[r1], constant, offset); } else { constant = MASK_OP_BRC_CONST4(ctx->opcode); gen_branch_condi(ctx, TCG_COND_LTU, cpu_gpr_d[r1], constant, offset); } break; case OPCM_32_BRC_JNE: temp = tcg_temp_new(); if (MASK_OP_BRC_OP2(ctx->opcode) == OPC2_32_BRC_JNED) { tcg_gen_mov_tl(temp, cpu_gpr_d[r1]); tcg_gen_subi_tl(cpu_gpr_d[r1], cpu_gpr_d[r1], 1); gen_branch_condi(ctx, TCG_COND_NE, temp, constant, offset); } else { tcg_gen_mov_tl(temp, cpu_gpr_d[r1]); tcg_gen_addi_tl(cpu_gpr_d[r1], cpu_gpr_d[r1], 1); gen_branch_condi(ctx, TCG_COND_NE, temp, constant, offset); } tcg_temp_free(temp); break; case OPCM_32_BRN_JTT: n = MASK_OP_BRN_N(ctx->opcode); temp = tcg_temp_new(); tcg_gen_andi_tl(temp, cpu_gpr_d[r1], (1 << n)); if (MASK_OP_BRN_OP2(ctx->opcode) == OPC2_32_BRN_JNZ_T) { gen_branch_condi(ctx, TCG_COND_NE, temp, 0, offset); } else { gen_branch_condi(ctx, TCG_COND_EQ, temp, 0, offset); } tcg_temp_free(temp); break; case OPCM_32_BRR_EQ_NEQ: if (MASK_OP_BRR_OP2(ctx->opcode) == OPC2_32_BRR_JEQ) { gen_branch_cond(ctx, TCG_COND_EQ, cpu_gpr_d[r1], cpu_gpr_d[r2], offset); } else { gen_branch_cond(ctx, TCG_COND_NE, cpu_gpr_d[r1], cpu_gpr_d[r2], offset); } break; case OPCM_32_BRR_ADDR_EQ_NEQ: if (MASK_OP_BRR_OP2(ctx->opcode) == OPC2_32_BRR_JEQ_A) { gen_branch_cond(ctx, TCG_COND_EQ, cpu_gpr_a[r1], cpu_gpr_a[r2], offset); } else { gen_branch_cond(ctx, TCG_COND_NE, cpu_gpr_a[r1], cpu_gpr_a[r2], offset); } break; case OPCM_32_BRR_GE: if (MASK_OP_BRR_OP2(ctx->opcode) == OPC2_32_BRR_JGE) { gen_branch_cond(ctx, TCG_COND_GE, cpu_gpr_d[r1], cpu_gpr_d[r2], offset); } else { gen_branch_cond(ctx, TCG_COND_GEU, cpu_gpr_d[r1], cpu_gpr_d[r2], offset); } break; case OPCM_32_BRR_JLT: if (MASK_OP_BRR_OP2(ctx->opcode) == OPC2_32_BRR_JLT) { gen_branch_cond(ctx, TCG_COND_LT, cpu_gpr_d[r1], cpu_gpr_d[r2], offset); } else { gen_branch_cond(ctx, TCG_COND_LTU, cpu_gpr_d[r1], cpu_gpr_d[r2], offset); } break; case OPCM_32_BRR_LOOP: if (MASK_OP_BRR_OP2(ctx->opcode) == OPC2_32_BRR_LOOP) { gen_loop(ctx, r2, offset * 2); } else { gen_goto_tb(ctx, 0, ctx->pc + offset * 2); } break; case OPCM_32_BRR_JNE: temp = tcg_temp_new(); temp2 = tcg_temp_new(); if (MASK_OP_BRC_OP2(ctx->opcode) == OPC2_32_BRR_JNED) { tcg_gen_mov_tl(temp, cpu_gpr_d[r1]); tcg_gen_mov_tl(temp2, cpu_gpr_d[r2]); tcg_gen_subi_tl(cpu_gpr_d[r1], cpu_gpr_d[r1], 1); gen_branch_cond(ctx, TCG_COND_NE, temp, temp2, offset); } else { tcg_gen_mov_tl(temp, cpu_gpr_d[r1]); tcg_gen_mov_tl(temp2, cpu_gpr_d[r2]); tcg_gen_addi_tl(cpu_gpr_d[r1], cpu_gpr_d[r1], 1); gen_branch_cond(ctx, TCG_COND_NE, temp, temp2, offset); } tcg_temp_free(temp); tcg_temp_free(temp2); break; case OPCM_32_BRR_JNZ: if (MASK_OP_BRR_OP2(ctx->opcode) == OPC2_32_BRR_JNZ_A) { gen_branch_condi(ctx, TCG_COND_NE, cpu_gpr_a[r1], 0, offset); } else { gen_branch_condi(ctx, TCG_COND_EQ, cpu_gpr_a[r1], 0, offset); } break; default: printf("Branch Error at %x\n", ctx->pc); } ctx->bstate = BS_BRANCH; }
1threat
static int vc1_decode_b_mb_intfr(VC1Context *v) { MpegEncContext *s = &v->s; GetBitContext *gb = &s->gb; int i, j; int mb_pos = s->mb_x + s->mb_y * s->mb_stride; int cbp = 0; int mqdiff, mquant; int ttmb = v->ttfrm; int mvsw = 0; int mb_has_coeffs = 1; int dmv_x, dmv_y; int val; int first_block = 1; int dst_idx, off; int skipped, direct, twomv = 0; int block_cbp = 0, pat, block_tt = 0; int idx_mbmode = 0, mvbp; int stride_y, fieldtx; int bmvtype = BMV_TYPE_BACKWARD; int dir, dir2; mquant = v->pq; s->mb_intra = 0; if (v->skip_is_raw) skipped = get_bits1(gb); else skipped = v->s.mbskip_table[mb_pos]; if (!skipped) { idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2); if (ff_vc1_mbmode_intfrp[0][idx_mbmode][0] == MV_PMODE_INTFR_2MV_FIELD) { twomv = 1; v->blk_mv_type[s->block_index[0]] = 1; v->blk_mv_type[s->block_index[1]] = 1; v->blk_mv_type[s->block_index[2]] = 1; v->blk_mv_type[s->block_index[3]] = 1; } else { v->blk_mv_type[s->block_index[0]] = 0; v->blk_mv_type[s->block_index[1]] = 0; v->blk_mv_type[s->block_index[2]] = 0; v->blk_mv_type[s->block_index[3]] = 0; } } if (v->dmb_is_raw) direct = get_bits1(gb); else direct = v->direct_mb_plane[mb_pos]; if (direct) { s->mv[0][0][0] = s->current_picture.motion_val[0][s->block_index[0]][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][0], v->bfraction, 0, s->quarter_sample); s->mv[0][0][1] = s->current_picture.motion_val[0][s->block_index[0]][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][1], v->bfraction, 0, s->quarter_sample); s->mv[1][0][0] = s->current_picture.motion_val[1][s->block_index[0]][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][0], v->bfraction, 1, s->quarter_sample); s->mv[1][0][1] = s->current_picture.motion_val[1][s->block_index[0]][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][1], v->bfraction, 1, s->quarter_sample); if (twomv) { s->mv[0][2][0] = s->current_picture.motion_val[0][s->block_index[2]][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[2]][0], v->bfraction, 0, s->quarter_sample); s->mv[0][2][1] = s->current_picture.motion_val[0][s->block_index[2]][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[2]][1], v->bfraction, 0, s->quarter_sample); s->mv[1][2][0] = s->current_picture.motion_val[1][s->block_index[2]][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[2]][0], v->bfraction, 1, s->quarter_sample); s->mv[1][2][1] = s->current_picture.motion_val[1][s->block_index[2]][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[2]][1], v->bfraction, 1, s->quarter_sample); for (i = 1; i < 4; i += 2) { s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0] = s->mv[0][i-1][0]; s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1] = s->mv[0][i-1][1]; s->mv[1][i][0] = s->current_picture.motion_val[1][s->block_index[i]][0] = s->mv[1][i-1][0]; s->mv[1][i][1] = s->current_picture.motion_val[1][s->block_index[i]][1] = s->mv[1][i-1][1]; } } else { for (i = 1; i < 4; i++) { s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0] = s->mv[0][0][0]; s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1] = s->mv[0][0][1]; s->mv[1][i][0] = s->current_picture.motion_val[1][s->block_index[i]][0] = s->mv[1][0][0]; s->mv[1][i][1] = s->current_picture.motion_val[1][s->block_index[i]][1] = s->mv[1][0][1]; } } } if (ff_vc1_mbmode_intfrp[0][idx_mbmode][0] == MV_PMODE_INTFR_INTRA) { for (i = 0; i < 4; i++) { s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0] = 0; s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1] = 0; s->mv[1][i][0] = s->current_picture.motion_val[1][s->block_index[i]][0] = 0; s->mv[1][i][1] = s->current_picture.motion_val[1][s->block_index[i]][1] = 0; } s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA; s->mb_intra = v->is_intra[s->mb_x] = 1; for (i = 0; i < 6; i++) v->mb_type[0][s->block_index[i]] = 1; fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb); mb_has_coeffs = get_bits1(gb); if (mb_has_coeffs) cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb); GET_MQUANT(); s->current_picture.qscale_table[mb_pos] = mquant; s->y_dc_scale = s->y_dc_scale_table[mquant]; s->c_dc_scale = s->c_dc_scale_table[mquant]; dst_idx = 0; for (i = 0; i < 6; i++) { s->dc_val[0][s->block_index[i]] = 0; dst_idx += i >> 2; val = ((cbp >> (5 - i)) & 1); v->mb_type[0][s->block_index[i]] = s->mb_intra; v->a_avail = v->c_avail = 0; if (i == 2 || i == 3 || !s->first_slice_line) v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]]; if (i == 1 || i == 3 || s->mb_x) v->c_avail = v->mb_type[0][s->block_index[i] - 1]; vc1_decode_intra_block(v, s->block[i], i, val, mquant, (i & 4) ? v->codingset2 : v->codingset); if (i > 3 && (s->flags & CODEC_FLAG_GRAY)) continue; v->vc1dsp.vc1_inv_trans_8x8(s->block[i]); if (i < 4) { stride_y = s->linesize << fieldtx; off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->linesize : (i & 1) * 8 + 4 * (i & 2) * s->linesize; } else { stride_y = s->uvlinesize; off = 0; } s->idsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, stride_y); } } else { s->mb_intra = v->is_intra[s->mb_x] = 0; if (!direct) { if (skipped || !s->mb_intra) { bmvtype = decode012(gb); switch (bmvtype) { case 0: bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_BACKWARD : BMV_TYPE_FORWARD; break; case 1: bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_FORWARD : BMV_TYPE_BACKWARD; break; case 2: bmvtype = BMV_TYPE_INTERPOLATED; } } if (twomv && bmvtype != BMV_TYPE_INTERPOLATED) mvsw = get_bits1(gb); } if (!skipped) { mb_has_coeffs = ff_vc1_mbmode_intfrp[0][idx_mbmode][3]; if (mb_has_coeffs) cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2); if (!direct) { if (bmvtype == BMV_TYPE_INTERPOLATED && twomv) { v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1); } else if (bmvtype == BMV_TYPE_INTERPOLATED || twomv) { v->twomvbp = get_vlc2(gb, v->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1); } } for (i = 0; i < 6; i++) v->mb_type[0][s->block_index[i]] = 0; fieldtx = v->fieldtx_plane[mb_pos] = ff_vc1_mbmode_intfrp[0][idx_mbmode][1]; dst_idx = 0; if (direct) { if (twomv) { for (i = 0; i < 4; i++) { ff_vc1_mc_4mv_luma(v, i, 0, 0); ff_vc1_mc_4mv_luma(v, i, 1, 1); } ff_vc1_mc_4mv_chroma4(v, 0, 0, 0); ff_vc1_mc_4mv_chroma4(v, 1, 1, 1); } else { ff_vc1_mc_1mv(v, 0); ff_vc1_interp_mc(v); } } else if (twomv && bmvtype == BMV_TYPE_INTERPOLATED) { mvbp = v->fourmvbp; for (i = 0; i < 4; i++) { dir = i==1 || i==3; dmv_x = dmv_y = 0; val = ((mvbp >> (3 - i)) & 1); if (val) get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0); j = i > 1 ? 2 : 0; ff_vc1_pred_mv_intfr(v, j, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0], dir); ff_vc1_mc_4mv_luma(v, j, dir, dir); ff_vc1_mc_4mv_luma(v, j+1, dir, dir); } ff_vc1_mc_4mv_chroma4(v, 0, 0, 0); ff_vc1_mc_4mv_chroma4(v, 1, 1, 1); } else if (bmvtype == BMV_TYPE_INTERPOLATED) { mvbp = v->twomvbp; dmv_x = dmv_y = 0; if (mvbp & 2) get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0); ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], 0); ff_vc1_mc_1mv(v, 0); dmv_x = dmv_y = 0; if (mvbp & 1) get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0); ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], 1); ff_vc1_interp_mc(v); } else if (twomv) { dir = bmvtype == BMV_TYPE_BACKWARD; dir2 = dir; if (mvsw) dir2 = !dir; mvbp = v->twomvbp; dmv_x = dmv_y = 0; if (mvbp & 2) get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0); ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0], dir); dmv_x = dmv_y = 0; if (mvbp & 1) get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0); ff_vc1_pred_mv_intfr(v, 2, dmv_x, dmv_y, 2, v->range_x, v->range_y, v->mb_type[0], dir2); if (mvsw) { for (i = 0; i < 2; i++) { s->mv[dir][i+2][0] = s->mv[dir][i][0] = s->current_picture.motion_val[dir][s->block_index[i+2]][0] = s->current_picture.motion_val[dir][s->block_index[i]][0]; s->mv[dir][i+2][1] = s->mv[dir][i][1] = s->current_picture.motion_val[dir][s->block_index[i+2]][1] = s->current_picture.motion_val[dir][s->block_index[i]][1]; s->mv[dir2][i+2][0] = s->mv[dir2][i][0] = s->current_picture.motion_val[dir2][s->block_index[i]][0] = s->current_picture.motion_val[dir2][s->block_index[i+2]][0]; s->mv[dir2][i+2][1] = s->mv[dir2][i][1] = s->current_picture.motion_val[dir2][s->block_index[i]][1] = s->current_picture.motion_val[dir2][s->block_index[i+2]][1]; } } else { ff_vc1_pred_mv_intfr(v, 0, 0, 0, 2, v->range_x, v->range_y, v->mb_type[0], !dir); ff_vc1_pred_mv_intfr(v, 2, 0, 0, 2, v->range_x, v->range_y, v->mb_type[0], !dir); } ff_vc1_mc_4mv_luma(v, 0, dir, 0); ff_vc1_mc_4mv_luma(v, 1, dir, 0); ff_vc1_mc_4mv_luma(v, 2, dir2, 0); ff_vc1_mc_4mv_luma(v, 3, dir2, 0); ff_vc1_mc_4mv_chroma4(v, dir, dir2, 0); } else { dir = bmvtype == BMV_TYPE_BACKWARD; mvbp = ff_vc1_mbmode_intfrp[0][idx_mbmode][2]; dmv_x = dmv_y = 0; if (mvbp) get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0); ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], dir); v->blk_mv_type[s->block_index[0]] = 1; v->blk_mv_type[s->block_index[1]] = 1; v->blk_mv_type[s->block_index[2]] = 1; v->blk_mv_type[s->block_index[3]] = 1; ff_vc1_pred_mv_intfr(v, 0, 0, 0, 2, v->range_x, v->range_y, 0, !dir); for (i = 0; i < 2; i++) { s->mv[!dir][i+2][0] = s->mv[!dir][i][0] = s->current_picture.motion_val[!dir][s->block_index[i+2]][0] = s->current_picture.motion_val[!dir][s->block_index[i]][0]; s->mv[!dir][i+2][1] = s->mv[!dir][i][1] = s->current_picture.motion_val[!dir][s->block_index[i+2]][1] = s->current_picture.motion_val[!dir][s->block_index[i]][1]; } ff_vc1_mc_1mv(v, dir); } if (cbp) GET_MQUANT(); s->current_picture.qscale_table[mb_pos] = mquant; if (!v->ttmbf && cbp) ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2); for (i = 0; i < 6; i++) { s->dc_val[0][s->block_index[i]] = 0; dst_idx += i >> 2; val = ((cbp >> (5 - i)) & 1); if (!fieldtx) off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize); else off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->linesize)); if (val) { pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : (s->linesize << fieldtx), (i & 4) && (s->flags & CODEC_FLAG_GRAY), &block_tt); block_cbp |= pat << (i << 2); if (!v->ttmbf && ttmb < 8) ttmb = -1; first_block = 0; } } } else { dir = 0; for (i = 0; i < 6; i++) { v->mb_type[0][s->block_index[i]] = 0; s->dc_val[0][s->block_index[i]] = 0; } s->current_picture.mb_type[mb_pos] = MB_TYPE_SKIP; s->current_picture.qscale_table[mb_pos] = 0; v->blk_mv_type[s->block_index[0]] = 0; v->blk_mv_type[s->block_index[1]] = 0; v->blk_mv_type[s->block_index[2]] = 0; v->blk_mv_type[s->block_index[3]] = 0; if (!direct) { if (bmvtype == BMV_TYPE_INTERPOLATED) { ff_vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0], 0); ff_vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0], 1); } else { dir = bmvtype == BMV_TYPE_BACKWARD; ff_vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0], dir); if (mvsw) { int dir2 = dir; if (mvsw) dir2 = !dir; for (i = 0; i < 2; i++) { s->mv[dir][i+2][0] = s->mv[dir][i][0] = s->current_picture.motion_val[dir][s->block_index[i+2]][0] = s->current_picture.motion_val[dir][s->block_index[i]][0]; s->mv[dir][i+2][1] = s->mv[dir][i][1] = s->current_picture.motion_val[dir][s->block_index[i+2]][1] = s->current_picture.motion_val[dir][s->block_index[i]][1]; s->mv[dir2][i+2][0] = s->mv[dir2][i][0] = s->current_picture.motion_val[dir2][s->block_index[i]][0] = s->current_picture.motion_val[dir2][s->block_index[i+2]][0]; s->mv[dir2][i+2][1] = s->mv[dir2][i][1] = s->current_picture.motion_val[dir2][s->block_index[i]][1] = s->current_picture.motion_val[dir2][s->block_index[i+2]][1]; } } else { v->blk_mv_type[s->block_index[0]] = 1; v->blk_mv_type[s->block_index[1]] = 1; v->blk_mv_type[s->block_index[2]] = 1; v->blk_mv_type[s->block_index[3]] = 1; ff_vc1_pred_mv_intfr(v, 0, 0, 0, 2, v->range_x, v->range_y, 0, !dir); for (i = 0; i < 2; i++) { s->mv[!dir][i+2][0] = s->mv[!dir][i][0] = s->current_picture.motion_val[!dir][s->block_index[i+2]][0] = s->current_picture.motion_val[!dir][s->block_index[i]][0]; s->mv[!dir][i+2][1] = s->mv[!dir][i][1] = s->current_picture.motion_val[!dir][s->block_index[i+2]][1] = s->current_picture.motion_val[!dir][s->block_index[i]][1]; } } } } ff_vc1_mc_1mv(v, dir); if (direct || bmvtype == BMV_TYPE_INTERPOLATED) { ff_vc1_interp_mc(v); } } } if (s->mb_x == s->mb_width - 1) memmove(v->is_intra_base, v->is_intra, sizeof(v->is_intra_base[0]) * s->mb_stride); v->cbp[s->mb_x] = block_cbp; v->ttblk[s->mb_x] = block_tt; return 0; }
1threat
static void kvm_ioapic_class_init(ObjectClass *klass, void *data) { IOAPICCommonClass *k = IOAPIC_COMMON_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass); k->realize = kvm_ioapic_realize; k->pre_save = kvm_ioapic_get; k->post_load = kvm_ioapic_put; dc->reset = kvm_ioapic_reset; dc->props = kvm_ioapic_properties; }
1threat
Cant sorting when use group by : I Have two table : 1- Products (id, product_name, option) 2- Prices (id, name, price, shop, available) Each product can have several prices that each shop enters. I want select products and sort them by price low to high But this code not work correctly : Select product_name, Prices.price FROM Products LEFT JOIN Prices ON Prices.name=Products.product_name AND Prices.available="yes" GROUP BY product_name ORDER BY Prices.price LIMIT 0,10 The above code at first Group products by name then sort them price And its my problem. **I dont want to show one product a few times** Is there any solution?
0debug
static int probe(AVProbeData *p) { if (p->buf_size < 13) return 0; if (p->buf[0] == 0x01 && p->buf[1] == 0x00 && p->buf[4] == 0x01 + p->buf[2] && p->buf[8] == p->buf[4] + p->buf[6] && p->buf[12] == p->buf[8] + p->buf[10]) return AVPROBE_SCORE_MAX; return 0; }
1threat
How to check if a string contains any of the characters of another string : <p>I'm trying to check if the name in an email is valid, which means it doesn't contain any of the following characters</p> <pre><code>*$£%ù^¨&amp;é"'()°-è_çà§æ«€¶ŧ←↓→øþ¨¤@ßðđŋħłµł»¢“ </code></pre>
0debug
Can I inject dependency into migration (using EF-Core code-first migrations)? : <p>I tried to inject <code>IConfiguration</code> into the migration (in constructor), and got exception: "No parameterless constructor defined for this object."</p> <p>any workaround?</p>
0debug
void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque) { struct capture_callback *cb; for (cb = cap->cb_head.lh_first; cb; cb = cb->entries.le_next) { if (cb->opaque == cb_opaque) { cb->ops.destroy (cb_opaque); LIST_REMOVE (cb, entries); qemu_free (cb); if (!cap->cb_head.lh_first) { SWVoiceOut *sw = cap->hw.sw_head.lh_first, *sw1; while (sw) { SWVoiceCap *sc = (SWVoiceCap *) sw; #ifdef DEBUG_CAPTURE dolog ("freeing %s\n", sw->name); #endif sw1 = sw->entries.le_next; if (sw->rate) { st_rate_stop (sw->rate); sw->rate = NULL; } LIST_REMOVE (sw, entries); LIST_REMOVE (sc, entries); qemu_free (sc); sw = sw1; } LIST_REMOVE (cap, entries); qemu_free (cap); } return; } } }
1threat
linked list syntax in C : <p>I am trying to understand the syntax of linked lists by visualising it through diagrams. However I am getting confused. This code prints out 0-9. I don't understand the commented bits, please explain visually.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; struct node { int item; struct node* link; }; int main() { struct node *start,*list; int i; start = (struct node *)malloc(sizeof(struct node)); //??????? list = start; // ???????? start-&gt;link = NULL; // ?????????? for(i=0;i&lt;10;i++) { list-&gt;item = i; list-&gt;link = (struct node *)malloc(sizeof(struct node)); list = list-&gt;link; } list-&gt;link = NULL; //???????????? while(start != NULL) //?????????????? { printf("%d\n",start-&gt;item); start = start-&gt;link; } return 0; } </code></pre>
0debug