problem
stringlengths
26
131k
labels
class label
2 classes
R Shiny selectInput that is dependent on another selectInput : <p>I have some data below that I'm using to create a donut chart in R shiny, where <code>date</code> is a character. I want to be able to select the email whose score I want to view, but then in the second dropdown selection only see the dates for which that email has activity.</p> <p>For example, if I select email = xxxx in the first dropdown, I want to see only 'no activity' in the date selection field. And for email = yyyy, I want to see only 6/17/14, 6/18/14, 6/19/14 as selections. </p> <p>I've tried a sort of nested subsetting in the ui. Example:</p> <pre><code>&gt; ui &lt;- shinyUI(fluidPage( + sidebarLayout( + sidebarPanel( + selectInput('Select', 'Customer:', choices = unique(as.character(dat5$email))), + selectInput("User", "Date:", choices = dat5[dat5$email==input$Select,date]) + ), + mainPanel(plotOutput("distPlot")) + ) + )) </code></pre> <p>But this still shows all possible date selections</p> <p><strong>DATA</strong></p> <pre><code>email date variable value ymin ymax xxxx no activity e_score 0 0 0 xxxx no activity diff 1 0 1 yyyy 6/17/14 e_score 0.7472 0 0.7472 yyyy 6/17/14 diff 0.2528 0.7472 1 yyyy 6/18/14 e_score 0.373 0 0.373 yyyy 6/18/14 diff 0.627 0.373 1 yyyy 6/19/14 e_score 0.533 0 0.533 yyyy 6/19/14 diff 0.467 0.533 1 </code></pre> <p>My code so far:</p> <p><strong>app.R</strong></p> <pre><code>library(shiny) library(shinydashboard) ui &lt;- shinyUI(fluidPage( sidebarLayout( sidebarPanel( selectInput('Select', 'Customer:', choices = unique(as.character(dat5$email))), selectInput("User", "Date:", choices = unique(dat5$date) ) ), mainPanel(plotOutput("distPlot")) ) )) server &lt;- function(input, output) { output$distPlot &lt;- renderPlot({ ggplot(data = subset(dat5, (email %in% input$Select &amp; date %in% input$User)), aes(fill=variable, ymax = ymax, ymin = ymin, xmax = 4, xmin = 3)) + geom_rect(colour = "grey30", show_guide = F) + coord_polar(theta = "y") + geom_text(aes(x = 0, y = 0,label = round(value[1]*100))) + xlim(c(0, 4)) + theme_bw() + theme(panel.grid=element_blank()) + theme(axis.text=element_blank()) + theme(axis.ticks=element_blank()) + xlab("") + ylab("") + scale_fill_manual(values=c('#33FF00','#CCCCCC')) }) } shinyApp(ui = ui, server = server) </code></pre>
0debug
'Go Get' Private Repo from Bitbucket : <p>So basically, I have an Openshift Project that on Git push, downloads all libraries with 'Go get' and builds the project on-the-fly and so, I have some code I don't want people to see from my own library, and for it to compile properly, the code needs to be taken from github.com or another repo, so I created a private bitbucket.org repo, now, as a public repo it works fine, but when I try to 'Go Get' from my private repo, it gives me 'Forbidden 403' </p> <p>How can I avoid this occurency? Thank you for reading and have a nice day!</p>
0debug
how to load dictionary data in table view cell in ios swift? : Here i am getting data in xml and i have retrieved into dictionary to load in table view. Work flow - When user in home screen and taps on create button and it takes to next search product screen there user can able their amazon products. searched product are loaded into table view cell. My issue is when taps on create button table view tries to load data and its getting crash Crash line is results!.count. Here is the code i tried: var results: [[String: String]]? var currentDictionary: [String: String]? // the current dictionary var currentValue: String? // the current value for one of the keys in the dictionary let recordKey = "ItemAttributes" let dictionaryKeys = Set<String>(["Title"]) func parserDidStartDocument(_ parser: XMLParser) { results = [] } // start element // // - If we're starting a "record" create the dictionary that will hold the results // - If we're starting one of our dictionary keys, initialize `currentValue` (otherwise leave `nil`) func parser(_ parser: XMLParser, didStartElement elementName: String, namespaceURI: String?, qualifiedName qName: String?, attributes attributeDict: [String : String]) { if elementName == recordKey { currentDictionary = [:] } else if dictionaryKeys.contains(elementName) { currentValue = "" } } // found characters // // - If this is an element we care about, append those characters. // - If `currentValue` still `nil`, then do nothing. func parser(_ parser: XMLParser, foundCharacters string: String) { currentValue? += string } // end element // // - If we're at the end of the whole dictionary, then save that dictionary in our array // - If we're at the end of an element that belongs in the dictionary, then save that value in the dictionary func parser(_ parser: XMLParser, didEndElement elementName: String, namespaceURI: String?, qualifiedName qName: String?) { if elementName == recordKey { results!.append(currentDictionary!) currentDictionary = nil } else if dictionaryKeys.contains(elementName) { currentDictionary![elementName] = currentValue currentValue = nil } } // Just in case, if there's an error, report it. (We don't want to fly blind here.) func parser(_ parser: XMLParser, parseErrorOccurred parseError: Error) { print(parseError) currentValue = nil currentDictionary = nil results = nil } // func numberOfSectionsInTableView(tableView: UITableView) -> Int { // return 1 // } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return results!.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath as IndexPath) as! amazonProductListTableViewCell let productlist = ProductName[indexPath.row] print("prodic:::\(productlist)") // cell.amazonProductTitle?.text = productlist[indexPath.row] // cell.detailTextLabel?.text = book.bookAuthor return cell }
0debug
trying to find blank columns in csv file with python : import csv f = open('E:\pythontest\ip_data.csv') csv_f = csv.reader(f) for row in csv_f: row_count = sum(1 for row in csv_f) + 1 print row_count now i m trying to find columns have spaces and count them ,can anyone please guide me though this
0debug
how to conduct multi-thread with task in C sharp? : Do you have a better way to do multi-thread? GenericLoad newload = new GenericLoad(); Task<IList<List<string>>> task1 = Task<IList<List<string>>>.Factory.StartNew(() => newload.Parse(CSVFile1, ',')); Task<IList<List<string>>> task2 = Task<IList<List<string>>>.Factory.StartNew(() => newload.Parse(CSVFile2, '|')); task1.wait(); task2.wait(); PrintCSV(task1.Result); PrintCSV(task2.Result); task1.Dispose(); task1.Dispose();
0debug
Registration form will no longer appear after register in android studio : How create a registration that after you register it wil no longer appear in the next open of the application? Pls help , i need it in our next class , thank you so much for your responding
0debug
static int ftp_getc(FTPContext *s) { int len; if (s->control_buf_ptr >= s->control_buf_end) { if (s->conn_control_block_flag) return AVERROR_EXIT; len = ffurl_read(s->conn_control, s->control_buffer, CONTROL_BUFFER_SIZE); if (len < 0) { return len; } else if (!len) { return -1; } else { s->control_buf_ptr = s->control_buffer; s->control_buf_end = s->control_buffer + len; } } return *s->control_buf_ptr++; }
1threat
Assignment at class level seperately from variable declaration : class Type { int s; s=10; public static void main(String[]args) { System.out.println(s); } } this program creates <identifier> expected error at **s=10** why?but when we write(int s;s=10;)in main program then it doesn't create any error at s=10 why? Assigning values at class level seperately from variable declaration
0debug
How to configure NDK for Android Studio : <p>I've installed Android Studio 2.2.3 and created a "myApplication" with <code>include C++ support</code>. I get this error: </p> <p><em>Error:NDK not configured.<br> Download it with SDK manager.)</em></p> <p>Is there any good way to solve it please?</p>
0debug
Python: How can i indent two "if" : I am following a tutorial in french about Python, and either in IDLE and terminal, i have some problems. [Picture from tutorial][1] [My attempt who failed][2] [1]: https://i.stack.imgur.com/mq2Lp.png [2]: https://i.stack.imgur.com/KAT8o.png I cannot go to my second condition if without print "pos". Someone have an idea ?
0debug
static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c, int payload_type, AVFormatContext *fmt) { char *config = NULL; switch (c->codec_id) { case AV_CODEC_ID_H264: { int mode = 1; if (fmt && fmt->oformat && fmt->oformat->priv_class && av_opt_flag_is_set(fmt->priv_data, "rtpflags", "h264_mode0")) mode = 0; if (c->extradata_size) { config = extradata2psets(c); } av_strlcatf(buff, size, "a=rtpmap:%d H264/90000\r\n" "a=fmtp:%d packetization-mode=%d%s\r\n", payload_type, payload_type, mode, config ? config : ""); break; } case AV_CODEC_ID_H263: case AV_CODEC_ID_H263P: if (!fmt || !fmt->oformat->priv_class || !av_opt_flag_is_set(fmt->priv_data, "rtpflags", "rfc2190") || c->codec_id == AV_CODEC_ID_H263P) av_strlcatf(buff, size, "a=rtpmap:%d H263-2000/90000\r\n" "a=framesize:%d %d-%d\r\n", payload_type, payload_type, c->width, c->height); break; case AV_CODEC_ID_HEVC: if (c->extradata_size) av_log(NULL, AV_LOG_WARNING, "HEVC extradata not currently " "passed properly through SDP\n"); av_strlcatf(buff, size, "a=rtpmap:%d H265/90000\r\n", payload_type); break; case AV_CODEC_ID_MPEG4: if (c->extradata_size) { config = extradata2config(c); } av_strlcatf(buff, size, "a=rtpmap:%d MP4V-ES/90000\r\n" "a=fmtp:%d profile-level-id=1%s\r\n", payload_type, payload_type, config ? config : ""); break; case AV_CODEC_ID_AAC: if (fmt && fmt->oformat->priv_class && av_opt_flag_is_set(fmt->priv_data, "rtpflags", "latm")) { config = latm_context2config(c); if (!config) return NULL; av_strlcatf(buff, size, "a=rtpmap:%d MP4A-LATM/%d/%d\r\n" "a=fmtp:%d profile-level-id=%d;cpresent=0;config=%s\r\n", payload_type, c->sample_rate, c->channels, payload_type, latm_context2profilelevel(c), config); } else { if (c->extradata_size) { config = extradata2config(c); } else { av_log(c, AV_LOG_ERROR, "AAC with no global headers is currently not supported.\n"); return NULL; } if (!config) { return NULL; } av_strlcatf(buff, size, "a=rtpmap:%d MPEG4-GENERIC/%d/%d\r\n" "a=fmtp:%d profile-level-id=1;" "mode=AAC-hbr;sizelength=13;indexlength=3;" "indexdeltalength=3%s\r\n", payload_type, c->sample_rate, c->channels, payload_type, config); } break; case AV_CODEC_ID_PCM_S16BE: if (payload_type >= RTP_PT_PRIVATE) av_strlcatf(buff, size, "a=rtpmap:%d L16/%d/%d\r\n", payload_type, c->sample_rate, c->channels); break; case AV_CODEC_ID_PCM_MULAW: if (payload_type >= RTP_PT_PRIVATE) av_strlcatf(buff, size, "a=rtpmap:%d PCMU/%d/%d\r\n", payload_type, c->sample_rate, c->channels); break; case AV_CODEC_ID_PCM_ALAW: if (payload_type >= RTP_PT_PRIVATE) av_strlcatf(buff, size, "a=rtpmap:%d PCMA/%d/%d\r\n", payload_type, c->sample_rate, c->channels); break; case AV_CODEC_ID_AMR_NB: av_strlcatf(buff, size, "a=rtpmap:%d AMR/%d/%d\r\n" "a=fmtp:%d octet-align=1\r\n", payload_type, c->sample_rate, c->channels, payload_type); break; case AV_CODEC_ID_AMR_WB: av_strlcatf(buff, size, "a=rtpmap:%d AMR-WB/%d/%d\r\n" "a=fmtp:%d octet-align=1\r\n", payload_type, c->sample_rate, c->channels, payload_type); break; case AV_CODEC_ID_VORBIS: if (c->extradata_size) config = xiph_extradata2config(c); else av_log(c, AV_LOG_ERROR, "Vorbis configuration info missing\n"); if (!config) return NULL; av_strlcatf(buff, size, "a=rtpmap:%d vorbis/%d/%d\r\n" "a=fmtp:%d configuration=%s\r\n", payload_type, c->sample_rate, c->channels, payload_type, config); break; case AV_CODEC_ID_THEORA: { const char *pix_fmt; switch (c->pix_fmt) { case AV_PIX_FMT_YUV420P: pix_fmt = "YCbCr-4:2:0"; break; case AV_PIX_FMT_YUV422P: pix_fmt = "YCbCr-4:2:2"; break; case AV_PIX_FMT_YUV444P: pix_fmt = "YCbCr-4:4:4"; break; default: av_log(c, AV_LOG_ERROR, "Unsupported pixel format.\n"); return NULL; } if (c->extradata_size) config = xiph_extradata2config(c); else av_log(c, AV_LOG_ERROR, "Theora configuation info missing\n"); if (!config) return NULL; av_strlcatf(buff, size, "a=rtpmap:%d theora/90000\r\n" "a=fmtp:%d delivery-method=inline; " "width=%d; height=%d; sampling=%s; " "configuration=%s\r\n", payload_type, payload_type, c->width, c->height, pix_fmt, config); break; } case AV_CODEC_ID_VP8: av_strlcatf(buff, size, "a=rtpmap:%d VP8/90000\r\n", payload_type); break; case AV_CODEC_ID_MJPEG: if (payload_type >= RTP_PT_PRIVATE) av_strlcatf(buff, size, "a=rtpmap:%d JPEG/90000\r\n", payload_type); break; case AV_CODEC_ID_ADPCM_G722: if (payload_type >= RTP_PT_PRIVATE) av_strlcatf(buff, size, "a=rtpmap:%d G722/%d/%d\r\n", payload_type, 8000, c->channels); break; case AV_CODEC_ID_ADPCM_G726: { if (payload_type >= RTP_PT_PRIVATE) av_strlcatf(buff, size, "a=rtpmap:%d G726-%d/%d\r\n", payload_type, c->bits_per_coded_sample*8, c->sample_rate); break; } case AV_CODEC_ID_ILBC: av_strlcatf(buff, size, "a=rtpmap:%d iLBC/%d\r\n" "a=fmtp:%d mode=%d\r\n", payload_type, c->sample_rate, payload_type, c->block_align == 38 ? 20 : 30); break; case AV_CODEC_ID_SPEEX: av_strlcatf(buff, size, "a=rtpmap:%d speex/%d\r\n", payload_type, c->sample_rate); break; case AV_CODEC_ID_OPUS: av_strlcatf(buff, size, "a=rtpmap:%d opus/48000/2\r\n", payload_type); if (c->channels == 2) { av_strlcatf(buff, size, "a=fmtp:%d sprop-stereo:1\r\n", payload_type); } break; default: break; } av_free(config); return buff; }
1threat
static void bonito_spciconf_writeb(void *opaque, target_phys_addr_t addr, uint32_t val) { PCIBonitoState *s = opaque; PCIDevice *d = PCI_DEVICE(s); PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost); uint32_t pciaddr; uint16_t status; DPRINTF("bonito_spciconf_writeb "TARGET_FMT_plx" val %x\n", addr, val); pciaddr = bonito_sbridge_pciaddr(s, addr); if (pciaddr == 0xffffffff) { return; } phb->config_reg = (pciaddr) | (1u << 31); pci_data_write(phb->bus, phb->config_reg, val & 0xff, 1); status = pci_get_word(d->config + PCI_STATUS); status &= ~(PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT); pci_set_word(d->config + PCI_STATUS, status); }
1threat
static int get_packet(URLContext *s, int for_header) { RTMPContext *rt = s->priv_data; int ret; uint8_t *p; const uint8_t *next; uint32_t data_size; uint32_t ts, cts, pts=0; if (rt->state == STATE_STOPPED) return AVERROR_EOF; for (;;) { RTMPPacket rpkt = { 0 }; if ((ret = ff_rtmp_packet_read(rt->stream, &rpkt, rt->chunk_size, rt->prev_pkt[0])) <= 0) { if (ret == 0) { return AVERROR(EAGAIN); } else { return AVERROR(EIO); } } rt->bytes_read += ret; if (rt->bytes_read > rt->last_bytes_read + rt->client_report_size) { av_log(s, AV_LOG_DEBUG, "Sending bytes read report\n"); gen_bytes_read(s, rt, rpkt.timestamp + 1); rt->last_bytes_read = rt->bytes_read; } ret = rtmp_parse_result(s, rt, &rpkt); if (ret < 0) { ff_rtmp_packet_destroy(&rpkt); return -1; } if (rt->state == STATE_STOPPED) { ff_rtmp_packet_destroy(&rpkt); return AVERROR_EOF; } if (for_header && (rt->state == STATE_PLAYING || rt->state == STATE_PUBLISHING)) { ff_rtmp_packet_destroy(&rpkt); return 0; } if (!rpkt.data_size || !rt->is_input) { ff_rtmp_packet_destroy(&rpkt); continue; } if (rpkt.type == RTMP_PT_VIDEO || rpkt.type == RTMP_PT_AUDIO || (rpkt.type == RTMP_PT_NOTIFY && !memcmp("\002\000\012onMetaData", rpkt.data, 13))) { ts = rpkt.timestamp; rt->flv_off = 0; rt->flv_size = rpkt.data_size + 15; rt->flv_data = p = av_realloc(rt->flv_data, rt->flv_size); bytestream_put_byte(&p, rpkt.type); bytestream_put_be24(&p, rpkt.data_size); bytestream_put_be24(&p, ts); bytestream_put_byte(&p, ts >> 24); bytestream_put_be24(&p, 0); bytestream_put_buffer(&p, rpkt.data, rpkt.data_size); bytestream_put_be32(&p, 0); ff_rtmp_packet_destroy(&rpkt); return 0; } else if (rpkt.type == RTMP_PT_METADATA) { rt->flv_off = 0; rt->flv_size = rpkt.data_size; rt->flv_data = av_realloc(rt->flv_data, rt->flv_size); next = rpkt.data; ts = rpkt.timestamp; while (next - rpkt.data < rpkt.data_size - 11) { next++; data_size = bytestream_get_be24(&next); p=next; cts = bytestream_get_be24(&next); cts |= bytestream_get_byte(&next) << 24; if (pts==0) pts=cts; ts += cts - pts; pts = cts; bytestream_put_be24(&p, ts); bytestream_put_byte(&p, ts >> 24); next += data_size + 3 + 4; } memcpy(rt->flv_data, rpkt.data, rpkt.data_size); ff_rtmp_packet_destroy(&rpkt); return 0; } ff_rtmp_packet_destroy(&rpkt); } return 0; }
1threat
bool aio_prepare(AioContext *ctx) { poll_set_started(ctx, false); return false; }
1threat
Why are you allowed to call one constructor from another? : <p>I was looking at other questions on SO, but I didn't really see an explanation for my question. I read that calling a constructor from another constructor (using the this keyword) was <em>valid</em>, but I didn't understand <em>why</em> it was valid.</p> <p>Previously, I thought that only one constructor could act per object. Constructor chaining seems to break this logic, in that while calling one constructor, it runs another in conjunction to the original, targeted constructor. Why does constructor chaining work?</p>
0debug
static int zero_single_l2(BlockDriverState *bs, uint64_t offset, uint64_t nb_clusters, int flags) { BDRVQcow2State *s = bs->opaque; uint64_t *l2_table; int l2_index; int ret; int i; ret = get_cluster_table(bs, offset, &l2_table, &l2_index); if (ret < 0) { return ret; } nb_clusters = MIN(nb_clusters, s->l2_size - l2_index); assert(nb_clusters <= INT_MAX); for (i = 0; i < nb_clusters; i++) { uint64_t old_offset; old_offset = be64_to_cpu(l2_table[l2_index + i]); qcow2_cache_entry_mark_dirty(bs, s->l2_table_cache, l2_table); if (old_offset & QCOW_OFLAG_COMPRESSED || flags & BDRV_REQ_MAY_UNMAP) { l2_table[l2_index + i] = cpu_to_be64(QCOW_OFLAG_ZERO); qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUEST); } else { l2_table[l2_index + i] |= cpu_to_be64(QCOW_OFLAG_ZERO); } } qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table); return nb_clusters; }
1threat
Create responsive Bootstrap navbar with two rows : <p>I am trying to create a responsive Bootstrap 3 based navbar with two rows. However, I am having trouble with the structure of the HTML and the collapse functionality.</p> <p>Below is a visual description of the desired result, and I was hoping someone could point me in the right direction in terms of HTML/CSS (with as much default Bootstrap functionality as possible).</p> <p><strong>Essentially the menu is desired to do the following:</strong></p> <ul> <li><p>On tablet/desktop devices, the first row is the logo and a menu of small secondary links (Link1-3). The second row is the main menu with main links (LinkA-E).</p></li> <li><p>On mobile, the classic collapse design should appear with the logo and hamburger icon. The expanded menu should show the main links (LinkA-E) first, and then the secondary links (Link1-3) last.</p></li> </ul> <p><strong>Tablet/Desktop device:</strong></p> <pre><code>|----------------------------------------------------------| | LOGO/BRAND Link1 Link2 Link3 | |----------------------------------------------------------| | LinkA LinkB LinkC LindD LinkE | |----------------------------------------------------------| </code></pre> <p><strong>Mobile device (collapsed):</strong></p> <pre><code>|--------------------------------------| | LOGO/BRAND HAMBURGER | |--------------------------------------| </code></pre> <p><strong>Mobile device (expanded):</strong></p> <pre><code>|--------------------------------------| | LOGO/BRAND HAMBURGER | |--------------------------------------| | LinkA | | LinkB | | LinkC | | LinkD | | LinkE | |--------------------------------------| | Link1 | | Link2 | | Link3 | |--------------------------------------| </code></pre>
0debug
Simple issue HTML/CSS not working : <p>The stylesheet is linked correctly. I have not done HTML/CSS in ages, however, this seems straight forward. What is not correct?</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.box{ width:100px; height:100px; } .box #1{ border: 1px solid red; } .box #2{ border: 1px solid blue; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" type="text/css" href="style.css"&gt; &lt;/head&gt; &lt;body&gt; The content of the document...... &lt;div class = "box" id = "1"&gt;&lt;/div&gt; &lt;div class = "box" id = "2"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
0debug
static void qemu_sgl_init_external(VirtIOSCSIReq *req, struct iovec *sg, hwaddr *addr, int num) { QEMUSGList *qsgl = &req->qsgl; qemu_sglist_init(qsgl, DEVICE(req->dev), num, &address_space_memory); while (num--) { qemu_sglist_add(qsgl, *(addr++), (sg++)->iov_len); } }
1threat
static TCGv_i32 read_fp_sreg(DisasContext *s, int reg) { TCGv_i32 v = tcg_temp_new_i32(); tcg_gen_ld_i32(v, cpu_env, fp_reg_offset(reg, MO_32)); return v; }
1threat
window.location.href = 'http://attack.com?user=' + user_input;
1threat
void ff_fix_long_p_mvs(MpegEncContext * s) { const int f_code= s->f_code; int y; UINT8 * fcode_tab= s->fcode_tab; for(y=0; y<s->mb_height; y++){ int x; int xy= (y+1)* (s->mb_width+2)+1; int i= y*s->mb_width; for(x=0; x<s->mb_width; x++){ if(s->mb_type[i]&MB_TYPE_INTER){ if( fcode_tab[s->p_mv_table[xy][0] + MAX_MV] > f_code || fcode_tab[s->p_mv_table[xy][0] + MAX_MV] == 0 || fcode_tab[s->p_mv_table[xy][1] + MAX_MV] > f_code || fcode_tab[s->p_mv_table[xy][1] + MAX_MV] == 0 ){ s->mb_type[i] &= ~MB_TYPE_INTER; s->mb_type[i] |= MB_TYPE_INTRA; s->p_mv_table[xy][0] = 0; s->p_mv_table[xy][1] = 0; } } xy++; i++; } } if(s->flags&CODEC_FLAG_4MV){ const int wrap= 2+ s->mb_width*2; for(y=0; y<s->mb_height; y++){ int xy= (y*2 + 1)*wrap + 1; int i= y*s->mb_width; int x; for(x=0; x<s->mb_width; x++){ if(s->mb_type[i]&MB_TYPE_INTER4V){ int block; for(block=0; block<4; block++){ int off= (block& 1) + (block>>1)*wrap; int mx= s->motion_val[ xy + off ][0]; int my= s->motion_val[ xy + off ][1]; if( fcode_tab[mx + MAX_MV] > f_code || fcode_tab[mx + MAX_MV] == 0 || fcode_tab[my + MAX_MV] > f_code || fcode_tab[my + MAX_MV] == 0 ){ s->mb_type[i] &= ~MB_TYPE_INTER4V; s->mb_type[i] |= MB_TYPE_INTRA; } } xy+=2; i++; } } } } }
1threat
ECR - What is the registry and what is a repository : <p>Trying to familiarize myself with ECR - i understand that you should be able to push as many repositories as you like to Docker registry.</p> <p>However, ECR has a concept of a 'repository'. So if i have 10 different containers comprising my app, does it mean i need 10 repositories in a registry? </p> <p>Can i have one repository and push 10 different containers with their 'latest' tags?</p> <p>Currently if i tag another image with the same {registry}/{repository_name} pattern, it replaces <code>latest</code> tag on my other image:</p> <p><a href="https://i.stack.imgur.com/P7hKy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/P7hKy.png" alt="ECR overview"></a></p>
0debug
Why is "auto const&" not read-only? : <pre><code>#include &lt;tuple&gt; int main() { int xa = 1; int ya = 2; auto const&amp; [xb, yb] = std::tuple&lt;int&amp;, int&amp;&gt;(xa, ya); xb = 9; // Shouldn't this be read-only? return xa + ya; } </code></pre> <p>This not only compiles, but returns 11. </p> <p>So two questions:</p> <ol> <li><p>Why am I allowed to write to xb when it is specified as auto const&amp;? Shouldn't this fail to compile?</p></li> <li><p>Why can't I replace "auto const&amp;" with "auto&amp;" and have it compile? Both Clang (6.0) and g++ (7.3) complain with an error message like "non-const lvalue reference of type&lt;...> cannot bind to temporary of type tuple&lt;...>"</p></li> </ol> <p>Thanks!</p>
0debug
static int kvm_put_tscdeadline_msr(X86CPU *cpu) { CPUX86State *env = &cpu->env; struct { struct kvm_msrs info; struct kvm_msr_entry entries[1]; } msr_data; struct kvm_msr_entry *msrs = msr_data.entries; if (!has_msr_tsc_deadline) { return 0; } kvm_msr_entry_set(&msrs[0], MSR_IA32_TSCDEADLINE, env->tsc_deadline); msr_data.info.nmsrs = 1; return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_MSRS, &msr_data); }
1threat
How to call object T from constructor copy T(const T&)? : <p>I have a copy constructor <code>T::T(const T&amp;)</code>. The object has two properties, let's say <code>color</code> and <code>height</code>. This means I need to assign the color and the height from the object in argument to my object. Problem is I don't know how to call the argument because it is not named.</p> <p>If the argument is named, let's say <strong>t</strong>, code looks like this:</p> <pre><code>T::T(const T&amp; t) { color = t.color height = t.height } </code></pre> <p>But in my case there's no <strong>t</strong> argument. What should I replace the question mark <code>?</code> with in the following code:</p> <pre><code>T::T(const T&amp;) { color = ?.color height = ?.height } </code></pre> <p>Thanks for help!</p>
0debug
Run Laravel project on local setup : <p>I have a project which was completed earlier by previous developer team using laravel framework and it is hosted on live. </p> <p>I have downloaded the source code using FTP 'Filezilla' from the live server and have the full project folder or the hard drive.</p> <p>Now In order to make changes and understand I want to set it locally.</p> <p>I want to set it up in local environment where I use WAMP server.</p> <p>Please suggest me how can I proceed and in which All files I have to make changes.</p> <p>So please tell me how can I install the same . It will be helpful if step-by step instruction can be provided.</p> <p>I am new to laravel and wanting to learn the framework. Please help</p> <p>Thanks in Advance.</p>
0debug
Why are certain variables marked as final in flutter custom classes? : <p>I noticed in some of the examples online that classes that extend <code>StatefulWidget</code> have instance variables marked with final. Why is that ? I understand what final keyword does.I do not understand why it is being declared with each instance variable that extends the widget class.</p>
0debug
How to parse below JSON response in android : { "status": true, "data": { "1": "Business People", "2": "Actors", "3": "Musicians", "4": "Sports People", "5": "Artists", "6": "Politicians" }, "message": "Get data successfully." }
0debug
Reload a page with location.href or window.location.reload(true) : <p>I need to reload a page in a success of an ajax call.</p> <p>I'm seeing some code (not mine) and there are two ways:</p> <pre><code>success : function(obj) { //code location.href = location.href; } </code></pre> <p>or</p> <pre><code>success : function(obj) { //code window.location.reload(true); } </code></pre> <p>Is there any difference in the behaviour? I know the difference of both location and window.location but in terms of do the job?</p>
0debug
static unsigned tget_long(GetByteContext *gb, int le) { unsigned v = le ? bytestream2_get_le32u(gb) : bytestream2_get_be32u(gb); return v; }
1threat
Android studio declaring activity in AndroidManifest : [enter image description here][1] [1]: https://i.stack.imgur.com/F6O7b.png I started yesterday with developing app on Android Studio and I am not sure how to declare my activity in AndroidManifest. I read the post on https://stackoverflow.com/questions/19122386/activity-declaration-in-androidmanifest-xml but I am still not sure what to put for the name and label and how to find their exact names. I would really appreciate your help and thank you.
0debug
Stylus linter (stylint) for vscode : <p>Repository <a href="https://github.com/SimenB/stylint" rel="noreferrer">Stylint</a> indicates that linter works in:</p> <ul> <li>Atom</li> <li>Sublime Text</li> <li>WebStorm / PhpStorm / IntelliJ IDEA</li> <li>Visual Studio Code</li> </ul> <p>In Atom it works perfectly. From CLI too. </p> <p>Link from repository to vscode extension: <a href="https://marketplace.visualstudio.com/items?itemName=vtfn.stylint" rel="noreferrer">Stylint</a>. Link from marketplace to <a href="https://github.com/vtfn/vscode-stylint" rel="noreferrer">github repository</a> - 404. Extension doesn't provide any description or commands (most likely it's removed or broken). </p> <p>How do I lint stylus?</p>
0debug
Mocking Bigquery for integration tests : <p>While other interfaces are relatively easy to mock in my Java integration tests, I couldn't find a proper way of mocking Bigquery.</p> <p>One possibility is to mock the layer I wrote on top of Bigquery itself, but I prefer mocking Bigquery in a more natural way. I'm looking for a limited, lightweight implementation, which allows defining the table contents, and supports queries using the standard API. Is there such a library? If not, what alternative approaches are recommended?</p>
0debug
how to make all resources files in anroid archive library public in my app android : i made android application then i want to use some activities from it in another application as part of new app [Error][1] [1]: https://i.stack.imgur.com/f3Z5D.png
0debug
What is the purpose of "pm2 save"? : <p>I am using pm2 to manage my node.js processes. Very happy with it so far.</p> <p>What is the purpose of <code>$ pm2 save</code>? What is the purpose of saving a process list? I don't quite understand from the documentation. <a href="https://github.com/Unitech/pm2" rel="noreferrer">https://github.com/Unitech/pm2</a></p>
0debug
void url_split(char *proto, int proto_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url) { const char *p; char *q; int port; port = -1; p = url; q = proto; while (*p != ':' && *p != '\0') { if ((q - proto) < proto_size - 1) *q++ = *p; p++; } if (proto_size > 0) *q = '\0'; if (*p == '\0') { if (proto_size > 0) proto[0] = '\0'; if (hostname_size > 0) hostname[0] = '\0'; p = url; } else { p++; if (*p == '/') p++; if (*p == '/') p++; q = hostname; while (*p != ':' && *p != '/' && *p != '?' && *p != '\0') { if ((q - hostname) < hostname_size - 1) *q++ = *p; p++; } if (hostname_size > 0) *q = '\0'; if (*p == ':') { p++; port = strtoul(p, (char **)&p, 10); } } if (port_ptr) *port_ptr = port; pstrcpy(path, path_size, p); }
1threat
static int vscsi_send_adapter_info(VSCSIState *s, vscsi_req *req) { struct viosrp_adapter_info *sinfo; struct mad_adapter_info_data info; int rc; sinfo = &req->iu.mad.adapter_info; #if 0 rc = spapr_tce_dma_read(&s->vdev, be64_to_cpu(sinfo->buffer), &info, be16_to_cpu(sinfo->common.length)); if (rc) { fprintf(stderr, "vscsi_send_adapter_info: DMA read failure !\n"); } #endif memset(&info, 0, sizeof(info)); strcpy(info.srp_version, SRP_VERSION); strncpy(info.partition_name, "qemu", sizeof("qemu")); info.partition_number = cpu_to_be32(0); info.mad_version = cpu_to_be32(1); info.os_type = cpu_to_be32(2); info.port_max_txu[0] = cpu_to_be32(VSCSI_MAX_SECTORS << 9); rc = spapr_tce_dma_write(&s->vdev, be64_to_cpu(sinfo->buffer), &info, be16_to_cpu(sinfo->common.length)); if (rc) { fprintf(stderr, "vscsi_send_adapter_info: DMA write failure !\n"); } sinfo->common.status = rc ? cpu_to_be32(1) : 0; return vscsi_send_iu(s, req, sizeof(*sinfo), VIOSRP_MAD_FORMAT); }
1threat
Java: I want to read a text file, split it based on column value into multiple files : public class FileSplitter2 { public static void main(String[] args) throws IOException { String filepath = "D:\\temp\\test.txt"; BufferedReader reader = new BufferedReader(new FileReader(filepath)); String strLine; boolean isFirst = true; String strGroupByColumnName = "city"; int positionOgHeader = 0; FileWriter objFileWriter; Map<String, FileWriter> groupByMap = new HashMap<String, FileWriter>(); while ((strLine = reader.readLine()) != null) { String[] splitted = strLine.split(","); if (isFirst) { isFirst = false; for (int i = 0; i < splitted.length; i++) { if (splitted[i].equalsIgnoreCase(strGroupByColumnName)) { positionOgHeader = i; break; } } } String strKey = splitted[positionOgHeader]; if (!groupByMap.containsKey(strKey)) { groupByMap.put(strKey, new FileWriter("D:/TestExample/" + strKey + ".txt")); } FileWriter fileWriter = groupByMap.get(strKey); fileWriter.write(strLine); } for (Map.Entry<String,FileWriter> entry : groupByMap.entrySet()) { entry.getKey(); } } } This is my code.. i am not getting proper result.. Someone please help me out..the file contains 10 columns and 5th column is city.. they are 10 different cities in a file.. i need to split each city in a separate file...
0debug
static void usb_host_speed_compat(USBHostDevice *s) { USBDevice *udev = USB_DEVICE(s); struct libusb_config_descriptor *conf; const struct libusb_interface_descriptor *intf; const struct libusb_endpoint_descriptor *endp; #ifdef HAVE_STREAMS struct libusb_ss_endpoint_companion_descriptor *endp_ss_comp; #endif bool compat_high = true; bool compat_full = true; uint8_t type; int rc, c, i, a, e; for (c = 0;; c++) { rc = libusb_get_config_descriptor(s->dev, c, &conf); if (rc != 0) { break; } for (i = 0; i < conf->bNumInterfaces; i++) { for (a = 0; a < conf->interface[i].num_altsetting; a++) { intf = &conf->interface[i].altsetting[a]; for (e = 0; e < intf->bNumEndpoints; e++) { endp = &intf->endpoint[e]; type = endp->bmAttributes & 0x3; switch (type) { case 0x01: compat_full = false; compat_high = false; break; case 0x02: #ifdef HAVE_STREAMS rc = libusb_get_ss_endpoint_companion_descriptor (ctx, endp, &endp_ss_comp); if (rc == LIBUSB_SUCCESS) { libusb_free_ss_endpoint_companion_descriptor (endp_ss_comp); compat_full = false; compat_high = false; } #endif break; case 0x03: if (endp->wMaxPacketSize > 64) { compat_full = false; } if (endp->wMaxPacketSize > 1024) { compat_high = false; } break; } } } } libusb_free_config_descriptor(conf); } udev->speedmask = (1 << udev->speed); if (udev->speed == USB_SPEED_SUPER && compat_high) { udev->speedmask |= USB_SPEED_MASK_HIGH; } if (udev->speed == USB_SPEED_SUPER && compat_full) { udev->speedmask |= USB_SPEED_MASK_FULL; } if (udev->speed == USB_SPEED_HIGH && compat_full) { udev->speedmask |= USB_SPEED_MASK_FULL; } }
1threat
What's the best way (in Android dev) to consume REST API (in addition to Retrofit)? : <p>I quite new in Android developing platform (I'm frontender who has been using jQuery and now Angular2 (for 5 months) with RxJs ). I used to code in core-Java in past for one year (6 years ago), so I'm little familiar with Java.</p> <p>As I'm familiar with consuming REST API by using jQuery/Angular2 (which is really easy thing) I was wondering if there is any Android-framework to do that, or my only option is Retrofit, because I found it tangled to use.</p>
0debug
Get file size of PHAsset without loading in the resource? : <p>Is there a way to get the file size on disk of a <code>PHAsset</code> without doing <code>requestImageDataForAsset</code> or converting it to <code>ALAsset</code>? I am loading in previews of a user's photo library - potentially many thousands of them - and it's imperative to my app that they know the size before import. </p>
0debug
How to make a table in python with adding data from one column to make one row : [I have a csv file that I need to make into a table][1] [How can I make a table with the first column being each year 2019 2018 etc and the second the total debited each year and the next column the total credited like this][2] [1]: https://i.stack.imgur.com/Kv6Lk.png [2]: https://i.stack.imgur.com/gclPw.png
0debug
static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2, bool parallel) { #if !defined(CONFIG_USER_ONLY) || defined(CONFIG_ATOMIC128) uint32_t mem_idx = cpu_mmu_index(env, false); #endif uintptr_t ra = GETPC(); uint32_t fc = extract32(env->regs[0], 0, 8); uint32_t sc = extract32(env->regs[0], 8, 8); uint64_t pl = get_address(env, 1) & -16; uint64_t svh, svl; uint32_t cc; if (fc > 1 || sc > 3) { if (!s390_has_feat(S390_FEAT_COMPARE_AND_SWAP_AND_STORE_2)) { goto spec_exception; } if (fc > 2 || sc > 4 || (fc == 2 && (r3 & 1))) { goto spec_exception; } } if (extract32(a1, 0, 4 << fc) || extract32(a2, 0, 1 << sc)) { goto spec_exception; } #ifndef CONFIG_USER_ONLY probe_write(env, a2, mem_idx, ra); #endif if (parallel) { int mask = 0; #if !defined(CONFIG_ATOMIC64) mask = -8; #elif !defined(CONFIG_ATOMIC128) mask = -16; #endif if (((4 << fc) | (1 << sc)) & mask) { cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } } svh = cpu_ldq_data_ra(env, pl + 16, ra); svl = cpu_ldq_data_ra(env, pl + 24, ra); switch (fc) { case 0: { uint32_t nv = cpu_ldl_data_ra(env, pl, ra); uint32_t cv = env->regs[r3]; uint32_t ov; if (parallel) { #ifdef CONFIG_USER_ONLY uint32_t *haddr = g2h(a1); ov = atomic_cmpxchg__nocheck(haddr, cv, nv); #else TCGMemOpIdx oi = make_memop_idx(MO_TEUL | MO_ALIGN, mem_idx); ov = helper_atomic_cmpxchgl_be_mmu(env, a1, cv, nv, oi, ra); #endif } else { ov = cpu_ldl_data_ra(env, a1, ra); cpu_stl_data_ra(env, a1, (ov == cv ? nv : ov), ra); } cc = (ov != cv); env->regs[r3] = deposit64(env->regs[r3], 32, 32, ov); } break; case 1: { uint64_t nv = cpu_ldq_data_ra(env, pl, ra); uint64_t cv = env->regs[r3]; uint64_t ov; if (parallel) { #ifdef CONFIG_ATOMIC64 # ifdef CONFIG_USER_ONLY uint64_t *haddr = g2h(a1); ov = atomic_cmpxchg__nocheck(haddr, cv, nv); # else TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN, mem_idx); ov = helper_atomic_cmpxchgq_be_mmu(env, a1, cv, nv, oi, ra); # endif #else g_assert_not_reached(); #endif } else { ov = cpu_ldq_data_ra(env, a1, ra); cpu_stq_data_ra(env, a1, (ov == cv ? nv : ov), ra); } cc = (ov != cv); env->regs[r3] = ov; } break; case 2: { uint64_t nvh = cpu_ldq_data_ra(env, pl, ra); uint64_t nvl = cpu_ldq_data_ra(env, pl + 8, ra); Int128 nv = int128_make128(nvl, nvh); Int128 cv = int128_make128(env->regs[r3 + 1], env->regs[r3]); Int128 ov; if (parallel) { #ifdef CONFIG_ATOMIC128 TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); ov = helper_atomic_cmpxchgo_be_mmu(env, a1, cv, nv, oi, ra); cc = !int128_eq(ov, cv); #else g_assert_not_reached(); #endif } else { uint64_t oh = cpu_ldq_data_ra(env, a1 + 0, ra); uint64_t ol = cpu_ldq_data_ra(env, a1 + 8, ra); ov = int128_make128(ol, oh); cc = !int128_eq(ov, cv); if (cc) { nv = ov; } cpu_stq_data_ra(env, a1 + 0, int128_gethi(nv), ra); cpu_stq_data_ra(env, a1 + 8, int128_getlo(nv), ra); } env->regs[r3 + 0] = int128_gethi(ov); env->regs[r3 + 1] = int128_getlo(ov); } break; default: g_assert_not_reached(); } if (cc == 0) { switch (sc) { case 0: cpu_stb_data_ra(env, a2, svh >> 56, ra); break; case 1: cpu_stw_data_ra(env, a2, svh >> 48, ra); break; case 2: cpu_stl_data_ra(env, a2, svh >> 32, ra); break; case 3: cpu_stq_data_ra(env, a2, svh, ra); break; case 4: if (parallel) { #ifdef CONFIG_ATOMIC128 TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); Int128 sv = int128_make128(svl, svh); helper_atomic_sto_be_mmu(env, a2, sv, oi, ra); #else g_assert_not_reached(); #endif } else { cpu_stq_data_ra(env, a2 + 0, svh, ra); cpu_stq_data_ra(env, a2 + 8, svl, ra); } break; default: g_assert_not_reached(); } } return cc; spec_exception: cpu_restore_state(ENV_GET_CPU(env), ra); program_interrupt(env, PGM_SPECIFICATION, 6); g_assert_not_reached(); }
1threat
why doesnt this prompt me a yes no at all? : <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> function myFunction() { if (confirm("Press a button!") == true) { if(this.style.backgroundColor == "white") this.style.backgroundColor = "yellow"; else if(this.style.backgroundColor == "yellow") this.style.backgroundColor = "red"; else if(this.style.backgroundColor == "red") this.style.backgroundColor = "" else this.style.backgroundColor = ""; } else { txt = "You pressed Cancel!"; } if (confirm('Are you sure you want to save this thing into the database?') == true) { // Save it! } else { // Do nothing! } } var blocks = document.getElementsByClassName("foo"); for (i = 0; i < blocks.length; i++) { blocks[i].addEventListener("click", myFunction); } <!-- language: lang-css --> .foo { float: left; width: 30px; height: 30px; margin: 5px; border: 1px solid rgba(0, 0, 0, .2); border-radius: 25%; } .blue { background: #13b4ff; } .whole { float: left; width: 900px; height: 900px; margin: 5px; border: 1px solid rgba(0, 0, 0, .2); } .purple { background: #ab3fdd; } .wine { background: #ae163e; } <!-- language: lang-html --> <div class="whole"> <div id="centerbox1" class="foo blue">A1</div> <div id="centerbox2" class="foo purple">A2</div> <div id="centerbox3" class="foo wine">A3</div><br><br> <div id="centerbox4" class="foo blue">B1</div> <div id="centerbox5" class="foo purple">B2</div> <div id="centerbox6" class="foo wine">B3</div> </div> <!-- end snippet --> how come it doesnt work? i am working on a website that receives the user data whether if he is indeed going to help a patient. i really dont know how to start this and im been on 1 simple function for weeks. Example: i clicked square, it prompts me yes or no, the color turns yellow. clicking on the square, which is yellow, will prompt me another yes or no. turning it back to the original color. this question is a follow up of https://stackoverflow.com/questions/47769965/div-onclick-prompts-yes-or-no-if-yes-div-change-to-different-color/47770269#47770269
0debug
Issue in pulling the code from GIT : i am trying to pull the latest code from git..but it is showing the below error...Do anyone have idea on how to solve it[enter image description here][1] [1]: https://i.stack.imgur.com/1idyE.png I went to the path it showed me in the above screenshot, but i dont find any file with that name
0debug
int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb) { int pqindex, lowquant; int status; int mbmodetab, imvtab, icbptab, twomvbptab, fourmvbptab; int scale, shift, i; v->numref=0; v->fcm=0; v->field_mode=0; v->p_frame_skipped = 0; if (v->second_field) { v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; if (v->fptype & 4) v->s.pict_type = (v->fptype & 1) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B; v->s.current_picture_ptr->f.pict_type = v->s.pict_type; if (!v->pic_header_flag) goto parse_common_info; } if (v->interlace) { v->fcm = decode012(gb); if (v->fcm) { if (v->fcm == 2) v->field_mode = 1; else v->field_mode = 0; if (!v->warn_interlaced++) av_log(v->s.avctx, AV_LOG_ERROR, "Interlaced frames/fields support is incomplete\n"); } } if (v->field_mode) { v->fptype = get_bits(gb, 3); v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; if (v->fptype & 4) v->s.pict_type = (v->fptype & 2) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B; } else { switch (get_unary(gb, 0, 4)) { case 0: v->s.pict_type = AV_PICTURE_TYPE_P; break; case 1: v->s.pict_type = AV_PICTURE_TYPE_B; break; case 2: v->s.pict_type = AV_PICTURE_TYPE_I; break; case 3: v->s.pict_type = AV_PICTURE_TYPE_BI; break; case 4: v->s.pict_type = AV_PICTURE_TYPE_P; v->p_frame_skipped = 1; break; } } if (v->tfcntrflag) skip_bits(gb, 8); if (v->broadcast) { if (!v->interlace || v->psf) { v->rptfrm = get_bits(gb, 2); } else { v->tff = get_bits1(gb); v->rff = get_bits1(gb); } } if (v->panscanflag) { av_log_missing_feature(v->s.avctx, "Pan-scan", 0); } if (v->p_frame_skipped) { return 0; } v->rnd = get_bits1(gb); if (v->interlace) v->uvsamp = get_bits1(gb); if (v->field_mode) { if (!v->refdist_flag) v->refdist = 0; else { if ((v->s.pict_type != AV_PICTURE_TYPE_B) && (v->s.pict_type != AV_PICTURE_TYPE_BI)) { v->refdist = get_bits(gb, 2); if (v->refdist == 3) v->refdist += get_unary(gb, 0, 16); } else { v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; v->frfd = (v->bfraction * v->refdist) >> 8; v->brfd = v->refdist - v->frfd - 1; if (v->brfd < 0) v->brfd = 0; } } goto parse_common_info; } if (v->finterpflag) v->interpfrm = get_bits1(gb); if (v->s.pict_type == AV_PICTURE_TYPE_B) { v->bfraction_lut_index = get_vlc2(gb, ff_vc1_bfraction_vlc.table, VC1_BFRACTION_VLC_BITS, 1); v->bfraction = ff_vc1_bfraction_lut[v->bfraction_lut_index]; if (v->bfraction == 0) { v->s.pict_type = AV_PICTURE_TYPE_BI; } } parse_common_info: if (v->field_mode) v->cur_field_type = !(v->tff ^ v->second_field); pqindex = get_bits(gb, 5); if (!pqindex) return -1; v->pqindex = pqindex; if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) v->pq = ff_vc1_pquant_table[0][pqindex]; else v->pq = ff_vc1_pquant_table[1][pqindex]; v->pquantizer = 1; if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) v->pquantizer = pqindex < 9; if (v->quantizer_mode == QUANT_NON_UNIFORM) v->pquantizer = 0; v->pqindex = pqindex; if (pqindex < 9) v->halfpq = get_bits1(gb); else v->halfpq = 0; if (v->quantizer_mode == QUANT_FRAME_EXPLICIT) v->pquantizer = get_bits1(gb); if (v->postprocflag) v->postproc = get_bits(gb, 2); if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_P) v->use_ic = 0; if (v->parse_only) return 0; switch (v->s.pict_type) { case AV_PICTURE_TYPE_I: case AV_PICTURE_TYPE_BI: if (v->fcm == 1) { status = bitplane_decoding(v->fieldtx_plane, &v->fieldtx_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "FIELDTX plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); } status = bitplane_decoding(v->acpred_plane, &v->acpred_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "ACPRED plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); v->condover = CONDOVER_NONE; if (v->overlap && v->pq <= 8) { v->condover = decode012(gb); if (v->condover == CONDOVER_SELECT) { status = bitplane_decoding(v->over_flags_plane, &v->overflg_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "CONDOVER plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); } } break; case AV_PICTURE_TYPE_P: if (v->field_mode) { av_log(v->s.avctx, AV_LOG_ERROR, "P Fields do not work currently\n"); return -1; v->numref = get_bits1(gb); if (!v->numref) { v->reffield = get_bits1(gb); v->ref_field_type[0] = v->reffield ^ !v->cur_field_type; } } if (v->extended_mv) v->mvrange = get_unary(gb, 0, 3); else v->mvrange = 0; if (v->interlace) { if (v->extended_dmv) v->dmvrange = get_unary(gb, 0, 3); else v->dmvrange = 0; if (v->fcm == 1) { v->fourmvswitch = get_bits1(gb); v->intcomp = get_bits1(gb); if (v->intcomp) { v->lumscale = get_bits(gb, 6); v->lumshift = get_bits(gb, 6); INIT_LUT(v->lumscale, v->lumshift, v->luty, v->lutuv); } status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); av_log(v->s.avctx, AV_LOG_DEBUG, "SKIPMB plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); mbmodetab = get_bits(gb, 2); if (v->fourmvswitch) v->mbmode_vlc = &ff_vc1_intfr_4mv_mbmode_vlc[mbmodetab]; else v->mbmode_vlc = &ff_vc1_intfr_non4mv_mbmode_vlc[mbmodetab]; imvtab = get_bits(gb, 2); v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab]; icbptab = get_bits(gb, 3); v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab]; twomvbptab = get_bits(gb, 2); v->twomvbp_vlc = &ff_vc1_2mv_block_pattern_vlc[twomvbptab]; if (v->fourmvswitch) { fourmvbptab = get_bits(gb, 2); v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab]; } } } v->k_x = v->mvrange + 9 + (v->mvrange >> 1); v->k_y = v->mvrange + 8; v->range_x = 1 << (v->k_x - 1); v->range_y = 1 << (v->k_y - 1); if (v->pq < 5) v->tt_index = 0; else if (v->pq < 13) v->tt_index = 1; else v->tt_index = 2; if (v->fcm != 1) { int mvmode; mvmode = get_unary(gb, 1, 4); lowquant = (v->pq > 12) ? 0 : 1; v->mv_mode = ff_vc1_mv_pmode_table[lowquant][mvmode]; if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { int mvmode2; mvmode2 = get_unary(gb, 1, 3); v->mv_mode2 = ff_vc1_mv_pmode_table2[lowquant][mvmode2]; if (v->field_mode) v->intcompfield = decode210(gb); v->lumscale = get_bits(gb, 6); v->lumshift = get_bits(gb, 6); INIT_LUT(v->lumscale, v->lumshift, v->luty, v->lutuv); if ((v->field_mode) && !v->intcompfield) { v->lumscale2 = get_bits(gb, 6); v->lumshift2 = get_bits(gb, 6); INIT_LUT(v->lumscale2, v->lumshift2, v->luty2, v->lutuv2); } v->use_ic = 1; } v->qs_last = v->s.quarter_sample; if (v->mv_mode == MV_PMODE_1MV_HPEL || v->mv_mode == MV_PMODE_1MV_HPEL_BILIN) v->s.quarter_sample = 0; else if (v->mv_mode == MV_PMODE_INTENSITY_COMP) { if (v->mv_mode2 == MV_PMODE_1MV_HPEL || v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN) v->s.quarter_sample = 0; else v->s.quarter_sample = 1; } else v->s.quarter_sample = 1; v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || (v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_1MV_HPEL_BILIN)); } if (v->fcm == 0) { if ((v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_MIXED_MV) || v->mv_mode == MV_PMODE_MIXED_MV) { status = bitplane_decoding(v->mv_type_mb_plane, &v->mv_type_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB MV Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); } else { v->mv_type_is_raw = 0; memset(v->mv_type_mb_plane, 0, v->s.mb_stride * v->s.mb_height); } status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); v->s.mv_table_index = get_bits(gb, 2); v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)]; } else if (v->fcm == 1) { v->qs_last = v->s.quarter_sample; v->s.quarter_sample = 1; v->s.mspel = 1; } else { mbmodetab = get_bits(gb, 3); imvtab = get_bits(gb, 2 + v->numref); if (!v->numref) v->imv_vlc = &ff_vc1_1ref_mvdata_vlc[imvtab]; else v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[imvtab]; icbptab = get_bits(gb, 3); v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab]; if ((v->mv_mode == MV_PMODE_INTENSITY_COMP && v->mv_mode2 == MV_PMODE_MIXED_MV) || v->mv_mode == MV_PMODE_MIXED_MV) { fourmvbptab = get_bits(gb, 2); v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab]; v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab]; } else { v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab]; } } if (v->dquant) { av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } v->ttfrm = 0; if (v->vstransform) { v->ttmbf = get_bits1(gb); if (v->ttmbf) { v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)]; } } else { v->ttmbf = 1; v->ttfrm = TT_8X8; } break; case AV_PICTURE_TYPE_B: if (v->fcm == 1) return -1; if (v->extended_mv) v->mvrange = get_unary(gb, 0, 3); else v->mvrange = 0; v->k_x = v->mvrange + 9 + (v->mvrange >> 1); v->k_y = v->mvrange + 8; v->range_x = 1 << (v->k_x - 1); v->range_y = 1 << (v->k_y - 1); if (v->pq < 5) v->tt_index = 0; else if (v->pq < 13) v->tt_index = 1; else v->tt_index = 2; if (v->field_mode) { int mvmode; av_log(v->s.avctx, AV_LOG_ERROR, "B Fields do not work currently\n"); return -1; if (v->extended_dmv) v->dmvrange = get_unary(gb, 0, 3); mvmode = get_unary(gb, 1, 3); lowquant = (v->pq > 12) ? 0 : 1; v->mv_mode = ff_vc1_mv_pmode_table2[lowquant][mvmode]; v->qs_last = v->s.quarter_sample; v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV || v->mv_mode == MV_PMODE_MIXED_MV); v->s.mspel = !(v->mv_mode == MV_PMODE_1MV_HPEL_BILIN || v->mv_mode == MV_PMODE_1MV_HPEL); status = bitplane_decoding(v->forward_mb_plane, &v->fmb_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB Forward Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); mbmodetab = get_bits(gb, 3); if (v->mv_mode == MV_PMODE_MIXED_MV) v->mbmode_vlc = &ff_vc1_if_mmv_mbmode_vlc[mbmodetab]; else v->mbmode_vlc = &ff_vc1_if_1mv_mbmode_vlc[mbmodetab]; imvtab = get_bits(gb, 3); v->imv_vlc = &ff_vc1_2ref_mvdata_vlc[imvtab]; icbptab = get_bits(gb, 3); v->cbpcy_vlc = &ff_vc1_icbpcy_vlc[icbptab]; if (v->mv_mode == MV_PMODE_MIXED_MV) { fourmvbptab = get_bits(gb, 2); v->fourmvbp_vlc = &ff_vc1_4mv_block_pattern_vlc[fourmvbptab]; } v->numref = 1; } else { v->mv_mode = get_bits1(gb) ? MV_PMODE_1MV : MV_PMODE_1MV_HPEL_BILIN; v->qs_last = v->s.quarter_sample; v->s.quarter_sample = (v->mv_mode == MV_PMODE_1MV); v->s.mspel = v->s.quarter_sample; status = bitplane_decoding(v->direct_mb_plane, &v->dmb_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB Direct Type plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); status = bitplane_decoding(v->s.mbskip_table, &v->skip_is_raw, v); if (status < 0) return -1; av_log(v->s.avctx, AV_LOG_DEBUG, "MB Skip plane encoding: " "Imode: %i, Invert: %i\n", status>>1, status&1); v->s.mv_table_index = get_bits(gb, 2); v->cbpcy_vlc = &ff_vc1_cbpcy_p_vlc[get_bits(gb, 2)]; } if (v->dquant) { av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } v->ttfrm = 0; if (v->vstransform) { v->ttmbf = get_bits1(gb); if (v->ttmbf) { v->ttfrm = ff_vc1_ttfrm_to_tt[get_bits(gb, 2)]; } } else { v->ttmbf = 1; v->ttfrm = TT_8X8; } break; } v->c_ac_table_index = decode012(gb); if (v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) { v->y_ac_table_index = decode012(gb); } v->s.dc_table_index = get_bits1(gb); if ((v->s.pict_type == AV_PICTURE_TYPE_I || v->s.pict_type == AV_PICTURE_TYPE_BI) && v->dquant) { av_log(v->s.avctx, AV_LOG_DEBUG, "VOP DQuant info\n"); vop_dquant_decoding(v); } v->bi_type = 0; if (v->s.pict_type == AV_PICTURE_TYPE_BI) { v->s.pict_type = AV_PICTURE_TYPE_B; v->bi_type = 1; } return 0; }
1threat
build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { AcpiSystemResourceAffinityTable *srat; AcpiSratProcessorGiccAffinity *core; AcpiSratMemoryAffinity *numamem; int i, srat_start; uint64_t mem_base; MachineClass *mc = MACHINE_GET_CLASS(vms); const CPUArchIdList *cpu_list = mc->possible_cpu_arch_ids(MACHINE(vms)); srat_start = table_data->len; srat = acpi_data_push(table_data, sizeof(*srat)); srat->reserved1 = cpu_to_le32(1); for (i = 0; i < cpu_list->len; ++i) { int node_id = cpu_list->cpus[i].props.has_node_id ? cpu_list->cpus[i].props.node_id : 0; core = acpi_data_push(table_data, sizeof(*core)); core->type = ACPI_SRAT_PROCESSOR_GICC; core->length = sizeof(*core); core->proximity = cpu_to_le32(node_id); core->acpi_processor_uid = cpu_to_le32(i); core->flags = cpu_to_le32(1); } mem_base = vms->memmap[VIRT_MEM].base; for (i = 0; i < nb_numa_nodes; ++i) { numamem = acpi_data_push(table_data, sizeof(*numamem)); build_srat_memory(numamem, mem_base, numa_info[i].node_mem, i, MEM_AFFINITY_ENABLED); mem_base += numa_info[i].node_mem; } build_header(linker, table_data, (void *)srat, "SRAT", table_data->len - srat_start, 3, NULL, NULL); }
1threat
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
i want to show traffic in google maps and to hide it with the same button : I want to **show and hide traffic** with the same button..so i tried method (onClick) in my xml and my java code is public void traffic (View view){ ImageButton bttn=findViewById(R.id.traffic); if(bttn.isClickable()){ mMap.setTrafficEnabled(true); } else { mMap.setTrafficEnabled(false); } but it doesnt work!!! it only shows traffic and if i press it again nothing happen! please tell me what i miss in my code !!!!
0debug
compiler throws error "is_enum not declared in this scope" among others wxwidgets : the g++ compiler throws the error when i compile. I am using code::blocks for this. the exact error is: C:\wx\include\wx\strvararg.h|350|error: 'is_enum' in namespace 'std' does not name a template type| C:\wx\include\wx\strvararg.h|354|error: 'is_enum' was not declared in this scope| C:\wx\include\wx\strvararg.h|354|error: template argument 1 is invalid| the build is a non-monolithic dll build. thanks for any help!
0debug
int64_t ff_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, int64_t pos_min, int64_t pos_max, int64_t pos_limit, int64_t ts_min, int64_t ts_max, int flags, int64_t *ts_ret, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )) { int64_t pos, ts; int64_t start_pos, filesize; int no_change; av_dlog(s, "gen_seek: %d %s\n", stream_index, av_ts2str(target_ts)); if(ts_min == AV_NOPTS_VALUE){ pos_min = s->data_offset; ts_min = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp); if (ts_min == AV_NOPTS_VALUE) return -1; } if(ts_min >= target_ts){ *ts_ret= ts_min; return pos_min; } if(ts_max == AV_NOPTS_VALUE){ int64_t step= 1024; int64_t limit; filesize = avio_size(s->pb); pos_max = filesize - 1; do{ limit = pos_max; pos_max = FFMAX(0, pos_max - step); ts_max = ff_read_timestamp(s, stream_index, &pos_max, limit, read_timestamp); step += step; }while(ts_max == AV_NOPTS_VALUE && pos_max > 0); if (ts_max == AV_NOPTS_VALUE) return -1; for(;;){ int64_t tmp_pos= pos_max + 1; int64_t tmp_ts= ff_read_timestamp(s, stream_index, &tmp_pos, INT64_MAX, read_timestamp); if(tmp_ts == AV_NOPTS_VALUE) break; ts_max= tmp_ts; pos_max= tmp_pos; if(tmp_pos >= filesize) break; } pos_limit= pos_max; } if(ts_max <= target_ts){ *ts_ret= ts_max; return pos_max; } if(ts_min > ts_max){ return -1; }else if(ts_min == ts_max){ pos_limit= pos_min; } no_change=0; while (pos_min < pos_limit) { av_dlog(s, "pos_min=0x%"PRIx64" pos_max=0x%"PRIx64" dts_min=%s dts_max=%s\n", pos_min, pos_max, av_ts2str(ts_min), av_ts2str(ts_max)); assert(pos_limit <= pos_max); if(no_change==0){ int64_t approximate_keyframe_distance= pos_max - pos_limit; pos = av_rescale(target_ts - ts_min, pos_max - pos_min, ts_max - ts_min) + pos_min - approximate_keyframe_distance; }else if(no_change==1){ pos = (pos_min + pos_limit)>>1; }else{ pos=pos_min; } if(pos <= pos_min) pos= pos_min + 1; else if(pos > pos_limit) pos= pos_limit; start_pos= pos; ts = ff_read_timestamp(s, stream_index, &pos, INT64_MAX, read_timestamp); if(pos == pos_max) no_change++; else no_change=0; av_dlog(s, "%"PRId64" %"PRId64" %"PRId64" / %s %s %s target:%s limit:%"PRId64" start:%"PRId64" noc:%d\n", pos_min, pos, pos_max, av_ts2str(ts_min), av_ts2str(ts), av_ts2str(ts_max), av_ts2str(target_ts), pos_limit, start_pos, no_change); if(ts == AV_NOPTS_VALUE){ av_log(s, AV_LOG_ERROR, "read_timestamp() failed in the middle\n"); return -1; } assert(ts != AV_NOPTS_VALUE); if (target_ts <= ts) { pos_limit = start_pos - 1; pos_max = pos; ts_max = ts; } if (target_ts >= ts) { pos_min = pos; ts_min = ts; } } pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max; ts = (flags & AVSEEK_FLAG_BACKWARD) ? ts_min : ts_max; #if 0 pos_min = pos; ts_min = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp); pos_min++; ts_max = ff_read_timestamp(s, stream_index, &pos_min, INT64_MAX, read_timestamp); av_dlog(s, "pos=0x%"PRIx64" %s<=%s<=%s\n", pos, av_ts2str(ts_min), av_ts2str(target_ts), av_ts2str(ts_max)); #endif *ts_ret= ts; return pos; }
1threat
static inline void celt_encode_pulses(OpusRangeCoder *rc, int *y, uint32_t N, uint32_t K) { ff_opus_rc_enc_uint(rc, celt_icwrsi(N, y), CELT_PVQ_V(N, K)); }
1threat
Thank you for the help in advance. (How to use Constants?) : //I am very new to java and coding, we have multiple assignments but the instructor has asked us to use constants when we are able to. This one of the assignments. import java.util.Scanner; public class PP2_6 { public static void main(String[] args) { Scanner myScan = new Scanner(System.in); float mileage, kilometer; System.out.print("Enter the Mileage: "); mileage = myScan.nextFloat(); kilometer = mileage * 1.60935F; System.out.println("The mileage in kilometers is : " + kilometer); } } //i know the code is very basic and probably sloppy, is there a way to use a constant in this example? thank you again
0debug
static int64_t ff_read_timestamp(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit, int64_t (*read_timestamp)(struct AVFormatContext *, int , int64_t *, int64_t )) { return wrap_timestamp(s->streams[stream_index], read_timestamp(s, stream_index, ppos, pos_limit)); }
1threat
static int net_client_init1(const void *object, int is_netdev, Error **errp) { union { const Netdev *netdev; const NetLegacy *net; } u; const NetClientOptions *opts; const char *name; if (is_netdev) { u.netdev = object; opts = u.netdev->opts; name = u.netdev->id; if (opts->kind == NET_CLIENT_OPTIONS_KIND_DUMP || opts->kind == NET_CLIENT_OPTIONS_KIND_NIC || !net_client_init_fun[opts->kind]) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a netdev backend type"); return -1; } } else { u.net = object; opts = u.net->opts; if (opts->kind == NET_CLIENT_OPTIONS_KIND_HUBPORT) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a net type"); return -1; } name = u.net->has_id ? u.net->id : u.net->name; if (opts->kind == NET_CLIENT_OPTIONS_KIND_NONE) { return 0; } if (!net_client_init_fun[opts->kind]) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "type", "a net backend type (maybe it is not compiled " "into this binary)"); return -1; } } if (net_client_init_fun[opts->kind]) { NetClientState *peer = NULL; if (!is_netdev && (opts->kind != NET_CLIENT_OPTIONS_KIND_NIC || !opts->nic->has_netdev)) { peer = net_hub_add_port(u.net->has_vlan ? u.net->vlan : 0, NULL); } if (net_client_init_fun[opts->kind](opts, name, peer, errp) < 0) { if (errp && !*errp) { error_setg(errp, QERR_DEVICE_INIT_FAILED, NetClientOptionsKind_lookup[opts->kind]); } return -1; } } return 0; }
1threat
How to get data from Ecto in a custom mix task : <p>I want to display data from my DB through Ecto in a custom mix task. How can I get the Ecto repo in my task (or start it)?</p> <p>I tried something like this but it didn't work:</p> <pre><code>defmodule Mix.Tasks.Users.List do use Mix.Task use Mix.Config use Ecto.Repo, otp_app: :app @shortdoc "List active users" @moduledoc """ List active users """ def run(_) do import Ecto.Query, only: [from: 1] Mix.shell.info "=== Active users ===" query = from u in "users" sync = all(query) Enum.each(users, fn(s) -&gt; IO.puts(u.name) end) end end </code></pre> <p>This will give me the following output when I launch mix users.list: </p> <pre><code>** (ArgumentError) repo Mix.Tasks.Users.List is not started, please ensure it is part of your supervision tree lib/ecto/query/planner.ex:64: Ecto.Query.Planner.query_lookup/5 lib/ecto/query/planner.ex:48: Ecto.Query.Planner.query_with_cache/6 lib/ecto/repo/queryable.ex:119: Ecto.Repo.Queryable.execute/5 </code></pre> <p>Any idea or other way to solve this problem?</p>
0debug
Python Pandas: Calculate moving average within group : <p>I have a dataframe containing time series for 100 objects:</p> <pre><code>object period value 1 1 24 1 2 67 ... 1 1000 56 2 1 59 2 2 46 ... 2 1000 64 3 1 54 ... 100 1 451 100 2 153 ... 100 1000 21 </code></pre> <p>I want to calculate moving average with window 10 for the <code>value</code> column. I guess I have to do something like</p> <pre><code>df.groupby('object').apply(lambda ~calculate MA~) </code></pre> <p>and then merge this Series to the original dataframe by object? Can't figure out exact commands</p>
0debug
Multiple Nested Routes in react-router-dom v4 : <p>I need multiple nested routes in react-router-dom</p> <p><strong><em>I am using v4 of react-router-dom</em></strong></p> <p>I've got my</p> <pre><code>import { BrowserRouter as Router, Route } from 'react-router-dom'; </code></pre> <p>and I need the components to render like so</p> <pre><code>--- Login --- Home --- Page 1 --- Page 2 --- Page 3 --- About --- etc </code></pre> <p>The Home component contains a Header component that is common to Page1, Page2, and, Page3 components, but is not present in Login and About.</p> <p>My js code reads like so</p> <pre><code>&lt;Router&gt; &lt;div&gt; &lt;Route path='/login' component={Login} /&gt; &lt;Home&gt; &lt;Route path='/page1' component={Page1} /&gt; &lt;Route path='/page2' component={Page2} /&gt; &lt;Route path='/page3' component={Page3} /&gt; &lt;/Home&gt; &lt;Route path='/about' component={About} /&gt; &lt;/div&gt; &lt;/Router&gt; </code></pre> <p>I expect the Login component to show only on /login When I request for /page1, /page2, /page3, they should contain the Home component and that page's content respectively.</p> <p>What I get instead is the Login component rendered and below that Page1's component is rendered.</p> <p>I'm pretty sure that I'm missing something very trivial or making a really silly mistake somewhere, and would appreciate all the help I could get. I've been stuck with this for the last two days.</p>
0debug
Customise/scale axis tick marks for 4 plots independent of each other in facet_wrap (RStudio) : [1]: http://i.stack.imgur.com/0Iq01.png I have created the above plot [1] using the code below: ggplot(data = gdt, aes(x = area)) + geom_histogram(bins = 10, colour = "black", fill = "grey50") + facet_wrap( ~ fires, scales = "free") + labs(x = "Area of Burnt Land (ha)", y = "Fires") + ggtitle("Count of Destructive Fires in Portugal (2007)") I want change the interval occurrence or the location of the tick marks individually for each sub plot, in other words I am trying to achieve a placement of one tick/grid-line at each point the bars meet. I have tried using scale_continuous and scale_x_discrete to no effect, if I set the marks to suit one of the sub plots it negatively affects the others. Is there a way to do this??
0debug
How to remove rows with non unique fields in django by timestamp? : TLDR: How to filter models which have duplicated `hash` field and remove the ones have latest timestamp? I'm creating models with `bulk_create` in django. The thing is one field which I want to be `unique=True` can't be set like this due to encryption applied by `fernet_fields` extension to this field. So I came up with a solution to create additional hash field by which I can determine uniqueness of specified model. One more problem is `bulk_create` does not run with SQL `IGNORE` statement and throws `IntegrityError` if there is non unique record to be recorded. At this point I have an idea just leave hash field with `unique=False` setting and remove non unique records which were added latest after `bulk_create` has been called.
0debug
Google drive file preview with api access token in iframe : <p>How we can get preview of Google drive files in web without login into Google account. In current scenario only public files are visible through embed link, we need to show preview of file in iframe which are not public and without login. We have access token for Google drive api.</p>
0debug
static int qemu_gluster_parseuri(GlusterConf *gconf, const char *filename) { URI *uri; QueryParams *qp = NULL; bool is_unix = false; int ret = 0; uri = uri_parse(filename); if (!uri) { return -EINVAL; } if (!strcmp(uri->scheme, "gluster")) { gconf->transport = g_strdup("tcp"); } else if (!strcmp(uri->scheme, "gluster+tcp")) { gconf->transport = g_strdup("tcp"); } else if (!strcmp(uri->scheme, "gluster+unix")) { gconf->transport = g_strdup("unix"); is_unix = true; } else if (!strcmp(uri->scheme, "gluster+rdma")) { gconf->transport = g_strdup("rdma"); } else { ret = -EINVAL; goto out; } ret = parse_volume_options(gconf, uri->path); if (ret < 0) { goto out; } qp = query_params_parse(uri->query); if (qp->n > 1 || (is_unix && !qp->n) || (!is_unix && qp->n)) { ret = -EINVAL; goto out; } if (is_unix) { if (uri->server || uri->port) { ret = -EINVAL; goto out; } if (strcmp(qp->p[0].name, "socket")) { ret = -EINVAL; goto out; } gconf->server = g_strdup(qp->p[0].value); } else { gconf->server = g_strdup(uri->server); gconf->port = uri->port; } out: if (qp) { query_params_free(qp); } uri_free(uri); return ret; }
1threat
Running through a column in excel and removing certain text based on a vlookup : <p>I apologize in advance if this is trivial but I am struggling to remember the syntax for visual basic as it has been so long.</p> <p>I have text in cells in column D that needs removing (Country names). I have a separate sheet that contains all the Country names and so I thought I could run through the column cell by cell and check whether there were any cells whose text matched that of the country table I have on a separate sheet. (I.e. a vlookup which changed the text if it matched to something like 'deletME')</p> <p>Thanks!</p>
0debug
Have eslint only show fatal errors? : <p>I would like to silence all style warnings and only be alerted when there is a major leak in my code, like a missing bracket, or a referenced var that doesn't exist. Is there a rule that can be inserted into eslint.json to quiet everything except fatal errors?</p>
0debug
Android: crash on launching a class : my app crashes when I try to launch it: DownloadTask downloadTask = new DownloadTask(); here there is the code of the class: > private class DownloadTask extends AsyncTask<String, Void, String>{ > > @Override > protected String doInBackground(String... url) { > > // For storing data from web service > String data = ""; > > try{ > // Fetching the data from web service > data = downloadUrl(url[0]); > }catch(Exception e){ > Log.d("Background Task",e.toString()); > } > return data; > } > > @Override > protected void onPostExecute(String result) { > super.onPostExecute(result); > ParserTask parserTask = new ParserTask(); > // Invokes the thread for parsing the JSON data > parserTask.execute(result); > } > } Where am I going wrong?
0debug
REST based message queue for microservices : <p>I'm given a task to implement Message queue to publish and consume message over queue but my requirement is, i'm gonna need to interact with queue using REST API (eg: ActiveMQ having REST API but problem with ActiveMq is when implementing consumer we don't have way to keep waiting for message queue to fetch,we cant listen to the queue using REST client ). So i'm leaving my problem to you guys to give me better alternative for this NOTE - solution should use only open source product only </p>
0debug
How to make username and password form work - where website cannot be seen by just typing in url : <p>So i have a website on a sever, and am using php code to access a 'log on' page where a person who has a username and password can add stuff to the website. But if you type the url in anyone can just access it without username and password. How do it change this. </p> <p>So there is a form on html page, that has username and password fields, user types them in, php checks the info and the redirects to the correct page if the info is correct. </p> <p>PHP code used</p> <pre><code> &lt;?php if ($_POST["usn"]=="ag316" || $_POST["psw"]=="rock") { header("Location: addentry.html"); exit(); } else { header("Location: login.html"); exit(); } ?&gt; </code></pre>
0debug
dotnet test not creating test results folder : <p>As part of our <strong>ASP.NET Core 2.0</strong> build process I have added a <em>dotnet test</em> command which I have added as a Windows batch file. </p> <p>Here is my command.</p> <pre><code>dotnet test "MyProject.csproj" --no-restore --results-directory "MyProject\TestResults" --verbosity minimal </code></pre> <p>And here is the output when run from the command line.</p> <p><a href="https://i.stack.imgur.com/EyCNT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/EyCNT.png" alt="enter image description here"></a></p> <p>So it all appears to work correctly, yet no test results / test output is created. </p>
0debug
How the Substitution of the 3rd to the last occurrence using SED command works? : <p>Let's consider the 'file.txt', <a href="https://i.stack.imgur.com/qt4sr.png" rel="nofollow noreferrer">click for the file contents</a></p> <p>I want to substitute the 3rd to the last occurrence of "p".</p> <pre><code>sed -E 's/(.*)p((.*p){2})/\1@\2/' file.txt </code></pre> <p>Here, "p" is substituted by "@". I want to know how it works. Can anyone explain me ? </p>
0debug
document.write('<script src="evil.js"></script>');
1threat
Using authentication token in azure sdk fluent : <p>To authenticate with Azure in azure sdk fluent nuget, there is a method that uses client id and secret as below</p> <pre><code>var azureCredentials = new AzureCredentials(new ServicePrincipalLoginInformation { ClientId = "ClientId", ClientSecret = "ClientSecret" }, "tenantId", AzureEnvironment.AzureGlobalCloud); </code></pre> <p>Is there any interface where authentication token (JWT) can be used instead of using client id and secret while creating IAzure in the below code?</p> <pre><code>_azure = Azure .Configure() .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic) .Authenticate(azureCredentials) .WithSubscription(_subscriptionId); </code></pre> <p>Note: I have a separate authenticater module that keeps client id and secret with itself and uses them to get authentication token which will be used by other components/sdks.</p>
0debug
Assignment doesn't work but address of with the dereference operator does? : <p>I've been playing around with C++ (just starting out), and I'm trying to make a program that needs a function to count the lines in C++. However, I've encountered weird behavior where normal assignment doesn't work, but assignment through address of, and then immediate dereference does. Like this:</p> <pre><code>int countLinesInFile(string fileName){ char c[32]; int numLines = 0; ifstream file(fileName); while(file &gt;&gt; c){ numLines += 1; cout &lt;&lt; "Lines: " &lt;&lt; numLines &lt;&lt; endl; } return numLines; } </code></pre> <p>Which results in:</p> <pre><code>Lines: 1 Lines: 1 Lines: 1 Lines: 1 Lines: 1 Lines: 1 </code></pre> <p>However, when I change <code>numLines += 1</code> to <code>*(&amp;numLines) += 1</code> it magically works:</p> <pre><code>Lines: 1 Lines: 2 Lines: 3 Lines: 4 Lines: 5 Lines: 6 </code></pre> <p>For a little background, the file I'm reading is a 6 line file where each line is a 32 bit binary string (equal to zero). When I print out c (with <code>cout &lt;&lt; c</code>) it prints out seemingly correctly. Also, I am aware that this may not be the optimal or correct way of doing read lines from a file, but unless this simply can not possibly work, I am more interested in the underlying mechanics of why this behavior is happening, and what I am doing wrong.</p>
0debug
static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index) { OutputStream *ost; AVStream *st = avformat_new_stream(oc, NULL); int idx = oc->nb_streams - 1, ret = 0; const char *bsfs = NULL, *time_base = NULL; char *next, *codec_tag = NULL; double qscale = -1; int i; if (!st) { av_log(NULL, AV_LOG_FATAL, "Could not alloc stream.\n"); exit_program(1); } if (oc->nb_streams - 1 < o->nb_streamid_map) st->id = o->streamid_map[oc->nb_streams - 1]; GROW_ARRAY(output_streams, nb_output_streams); if (!(ost = av_mallocz(sizeof(*ost)))) exit_program(1); output_streams[nb_output_streams - 1] = ost; ost->file_index = nb_output_files - 1; ost->index = idx; ost->st = st; st->codecpar->codec_type = type; ret = choose_encoder(o, oc, ost); if (ret < 0) { av_log(NULL, AV_LOG_FATAL, "Error selecting an encoder for stream " "%d:%d\n", ost->file_index, ost->index); exit_program(1); } ost->enc_ctx = avcodec_alloc_context3(ost->enc); if (!ost->enc_ctx) { av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding context.\n"); exit_program(1); } ost->enc_ctx->codec_type = type; ost->ref_par = avcodec_parameters_alloc(); if (!ost->ref_par) { av_log(NULL, AV_LOG_ERROR, "Error allocating the encoding parameters.\n"); exit_program(1); } if (ost->enc) { AVIOContext *s = NULL; char *buf = NULL, *arg = NULL, *preset = NULL; ost->encoder_opts = filter_codec_opts(o->g->codec_opts, ost->enc->id, oc, st, ost->enc); MATCH_PER_STREAM_OPT(presets, str, preset, oc, st); if (preset && (!(ret = get_preset_file_2(preset, ost->enc->name, &s)))) { do { buf = get_line(s); if (!buf[0] || buf[0] == '#') { av_free(buf); continue; } if (!(arg = strchr(buf, '='))) { av_log(NULL, AV_LOG_FATAL, "Invalid line found in the preset file.\n"); exit_program(1); } *arg++ = 0; av_dict_set(&ost->encoder_opts, buf, arg, AV_DICT_DONT_OVERWRITE); av_free(buf); } while (!s->eof_reached); avio_closep(&s); } if (ret) { av_log(NULL, AV_LOG_FATAL, "Preset %s specified for stream %d:%d, but could not be opened.\n", preset, ost->file_index, ost->index); exit_program(1); } } else { ost->encoder_opts = filter_codec_opts(o->g->codec_opts, AV_CODEC_ID_NONE, oc, st, NULL); } MATCH_PER_STREAM_OPT(time_bases, str, time_base, oc, st); if (time_base) { AVRational q; if (av_parse_ratio(&q, time_base, INT_MAX, 0, NULL) < 0 || q.num <= 0 || q.den <= 0) { av_log(NULL, AV_LOG_FATAL, "Invalid time base: %s\n", time_base); exit_program(1); } st->time_base = q; } MATCH_PER_STREAM_OPT(enc_time_bases, str, time_base, oc, st); if (time_base) { AVRational q; if (av_parse_ratio(&q, time_base, INT_MAX, 0, NULL) < 0 || q.den <= 0) { av_log(NULL, AV_LOG_FATAL, "Invalid time base: %s\n", time_base); exit_program(1); } ost->enc_timebase = q; } ost->max_frames = INT64_MAX; MATCH_PER_STREAM_OPT(max_frames, i64, ost->max_frames, oc, st); for (i = 0; i<o->nb_max_frames; i++) { char *p = o->max_frames[i].specifier; if (!*p && type != AVMEDIA_TYPE_VIDEO) { av_log(NULL, AV_LOG_WARNING, "Applying unspecific -frames to non video streams, maybe you meant -vframes ?\n"); break; } } ost->copy_prior_start = -1; MATCH_PER_STREAM_OPT(copy_prior_start, i, ost->copy_prior_start, oc ,st); MATCH_PER_STREAM_OPT(bitstream_filters, str, bsfs, oc, st); while (bsfs && *bsfs) { const AVBitStreamFilter *filter; char *bsf, *bsf_options_str, *bsf_name; bsf = av_get_token(&bsfs, ","); if (!bsf) exit_program(1); bsf_name = av_strtok(bsf, "=", &bsf_options_str); if (!bsf_name) exit_program(1); filter = av_bsf_get_by_name(bsf_name); if (!filter) { av_log(NULL, AV_LOG_FATAL, "Unknown bitstream filter %s\n", bsf_name); exit_program(1); } ost->bsf_ctx = av_realloc_array(ost->bsf_ctx, ost->nb_bitstream_filters + 1, sizeof(*ost->bsf_ctx)); if (!ost->bsf_ctx) exit_program(1); ret = av_bsf_alloc(filter, &ost->bsf_ctx[ost->nb_bitstream_filters]); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error allocating a bitstream filter context\n"); exit_program(1); } ost->nb_bitstream_filters++; if (bsf_options_str && filter->priv_class) { const AVOption *opt = av_opt_next(ost->bsf_ctx[ost->nb_bitstream_filters-1]->priv_data, NULL); const char * shorthand[2] = {NULL}; if (opt) shorthand[0] = opt->name; ret = av_opt_set_from_string(ost->bsf_ctx[ost->nb_bitstream_filters-1]->priv_data, bsf_options_str, shorthand, "=", ":"); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error parsing options for bitstream filter %s\n", bsf_name); exit_program(1); } } av_freep(&bsf); if (*bsfs) bsfs++; } if (ost->nb_bitstream_filters) { ost->bsf_extradata_updated = av_mallocz_array(ost->nb_bitstream_filters, sizeof(*ost->bsf_extradata_updated)); if (!ost->bsf_extradata_updated) { av_log(NULL, AV_LOG_FATAL, "Bitstream filter memory allocation failed\n"); exit_program(1); } } MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st); if (codec_tag) { uint32_t tag = strtol(codec_tag, &next, 0); if (*next) tag = AV_RL32(codec_tag); ost->st->codecpar->codec_tag = ost->enc_ctx->codec_tag = tag; } MATCH_PER_STREAM_OPT(qscale, dbl, qscale, oc, st); if (qscale >= 0) { ost->enc_ctx->flags |= AV_CODEC_FLAG_QSCALE; ost->enc_ctx->global_quality = FF_QP2LAMBDA * qscale; } MATCH_PER_STREAM_OPT(disposition, str, ost->disposition, oc, st); ost->disposition = av_strdup(ost->disposition); ost->max_muxing_queue_size = 128; MATCH_PER_STREAM_OPT(max_muxing_queue_size, i, ost->max_muxing_queue_size, oc, st); ost->max_muxing_queue_size *= sizeof(AVPacket); if (oc->oformat->flags & AVFMT_GLOBALHEADER) ost->enc_ctx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER; av_dict_copy(&ost->sws_dict, o->g->sws_dict, 0); av_dict_copy(&ost->swr_opts, o->g->swr_opts, 0); if (ost->enc && av_get_exact_bits_per_sample(ost->enc->id) == 24) av_dict_set(&ost->swr_opts, "output_sample_bits", "24", 0); av_dict_copy(&ost->resample_opts, o->g->resample_opts, 0); ost->source_index = source_index; if (source_index >= 0) { ost->sync_ist = input_streams[source_index]; input_streams[source_index]->discard = 0; input_streams[source_index]->st->discard = input_streams[source_index]->user_set_discard; } ost->last_mux_dts = AV_NOPTS_VALUE; ost->muxing_queue = av_fifo_alloc(8 * sizeof(AVPacket)); if (!ost->muxing_queue) exit_program(1); return ost; }
1threat
static av_always_inline void idct_internal(uint8_t *dst, DCTELEM *block, int stride, int block_stride, int shift, int add){ int i; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; block[0] += 1<<(shift-1); for(i=0; i<4; i++){ const int z0= block[0 + block_stride*i] + block[2 + block_stride*i]; const int z1= block[0 + block_stride*i] - block[2 + block_stride*i]; const int z2= (block[1 + block_stride*i]>>1) - block[3 + block_stride*i]; const int z3= block[1 + block_stride*i] + (block[3 + block_stride*i]>>1); block[0 + block_stride*i]= z0 + z3; block[1 + block_stride*i]= z1 + z2; block[2 + block_stride*i]= z1 - z2; block[3 + block_stride*i]= z0 - z3; } for(i=0; i<4; i++){ const int z0= block[i + block_stride*0] + block[i + block_stride*2]; const int z1= block[i + block_stride*0] - block[i + block_stride*2]; const int z2= (block[i + block_stride*1]>>1) - block[i + block_stride*3]; const int z3= block[i + block_stride*1] + (block[i + block_stride*3]>>1); dst[i + 0*stride]= cm[ add*dst[i + 0*stride] + ((z0 + z3) >> shift) ]; dst[i + 1*stride]= cm[ add*dst[i + 1*stride] + ((z1 + z2) >> shift) ]; dst[i + 2*stride]= cm[ add*dst[i + 2*stride] + ((z1 - z2) >> shift) ]; dst[i + 3*stride]= cm[ add*dst[i + 3*stride] + ((z0 - z3) >> shift) ]; } }
1threat
static void uart_write(void *opaque, hwaddr addr, uint64_t value, unsigned size) { LM32UartState *s = opaque; unsigned char ch = value; trace_lm32_uart_memory_write(addr, value); addr >>= 2; switch (addr) { case R_RXTX: if (s->chr) { qemu_chr_fe_write_all(s->chr, &ch, 1); } break; case R_IER: case R_LCR: case R_MCR: case R_DIV: s->regs[addr] = value; break; case R_IIR: case R_LSR: case R_MSR: error_report("lm32_uart: write access to read only register 0x" TARGET_FMT_plx, addr << 2); break; default: error_report("lm32_uart: write access to unknown register 0x" TARGET_FMT_plx, addr << 2); break; } uart_update_irq(s); }
1threat
why <li> is kept open without a </li> html nested lists : <p>I posted a question and everyone said things that i was not really asking I will try to be more clear next time.</p> <p>I was told that when nesting lists you must leave a <code>&lt;li&gt;</code> without a <code>&lt;/li&gt;</code></p> <p>The &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; point to the tags.</p> <p>That is what i need someone to explain... I was told this is necessary and i can't find a resource that tells me why.</p> <pre><code>&lt;ul&gt; &lt;li&gt; Louis &lt;/li&gt; &lt;li&gt; Louis &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; &lt;ol&gt; &lt;li&gt; Louis &lt;/li&gt; &lt;li&gt; Louis &lt;/li&gt; &lt;ul&gt; &lt;li&gt; Louis &lt;/li&gt; &lt;li&gt; Louis &lt;/li&gt; &lt;ol&gt; &lt;li&gt; Louis &lt;/li&gt; &lt;li&gt; Louis &lt;/li&gt; &lt;/ol&gt; &lt;/ul&gt; &lt;/ol&gt; &lt;/li&gt; &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; &lt;/ul&gt; </code></pre>
0debug
Matplotlib: set axis tight only to x or y axis : <p>I have a plot look like this:</p> <p><a href="https://i.stack.imgur.com/5ePuJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5ePuJ.png" alt="enter image description here"></a></p> <p>Obviously, the left and right side is a waste of space, so I set</p> <pre><code>plt.axis('tight') </code></pre> <p>But this gives me plot like this:</p> <p><a href="https://i.stack.imgur.com/lOPO0.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lOPO0.png" alt="enter image description here"></a></p> <p>The xlim looks right now, but the ylim is too tight for the plot.</p> <p>I'm wondering, if I can only set <code>axis(tight)</code> only to x axis in my case?</p> <p>So the plot may look something like this:</p> <p><a href="https://i.stack.imgur.com/RKKfy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RKKfy.png" alt="enter image description here"></a></p> <p>It's certainly possible that I can do this manually by</p> <pre><code>plt.gca().set_xlim(left=-10, right=360) </code></pre> <p>But I'm afraid this is not a very elegant solution.</p>
0debug
How can I generate random real symmetric matrix in R : <p>I know A'A will give a symmetric positive definite matrix. But how can I generate random matrix in R that is symmetric, but not necessary to be positive definite?</p>
0debug
EXCEPTION: $ is not defined : <p>I'm getting this error in Google Chrome : EXCEPTION: $ is not defined. Jquery and bootstrap are properly installed because there are no compilation errors. </p> <p>My code here in TypeScript file : </p> <pre><code>declare var $: JQueryStatic; $('.carousel').carousel(); </code></pre> <p>I don't understand. Any fixes for this ?</p>
0debug
Why are entity framework entities partial classes? : <p>I recently began using entity framework, and I noticed that generated entities are partial classes. What are the uses of that? I googled a bit and people mostly speak of validation, but I can add validation on the generated entity as well.</p>
0debug
How to do if pattern matching with multiple cases? : <p>I'm searching for the syntax to do pattern matching with multiple cases in an if case statement. The example would be this:</p> <pre><code>enum Gender { case Male, Female, Transgender } let a = Gender.Male </code></pre> <p>Now I want to check, if a is .Male OR .Female. But I would like to avoid using switch for this. However the switch statement would be like this:</p> <pre><code>switch a { case .Male, .Female: // do something } </code></pre> <p>Is it possible to write this with if case? I would expect this, but it didn't work :(</p> <pre><code>if case .Male, .Female = a { } </code></pre>
0debug
Google Cloud SDK installer fails to complete component installation on Windows 7 : <p>During installation I get a message:</p> <p>Unfortunately, the component installation did not complete successfully. Please check the detailed logs for the error message.</p> <p>I tried installing to all users, single user, many destinations and names.</p> <p>Details:</p> <p>Output folder: C:\Program Files (x86)\Google\Cloud SDK Downloading Google Cloud SDK core. Extracting Google Cloud SDK core. Create Google Cloud SDK bat file: C:\Program Files (x86)\Google\Cloud SDK\cloud_env.bat Installing components. The filename, directory name, or volume label syntax is incorrect. Failed to install.</p> <p>What to do?</p>
0debug
static void cmd_prevent_allow_medium_removal(IDEState *s, uint8_t* buf) { s->tray_locked = buf[4] & 1; bdrv_lock_medium(s->bs, buf[4] & 1); ide_atapi_cmd_ok(s); }
1threat
static int rtsp_read_play(AVFormatContext *s) { RTSPState *rt = s->priv_data; RTSPMessageHeader reply1, *reply = &reply1; int i; char cmd[1024]; av_log(s, AV_LOG_DEBUG, "hello state=%d\n", rt->state); if (!(rt->server_type == RTSP_SERVER_REAL && rt->need_subscription)) { if (rt->state == RTSP_STATE_PAUSED) { cmd[0] = 0; } else { snprintf(cmd, sizeof(cmd), "Range: npt=%0.3f-\r\n", (double)rt->seek_timestamp / AV_TIME_BASE); } ff_rtsp_send_cmd(s, "PLAY", rt->control_uri, cmd, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) { return -1; } if (reply->range_start != AV_NOPTS_VALUE && rt->transport == RTSP_TRANSPORT_RTP) { for (i = 0; i < rt->nb_rtsp_streams; i++) { RTSPStream *rtsp_st = rt->rtsp_streams[i]; RTPDemuxContext *rtpctx = rtsp_st->transport_priv; AVStream *st = NULL; if (rtsp_st->stream_index >= 0) st = s->streams[rtsp_st->stream_index]; rtpctx->last_rtcp_ntp_time = AV_NOPTS_VALUE; rtpctx->first_rtcp_ntp_time = AV_NOPTS_VALUE; if (st) rtpctx->range_start_offset = av_rescale_q(reply->range_start, AV_TIME_BASE_Q, st->time_base); } } } rt->state = RTSP_STATE_STREAMING; return 0; }
1threat
How to create a dataframe outof an existing dataframe based on two values in Pyspark : I've one datafrema and I want to create another dataframe based on some column values using pyspark. For example : below is my main dataframe - Part1 Part2 Part3 Part4 aaa up 24 k-123 bbb down 45 i-98 ccc down 54 k-89 fff int 23 l-34 xyz up 22 o-89 www up 89 u-56 Now, I want to create another dataframe which will search for 1st occurrence of 'down' and will go till 1st occurrence of up. So, the expected dataframe would be : Part1 Part2 Part3 Part4 bbb down 45 i-98 ccc down 54 k-89 fff int 23 l-34 xyz up 22 o-89
0debug
static AVStream *get_subtitle_pkt(AVFormatContext *s, AVStream *next_st, AVPacket *pkt) { AVIStream *ast, *next_ast = next_st->priv_data; int64_t ts, next_ts, ts_min = INT64_MAX; AVStream *st, *sub_st = NULL; int i; next_ts = av_rescale_q(next_ast->frame_offset, next_st->time_base, AV_TIME_BASE_Q); for (i=0; i<s->nb_streams; i++) { st = s->streams[i]; ast = st->priv_data; if (st->discard < AVDISCARD_ALL && ast->sub_pkt.data) { ts = av_rescale_q(ast->sub_pkt.dts, st->time_base, AV_TIME_BASE_Q); if (ts <= next_ts && ts < ts_min) { ts_min = ts; sub_st = st; } } } if (sub_st) { ast = sub_st->priv_data; *pkt = ast->sub_pkt; pkt->stream_index = sub_st->index; if (av_read_packet(ast->sub_ctx, &ast->sub_pkt) < 0) ast->sub_pkt.data = NULL; } return sub_st; }
1threat
Cant Acess Second Level of JSON String : So programming for a school project. Iam making a weather app where I need to display the current temperature. In the JSON string the current temp is in the second level which i cant figure out how to access. In furture I would also like to access the hourly and daily forecasts included in this string if you have any ideas on that. Any help would be appreciated here is my data: {"latitude":- 32.9283,"longitude":151.7817,"timezone":"Australia/Sydney","currently":{"time":1546405401,"summary":"Clear","icon":"clear-day","precipIntensity":0,"precipProbability":0,"temperature":93.03,"apparentTemperature":93.03,"dewPoint":58.07,"humidity":0.31,"pressure":1009.17,"windSpeed":14.77,"windGust":19.66,"windBearing":68,"cloudCover":0,"uvIndex":7,"visibility":7.75,"ozone":276.4},"hourly":{"summary":"Clear throughout the day.","icon":"clear-day","data":[{"time":1546405200,"summary":"Clear","icon":"clear-day","precipIntensity":0,"precipProbability":0,"temperature":93.25,"apparentTemperature":93.25,"dewPoint":57.89,"humidity":0.31,"pressure":1009.18,"windSpeed":14.78,"windGust":19.53,"windBearing":68,"cloudCover":0,"uvIndex":7,"visibility":7.58,"ozone":276.43},{"time":1546408800,"summary":"Clear","icon":"clear-day","precipIntensity":0,"precipProbability":0,"temperature":89.44,"apparentTemperature":89.44,"dewPoint":60.5,"humidity":0.38,"pressure":1008.99,"windSpeed":14.58,"windGust":21.84,"windBearing":66,"cloudCover":0,"uvIndex":4,"visibility":10,"ozone":275.8}, Imports System.IO Imports System.Net Imports System.Drawing Imports System.Web.Script.Serialization Imports Newtonsoft.Json Imports Newtonsoft.Json.Linq Dim request As HttpWebRequest Dim response As HttpWebResponse = Nothing Dim reader As StreamReader request = DirectCast(WebRequest.Create("https://api.darksky.net/forecast/412498ac9648999c8185723817a897d3/-32.9283,151.7817"), HttpWebRequest) response = DirectCast(request.GetResponse(), HttpWebResponse) reader = New StreamReader(response.GetResponseStream()) Dim data As String data = reader.ReadToEnd() Dim jsonObject As JObject = JObject.Parse(data) MessageBox.Show(jsonObject.SelectToken("currently").ToString) Dim JsonArray As JArray = JArray.Parse(jsonObject.SelectToken("currently").ToString) MessageBox.Show(jsonObject.SelectToken("temperature").ToString) Error Message: Newtonsoft.Json.JsonReaderException: 'Error reading JArray from JsonReader. Current JsonReader item is not an array: StartObject. Path '', line 1, position 1.'
0debug
static void ppcuic_set_irq (void *opaque, int irq_num, int level) { ppcuic_t *uic; uint32_t mask, sr; uic = opaque; mask = 1 << (31-irq_num); LOG_UIC("%s: irq %d level %d uicsr %08" PRIx32 " mask %08" PRIx32 " => %08" PRIx32 " %08" PRIx32 "\n", __func__, irq_num, level, uic->uicsr, mask, uic->uicsr & mask, level << irq_num); if (irq_num < 0 || irq_num > 31) return; sr = uic->uicsr; if (uic->uictr & mask) { if (level == 1) uic->uicsr |= mask; } else { if (level == 1) { uic->uicsr |= mask; uic->level |= mask; } else { uic->uicsr &= ~mask; uic->level &= ~mask; } } LOG_UIC("%s: irq %d level %d sr %" PRIx32 " => " "%08" PRIx32 "\n", __func__, irq_num, level, uic->uicsr, sr); if (sr != uic->uicsr) ppcuic_trigger_irq(uic); }
1threat
How to make color patterns in css? : <p><a href="https://i.stack.imgur.com/PLG18.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PLG18.png" alt="enter image description here"></a></p> <p>To achieve this design I created a div of certain size. In above image background color of the div is red and green is used as smoke on top of it in some pattern. How can I create such patterns ? What are different ways to achieve this in CSS ?</p> <pre><code>&lt;div id="canvas" style="background-color:red;"&gt; &lt;/div&gt; </code></pre> <p>This is all I could do. I created a similar color pattern (the pattern of green) on photoshop. Placed it on this div then tried to change the color of that pattern. But it didnot reflect any changes.</p>
0debug
Docker look at the log of an exited container : <p>Is there any way I can see the log of a container that has exited?</p> <p>I can get the container id of the exited container using <code>docker ps -a</code> but I want to know what happened when it was running.</p>
0debug
Iterator is not including values added to it inside the loop : I am using `ids.each do |id|` which will loop through the id and look for child ids to add to the `ids` array. At the start, ids contains 1 value, but during the first iteration it gets a second value. However, the iterator only runs once. the second value is never accessed Here's my code: ids = [1] ids.each do |id| # Do some things ids |= search_for_more_ids(id) # ids is now [1,2] but the loop still exists on the first iteration end It's weird because this used to work. Any help would be appreciated
0debug
static int vapic_prepare(VAPICROMState *s) { vapic_map_rom_writable(s); if (patch_hypercalls(s) < 0) { return -1; } vapic_enable_tpr_reporting(true); return 0; }
1threat
How do I set score in a for loop, after a an if, and switch statement? : This is some code for an Android program I am currently writing: try { reader = new BufferedReader( new InputStreamReader(getAssets().open("Words.txt"))); int i = 0; int f=0; int h=0; int k=0; String mLine; String[] lines = new String[1500]; while (((mLine = reader.readLine()) != null)) { lines[i] = mLine; i++; } for (int q = 0; q < lines.length; q++) { if(lines[q].contentEquals((wordEntry.getText()))) { int length = wordEntry.length(); switch (length) { case 3: f++; continue; case 4: h++; continue; case 5: k++; continue; } } else score.setText("Incorrect"); } int total=(f*3)+(h*4)+(k*5); score.setText(String.valueOf(total)); } catch (IOException e) { e.printStackTrace(); } } }); I am attempting to record the amount of times a user's input matches input from a text file. And if the entries are a length of 3, 4, or 5, the total score should increase by however long the user's entry is. Instead, what happens is the score label updates each time to either 3, 4, or 5. Any help will be greatly appreciated!
0debug
How to implement info about error when send message in MessageKit? SWIFT : <p>How to implement info about error when send message in MessageKit? I need show info when message not send. Any ideas?</p>
0debug
Calculated value from a variable conditionated by a third variable in R : I´m working in R with a dataframe that includes Patient_ID, date, ulcer_area(cm2), initial measure(yes/no). Each patien has one or more measures of area (ulcer_area) in different dates I´m trying to create for EACH patient a new variable called area_dif that is a proportion of de current measure and the initial measure area_dif = by Patien_ID (ulcer_area/(ulcer_area WHERE initial measure=yes)) [database][1] [1]: https://i.stack.imgur.com/pvgD2.png
0debug
pandas check if column is null with query function : <p>I have pandas dataframe that I want to execute on it query function with isnull() or not isnull() condition like that:</p> <pre><code>In [67]: df_data = pd.DataFrame({'a':[1,20,None,40,50]}) In [68]: df_data Out[68]: a 0 1.0 1 20.0 2 NaN 3 40.0 4 50.0 </code></pre> <p>if I use this command:</p> <pre><code>df_data.query('a isnull', engine='python') </code></pre> <p>or this command:</p> <pre><code>df_data.query('a isnull()', engine='python') </code></pre> <p>I get an error:</p> <pre><code>In [75]: df_data.query('a isnull', engine='python') File "&lt;unknown&gt;", line 1 a isnull SyntaxError: invalid syntax In [76]: df_data.query('a isnull()', engine='python') File "&lt;unknown&gt;", line 1 a isnull () SyntaxError: invalid syntax </code></pre> <p>What is the right way to do that?</p> <p>Thank you.</p>
0debug
static void sdram_map_bcr (ppc4xx_sdram_t *sdram) { int i; for (i = 0; i < sdram->nbanks; i++) { if (sdram->ram_sizes[i] != 0) { sdram_set_bcr(&sdram->bcr[i], sdram_bcr(sdram->ram_bases[i], sdram->ram_sizes[i]), 1); } else { sdram_set_bcr(&sdram->bcr[i], 0x00000000, 0); } } }
1threat
An uncaught Exception was encountered : <p>Type: Exception</p> <p>Message: Session: Configured save path 'C:\Windows\Temp' is not writable by the PHP process.</p>
0debug