problem
stringlengths
26
131k
labels
class label
2 classes
void qemu_start_warp_timer(void) { int64_t clock; int64_t deadline; if (!use_icount) { return; } if (!runstate_is_running()) { return; } if (!replay_checkpoint(CHECKPOINT_CLOCK_WARP_START)) { return; } if (!all_cpu_threads_idle()) { return; } if (qtest_enabled()) { return; } clock = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL_RT); deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); if (deadline < 0) { static bool notified; if (!icount_sleep && !notified) { error_report("WARNING: icount sleep disabled and no active timers"); notified = true; } return; } if (deadline > 0) { if (!icount_sleep) { seqlock_write_begin(&timers_state.vm_clock_seqlock); timers_state.qemu_icount_bias += deadline; seqlock_write_end(&timers_state.vm_clock_seqlock); qemu_clock_notify(QEMU_CLOCK_VIRTUAL); } else { seqlock_write_begin(&timers_state.vm_clock_seqlock); if (vm_clock_warp_start == -1 || vm_clock_warp_start > clock) { vm_clock_warp_start = clock; } seqlock_write_end(&timers_state.vm_clock_seqlock); timer_mod_anticipate(icount_warp_timer, clock + deadline); } } else if (deadline == 0) { qemu_clock_notify(QEMU_CLOCK_VIRTUAL); } }
1threat
Facebook poll based on images : <p>I wish to submit couple of images to Facebook using my app and invite my friends to vote on it for a specific time interval. My question is -</p> <ol> <li>Does graphAPI support this.</li> <li>Can I integrate this with my backend system so that I can get the count of likes/dislikes against each image.</li> </ol> <p>Would appreciate support on this. </p>
0debug
Error: ggplot2 doesn't know how to deal with data of class uneval : <p>Pretty new to R. Trying to create a bar graph using ggplot2 to compare the type of 2016 primary election and Bernie Sanders's respective percentage of votes in that election.</p> <p>I have:</p> <pre><code>y = $ Type : Factor w/ 2 levels "Caucus","Primary": 1 2 2 1 2 2 1 2 2 1 ... and x = $ SandersPercent : num 0.274 0.69 0.198 0.797 0.409 ... </code></pre> <p>I run:</p> <pre><code>geom_bar(Primary2016, aes(SandersPercent, Type)) </code></pre> <p>and get: </p> <pre><code>Error: ggplot2 doesn't know how to deal with data of class uneval </code></pre> <p>Sorry for such a dumb question. I've tried searching around and for some reason am stuck.</p>
0debug
Remove element from list using linq : <p>I have and object of type ct_CompleteOrder and have following classes:</p> <p><strong>ct_CompleteOrder class</strong></p> <pre><code>public partial class ct_CompleteOrder { private ct_CompleteOrderPayments paymentsField; } </code></pre> <p><strong>ct_CompleteOrderPayments class</strong></p> <pre><code>public partial class ct_CompleteOrderPayments { private ct_Payment[] paymentField; public ct_Payment[] Payment { get { return this.paymentField; } set { this.paymentField = value; } } } </code></pre> <p><strong>ct_Payment class</strong></p> <pre><code>public partial class ct_Payment { public string type{get; set;} } </code></pre> <p>I want to remove elements of the <code>ct_Payment</code> array on the basis of type value. I tried to convert it into list first to apply RemoveAll, but its not working. what am I doing wrong?</p> <pre><code>completeOrder.Payments.Payment.ToList().RemoveAll(x =&gt; x.type == "AUTO"); </code></pre>
0debug
static inline void RENAME(rgb15ToY)(uint8_t *dst, uint8_t *src, int width) { int i; for(i=0; i<width; i++) { int d= ((uint16_t*)src)[i]; int r= d&0x1F; int g= (d>>5)&0x1F; int b= (d>>10)&0x1F; dst[i]= ((RY*r + GY*g + BY*b)>>(RGB2YUV_SHIFT-3)) + 16; } }
1threat
How to handle popups in puppeteer : <p>how to handle the popup and access the popup to do some operations on it. </p> <pre><code>const puppeteer = require('puppeteer'); async function run() { const browser = await puppeteer.launch(); const page = await browser.newPage(); await page.goto('https://example.com'); await page.click(Launchpopup); } </code></pre>
0debug
Please help me to fix this codeigniter php code because it can not update the data : I have the code like below, but when I update the data, the data is not updated but add new data in the database How can I make updates / edit data and not add new data when saved? Here I use codeigniter version 3.1.8, php version 7.2.4 Please help me to solve this problem, thanks model_anggota.php <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Model_anggota extends CI_model { public function getdata($key){ $this->db->where('nama',$key); $hasil = $this->db->get('tb_anggota'); return $hasil; } public function getupdate($key,$data){ $this->db->where('nama',$key); $this->db->update('tb_anggota',$data); } public function getinsert($data){ $this->db->insert('tb_anggota',$data); } public function getdelete($key){ $this->db->where('nim',$key); $this->db->delete('tb_anggota'); } } data_anggota.php <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Data_anggota extends CI_Controller { public function index() { $this->model_security->getsecurity(); $isi['content'] = 'data_anggota/tampil_dataanggota'; $isi['data'] = $this->db->get('tb_anggota'); $this->load->view('tampilan_home',$isi); } public function tambah(){ $this->model_security->getsecurity(); $isi['content'] = 'data_anggota/form_tambahanggota'; $this->load->view('tampilan_home',$isi); } public function edit(){ $this->model_security->getsecurity(); $isi['content'] = 'data_anggota/form_editanggota'; $key = $this->uri->segment(3); $this->db->where('nim',$key); $query = $this->db->get('tb_anggota'); if($query->num_rows()>0){ foreach ($query->result() as $row) { $isi['nama'] = $row->nama; $isi['nim'] = $row->nim; $isi['jurusan'] = $row->jurusan; $isi['tempat_lahir'] = $row->tempat_lahir; $isi['tanggal_lahir'] = $row->tanggal_lahir; $isi['alamat'] = $row->alamat; $isi['agama'] = $row->agama; $isi['kelamin'] = $row->kelamin; $isi['angkatan'] = $row->angkatan; $isi['status'] = $row->status; } } $this->load->view('tampilan_home',$isi); } public function simpan(){ $this->model_security->getsecurity(); $key = $this->input->post('nim'); $data['nama'] = $this->input->post('nama'); $data['nim'] = $this->input->post('nim'); $data['jurusan'] = $this->input->post('jurusan'); $data['tempat_lahir'] = $this->input->post('tempat_lahir'); $data['tanggal_lahir'] = $this->input->post('tanggal_lahir'); $data['alamat'] = $this->input->post('alamat'); $data['agama'] = $this->input->post('agama'); $data['kelamin'] = $this->input->post('kelamin'); $data['angkatan'] = $this->input->post('angkatan'); $data['status'] = $this->input->post('status'); $this->load->model('model_anggota'); $query = $this->model_anggota->getdata($key); if($query->num_rows()>0){ $this->model_anggota->getupdate($key,$data); $this->session->set_flashdata('info','Data sukses diupdate'); }else{ $this->model_anggota->getinsert($data); $this->session->set_flashdata('info','Data sukses disimpan'); } redirect('data_anggota'); } public function delete(){ $this->model_security->getsecurity(); $this->load->model('model_anggota'); $key = $this->uri->segment(3); $this->db->where('nim',$key); $query = $this->db->get('tb_anggota'); if($query->num_rows()>0){ $this->model_anggota->getdelete($key); $this->session->set_flashdata('info','Data sukses dihapus'); } redirect('data_anggota'); } }
0debug
static int mmu_translate_pte(CPUS390XState *env, target_ulong vaddr, uint64_t asc, uint64_t pt_entry, target_ulong *raddr, int *flags, int rw, bool exc) { if (pt_entry & _PAGE_INVALID) { DPRINTF("%s: PTE=0x%" PRIx64 " invalid\n", __func__, pt_entry); trigger_page_fault(env, vaddr, PGM_PAGE_TRANS, asc, rw, exc); return -1; } if (pt_entry & _PAGE_RO) { *flags &= ~PAGE_WRITE; } *raddr = pt_entry & _ASCE_ORIGIN; PTE_DPRINTF("%s: PTE=0x%" PRIx64 "\n", __func__, pt_entry); return 0; }
1threat
Amazon aws ec2 windows ebs and bandwidth charges : I would like to know how the amazon aws ec2 charge for EBS and the bandwidth for windows and I want to know the how many tomcat web servers and mysql servers can be placed in once ec2 server. Thanks.
0debug
What to use, external calls or COM or smth else? : <p>I have a large amount of C/C++ legacy code. And I want to call it from my C# managed code. There are types and functions in C++. What the best approach here?</p> <p>I found out that COM is the most versatile and appropriate way to do so. But I didn't find any examples with classes. Does it support using C++'s types as .NET classes?</p>
0debug
static void virt_set_gic_version(Object *obj, const char *value, Error **errp) { VirtMachineState *vms = VIRT_MACHINE(obj); if (!strcmp(value, "3")) { vms->gic_version = 3; } else if (!strcmp(value, "2")) { vms->gic_version = 2; } else if (!strcmp(value, "host")) { vms->gic_version = 0; } else { error_report("Invalid gic-version option value"); error_printf("Allowed gic-version values are: 3, 2, host\n"); exit(1); } }
1threat
Create an array of objects and initialize them differently : When creating a array of objects of a class and the number of objects in the array is only determined at runtime, how can I initialize each object in the array differently? For example, `SimpleJob` is a class. I want to create an array of objects of `SimpleJob`, and initialize them differently SimpleJob[] jobs = new SimpleJob[nbJobs]; for (int i = 1; i <= nbJobs; ++i) { jobs[i] = new SimpleJob(i, false); } Is it a good way? Thanks.
0debug
DeviceState *nand_init(BlockBackend *blk, int manf_id, int chip_id) { DeviceState *dev; if (nand_flash_ids[chip_id].size == 0) { hw_error("%s: Unsupported NAND chip ID.\n", __FUNCTION__); } dev = DEVICE(object_new(TYPE_NAND)); qdev_prop_set_uint8(dev, "manufacturer_id", manf_id); qdev_prop_set_uint8(dev, "chip_id", chip_id); if (blk) { qdev_prop_set_drive(dev, "drive", blk, &error_fatal); } qdev_init_nofail(dev); return dev; }
1threat
Send Apple push notification from a Go appengine site : <p>I'm trying to send an Apple push notification from a Go appengine site. I'm using the <a href="https://godoc.org/github.com/sideshow/apns2" rel="noreferrer">apns2 library</a> as follows:</p> <pre><code>cert, err := certificate.FromPemFile(pemFile, "") if err != nil { log.Fatalf("cert error: %v", err) } client := apns2.NewClient(cert).Development() n := &amp;apns2.Notification{...} if res, err := client.Push(n); err != nil { ... } </code></pre> <p>On a local development server, it works fine; but in production I'm seeing:</p> <pre><code>Post https://api.development.push.apple.com/3/device/995aa87050518ca346f7254f3484d7d5c731ee93c35e3c359db9ddf95d035003: dial tcp: lookup api.development.push.apple.com on [::1]:53: dial udp [::1]:53: socket: operation not permitted </code></pre> <p>It looks like appengine expects you to use its own <a href="https://cloud.google.com/appengine/docs/go/outbound-requests" rel="noreferrer">urlfetch library</a> when sending outbound requests, so I tried setting the underlying <code>HTTPClient</code> to use that:</p> <pre><code>client.HTTPClient = urlfetch.Client(ctx) </code></pre> <p>However, the response from the Apple server is now</p> <pre><code>@@?HTTP/2 client preface string missing or corrupt. Hex dump for received bytes: 504f5354202f332f6465766963652f393935616138373035 </code></pre> <p>I believe the problem is that Apple push notifications <a href="https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html" rel="noreferrer">require HTTP/2</a>, but urlfetch only implements HTTP/1.1.</p> <p>How do I solve this problem? Is there a way for an appengine app to send an HTTP/2 request?</p>
0debug
Dynamic Memory allocation to string, gives out incorrect size : <p>I try to dynamically allocate memory to a string but when I print out the size it shows 4 instead of the (11+1) bytes that should be allocated. Why does this happen? The string prints out just fine.</p> <pre><code>#include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; #include&lt;string.h&gt; int main(){ char c, *string; int i=0, a=1; printf("\nEnter the string : "); string = (char *) malloc (sizeof(char)); while(c != '\n'){ c = getchar(); string = (char *) realloc (string, sizeof(char) * a); string[i] = c; a++, i++; } string[i] = '\0'; puts(string); printf("\n%d", sizeof(string)); } Input : Sample Text Output : Sample Text 4 </code></pre>
0debug
static void av_always_inline filter_mb_mbaff_edgecv( H264Context *h, uint8_t *pix, int stride, const int16_t bS[7], int bsi, int qp, int intra ) { const int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8); int index_a = qp - qp_bd_offset + h->slice_alpha_c0_offset; int alpha = alpha_table[index_a]; int beta = beta_table[qp - qp_bd_offset + h->slice_beta_offset]; if (alpha ==0 || beta == 0) return; if( bS[0] < 4 || !intra ) { int8_t tc[4]; tc[0] = tc0_table[index_a][bS[0*bsi]] + 1; tc[1] = tc0_table[index_a][bS[1*bsi]] + 1; tc[2] = tc0_table[index_a][bS[2*bsi]] + 1; tc[3] = tc0_table[index_a][bS[3*bsi]] + 1; h->h264dsp.h264_h_loop_filter_chroma_mbaff(pix, stride, alpha, beta, tc); } else { h->h264dsp.h264_h_loop_filter_chroma_mbaff_intra(pix, stride, alpha, beta); } }
1threat
How to get all the child elements attribute in an array from xdocument : I have xml in the following format <ABC Attr1="1" Attr2="2"> <PQR Attr1="1" Attr2="2" Attr="3"> <XYZ Attr1="1" Attr2="2"></XYZ> <HIJ Attr1="1" Attr2="2"></HIJ> </PQR> </ABC> Now i want to get all the attributes of PQR,XY and HIJ in a single array. Can anyone guide me how to get that?
0debug
def find_first_occurrence(A, x): (left, right) = (0, len(A) - 1) result = -1 while left <= right: mid = (left + right) // 2 if x == A[mid]: result = mid right = mid - 1 elif x < A[mid]: right = mid - 1 else: left = mid + 1 return result
0debug
Pass JSON string via POST to PHP : <p>I have a page that is part of CRUD on which I can edit my data and send it to Update action of my php app. Basically, it is a HTML form with input fields. On this page I'm trying to implement some kind of drag-n-drop list arrangement via jQuery plugin. After sorting elements I create an array by js script that holds my hierarchy and it looks like this:</p> <pre><code>[ { "id": 21, "name": "John" }, [ { "id": 25, "name": "Bill" }, { "id": 20, "name": "Ann" } ], { "id": 18, "name": "Sally" }, { "id": 24, "name": "Tom" } ] </code></pre> <p>Now, how can I pass this array from javascript to my update action via POST with the rest of my form so I can store it in DB in a proper JSON format?</p>
0debug
static av_cold int aacPlus_encode_init(AVCodecContext *avctx) { aacPlusAudioContext *s = avctx->priv_data; aacplusEncConfiguration *aacplus_cfg; if (avctx->channels < 1 || avctx->channels > 2) { av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed\n", avctx->channels); return AVERROR(EINVAL); if (avctx->profile != FF_PROFILE_AAC_LOW && avctx->profile != FF_PROFILE_UNKNOWN) { av_log(avctx, AV_LOG_ERROR, "invalid AAC profile: %d, only LC supported\n", avctx->profile); return AVERROR(EINVAL); s->aacplus_handle = aacplusEncOpen(avctx->sample_rate, avctx->channels, &s->samples_input, &s->max_output_bytes); if (!s->aacplus_handle) { av_log(avctx, AV_LOG_ERROR, "can't open encoder\n"); return AVERROR(EINVAL); aacplus_cfg = aacplusEncGetCurrentConfiguration(s->aacplus_handle); aacplus_cfg->bitRate = avctx->bit_rate; aacplus_cfg->bandWidth = avctx->cutoff; aacplus_cfg->outputFormat = !(avctx->flags & CODEC_FLAG_GLOBAL_HEADER); aacplus_cfg->inputFormat = avctx->sample_fmt == AV_SAMPLE_FMT_FLT ? AACPLUS_INPUT_FLOAT : AACPLUS_INPUT_16BIT; if (!aacplusEncSetConfiguration(s->aacplus_handle, aacplus_cfg)) { av_log(avctx, AV_LOG_ERROR, "libaacplus doesn't support this output format!\n"); return AVERROR(EINVAL); avctx->frame_size = s->samples_input / avctx->channels; avctx->extradata_size = 0; if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { unsigned char *buffer = NULL; unsigned long decoder_specific_info_size; if (aacplusEncGetDecoderSpecificInfo(s->aacplus_handle, &buffer, &decoder_specific_info_size) == 1) { avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE); avctx->extradata_size = decoder_specific_info_size; memcpy(avctx->extradata, buffer, avctx->extradata_size); return 0;
1threat
Is it thread-safe when using tf.Session in inference service? : <p>Now we have used TensorFlow to train and export an model. We can implement the inference service with this model just like how <code>tensorflow/serving</code> does.</p> <p>I have a question about whether the <code>tf.Session</code> object is thread-safe or not. If it's true, we may initialize the object after starting and use the singleton object to process the concurrent requests.</p>
0debug
License status check failure on downladoing android sdk tools from Delphi Seattle : I am getting started with ANdroid developement on Delphi seattle. By following some tutorials i realized that a quick way to setup the android sdk is to create a new multi device app, set android as target platform and build. At this moment the ide asks > Android SDK tools are required. Do you want to download and install > Android SDK tools automatically? on yes a downlaod process starts, after a license confirmation page i get: [![android error][1]][1] Does anyone know how to fix this? [1]: http://i.stack.imgur.com/EZfHX.png
0debug
Python - Check if a string contains multiple words : <p>I'm wondering if there was a function in Python 2.7 that checks to see if a string contains multiple words (as in words with spaces/punctuation marks between them), similar to how <code>.isalpha()</code> checks to see if a string contains only letters?</p> <p>For example, if something along the lines of this exists...</p> <pre><code>var_1 = "Two Words" if var_1.containsmultiplewords(): print "Yes" </code></pre> <p>And then "Yes" would be the output.</p> <p>Thanks!</p>
0debug
Can i access device files using Android NDK? : Can i write to device files (/dev/...) using Android NDK. If yes, to all of them? Which permissions are needed? Unfortunately i found nothing about this case.
0debug
What is the logic of ATM machines? : <p>I am developing some basic applications.But i want to learn about the systems like ATM machines. There is PC in it and it's always running the bank's application and there is no desktop,no main menu,no other things except the choosen application. <br> So what is the OS generally used for this systems? Is it linux? <br> Are they building OS from scracth ? <br> What is the general names of this systems ? Is it "embedded systems"?</p>
0debug
static void gen_tlbsx_40x(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else TCGv t0; if (unlikely(ctx->pr)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } t0 = tcg_temp_new(); gen_addr_reg_index(ctx, t0); gen_helper_4xx_tlbsx(cpu_gpr[rD(ctx->opcode)], cpu_env, t0); tcg_temp_free(t0); if (Rc(ctx->opcode)) { TCGLabel *l1 = gen_new_label(); tcg_gen_trunc_tl_i32(cpu_crf[0], cpu_so); tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_gpr[rD(ctx->opcode)], -1, l1); tcg_gen_ori_i32(cpu_crf[0], cpu_crf[0], 0x02); gen_set_label(l1); } #endif }
1threat
divide 2 raw of table and result in percentage : select count(TotalPrice /paidprice ) from Factors where TotalPrice>=PaidPrice I have 4 factore,3customer paid completely their factor but 1 one them did not paid ,it return 3, but I want return 75%
0debug
void s390_pci_sclp_configure(SCCB *sccb) { PciCfgSccb *psccb = (PciCfgSccb *)sccb; S390PCIBusDevice *pbdev = s390_pci_find_dev_by_fid(be32_to_cpu(psccb->aid)); uint16_t rc; if (be16_to_cpu(sccb->h.length) < 16) { rc = SCLP_RC_INSUFFICIENT_SCCB_LENGTH; goto out; } if (pbdev) { if (pbdev->configured) { rc = SCLP_RC_NO_ACTION_REQUIRED; } else { pbdev->configured = true; rc = SCLP_RC_NORMAL_COMPLETION; } } else { DPRINTF("sclp config no dev found\n"); rc = SCLP_RC_ADAPTER_ID_NOT_RECOGNIZED; } out: psccb->header.response_code = cpu_to_be16(rc); }
1threat
Singleton: create instance inside static constructor : <p>I was reading about Singleton design pattern when i come across this implementation:</p> <pre><code>public class Singleton { private static Singleton Instance { get; private set; } private Singleton() { } static Singleton() { Instance = new Singleton(); } } </code></pre> <p>Is this singleton thread safe? What are pros and cons of such implementation? </p>
0debug
AVFormatContext *avformat_alloc_context(void) { AVFormatContext *ic; ic = av_malloc(sizeof(AVFormatContext)); if (!ic) return ic; avformat_get_context_defaults(ic); ic->av_class = &av_format_context_class; return ic; }
1threat
static void start_auth_vencrypt_subauth(VncState *vs) { switch (vs->subauth) { case VNC_AUTH_VENCRYPT_TLSNONE: case VNC_AUTH_VENCRYPT_X509NONE: VNC_DEBUG("Accept TLS auth none\n"); vnc_write_u32(vs, 0); start_client_init(vs); break; case VNC_AUTH_VENCRYPT_TLSVNC: case VNC_AUTH_VENCRYPT_X509VNC: VNC_DEBUG("Start TLS auth VNC\n"); start_auth_vnc(vs); break; #ifdef CONFIG_VNC_SASL case VNC_AUTH_VENCRYPT_TLSSASL: case VNC_AUTH_VENCRYPT_X509SASL: VNC_DEBUG("Start TLS auth SASL\n"); start_auth_sasl(vs); break; #endif default: VNC_DEBUG("Reject subauth %d server bug\n", vs->auth); vnc_write_u8(vs, 1); if (vs->minor >= 8) { static const char err[] = "Unsupported authentication type"; vnc_write_u32(vs, sizeof(err)); vnc_write(vs, err, sizeof(err)); } vnc_client_error(vs); } }
1threat
import re def occurance_substring(text,pattern): for match in re.finditer(pattern, text): s = match.start() e = match.end() return (text[s:e], s, e)
0debug
int ff_hevc_split_packet(HEVCContext *s, HEVCPacket *pkt, const uint8_t *buf, int length, AVCodecContext *avctx, int is_nalff, int nal_length_size) { int consumed, ret = 0; pkt->nb_nals = 0; while (length >= 4) { HEVCNAL *nal; int extract_length = 0; if (is_nalff) { int i; for (i = 0; i < nal_length_size; i++) extract_length = (extract_length << 8) | buf[i]; buf += nal_length_size; length -= nal_length_size; if (extract_length > length) { av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit size.\n"); return AVERROR_INVALIDDATA; } } else { while (buf[0] != 0 || buf[1] != 0 || buf[2] != 1) { ++buf; --length; if (length < 4) { if (pkt->nb_nals > 0) { return 0; } else { av_log(avctx, AV_LOG_ERROR, "No start code is found.\n"); return AVERROR_INVALIDDATA; } } } buf += 3; length -= 3; extract_length = length; } if (pkt->nals_allocated < pkt->nb_nals + 1) { int new_size = pkt->nals_allocated + 1; void *tmp = av_realloc_array(pkt->nals, new_size, sizeof(*pkt->nals)); if (!tmp) return AVERROR(ENOMEM); pkt->nals = tmp; memset(pkt->nals + pkt->nals_allocated, 0, (new_size - pkt->nals_allocated) * sizeof(*pkt->nals)); nal = &pkt->nals[pkt->nb_nals]; nal->skipped_bytes_pos_size = 1024; nal->skipped_bytes_pos = av_malloc_array(nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos)); if (!nal->skipped_bytes_pos) return AVERROR(ENOMEM); pkt->nals_allocated = new_size; } nal = &pkt->nals[pkt->nb_nals]; consumed = ff_hevc_extract_rbsp(s, buf, extract_length, nal); if (consumed < 0) return consumed; pkt->nb_nals++; ret = init_get_bits8(&nal->gb, nal->data, nal->size); if (ret < 0) return ret; ret = hls_nal_unit(nal, avctx); if (ret <= 0) { if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\n", nal->type); } pkt->nb_nals--; } buf += consumed; length -= consumed; } return 0; }
1threat
How can I unwrap a string in Xcode to fix error? : I'm a beginner in iOS programming, so please understand that my question will probably sound dumb for you. I am trying to make an app that the user selects an option from a tableview cell, but I get a "Value of optional type 'String?' must be unwrapped to a value of type 'String'" error. I get the error on the 5th line and line 16, both about "unwrapping an optional type". I've tried adding a !, and searching on the internet, but I couldn't find any information that could help me fix the error. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as? DataTableViewCell cell?.img.image = UIImage(named: arr[indexPath.row]["name"!]) cell?.lbl.text = arr[indexPath.row]["name"] cell?.lbl2.text = arr[indexPath.row]["subject"] cell?.lbl3.text = arr[indexPath.row]["grade"] return cell! } func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let vc = storyboard?.instantiateViewController(withIdentifier: "DetailViewController") as? DetailViewController vc?.str = arr[indexPath.row]["name"] navigationController?.pushViewController(vc!, animated: true) } I expect the program to run without errors.
0debug
Google Play Store Internal Test cannot start roll out : <p>I am going to start rolling out the first version of the application to the internal testers.</p> <p>But the button <code>START ROLLOUT TO INTERNAL TEST</code> is disabled and I cannot see any other error messages or warnings here.</p> <p>Can anyone let me know what's going? <a href="https://i.stack.imgur.com/uBJAX.png" rel="noreferrer">Screenshot attached</a></p>
0debug
Class weights in binary classification model with Keras : <p>We know that we can pass a class weights dictionary in the fit method for imbalanced data in binary classification model. My question is that, when using only 1 node in the output layer with sigmoid activation, can we still apply the class weights during the training? </p> <pre class="lang-py prettyprint-override"><code>model = Sequential() model.add(Dense(64, activation='tanh',input_shape=(len(x_train[0]),))) model.add(Dense(1, activation='sigmoid')) model.compile( optimizer=optimizer, loss=loss, metrics=metrics) model.fit( x_train, y_train, epochs=args.e, batch_size=batch_size, class_weight={0: 1, 1: 3}) </code></pre>
0debug
Why is my Jquery is not append in select option? : I try to append data in select option but it's not showing/append in it This is the select option <select class="form-control show-tick" style="font-size: 14px;" id="kode_kantor" name="office_code" data-live-search="true"> <option value="choose" disabled selected>-- choose office --</option> </select> This is the ajax code <script type="text/javascript"> $.ajax({ 'url': 'http://x.x.x.x/test/API/getOfficeBySearch', 'method': 'POST', 'data': { 'request': JSON.stringify({"username":"test","password":"test","searchparam":"type","searchvalue":"office"}) }, 'success': function(result) { result = JSON.parse(result) result.data.forEach(function(value, index) { var element = ` <option value="${value.officeid}">${value.name}</option> ` $('#office_code').append(element) }) } }) </script> ------------------------------------
0debug
How to add an existing project to TFS : <p>I have a solution with 6 projects already in TFS. Each project is in its own folder.</p> <p>I right clicked the solution and added a new project, so the solution XML knows about my new project.</p> <p>I checked in the solution file, but the newly added project is not listed in the source control explorer, presumably because I never checked in the files.</p> <p>My question is how can I check in the project and ensure that the new project files go into its own folder?</p> <p>If I right click in the root of the solution and select the new project files the "Destination source control folder" is set to the root - do I need to first create a folder in TFS which matches the name of my project folder? That seems backwards.</p>
0debug
static void jazz_led_text_update(void *opaque, console_ch_t *chardata) { LedState *s = opaque; char buf[2]; dpy_text_cursor(s->con, -1, -1); qemu_console_resize(s->con, 2, 1); snprintf(buf, 2, "%02hhx\n", s->segments); console_write_ch(chardata++, 0x00200100 | buf[0]); console_write_ch(chardata++, 0x00200100 | buf[1]); dpy_text_update(s->con, 0, 0, 2, 1); }
1threat
What is address(0) in Solidity : <p>Can anyone explain to me what <code>address(0)</code> is in Solidity? I found the following in the docs but it doesn't really make sense to me:</p> <blockquote> <p>If the target account is the zero-account (the account with the address 0), the transaction creates a new contract. As already mentioned, the address of that contract is not the zero address but an address derived from the sender and its number of transactions sent (the “nonce”). The payload of such a contract creation transaction is taken to be EVM bytecode and executed. The output of this execution is permanently stored as the code of the contract. This means that in order to create a contract, you do not send the actual code of the contract, but in fact code that returns that code.</p> </blockquote> <p><a href="http://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html?highlight=address(0)#index-8" rel="noreferrer">http://solidity.readthedocs.io/en/develop/introduction-to-smart-contracts.html?highlight=address(0)#index-8</a></p>
0debug
static void rtl8139_io_writew(void *opaque, uint8_t addr, uint32_t val) { RTL8139State *s = opaque; addr &= 0xfe; switch (addr) { case IntrMask: rtl8139_IntrMask_write(s, val); break; case IntrStatus: rtl8139_IntrStatus_write(s, val); break; case MultiIntr: rtl8139_MultiIntr_write(s, val); break; case RxBufPtr: rtl8139_RxBufPtr_write(s, val); break; case BasicModeCtrl: rtl8139_BasicModeCtrl_write(s, val); break; case BasicModeStatus: rtl8139_BasicModeStatus_write(s, val); break; case NWayAdvert: DPRINTF("NWayAdvert write(w) val=0x%04x\n", val); s->NWayAdvert = val; break; case NWayLPAR: DPRINTF("forbidden NWayLPAR write(w) val=0x%04x\n", val); break; case NWayExpansion: DPRINTF("NWayExpansion write(w) val=0x%04x\n", val); s->NWayExpansion = val; break; case CpCmd: rtl8139_CpCmd_write(s, val); break; case IntrMitigate: rtl8139_IntrMitigate_write(s, val); break; default: DPRINTF("ioport write(w) addr=0x%x val=0x%04x via write(b)\n", addr, val); rtl8139_io_writeb(opaque, addr, val & 0xff); rtl8139_io_writeb(opaque, addr + 1, (val >> 8) & 0xff); break; } }
1threat
I need to sum a number over loop : Sum over loop base_times=14 base_times.times do |i| x=3 x = x + 2,50 puts "#{x}" end I want to iterate 14 times and on each time sum 2.50 to x, so i=0 > x=5.5, i=1 > x=8, i=2 > x=10.5, i=3 > x=13, and so on....
0debug
Make a data frame of two columns based on values less than a threshold value in column 2 in r : <p>I want to make a data frame that only has entries below a certain defined threshold that is compared with column b, such that entry "OP2775iib SAV OP2958i_b POR" is excluded.</p> <p>I tried this code:</p> <pre><code>less_than_threshold &lt;- data.frame(which(data[data$b &lt; threshold])) </code></pre> <p>but it returns and error that I cant quite grasp:</p> <p>Error in <code>[.data.frame</code>(pairwise_ind_Mdists, pairwise_ind_Mdists$Mdist &lt; : undefined columns selected</p> <p>This is a sample of the data I'm working with:</p> <pre><code>data &lt;- data.frame(a = c("OP2775iia MOU OP2775iib SAV","OP2775iia MOU OP2958i_a COM","OP2775iib SAV OP2958i_a COM","OP2775iia MOU OP2958i_b POR","OP2775iib SAV OP2958i_b POR"), b = c(4.9022276,3.8867063,3.0126033,5.0261763,6.3745697)) threshold &lt;- 6.3745697 </code></pre> <p>I want a data frame that has all the entries from the original dataset except for the last entry "OP2775iib SAV OP2958i_b POR"</p>
0debug
Generate a composite unique constraint/index, in EF Core : <p>I need a composite unique constraint for my entity's <code>Name</code> property, which is unique per <code>Category</code> (for which it has an FK).</p> <p>So something like this:</p> <pre><code>entityTypeBuilder .HasIndex(i =&gt; new { i.Name, i.Category.Id }) .IsUnique(); </code></pre> <p>But this fails when I generate a migration, because of the <code>Category.Id</code> navigation property.</p> <p>I know I can hardcode the values as strings, but I don't want to lose the static typing.</p> <p>What options do I have?</p>
0debug
Download an image using Axios and convert it to base64 : <p>I need to download a .jpg image from a remote server and convert it into a base64 format. I'm using axios as my HTTP client. I've tried issuing a git request to the server and checking the <code>response.data</code> however it doesn't seem to work like that. </p> <p>Link to axios: <a href="https://github.com/mzabriskie/axios" rel="noreferrer">https://github.com/mzabriskie/axios</a></p> <p>Link to base64 implementation: <a href="https://www.npmjs.com/package/base-64" rel="noreferrer">https://www.npmjs.com/package/base-64</a></p> <p>I'm using NodeJS / React so atob/btoa doesn't work, hense the library. </p> <pre><code>axios.get('http://placehold.it/32').then(response =&gt; { console.log(response.data); // Blank console.log(response.data == null); // False console.log(base64.encode(response.data); // Blank }).catch(err =&gt; console.log(err)); </code></pre>
0debug
def sum_column(list1, C): result = sum(row[C] for row in list1) return result
0debug
How to check if a file is an .exe in vb.net : Hi I was wondering if anyone knew how I could do something like if file.Exists("file path")then message box.show("exists") else file.delete. Can i do something like that but to check if a file is a executable and if it is do a command and if its not do another command thanks in advance.
0debug
After Ubuntu 18.04 upgrade php7.2-curl cannot be installed : <p>Upgraded to 18.04 from 16.04 today using <code>do-release-upgrade -d</code></p> <p>During the upgrade I was informed that some packages would be removed, these included:</p> <blockquote> <p>Remove: libperl5.22 lxc-common perl-modules-5.22 php-imagick<br> php7.1-curl php7.2-curl python3-certbot-nginx</p> </blockquote> <p>I could re-install imagick and certbot without issue, but if I try to install php7.2-curl I get the message:</p> <pre><code># apt install php7.2-curl -y Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: php7.2-curl : Depends: php7.2-common (= 7.2.3-1ubuntu1) but 7.2.4-1+ubuntu16.04.1+deb.sury.org+1 is to be installed E: Unable to correct problems, you have held broken packages. </code></pre> <p>How can I correct the situation?</p>
0debug
Given three numbers, two are guaranteed equal, find the different number. : <p>For example: A = 2, B = 4 &amp; C = 2 then output should be uniqueNumber(A, B, C) = 4</p>
0debug
static inline void tcg_out_adr(TCGContext *s, TCGReg rd, void *target) { ptrdiff_t offset = tcg_pcrel_diff(s, target); assert(offset == sextract64(offset, 0, 21)); tcg_out_insn(s, 3406, ADR, rd, offset); }
1threat
static inline int show_tags(WriterContext *wctx, AVDictionary *tags, int section_id) { AVDictionaryEntry *tag = NULL; int ret = 0; if (!tags) return 0; writer_print_section_header(wctx, section_id); while ((tag = av_dict_get(tags, "", tag, AV_DICT_IGNORE_SUFFIX))) { ret = writer_print_string(wctx, tag->key, tag->value, 0); if (ret < 0) break; } writer_print_section_footer(wctx); return ret; }
1threat
connect_to_qemu( const char *host, const char *port ) { struct addrinfo hints; struct addrinfo *server; int ret, sock; sock = qemu_socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) { fprintf(stderr, "Error opening socket!\n"); return -1; } memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = 0; hints.ai_protocol = 0; ret = getaddrinfo(host, port, &hints, &server); if (ret != 0) { fprintf(stderr, "getaddrinfo failed\n"); goto cleanup_socket; } if (connect(sock, server->ai_addr, server->ai_addrlen) < 0) { fprintf(stderr, "Could not connect\n"); goto cleanup_socket; } if (verbose) { printf("Connected (sizeof Header=%zd)!\n", sizeof(VSCMsgHeader)); } return sock; cleanup_socket: closesocket(sock); return -1; }
1threat
how to arrange two divs side by side : <div id="quarterlistpanel" style="display:None; " > <apex:selectList id="QuarterSelList" size="1" title="List of Quartersin year" style=" padding: 2px 4px; margin: 4px 2px;" > <apex:selectOption itemvalue="Quarters" itemLabel="Select a Quarter" /> <apex:selectOption itemvalue="Q1" itemLabel="Quarter 1"/> </apex:selectList> </div> <div id="buttonpanel" style="display:None; float:left"> <apex:commandButton action="{!selectQuarter}" value="Go!" status="actStatusId2" reRender="pgBlckId,panelrender,panelrender1,panelrender14,panelrender15,panelrender24,panelrender23,panelrender12,panelrender13,panelrender2,panelrender21,panelrender22" id="button2"/> <apex:actionStatus id="actStatusId2" title="This is the status for loading image"> <apex:facet name="start" > <img src="/img/loading.gif" width="25" height="25" align="bottom" title="Loading"/> <h3> Loading..</h3> </apex:facet> </apex:actionStatus> </div> I want to display these two div tags side by side.please let me know how can i achieve this.
0debug
group an array of objects by a property javascript : <p>I have an array of objects. I need to group them by name and then combine another property in an array.</p> <pre><code>[ { NAME: 'TEST_1', ID: '1', FROM: '20191223', TO: '99991231' }, { NAME: 'TEST_1', ID: '2', FROM: '20191223', TO: '99991231' }, { NAME: 'TEST_2', ID: '3', FROM: '20191223', TO: '99991231' }, { NAME: 'TEST_2', ID: '4', FROM: '20191223', TO: '99991231' }, ] </code></pre> <p>Any my output will be:</p> <pre><code>[ { NAME: 'TEST_1', ID: '[1, 2]', FROM: '20191223', TO: '99991231' }, { NAME: 'TEST_2', ID: '[3, 4]', FROM: '20191223', TO: '99991231' }, ] </code></pre>
0debug
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost) { AVFormatContext *s = of->ctx; AVStream *st = ost->st; int ret; if (!of->header_written) { AVPacket tmp_pkt; if (!av_fifo_space(ost->muxing_queue)) { int new_size = FFMIN(2 * av_fifo_size(ost->muxing_queue), ost->max_muxing_queue_size); if (new_size <= av_fifo_size(ost->muxing_queue)) { av_log(NULL, AV_LOG_ERROR, "Too many packets buffered for output stream %d:%d.\n", ost->file_index, ost->st->index); exit_program(1); } ret = av_fifo_realloc2(ost->muxing_queue, new_size); if (ret < 0) exit_program(1); } av_packet_move_ref(&tmp_pkt, pkt); av_fifo_generic_write(ost->muxing_queue, &tmp_pkt, sizeof(tmp_pkt), NULL); return; } if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && video_sync_method == VSYNC_DROP) || (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0)) pkt->pts = pkt->dts = AV_NOPTS_VALUE; if (!(st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->encoding_needed)) { if (ost->frame_number >= ost->max_frames) { av_packet_unref(pkt); return; } ost->frame_number++; } if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { int i; uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_STATS, NULL); ost->quality = sd ? AV_RL32(sd) : -1; ost->pict_type = sd ? sd[4] : AV_PICTURE_TYPE_NONE; for (i = 0; i<FF_ARRAY_ELEMS(ost->error); i++) { if (sd && i < sd[5]) ost->error[i] = AV_RL64(sd + 8 + 8*i); else ost->error[i] = -1; } if (ost->frame_rate.num && ost->is_cfr) { if (pkt->duration > 0) av_log(NULL, AV_LOG_WARNING, "Overriding packet duration by frame rate, this should not happen\n"); pkt->duration = av_rescale_q(1, av_inv_q(ost->frame_rate), ost->st->time_base); } } if (!(s->oformat->flags & AVFMT_NOTIMESTAMPS)) { if (pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->dts > pkt->pts) { av_log(s, AV_LOG_WARNING, "Invalid DTS: %"PRId64" PTS: %"PRId64" in output stream %d:%d, replacing by guess\n", pkt->dts, pkt->pts, ost->file_index, ost->st->index); pkt->pts = pkt->dts = pkt->pts + pkt->dts + ost->last_mux_dts + 1 - FFMIN3(pkt->pts, pkt->dts, ost->last_mux_dts + 1) - FFMAX3(pkt->pts, pkt->dts, ost->last_mux_dts + 1); } if ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && pkt->dts != AV_NOPTS_VALUE && !(st->codecpar->codec_id == AV_CODEC_ID_VP9 && ost->stream_copy) && ost->last_mux_dts != AV_NOPTS_VALUE) { int64_t max = ost->last_mux_dts + !(s->oformat->flags & AVFMT_TS_NONSTRICT); if (pkt->dts < max) { int loglevel = max - pkt->dts > 2 || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO ? AV_LOG_WARNING : AV_LOG_DEBUG; av_log(s, loglevel, "Non-monotonous DTS in output stream " "%d:%d; previous: %"PRId64", current: %"PRId64"; ", ost->file_index, ost->st->index, ost->last_mux_dts, pkt->dts); if (exit_on_error) { av_log(NULL, AV_LOG_FATAL, "aborting.\n"); exit_program(1); } av_log(s, loglevel, "changing to %"PRId64". This may result " "in incorrect timestamps in the output file.\n", max); if (pkt->pts >= pkt->dts) pkt->pts = FFMAX(pkt->pts, max); pkt->dts = max; } } } ost->last_mux_dts = pkt->dts; ost->data_size += pkt->size; ost->packets_written++; pkt->stream_index = ost->index; if (debug_ts) { av_log(NULL, AV_LOG_INFO, "muxer <- type:%s " "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s size:%d\n", av_get_media_type_string(ost->enc_ctx->codec_type), av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &ost->st->time_base), av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &ost->st->time_base), pkt->size ); } ret = av_interleaved_write_frame(s, pkt); if (ret < 0) { print_error("av_interleaved_write_frame()", ret); main_return_code = 1; close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED); } av_packet_unref(pkt); }
1threat
Specify a root path for imports? : <p>I'm converting my ongoing Vue.js app over to use vue-cli/Webpack and imported modules Something I'm finding rather tedious at the moment is specifying the relative paths for imports accurately. E.g. <code>import bus from '../../bus'</code>, <code>import Cell from '../Cell'</code>. Easy to make a mistake. </p> <p>I'm assuming it must be straightforward enough to specify a base or root directory and specify absolute paths from that, but I can't see where one would do that. For example, in the standard vue-cli webpack setup, the code I'm working on is all in the 'src' directory, inside which I have 'components', 'mixins', etc. It would be handy if I could use <code>import xxx from 'components/xxx'</code>, <code>import yyy from 'components/a/yyy'</code>. How would I do that?</p>
0debug
Error sending to the following VALID addresses Jenkins : <p>I will receive emails when I trigger using build now manually, but I don't receive emails when I tried to using it in batch mode. Below is the log I obtain when triggered in batch mode.</p> <p>Email was triggered for: Always Sending email for trigger: Always Sending email to: abc@example.com Error sending to the following VALID addresses: abc@example.com</p> <p>Note: There are no build logs attached while sending email.</p>
0debug
static int plot_cqt(AVFilterContext *ctx) { AVFilterLink *outlink = ctx->outputs[0]; ShowCQTContext *s = ctx->priv; int ret; memcpy(s->fft_result, s->fft_data, s->fft_len * sizeof(*s->fft_data)); av_fft_permute(s->fft_ctx, s->fft_result); av_fft_calc(s->fft_ctx, s->fft_result); s->fft_result[s->fft_len] = s->fft_result[0]; s->cqt_calc(s->cqt_result, s->fft_result, s->coeffs, s->cqt_len, s->fft_len); process_cqt(s); if (s->sono_h) s->update_sono(s->sono_frame, s->c_buf, s->sono_idx); if (!s->sono_count) { AVFrame *out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) return AVERROR(ENOMEM); if (s->bar_h) s->draw_bar(out, s->h_buf, s->rcp_h_buf, s->c_buf, s->bar_h); if (s->axis_h) s->draw_axis(out, s->axis_frame, s->c_buf, s->bar_h); if (s->sono_h) s->draw_sono(out, s->sono_frame, s->bar_h + s->axis_h, s->sono_idx); out->pts = s->frame_count; ret = ff_filter_frame(outlink, out); s->frame_count++; } s->sono_count = (s->sono_count + 1) % s->count; if (s->sono_h) s->sono_idx = (s->sono_idx + s->sono_h - 1) % s->sono_h; return ret; }
1threat
static int vc1_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { VC1Context *v = avctx->priv_data; MpegEncContext *s = &v->s; AVFrame *pict = data; uint8_t *buf2 = NULL; if (buf_size == 0) { if (s->low_delay==0 && s->next_picture_ptr) { *pict= *(AVFrame*)s->next_picture_ptr; s->next_picture_ptr= NULL; *data_size = sizeof(AVFrame); } return 0; } if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){ int i= ff_find_unused_picture(s, 0); s->current_picture_ptr= &s->picture[i]; } avctx->has_b_frames= !s->low_delay; if (avctx->codec_id == CODEC_ID_VC1) { int i, buf_size2; buf2 = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); buf_size2 = 0; for(i = 0; i < buf_size; i++) { if(buf[i] == 3 && i >= 2 && !buf[i-1] && !buf[i-2] && i < buf_size-1 && buf[i+1] < 4) { buf2[buf_size2++] = buf[i+1]; i++; } else buf2[buf_size2++] = buf[i]; } init_get_bits(&s->gb, buf2, buf_size2*8); } else init_get_bits(&s->gb, buf, buf_size*8); if(v->profile < PROFILE_ADVANCED) { if(vc1_parse_frame_header(v, &s->gb) == -1) { if(buf2)av_free(buf2); return -1; } } else { if(vc1_parse_frame_header_adv(v, &s->gb) == -1) { if(buf2)av_free(buf2); return -1; } } if(s->pict_type != I_TYPE && !v->res_rtm_flag){ if(buf2)av_free(buf2); return -1; } s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == I_TYPE; if(s->last_picture_ptr==NULL && (s->pict_type==B_TYPE || s->dropable)){ if(buf2)av_free(buf2); return -1; } if(avctx->hurry_up && s->pict_type==B_TYPE) return -1; if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==B_TYPE) || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=I_TYPE) || avctx->skip_frame >= AVDISCARD_ALL) { if(buf2)av_free(buf2); return buf_size; } if(avctx->hurry_up>=5) { if(buf2)av_free(buf2); return -1; } if(s->next_p_frame_damaged){ if(s->pict_type==B_TYPE) return buf_size; else s->next_p_frame_damaged=0; } if(MPV_frame_start(s, avctx) < 0) { if(buf2)av_free(buf2); return -1; } ff_er_frame_start(s); v->bits = buf_size * 8; vc1_decode_blocks(v); ff_er_frame_end(s); MPV_frame_end(s); assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); assert(s->current_picture.pict_type == s->pict_type); if (s->pict_type == B_TYPE || s->low_delay) { *pict= *(AVFrame*)s->current_picture_ptr; } else if (s->last_picture_ptr != NULL) { *pict= *(AVFrame*)s->last_picture_ptr; } if(s->last_picture_ptr || s->low_delay){ *data_size = sizeof(AVFrame); ff_print_debug_info(s, pict); } avctx->frame_number = s->picture_number - 1; if(buf2)av_free(buf2); return buf_size; }
1threat
Illegal instruction 4 - Python : I can’t get Pycharm in my current project to run the debugger. When I run the debugger, it throws me that: /Users/jeremie/.local/share/virtualenvs/proxi-server/bin/python /Applications/PyCharm.app/Contents/helpers/pydev/pydevd.py --multiproc --qt-support --client 127.0.0.1 --port 52293 --file /Users/jeremie/Code/proxi-server/server.py Process finished with exit code 132 I ran that command on my terminal to figure out the problem: Illegal instruction: 4 Didn't help me much.
0debug
int omap_validate_tipb_addr(struct omap_mpu_state_s *s, target_phys_addr_t addr) { return addr >= 0xfffb0000 && addr < 0xffff0000; }
1threat
void kbd_mouse_event(int dx, int dy, int dz, int buttons_state) { QEMUPutMouseEntry *entry; QEMUPutMouseEvent *mouse_event; void *mouse_event_opaque; int width, height; if (!runstate_is_running()) { return; } if (QTAILQ_EMPTY(&mouse_handlers)) { return; } entry = QTAILQ_FIRST(&mouse_handlers); mouse_event = entry->qemu_put_mouse_event; mouse_event_opaque = entry->qemu_put_mouse_event_opaque; if (mouse_event) { if (entry->qemu_put_mouse_event_absolute) { width = 0x7fff; height = 0x7fff; } else { width = graphic_width - 1; height = graphic_height - 1; } switch (graphic_rotate) { case 0: mouse_event(mouse_event_opaque, dx, dy, dz, buttons_state); break; case 90: mouse_event(mouse_event_opaque, width - dy, dx, dz, buttons_state); break; case 180: mouse_event(mouse_event_opaque, width - dx, height - dy, dz, buttons_state); break; case 270: mouse_event(mouse_event_opaque, dy, height - dx, dz, buttons_state); break; } } }
1threat
static int tta_get_unary(GetBitContext *gb) { int ret = 0; while(get_bits1(gb)) ret++; return ret; }
1threat
static int pte_check_hash32(mmu_ctx_t *ctx, target_ulong pte0, target_ulong pte1, int h, int rw, int type) { target_ulong ptem, mmask; int access, ret, pteh, ptev, pp; ret = -1; ptev = pte_is_valid_hash32(pte0); pteh = (pte0 >> 6) & 1; if (ptev && h == pteh) { ptem = pte0 & PTE_PTEM_MASK; mmask = PTE_CHECK_MASK; pp = pte1 & 0x00000003; if (ptem == ctx->ptem) { if (ctx->raddr != (hwaddr)-1ULL) { if ((ctx->raddr & mmask) != (pte1 & mmask)) { qemu_log("Bad RPN/WIMG/PP\n"); return -3; } } access = pp_check(ctx->key, pp, ctx->nx); ctx->raddr = pte1; ctx->prot = access; ret = check_prot(ctx->prot, rw, type); if (ret == 0) { LOG_MMU("PTE access granted !\n"); } else { LOG_MMU("PTE access rejected\n"); } } } return ret; }
1threat
sparse list of values using ranges : <p>is there a more terse way of writing</p> <pre><code>listOf('a'..'z','A'..'Z').flatMap { it } </code></pre> <p>The idea here is to iterate over some values in a range, like the numbers from 1 through 100, skipping 21 through 24</p> <pre><code>listOf(1..20, 25..100).flatMap { it } </code></pre>
0debug
Using random numbers vs hardcoded values in unit tests : <p>When I write tests, I like to use random numbers to calculate things.</p> <p>e.g.</p> <pre><code> func init() { rand.Seed(time.Now().UnixNano()) } func TestXYZ(t *testing.T) { amount := rand.Intn(100) cnt := 1 + rand.Intn(10) for i := 0; i &lt; cnt; i++ { doSmth(amount) } //more stuff } </code></pre> <p>which of course has the disadvantage that </p> <pre><code>expected := calcExpected(amount, cnt) </code></pre> <p>in that the expected value for the test needs to be calculated from the random values.</p> <p>If have received criticism for this approach:</p> <ul> <li>It makes the test unnecessarily complex</li> <li>Less reproduceable due to randomness</li> </ul> <p>I think though that without randomness, I could actually:</p> <ul> <li>Make up my results, e.g. the test only works for a specific value. Randomness proves my test is "robust"</li> <li>Catch more edge cases (debatable as edge cases are usually specific, e.g. 0,1,-1)</li> </ul> <p>Is it really that bad to use random numbers?</p> <p>(I realize this is a bit of an opinion question, but I am very much interested in people's point of views, don't mind downvotes).</p>
0debug
bot is removing all messages : <p>I wrote this script to delete all messages from a specific channel that were not images, but the bot removes all text messages and images. </p> <p>here is the code:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>client.on("message", (message) =&gt; { let channel = client.channels.get(`642417479708049418`); if (message.author.bot) return; if (message.member.roles.some(r =&gt; ["DEAN!"].includes(r.name))) return; if (message.channel.id != channel.id) { return } else { if (message.embeds.length &gt; 0) { return } else { message.channel.send(`${message.author} this channel is for images only`); message.delete(); } } });</code></pre> </div> </div> </p>
0debug
static inline void RENAME(rgb24to15)(const uint8_t *src, uint8_t *dst, int src_size) { const uint8_t *s = src; const uint8_t *end; const uint8_t *mm_end; uint16_t *d = (uint16_t *)dst; end = s + src_size; __asm__ volatile(PREFETCH" %0"::"m"(*src):"memory"); __asm__ volatile( "movq %0, %%mm7 \n\t" "movq %1, %%mm6 \n\t" ::"m"(red_15mask),"m"(green_15mask)); mm_end = end - 15; while (s < mm_end) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movd %1, %%mm0 \n\t" "movd 3%1, %%mm3 \n\t" "punpckldq 6%1, %%mm0 \n\t" "punpckldq 9%1, %%mm3 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm0, %%mm2 \n\t" "movq %%mm3, %%mm4 \n\t" "movq %%mm3, %%mm5 \n\t" "psllq $7, %%mm0 \n\t" "psllq $7, %%mm3 \n\t" "pand %%mm7, %%mm0 \n\t" "pand %%mm7, %%mm3 \n\t" "psrlq $6, %%mm1 \n\t" "psrlq $6, %%mm4 \n\t" "pand %%mm6, %%mm1 \n\t" "pand %%mm6, %%mm4 \n\t" "psrlq $19, %%mm2 \n\t" "psrlq $19, %%mm5 \n\t" "pand %2, %%mm2 \n\t" "pand %2, %%mm5 \n\t" "por %%mm1, %%mm0 \n\t" "por %%mm4, %%mm3 \n\t" "por %%mm2, %%mm0 \n\t" "por %%mm5, %%mm3 \n\t" "psllq $16, %%mm3 \n\t" "por %%mm3, %%mm0 \n\t" MOVNTQ" %%mm0, %0 \n\t" :"=m"(*d):"m"(*s),"m"(blue_15mask):"memory"); d += 4; s += 12; } __asm__ volatile(SFENCE:::"memory"); __asm__ volatile(EMMS:::"memory"); while (s < end) { const int r = *s++; const int g = *s++; const int b = *s++; *d++ = (b>>3) | ((g&0xF8)<<2) | ((r&0xF8)<<7); } }
1threat
Kotlin synthetic extension for view : <p>I have a layout with some views, one of them has the id <code>title_whalemare</code></p> <pre><code>import kotlinx.android.synthetic.main.controller_settings.* import kotlinx.android.synthetic.main.view_double_text.* class MainSettingsController : BaseMvpController&lt;MvpView, MvpPresenter&gt;() { val title: TextView = title_whalemare override fun getLayout(): Int { return R.layout.controller_settings } } </code></pre> <p>I try find it with <code>kotlin extensions</code>, but I can't because I get the following error</p> <p><em>None of the following candidates is applicable because of receiver type mismatch</em> <a href="https://i.stack.imgur.com/chqBS.png" rel="noreferrer"><img src="https://i.stack.imgur.com/chqBS.png" alt="None of the following candidates is applicable because of receiver type mismatch"></a></p> <p><code>controller_settings.xml</code></p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"&gt; &lt;TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/title_whalemare"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>Where is my mistake?</p>
0debug
python replace value if it starts with certain character : I have a following list and I am trying to replace any value which starts with ```23:``` to ```00:00:00.00``` ```tc = ['00:00:00.360', '00:00:00.920', '00:00:00.060', '00:00:02.600', '23:59:55.680', '00:00:05.960', '00:00:01.040', '00:00:01.140', '00:00:01.060', '00:00:01.480', '00:00:00.140', '00:00:00.280', '23:59:59.800', '00:00:01.200', '00:00:00.400', '23:59:59.940', '00:00:01.220', '00:00:00.380']``` I am able to get what I need using regex, ```tc = [re.sub(r'(\b23:)(.*)',r'00:00:00.00', item) for item in tc]``` and it gives me expected result as per below, ```['00:00:00.360', '00:00:00.920', '00:00:00.060', '00:00:02.600', '00:00:00.00', '00:00:05.960', '00:00:01.040', '00:00:01.140', '00:00:01.060', '00:00:01.480', '00:00:00.140', '00:00:00.280', '00:00:00.00', '00:00:01.200', '00:00:00.400', '00:00:00.00', '00:00:01.220', '00:00:00.380']``` But if I use the below method without using regex, then the result is not what I expect, ```tc = [item.replace(item, '00:00:00.00') for item in tc if item.startswith('23:')]``` Result: ```['00:00:00.00', '00:00:00.00', '00:00:00.00']``` The resultant list is only with replaced items and not the whole list. How to I use the above method to get complete list?
0debug
bootstrap 4 pull-xs-right not working as expected : <p>I have this html using <a href="http://v4-alpha.getbootstrap.com/components/utilities/" rel="noreferrer">bootstrap 4 utilities</a> to pull the buttons to the right of the screen. And it does do this.</p> <p>However, the buttons do not push down the content below it as expected. They end up overlayed on top of the content below.</p> <p>If I do not use <code>pull-xs-right</code> then the buttons are left aligned, but they do push the items below.</p> <p>Is there some other class I need to apply?</p> <pre><code> &lt;div class="pull-xs-right"&gt; &lt;button click.delegate="saveEdit()" type="submit" class="k-button k-primary"&gt; Save &lt;/button&gt; &lt;button click.delegate="cancel()" class="k-button"&gt; Cancel &lt;/button&gt; &lt;/div&gt; </code></pre>
0debug
Npm package.json inheritance : <p>Is there a mechanism in npm like parent pom in Maven. The goal is to have a common base configuration for scripts, dependencies, devDependencies. Not based on templates like yeoman or so, but based on a parent version. So that, any project that changes his parent version gets the changes in this parent automatically.</p> <p>Can you point me to hints to achieve this?</p> <p>Thanks!</p>
0debug
static void *iothread_run(void *opaque) { IOThread *iothread = opaque; rcu_register_thread(); my_iothread = iothread; qemu_mutex_lock(&iothread->init_done_lock); iothread->thread_id = qemu_get_thread_id(); qemu_cond_signal(&iothread->init_done_cond); qemu_mutex_unlock(&iothread->init_done_lock); while (!atomic_read(&iothread->stopping)) { aio_poll(iothread->ctx, true); if (atomic_read(&iothread->worker_context)) { GMainLoop *loop; g_main_context_push_thread_default(iothread->worker_context); iothread->main_loop = g_main_loop_new(iothread->worker_context, TRUE); loop = iothread->main_loop; g_main_loop_run(iothread->main_loop); iothread->main_loop = NULL; g_main_loop_unref(loop); g_main_context_pop_thread_default(iothread->worker_context); } } rcu_unregister_thread(); return NULL; }
1threat
Script editor for Google sheets (auto email function) : Google sheets - Script Editor I need to generate an auto email reply when Column "A" is marked "Completed". The email address to send this to is in Column "I" and subject of the email needs to be data in Column "H" while the body of the email will be generic for all emails sent. This is all specific to each Row. I have multiple script editors running, for hiding rows etc, but nothing this complex. All data is sent in to spreadsheet from Google Forms, and will need to encompass all rows Any help would be much appreciated.
0debug
convert decimal number including decimal point to binary number in java : <p>//I want to make a program to make binary number using the following programs. //But I can use only "for" and "if" .</p> <pre><code>public class Name { public static void main(String[] args) { double x =Math.PI-3; int t; for(t=0;t&lt;=19;t++){ System.out.print(x+"\t"); if(x&lt;0.5){ x=2*x; } else{ x=2*x-1; } System.out.print(x); } } </code></pre> <p>}</p>
0debug
A javascript 'let' global variable is not a property of 'window' unlike a global 'var' : <p>I used to check if a global <code>var</code> has been defined with:</p> <pre><code>if (window['myvar']==null) ... </code></pre> <p>or</p> <pre><code>if (window.myvar==null) ... </code></pre> <p>It works with <code>var myvar</code></p> <p>Now that I am trying to switch to let, this does not work anymore.</p> <pre><code>var myvar='a'; console.log(window.myvar); // gives me a let mylet='b'; console.log(window.mylet); // gives me undefined </code></pre> <p>Question: With a global <code>let</code>, is there any place I can look if something has been defined like I could with <code>var</code> from the <code>window</code> object?</p> <p><b>More generally</b>:<br> Is <code>var myvar='a'</code> equivalent to <code>window.myvar='a'</code>?<br> I hear people say that at the global level, <code>let</code> and <code>var</code> are/behave the same, but this is not what I am seeing.</p>
0debug
C++, DevStudio, array indices, why does this work? : #include <windows.h> #include <stdio.h> WCHAR *HiveName[4] = {L"HKCR", L"HKCU", L"HKLM", L"HKU"}; int wmain( INT argc, WCHAR **argv ) { for ( DWORD i = 0x80000000; i < 0x80000004; i++ ) wprintf(L"%lu %s\n", i, HiveName[i]); return 0; } Output: 2147483648 HKCR 2147483649 HKCU 2147483650 HKLM 2147483651 HKU Why does it work?
0debug
static int output_packet(AVInputStream *ist, int ist_index, AVOutputStream **ost_table, int nb_ostreams, const AVPacket *pkt) { AVFormatContext *os; AVOutputStream *ost; uint8_t *ptr; int len, ret, i; uint8_t *data_buf; int data_size, got_picture; AVFrame picture; short samples[pkt && pkt->size > AVCODEC_MAX_AUDIO_FRAME_SIZE/2 ? pkt->size : AVCODEC_MAX_AUDIO_FRAME_SIZE/2]; void *buffer_to_free; if (pkt && pkt->dts != AV_NOPTS_VALUE) { ist->next_pts = ist->pts = pkt->dts; } else { assert(ist->pts == ist->next_pts); } if (pkt == NULL) { ptr = NULL; len = 0; goto handle_eof; } len = pkt->size; ptr = pkt->data; while (len > 0) { handle_eof: data_buf = NULL; data_size = 0; if (ist->decoding_needed) { switch(ist->st->codec.codec_type) { case CODEC_TYPE_AUDIO: ret = avcodec_decode_audio(&ist->st->codec, samples, &data_size, ptr, len); if (ret < 0) goto fail_decode; ptr += ret; len -= ret; if (data_size <= 0) { continue; } data_buf = (uint8_t *)samples; ist->next_pts += ((int64_t)AV_TIME_BASE/2 * data_size) / (ist->st->codec.sample_rate * ist->st->codec.channels); break; case CODEC_TYPE_VIDEO: data_size = (ist->st->codec.width * ist->st->codec.height * 3) / 2; avcodec_get_frame_defaults(&picture); ret = avcodec_decode_video(&ist->st->codec, &picture, &got_picture, ptr, len); ist->st->quality= picture.quality; if (ret < 0) goto fail_decode; if (!got_picture) { goto discard_packet; } if (ist->st->codec.frame_rate_base != 0) { ist->next_pts += ((int64_t)AV_TIME_BASE * ist->st->codec.frame_rate_base) / ist->st->codec.frame_rate; } len = 0; break; default: goto fail_decode; } } else { data_buf = ptr; data_size = len; ret = len; len = 0; } buffer_to_free = NULL; if (ist->st->codec.codec_type == CODEC_TYPE_VIDEO) { pre_process_video_frame(ist, (AVPicture *)&picture, &buffer_to_free); } if (ist->st->codec.rate_emu) { int64_t pts = av_rescale((int64_t) ist->frame * ist->st->codec.frame_rate_base, 1000000, ist->st->codec.frame_rate); int64_t now = av_gettime() - ist->start; if (pts > now) usleep(pts - now); ist->frame++; } #if 0 if (ist->st->codec.codec_id == CODEC_ID_MPEG1VIDEO) { if (ist->st->codec.pict_type != B_TYPE) { int64_t tmp; tmp = ist->last_ip_pts; ist->last_ip_pts = ist->frac_pts.val; ist->frac_pts.val = tmp; } } #endif if (start_time == 0 || ist->pts >= start_time) for(i=0;i<nb_ostreams;i++) { int frame_size; ost = ost_table[i]; if (ost->source_index == ist_index) { os = output_files[ost->file_index]; #if 0 printf("%d: got pts=%0.3f %0.3f\n", i, (double)pkt->pts / AV_TIME_BASE, ((double)ist->pts / AV_TIME_BASE) - ((double)ost->st->pts.val * ost->st->time_base.num / ost->st->time_base.den)); #endif ost->sync_ipts = (double)(ist->pts + input_files_ts_offset[ist->file_index])/ AV_TIME_BASE; if (ost->encoding_needed) { switch(ost->st->codec.codec_type) { case CODEC_TYPE_AUDIO: do_audio_out(os, ost, ist, data_buf, data_size); break; case CODEC_TYPE_VIDEO: { int i; AVOutputStream *audio_sync, *ost1; audio_sync = NULL; for(i=0;i<nb_ostreams;i++) { ost1 = ost_table[i]; if (ost1->file_index == ost->file_index && ost1->st->codec.codec_type == CODEC_TYPE_AUDIO) { audio_sync = ost1; break; } } do_video_out(os, ost, ist, &picture, &frame_size); video_size += frame_size; if (do_vstats && frame_size) do_video_stats(os, ost, frame_size); } break; default: av_abort(); } } else { AVFrame avframe; AVPacket opkt; av_init_packet(&opkt); avcodec_get_frame_defaults(&avframe); ost->st->codec.coded_frame= &avframe; avframe.key_frame = pkt->flags & PKT_FLAG_KEY; if(ost->st->codec.codec_type == CODEC_TYPE_AUDIO) audio_size += data_size; else if (ost->st->codec.codec_type == CODEC_TYPE_VIDEO) video_size += data_size; opkt.stream_index= ost->index; opkt.data= data_buf; opkt.size= data_size; opkt.pts= pkt->pts + input_files_ts_offset[ist->file_index]; opkt.dts= pkt->dts + input_files_ts_offset[ist->file_index]; opkt.flags= pkt->flags; av_interleaved_write_frame(os, &opkt); ost->st->codec.frame_number++; ost->frame_number++; } } } av_free(buffer_to_free); } discard_packet: if (pkt == NULL) { for(i=0;i<nb_ostreams;i++) { ost = ost_table[i]; if (ost->source_index == ist_index) { AVCodecContext *enc= &ost->st->codec; os = output_files[ost->file_index]; if(ost->st->codec.codec_type == CODEC_TYPE_AUDIO && enc->frame_size <=1) continue; if(ost->st->codec.codec_type == CODEC_TYPE_VIDEO && (os->oformat->flags & AVFMT_RAWPICTURE)) continue; if (ost->encoding_needed) { for(;;) { AVPacket pkt; av_init_packet(&pkt); pkt.stream_index= ost->index; switch(ost->st->codec.codec_type) { case CODEC_TYPE_AUDIO: ret = avcodec_encode_audio(enc, bit_buffer, VIDEO_BUFFER_SIZE, NULL); audio_size += ret; pkt.flags |= PKT_FLAG_KEY; break; case CODEC_TYPE_VIDEO: ret = avcodec_encode_video(enc, bit_buffer, VIDEO_BUFFER_SIZE, NULL); video_size += ret; if(enc->coded_frame && enc->coded_frame->key_frame) pkt.flags |= PKT_FLAG_KEY; if (ost->logfile && enc->stats_out) { fprintf(ost->logfile, "%s", enc->stats_out); } break; default: ret=-1; } if(ret<=0) break; pkt.data= bit_buffer; pkt.size= ret; if(enc->coded_frame) pkt.pts= enc->coded_frame->pts; av_interleaved_write_frame(os, &pkt); } } } } } return 0; fail_decode: return -1; }
1threat
Plotting multiple curves in same graph : <p><a href="https://i.stack.imgur.com/bZcba.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bZcba.png" alt="enter image description here"></a></p> <p>I'm trying implement a graph like the attached image. I tried many open sources but no luck. Can someone help me where can i get this kind of graph.</p>
0debug
C++ Using enum in a Class to specify value options for user input : I'm new to the implementation of enum, but have an idea on how it's supposed to be used. I have the bellow Allergy program to record information about an allergy provided by user input. I want to add another option for the user to select the "severity" of the allergy. I want to create an enum to hold the values the user should choose from. Here is what I have so far, but I'm just ignorant when it comes to enum and just how exactly it should be implemented. Thanks in advance for any help!! Allergy.hpp: #ifndef Allergy_hpp #define Allergy_hpp #include <iostream> #include <string> #include <list> using namespace std; class Allergy { public: enum severity {mild, moderate, severe}; Allergy(); Allergy(string, string, list <string>); ~Allergy(); //getters string getCategory() const; string getName() const; list <string> getSymptom() const; private: string newCategory; string newName; list <string> newSymptom; }; #endif /* Allergy_hpp */ Allergy.cpp: include "Allergy.hpp" Allergy::Allergy(string name, string category, list <string> symptom){ newName = name; newCategory = category; newSymptom = symptom; } Allergy::~Allergy(){ } //getters string Allergy::getName() const{ return newName; } string Allergy::getCategory() const{ return newCategory; } list <string> Allergy::getSymptom() const{ return newSymptom; } main.cpp: #include <iostream> #include <string> #include "Allergy.hpp" using namespace std; int main() { string name; string category; int numSymptoms; string symptHold; list <string> symptom; cout << "Enter allergy name: "; getline(cin, name); cout << "Enter allergy category: "; getline(cin, category); cout << "Enter number of allergy symptoms: "; cin >> numSymptoms; for(int i = 0; i < numSymptoms; i++){ cout << "Enter symptom # " << i+1 << ": "; cin >> symptHold; symptom.push_back(symptHold); } Allergy Allergy_1(name, category, symptom); cout << endl << "Allergy Name: " << Allergy_1.getName() << endl << "Allergy Category: " << Allergy_1.getCategory() << endl << "Allergy Symptoms: "; for(auto& s : Allergy_1.getSymptom()){ cout << s << ", "; } cout << endl; return 0; }
0debug
static void windowing_and_mdct_ltp(AACContext *ac, float *out, float *in, IndividualChannelStream *ics) { const float *lwindow = ics->use_kb_window[0] ? ff_aac_kbd_long_1024 : ff_sine_1024; const float *swindow = ics->use_kb_window[0] ? ff_aac_kbd_short_128 : ff_sine_128; const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024 : ff_sine_1024; const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128 : ff_sine_128; if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) { ac->dsp.vector_fmul(in, in, lwindow_prev, 1024); } else { memset(in, 0, 448 * sizeof(float)); ac->dsp.vector_fmul(in + 448, in + 448, swindow_prev, 128); memcpy(in + 576, in + 576, 448 * sizeof(float)); } if (ics->window_sequence[0] != LONG_START_SEQUENCE) { ac->dsp.vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024); } else { memcpy(in + 1024, in + 1024, 448 * sizeof(float)); ac->dsp.vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128); memset(in + 1024 + 576, 0, 448 * sizeof(float)); } ac->mdct_ltp.mdct_calc(&ac->mdct_ltp, out, in); }
1threat
How to test components using new react router hooks? : <p>Until now, in unit tests, react router match params were retrieved as props of component. So testing a component considering some specific match, with specific url parameters, was easy : we just had to precise router match's props as we want when rendering the component in test (I'm using enzyme library for this purpose).</p> <p>I really enjoy new hooks for retrieving routing stuff, but I didn't find examples about how to simulate a react router match in unit testing, with new react router hooks ?</p>
0debug
explain about this code jquery : <p>I found this code to get value from scan barcode</p> <pre><code>$(document).ready(function() { $(document).focus(); var coba=[]; $(document).on('keypress',function(e){ coba.push(String.fromCharCode(e.which)); if (coba[coba.length-1]=="\r") { console.log(coba.join('')); simpan(coba.join('')); coba = []; }; }); }); </code></pre> <p>anyone can explain about it?</p>
0debug
Failed to set local answer sdp: Called in wrong state: kStable : <p>for a couple of days I'm now stuck with trying to get my webRTC client to work and I can't figure out what I'm doing wrong. I'm trying to create multi peer webrtc client and am testing both sides with Chrome. When the callee receives the call and create the Answer, I get the following error:</p> <pre><code>Failed to set local answer sdp: Called in wrong state: kStable </code></pre> <p>The receiving side correctly establishes both video connnections and is showing the local and remote streams. But the caller seems not to receive the callees answer. Can someone hint me what I am doing wrong here?</p> <p>Here is the code I am using (it's a stripped version to just show the relevant parts and make it better readable)</p> <pre><code>class WebRTC_Client { private peerConns = {}; private sendAudioByDefault = true; private sendVideoByDefault = true; private offerOptions = { offerToReceiveAudio: true, offerToReceiveVideo: true }; private constraints = { "audio": true, "video": { frameRate: 5, width: 256, height: 194 } }; private serversCfg = { iceServers: [{ urls: ["stun:stun.l.google.com:19302"] }] }; private SignalingChannel; public constructor(SignalingChannel){ this.SignalingChannel = SignalingChannel; this.bindSignalingHandlers(); } /*...*/ private gotStream(stream) { (&lt;any&gt;window).localStream = stream; this.videoAssets[0].srcObject = stream; } private stopLocalTracks(){} private start() { var self = this; if( !this.isReady() ){ console.error('Could not start WebRTC because no WebSocket user connectionId had been assigned yet'); } this.buttonStart.disabled = true; this.stopLocalTracks(); navigator.mediaDevices.getUserMedia(this.getConstrains()) .then((stream) =&gt; { self.gotStream(stream); self.SignalingChannel.send(JSON.stringify({type: 'onReadyForTeamspeak'})); }) .catch(function(error) { trace('getUserMedia error: ', error); }); } public addPeerId(peerId){ this.availablePeerIds[peerId] = peerId; this.preparePeerConnection(peerId); } private preparePeerConnection(peerId){ var self = this; if( this.peerConns[peerId] ){ return; } this.peerConns[peerId] = new RTCPeerConnection(this.serversCfg); this.peerConns[peerId].ontrack = function (evt) { self.gotRemoteStream(evt, peerId); }; this.peerConns[peerId].onicecandidate = function (evt) { self.iceCallback(evt, peerId); }; this.peerConns[peerId].onnegotiationneeded = function (evt) { if( self.isCallingTo(peerId) ) { self.createOffer(peerId); } }; this.addLocalTracks(peerId); } private addLocalTracks(peerId){ var self = this; var localTracksCount = 0; (&lt;any&gt;window).localStream.getTracks().forEach( function (track) { self.peerConns[peerId].addTrack( track, (&lt;any&gt;window).localStream ); localTracksCount++; } ); trace('Added ' + localTracksCount + ' local tracks to remote peer #' + peerId); } private call() { var self = this; trace('Start calling all available new peers if any available'); // only call if there is anyone to call if( !Object.keys(this.availablePeerIds).length ){ trace('There are no callable peers available that I know of'); return; } for( let peerId in this.availablePeerIds ){ if( !this.availablePeerIds.hasOwnProperty(peerId) ){ continue; } this.preparePeerConnection(peerId); } } private createOffer(peerId){ var self = this; this.peerConns[peerId].createOffer( this.offerOptions ) .then( function (offer) { return self.peerConns[peerId].setLocalDescription(offer); } ) .then( function () { trace('Send offer to peer #' + peerId); self.SignalingChannel.send(JSON.stringify({ "sdp": self.peerConns[peerId].localDescription, "remotePeerId": peerId, "type": "onWebRTCPeerConn" })); }) .catch(function(error) { self.onCreateSessionDescriptionError(error); }); } private answerCall(peerId){ var self = this; trace('Answering call from peer #' + peerId); this.peerConns[peerId].createAnswer() .then( function (answer) { return self.peerConns[peerId].setLocalDescription(answer); } ) .then( function () { trace('Send answer to peer #' + peerId); self.SignalingChannel.send(JSON.stringify({ "sdp": self.peerConns[peerId].localDescription, "remotePeerId": peerId, "type": "onWebRTCPeerConn" })); }) .catch(function(error) { self.onCreateSessionDescriptionError(error); }); } private onCreateSessionDescriptionError(error) { console.warn('Failed to create session description: ' + error.toString()); } private gotRemoteStream(e, peerId) { if (this.audioAssets[peerId].srcObject !== e.streams[0]) { this.videoAssets[peerId].srcObject = e.streams[0]; trace('Added stream source of remote peer #' + peerId + ' to DOM'); } } private iceCallback(event, peerId) { this.SignalingChannel.send(JSON.stringify({ "candidate": event.candidate, "remotePeerId": peerId, "type": "onWebRTCPeerConn" })); } private handleCandidate(candidate, peerId) { this.peerConns[peerId].addIceCandidate(candidate) .then( this.onAddIceCandidateSuccess, this.onAddIceCandidateError ); trace('Peer #' + peerId + ': New ICE candidate: ' + (candidate ? candidate.candidate : '(null)')); } private onAddIceCandidateSuccess() { trace('AddIceCandidate success.'); } private onAddIceCandidateError(error) { console.warn('Failed to add ICE candidate: ' + error.toString()); } private hangup() {} private bindSignalingHandlers(){ this.SignalingChannel.registerHandler('onWebRTCPeerConn', (signal) =&gt; this.handleSignals(signal)); } private handleSignals(signal){ var self = this, peerId = signal.connectionId; if( signal.sdp ) { trace('Received sdp from peer #' + peerId); this.peerConns[peerId].setRemoteDescription(new RTCSessionDescription(signal.sdp)) .then( function () { if( self.peerConns[peerId].remoteDescription.type === 'answer' ){ trace('Received sdp answer from peer #' + peerId); } else if( self.peerConns[peerId].remoteDescription.type === 'offer' ){ trace('Received sdp offer from peer #' + peerId); self.answerCall(peerId); } else { trace('Received sdp ' + self.peerConns[peerId].remoteDescription.type + ' from peer #' + peerId); } }) .catch(function(error) { trace('Unable to set remote description for peer #' + peerId + ': ' + error); }); } else if( signal.candidate ){ this.handleCandidate(new RTCIceCandidate(signal.candidate), peerId); } else if( signal.closeConn ){ trace('Closing signal received from peer #' + peerId); this.endCall(peerId,true); } } } </code></pre>
0debug
static BlockAIOCB *bdrv_aio_readv_em(BlockDriverState *bs, int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, BlockCompletionFunc *cb, void *opaque) { return bdrv_aio_rw_vector(bs, sector_num, qiov, nb_sectors, cb, opaque, 0); }
1threat
How to connect RNN at the end of a CNN to use to train video frames? : <p>I'm trying to classify a video as image classification thus to use the frames as the classified method. But i have no idea how to code it out. I'm using Inception ResNet as my CNN but don't know any RNN or how to use them.</p>
0debug
I'm currently learning JavaScript and am having problems with my code : So I am practicing JavaScript in the Brackets Text Editor after learning a little bit of it on Codecademy. I want to alter the text in the p tags to gain (upon clicking the text) the properties set by the attribution class. Here is the HTML: <p onclick="function">Hello</p> CSS: .attribution{ color:blue; font-weight:bold; } Javascript: var main = function() { $('<p>').text('.attribution'); }; $(document).ready(main); Thank You!
0debug
How to Accelerate the Process of Multiple Image/file Upload from Client Browser to Server using Javascript? : I have to accelerate the process of file upload coz our application has to handle large files. looking for a good technique to improve file upload process.
0debug
Mock static java methods using Mockk : <p>We are currently working with java with kotlin project, slowly migrating the whole code to the latter.</p> <p>Is it possible to mock static methods like <code>Uri.parse()</code> using Mockk?</p> <p>How would the sample code look like?</p>
0debug
QGuestAllocator *pc_alloc_init(void) { PCAlloc *s = g_malloc0(sizeof(*s)); uint64_t ram_size; QFWCFG *fw_cfg = pc_fw_cfg_init(); s->alloc.alloc = pc_alloc; s->alloc.free = pc_free; ram_size = qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE); s->start = 1 << 20; s->end = MIN(ram_size, 0xE0000000); return &s->alloc; }
1threat
How to number values in string array with int : <p>I have some strings in string array. Now I wanna to give before first string prefix 1: string..etc</p> <p>Example:</p> <pre><code>Test Test Test </code></pre> <p>Expected result:</p> <pre><code>1. Test 2. Test 3. Test </code></pre> <p>Is that even possible? Thanks!</p>
0debug
how to do insertion in if and else condition of Triggers in sql server : create trigger thequery4 on employees instead of insert,delete as declare @var3 int select @var3=d.D_ID from inserted d,DEPARTMENTS dp where d.D_ID=dp.D_ID if( @var3 is null) begin print 'you are NOT allowed , B/C IS Its d_Id is not present in department ' end else begin ----insertion---- end
0debug
How to open a new box when clicked on a link : <p>I am a beginner in web developing world.</p> <p>I have a table of data fetched from mysql database shown in php. Now I want to create a link on each row which on click will open up a new box (not window) of specific width-height and will show detailed information.</p> <p>How can i do this ?</p>
0debug
python how to make a countdown : <p>Hello I have been trying to figure out to make a countdown I even tried searching but they where a bit different to what type I wanted the type of countdown I am trying to find/use is one where when the number goes down it does not create a new number in print what it does is edits the already placed number for example: I don't want</p> <pre><code>10 9 8 7 6 5 4 3 2 1 </code></pre> <p>I want it to delete the number 10 and replace it with 9 but I cannot figure it out</p>
0debug
static int ac3_decode_init(AVCodecContext *avctx) { AC3DecodeContext *ctx = avctx->priv_data; ac3_common_init(); ff_mdct_init(&ctx->imdct_ctx_256, 8, 1); ff_mdct_init(&ctx->imdct_ctx_512, 9, 1); ctx->samples = av_mallocz(6 * 256 * sizeof (float)); if (!ctx->samples) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate memory for samples\n"); return -1; } dither_seed(&ctx->state, 0); return 0; }
1threat
Are document.url and location.href considered part of the DOM? : Simply, Are `document.url` and `location.href`considered part of the DOM (Document object module)? Thanks!
0debug
Intellij IDEA 2016.2 high CPU usage : <p>I have only one project (an ordinary SpringFramework project) opened. And the IDE is crazy using CPU:</p> <p><a href="https://i.stack.imgur.com/mrlw9.png"><img src="https://i.stack.imgur.com/mrlw9.png" alt="enter image description here"></a></p> <p>JVisualVM CPU sample:</p> <p><a href="https://i.stack.imgur.com/B00GX.png"><img src="https://i.stack.imgur.com/B00GX.png" alt="enter image description here"></a></p> <p><strong>Note</strong> this happened just recently</p> <p>Any idea?</p>
0debug
What can I delete from ~/Library/Developer/Xcode folder? : <p>My <code>~/Library/Developer/Xcode</code> folder is over 17 gigs in size. As I work in virtual machine (Parallels 12) with a 64 gig limit in total virtual disk size, I need to recover some disk space.</p> <p>Amongst the folders such as “Archives”, “DerivedDate”, “Installs”, “iOS Device Logs”, “iOS DeviceSupport”, “Snapshots”, and “UserData”, what might I be able to delete without ruining my project?</p>
0debug
int chr_baum_init(QemuOpts *opts, CharDriverState **_chr) { BaumDriverState *baum; CharDriverState *chr; brlapi_handle_t *handle; #ifdef CONFIG_SDL SDL_SysWMinfo info; #endif int tty; baum = g_malloc0(sizeof(BaumDriverState)); baum->chr = chr = g_malloc0(sizeof(CharDriverState)); chr->opaque = baum; chr->chr_write = baum_write; chr->chr_accept_input = baum_accept_input; chr->chr_close = baum_close; handle = g_malloc0(brlapi_getHandleSize()); baum->brlapi = handle; baum->brlapi_fd = brlapi__openConnection(handle, NULL, NULL); if (baum->brlapi_fd == -1) { brlapi_perror("baum_init: brlapi_openConnection"); goto fail_handle; } baum->cellCount_timer = qemu_new_timer_ns(vm_clock, baum_cellCount_timer_cb, baum); if (brlapi__getDisplaySize(handle, &baum->x, &baum->y) == -1) { brlapi_perror("baum_init: brlapi_getDisplaySize"); goto fail; } #ifdef CONFIG_SDL memset(&info, 0, sizeof(info)); SDL_VERSION(&info.version); if (SDL_GetWMInfo(&info)) tty = info.info.x11.wmwindow; else #endif tty = BRLAPI_TTY_DEFAULT; if (brlapi__enterTtyMode(handle, tty, NULL) == -1) { brlapi_perror("baum_init: brlapi_enterTtyMode"); goto fail; } qemu_set_fd_handler(baum->brlapi_fd, baum_chr_read, NULL, baum); qemu_chr_generic_open(chr); *_chr = chr; return 0; fail: qemu_free_timer(baum->cellCount_timer); brlapi__closeConnection(handle); fail_handle: g_free(handle); g_free(chr); g_free(baum); return -EIO; }
1threat
How to call a named constructor from a generic function in Dart/Flutter : <p>I want to be able to construct an object from inside a generic function. I tried the following:</p> <pre><code>abstract class Interface { Interface.func(int x); } class Test implements Interface { Test.func(int x){} } T make&lt;T extends Interface&gt;(int x) { // the next line doesn't work return T.func(x); } </code></pre> <p>However, this doesn't work. And I get the following error message: <code>The method 'func' isn't defined for the class 'Type'</code>.</p> <p><strong>Note</strong>: I cannot use mirrors because I'm using dart with flutter.</p>
0debug