problem
stringlengths
26
131k
labels
class label
2 classes
java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter : <p>After installing JDK9, I get this exception when running my Scala projects. Upgrading Scala to 2.12.2 also didn't resolve my problem. </p>
0debug
Connect to psql instance running in a docker container : I have a simple flask application running with an instance of psql using docker-compose. How can I connect to my psql instance? Here is my docker-compose file: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> version: '2' services: web: build: . command: python manage.py runserver volumes: - .:/app ports: - 5000:5000 links: - postgres env_file: - .env postgres: image: postgres:9.4 ports: - 5432:5432 environment: POSTGRES_PASSWORD: user POSTGRES_USER: password POSTGRES_DB: postgresdb <!-- end snippet -->
0debug
Input data using Scanner in Java : <p>Can anyone one tell what this statement exactly does?</p> <pre><code>Scanner input = new Scanner(System.in) ; </code></pre> <p>what is (input) a variable or an object.What is System.in? Please someone tell me what is meaning of this whole statement</p>
0debug
static void setup_vm_cmd(IVState *s, const char *cmd, bool msix) { uint64_t barsize; s->qtest = qtest_start(cmd); s->pcibus = qpci_init_pc(NULL); s->dev = get_device(s->pcibus); s->reg_base = qpci_iomap(s->dev, 0, &barsize); g_assert_nonnull(s->reg_base); g_assert_cmpuint(barsize, ==, 256); if (msix) { qpci_msix_enable(s->dev); } s->mem_base = qpci_iomap(s->dev, 2, &barsize); g_assert_nonnull(s->mem_base); g_assert_cmpuint(barsize, ==, TMPSHMSIZE); qpci_device_enable(s->dev); }
1threat
How can I get this text with the ID? : <p>Hello I have this code in HTML :</p> <pre><code>&lt;td id="t_startdate"&gt;2019-04-29 00:00&lt;/td&gt; </code></pre> <p>And I would like to get <code>2019-04-29 00:00</code> using jquery I tried this :</p> <pre><code>var start = $('#t_startdate'); </code></pre> <p>But when I try to show the variable start with :</p> <pre><code>alert(start); </code></pre> <p>I get <code>undefined</code></p> <p>Could you help me please ?</p> <p>Thank you !</p>
0debug
AVRational av_d2q(double d, int max) { AVRational a; int exponent; int64_t den; if (isnan(d)) return (AVRational) { 0,0 }; if (fabs(d) > INT_MAX + 3LL) return (AVRational) { d < 0 ? -1 : 1, 0 }; frexp(d, &exponent); exponent = FFMAX(exponent-1, 0); den = 1LL << (61 - exponent); av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, max); if ((!a.num || !a.den) && d && max>0 && max<INT_MAX) av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, INT_MAX); return a; }
1threat
why is the output of System.out.println((5/2.0)*2); is 5.0? : <p>I think 5 is an int. But there are no variables. I don't know why the output is a double. I tried in Netbeans already.</p>
0debug
what algorithm does STL size() use to find the size of string or vector in c++ : what algorithm does STL size() use to find the size of string or vector in c++? I know that working of strlen() is dependent on finding the NUL character in the c char array but I want to know how does size() function work to find the size of string which is not null terminated as we know. Does stl containers use some sort of pointers to mark the ending of container? And does that help in finding the size or something else?
0debug
void parse_option_size(const char *name, const char *value, uint64_t *ret, Error **errp) { uint64_t size; int err; err = qemu_strtosz(value, NULL, &size); if (err == -ERANGE) { error_setg(errp, "Value '%s' is too large for parameter '%s'", value, name); return; } if (err) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, name, "a non-negative number below 2^64"); error_append_hint(errp, "Optional suffix k, M, G, T, P or E means" " kilo-, mega-, giga-, tera-, peta-\n" "and exabytes, respectively.\n"); return; } *ret = size; }
1threat
void blk_mig_init(void) { QSIMPLEQ_INIT(&block_mig_state.bmds_list); QSIMPLEQ_INIT(&block_mig_state.blk_list); qemu_mutex_init(&block_mig_state.lock); register_savevm_live(NULL, "block", 0, 1, &savevm_block_handlers, &block_mig_state); }
1threat
Print all arrays with m number of -1 and n-m number of 1 : <p>Given the number of elements n and m i have to print all different arrays with m number of -1 values and n-m values of 1.</p>
0debug
def remove_tuple(test_list): res = [sub for sub in test_list if not all(ele == None for ele in sub)] return (str(res))
0debug
How to test android application using android studio? : <p>i am an QA i am performing Manual Testing for testing the Android Applications.</p> <p>Now, i am planning to test android applications by using automation tools. i tried Robotium. it seemed to an paid version. so i dropped Robotium.</p> <p>i am preferring Android studio. i am not having sufficient knowledge over android studio.</p> <p>While gathering data about this, i found Android Studio has Monkey and Monkey Runner. for Unit Testing.</p> <p>Is there any other tool can be useful for Android Testing? and say how to test applications with that tools.</p>
0debug
Use Moment to get month of Date object : <p>I'm sure this is a simple thing but I haven't been able to find the specific syntax in any of the documentation or in any related posts. </p> <p>In order to get a month-picker to work i need to instantiate a new <code>Date</code> object when my controller initializes. </p> <p><strong>Controller</strong></p> <pre><code>scope.date = new Date(); </code></pre> <p>This creates a date object with the following format: </p> <blockquote> <p>Mon Feb 01 2016 15:21:43 GMT-0500 (Eastern Standard Time)</p> </blockquote> <p>However when I attempt to pull the month from the date object, using moment, I get the error: </p> <blockquote> <p>enter code here</p> </blockquote> <p><strong>getMonth method</strong></p> <pre><code>var month = moment().month(scope.date, "ddd MMM DD YYYY"); </code></pre> <p>Any idea how to pull the month from the above date object without using substring?</p>
0debug
static void pxa2xx_lcdc_dma0_redraw_rot270(PXA2xxLCDState *s, hwaddr addr, int *miny, int *maxy) { DisplaySurface *surface = qemu_console_surface(s->con); int src_width, dest_width; drawfn fn = NULL; if (s->dest_width) { fn = s->line_fn[s->transp][s->bpp]; } if (!fn) { return; } src_width = (s->xres + 3) & ~3; if (s->bpp == pxa_lcdc_19pbpp || s->bpp == pxa_lcdc_18pbpp) { src_width *= 3; } else if (s->bpp > pxa_lcdc_16bpp) { src_width *= 4; } else if (s->bpp > pxa_lcdc_8bpp) { src_width *= 2; } dest_width = s->yres * s->dest_width; *miny = 0; framebuffer_update_display(surface, s->sysmem, addr, s->xres, s->yres, src_width, -s->dest_width, dest_width, s->invalidated, fn, s->dma_ch[0].palette, miny, maxy); }
1threat
window.location.href = 'http://attack.com?user=' + user_input;
1threat
void *qemu_get_ram_ptr(ram_addr_t addr) { RAMBlock *prev; RAMBlock **prevp; RAMBlock *block; #ifdef CONFIG_KQEMU if (kqemu_phys_ram_base) { return kqemu_phys_ram_base + addr; } #endif prev = NULL; prevp = &ram_blocks; block = ram_blocks; while (block && (block->offset > addr || block->offset + block->length <= addr)) { if (prev) prevp = &prev->next; prev = block; block = block->next; } if (!block) { fprintf(stderr, "Bad ram offset %" PRIx64 "\n", (uint64_t)addr); abort(); } if (prev) { prev->next = block->next; block->next = *prevp; *prevp = block; } return block->host + (addr - block->offset); }
1threat
Capture negative dollar values : <p>the following expression captures positive dollar values i.e. 400$ how can i modify this to capture negative values only.</p> <pre><code>pattern = re.compile(r'^\d+\$$') </code></pre>
0debug
static int hq_decode_block(HQContext *c, GetBitContext *gb, int16_t block[64], int qsel, int is_chroma, int is_hqa) { const int32_t *q; int val, pos = 1; memset(block, 0, 64 * sizeof(*block)); if (!is_hqa) { block[0] = get_sbits(gb, 9) * 64; q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)]; } else { q = ff_hq_quants[qsel][is_chroma][get_bits(gb, 2)]; block[0] = get_sbits(gb, 9) * 64; } for (;;) { val = get_vlc2(gb, c->hq_ac_vlc.table, 9, 2); if (val < 0) return AVERROR_INVALIDDATA; pos += ff_hq_ac_skips[val]; if (pos >= 64) break; block[ff_zigzag_direct[pos]] = (ff_hq_ac_syms[val] * q[pos]) >> 12; pos++; } return 0; }
1threat
simple http server (epoll) : I continue learn network programming using c/c++, and after that I have created multi process tcp server, I want to create simple http server, which return static resources, I use epoll so let me show my code first of all I use [fd passing for handle request in workers][1] so, my main function and head process struct Descriptors{ int sv[2]; }; class Parent{ public: static Parent& getInstance(){ static Parent instance; return instance; } Parent(Parent const&) = delete; void operator=(Parent const&) = delete; void addFd(int fd){ m_fd.push_back(fd); }; void run() { startServer(); size_t index = 0; while(true){ struct epoll_event Events[MAX_EVENTS]; int N = epoll_wait(m_epoll, Events, MAX_EVENTS, -1); for (size_t i =0; i < N; ++i){ if (Events[i].events & EPOLLHUP){ epoll_ctl(m_epoll, EPOLL_CTL_DEL, Events[i].data.fd, &(Events[i])); shutdown(Events[i].data.fd,SHUT_RDWR); close(Events[i].data.fd); continue; }else { if (Events[i].data.fd == m_masterSocket) { handleConnection(); }else { char * arg = "1"; ssize_t size = sock_fd_write(m_fd[index], arg, 1,Events[i].data.fd); index = (1+index) % m_fd.size(); } } } } } private: Parent(){ m_numCpu = sysconf(_SC_NPROCESSORS_ONLN); } void startServer(){ m_masterSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); struct sockaddr_in SockAddr; SockAddr.sin_family = AF_INET; SockAddr.sin_port = htons(11141); SockAddr.sin_addr.s_addr = htonl(INADDR_ANY); bind(m_masterSocket, (struct sockaddr *)(&SockAddr), sizeof(SockAddr)); set_nonblock(m_masterSocket); listen(m_masterSocket, SOMAXCONN); m_epoll = epoll_create1(0); struct epoll_event Event; Event.data.fd = m_masterSocket; Event.events = EPOLLIN | EPOLLRDHUP; epoll_ctl(m_epoll, EPOLL_CTL_ADD, m_masterSocket, &Event); } void handleConnection(){ int SlaveSocket = accept(m_masterSocket, 0, 0); set_nonblock(SlaveSocket); struct epoll_event Event; Event.data.fd = SlaveSocket; Event.events = EPOLLIN | EPOLLRDHUP; epoll_ctl(m_epoll, EPOLL_CTL_ADD, SlaveSocket, &Event); } int m_epoll; int m_masterSocket; int m_numCpu; std::vector<int> m_fd; }; void parent(int sock){ Parent::getInstance().addFd(sock); } int main(int argc, char **argv){ int numCpu = sysconf(_SC_NPROCESSORS_ONLN); std::vector<Descriptors> desc; desc.resize(numCpu); bool isParent = true; for (int i = 0; i < numCpu && isParent; ++i){ std::cout << "pid my is = " << getpid() <<std::endl; int sv[2]; if (socketpair(AF_UNIX, SOCK_STREAM, 0, sv) < 0) { perror("socketpair"); exit(1); } pid_t forkId = fork(); switch (forkId){ case 0:{ isParent = false; close(sv[0]); child(sv[1]); break; } case -1: perror("fork"); exit(1); default: close(sv[1]); parent(sv[0]); break; } } if (isParent){ Parent::getInstance().run(); int status; waitpid(-1, &status, 0); } } And my worker process is void respond(int fd) { char mesg[99999], *reqline[3], data_to_send[BYTES], path[99999]; int rcvd, fileDesc, bytes_read; memset( (void*)mesg, (int)'\0', 99999 ); const char *ROOT = "/home/misha/web_server/"; int RecvResult = recv(fd,mesg, 99999, MSG_NOSIGNAL); if (RecvResult == 0 && errno != EAGAIN){ shutdown(fd,SHUT_RDWR); close(fd); }else if (RecvResult >0){ printf("%s", mesg); reqline[0] = strtok (mesg, " \t\n"); // split on lexemes if ( strncmp(reqline[0], "GET\0", 4)==0 ) // if first 4 character equal { reqline[1] = strtok (NULL, " \t"); reqline[2] = strtok (NULL, " \t\n"); std::cout << "reqline 1 " << reqline[1] << std::endl; std::cout << "reqline 2 " << reqline[2] << std::endl; if ( strncmp( reqline[2], "HTTP/1.0", 8)!=0 && strncmp(reqline[2], "HTTP/1.1", 8 ) !=0 ) { write(fd, "HTTP/1.0 400 Bad Request\n", 25); } else { if ( strncmp(reqline[1], "/\0", 2)==0 ) reqline[1] = "/index.html"; strcpy(path, ROOT); strcpy(&path[strlen(ROOT)], reqline[1]); printf("file: %s\n", path); if ( (fileDesc=open(path, O_RDONLY))!=-1 ) { send(fd, "HTTP/1.0 200 OK\n\n", 17, 0); while ( (bytes_read=read(fileDesc, data_to_send, BYTES))>0 ) write (fd, data_to_send, bytes_read); } else write(fd, "HTTP/1.0 404 Not Found\n", 23); } } } shutdown(fd,SHUT_RDWR); close(fd); } void child(int sock) { int fd; char buf[16]; ssize_t size; sleep(1); for (;;) { size = sock_fd_read(sock, buf, sizeof(buf), &fd); if (size <= 0) break; if (fd != -1) { respond(fd); } } printf("child processes is end\n"); } And when I go in browser http://127.0.0.1:11141/ it is ok, and I get index.html, but when I run in apache benchmark, as ab -n 10 -c 10 http://127.0.0.1:11141/ I get answer as This is ApacheBench, Version 2.3 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient)...apr_socket_recv: Connection reset by peer (104) Total of 2 requests completed I don't understand where is my error, because I I think that my server in theory(because using epoll ) have to resolved [C10K problem][2]. but on the practice, my server can not resolved 10 connection. Could you help me please? Thank you for useful links and any advices! [1]: http://keithp.com/blogs/fd-passing/ [2]: http://www.kegel.com/c10k.html
0debug
ng-reflect-model shows correct value but not reflecting in input : <p>Encountered a very weird issue where my application misbehaves in a very specific user case. I have a portal where users can add questions and answers and then edit them. In this case when I remove a set(q+a) and then try adding it, the model is getting updated but my view takes values from placeholders and updates itself. Here I am just splicing and pushing values in an array and rendering using ngFor. The last element is a dummy and that is used to enter values which are pushed up.</p> <p>Attaching a screenshot if it makes any sense.</p> <p>You can see that for the textbox, the ng-reflect-model shows correct question, but the element itself displays the placeholder text.</p> <p><a href="https://i.stack.imgur.com/h7PY3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/h7PY3.png" alt=""></a></p>
0debug
Android calendar example : i'm trying to use material calendar view library <https://github.com/prolificinteractive/material-calendarview> in my app. The problem is that I need to creare the calendar view in a fragment and on date click I need to create another fragment related to the selected date. Can anyone do an example for this?
0debug
int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputFormat *fmt, AVDictionary **options) { AVFormatContext *s = *ps; int ret = 0; AVFormatParameters ap = { 0 }; AVDictionary *tmp = NULL; if (!s && !(s = avformat_alloc_context())) return AVERROR(ENOMEM); if (fmt) s->iformat = fmt; if (options) av_dict_copy(&tmp, *options, 0); if ((ret = av_opt_set_dict(s, &tmp)) < 0) goto fail; if ((ret = init_input(s, filename)) < 0) goto fail; if (s->iformat->flags & AVFMT_NEEDNUMBER) { if (!av_filename_number_test(filename)) { ret = AVERROR(EINVAL); goto fail; } } s->duration = s->start_time = AV_NOPTS_VALUE; av_strlcpy(s->filename, filename, sizeof(s->filename)); if (s->iformat->priv_data_size > 0) { if (!(s->priv_data = av_mallocz(s->iformat->priv_data_size))) { ret = AVERROR(ENOMEM); goto fail; } if (s->iformat->priv_class) { *(const AVClass**)s->priv_data = s->iformat->priv_class; av_opt_set_defaults(s->priv_data); if ((ret = av_opt_set_dict(s->priv_data, &tmp)) < 0) goto fail; } } if (s->pb) ff_id3v2_read(s, ID3v2_DEFAULT_MAGIC); if (s->iformat->read_header) if ((ret = s->iformat->read_header(s, &ap)) < 0) goto fail; if (s->pb && !s->data_offset) s->data_offset = avio_tell(s->pb); s->raw_packet_buffer_remaining_size = RAW_PACKET_BUFFER_SIZE; if (options) { av_dict_free(options); *options = tmp; } *ps = s; return 0; fail: av_dict_free(&tmp); if (s->pb && !(s->flags & AVFMT_FLAG_CUSTOM_IO)) avio_close(s->pb); avformat_free_context(s); *ps = NULL; return ret; }
1threat
bool vhost_dev_query(struct vhost_dev *hdev, VirtIODevice *vdev) { BusState *qbus = BUS(qdev_get_parent_bus(DEVICE(vdev))); VirtioBusState *vbus = VIRTIO_BUS(qbus); VirtioBusClass *k = VIRTIO_BUS_GET_CLASS(vbus); return !k->query_guest_notifiers || k->query_guest_notifiers(qbus->parent) || hdev->force; }
1threat
How to disable pane switching with ESC in Tmux : <p>I noticed that esc will also start listening for instructions to switch panes. I'm new to Tmux, I copied a Tmux conf file earlier today which <em>should</em> only have enabled alt to switch panes, so I'm not sure if this conf file enabled it or if it's standard in Tmux 2.3.</p> <p>Seeing as I tend to start moving around after entering normal mode, this annoys the hell out of me. Can anyone tell me how to disable pane switching with esc?</p>
0debug
static int dvdsub_parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size) { DVDSubParseContext *pc = s->priv_data; if (pc->packet_index == 0) { if (buf_size < 2) return buf_size; pc->packet_len = AV_RB16(buf); if (pc->packet_len == 0) pc->packet_len = AV_RB32(buf+2); av_freep(&pc->packet); pc->packet = av_malloc(pc->packet_len); } if (pc->packet) { if (pc->packet_index + buf_size <= pc->packet_len) { memcpy(pc->packet + pc->packet_index, buf, buf_size); pc->packet_index += buf_size; if (pc->packet_index >= pc->packet_len) { *poutbuf = pc->packet; *poutbuf_size = pc->packet_len; pc->packet_index = 0; return buf_size; } } else { pc->packet_index = 0; } } *poutbuf = NULL; *poutbuf_size = 0; return buf_size; }
1threat
How can i read an entire text from a txt file? : <p>Im working on a project for school, and im stuck at reading a txt file, i tried using this code </p> <pre><code>public static String txt (String a) { String[] Text= new String[Readfile.counter(a)]; // Creates a string array for every word String s=""; int i=0; try{ Scanner scan =new Scanner(new File(a)); while(scan.hasNext()){ s =scan.next(); // läser en rad från fil till s Text[i]=s; i++; // System.out.print(s + " "); // skriver ut den } } catch( Exception exp) {} String txt= Arrays.toString(Text); return txt; } </code></pre> <p>wanted to save the strings in an array as it loops then turn it into a string, but the problem here is that the results will have brackets"[]" and commas "," in it. Is there any way to read the entire txt file and save it in a single variable?</p>
0debug
static void result_to_network(RDMARegisterResult *result) { result->rkey = htonl(result->rkey); result->host_addr = htonll(result->host_addr); };
1threat
use reduce instead of for loop : <p>I want to convert this code to use reduce instead of for loop.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>var a = [1, 2, 30, 4, 5, 6]; var add = 0; var r = []; for (var i = 0; i &lt; a.length; i++) { add = 0; for (var j = 0; j &lt; i; j++) { add += a[j]; } if (a[i] &gt; add) { r.push(a[i]); } } console.log(r); // =&gt; [ 1, 2, 30 ]</code></pre> </div> </div> </p> <p>How we can get same out put using reduce?</p>
0debug
static uint_fast8_t vorbis_floor0_decode(vorbis_context *vc, vorbis_floor_data *vfu, float *vec) { vorbis_floor0 * vf=&vfu->t0; float * lsp=vf->lsp; uint_fast32_t amplitude; uint_fast32_t book_idx; amplitude=get_bits(&vc->gb, vf->amplitude_bits); if (amplitude>0) { float last = 0; uint_fast16_t lsp_len = 0; uint_fast16_t idx; vorbis_codebook codebook; book_idx=get_bits(&vc->gb, ilog(vf->num_books)); if ( book_idx >= vf->num_books ) { av_log( vc->avccontext, AV_LOG_ERROR, "floor0 dec: booknumber too high!\n" ); } AV_DEBUG( "floor0 dec: booknumber: %u\n", book_idx ); codebook=vc->codebooks[vf->book_list[book_idx]]; while (lsp_len<vf->order) { int vec_off; AV_DEBUG( "floor0 dec: book dimension: %d\n", codebook.dimensions ); AV_DEBUG( "floor0 dec: maximum depth: %d\n", codebook.maxdepth ); vec_off=get_vlc2(&vc->gb, codebook.vlc.table, codebook.nb_bits, codebook.maxdepth ) * codebook.dimensions; AV_DEBUG( "floor0 dec: vector offset: %d\n", vec_off ); for (idx=0; idx<codebook.dimensions; ++idx) { lsp[lsp_len+idx]=codebook.codevectors[vec_off+idx]+last; } last=lsp[lsp_len+idx-1]; lsp_len += codebook.dimensions; } #ifdef V_DEBUG { int idx; for ( idx = 0; idx < lsp_len; ++idx ) AV_DEBUG("floor0 dec: coeff at %d is %f\n", idx, lsp[idx] ); } #endif { int i; int order=vf->order; float wstep=M_PI/vf->bark_map_size; for(i=0;i<order;i++) { lsp[i]=2.0f*cos(lsp[i]); } AV_DEBUG("floor0 synth: map_size=%d; m=%d; wstep=%f\n", vf->map_size, order, wstep); i=0; while(i<vf->map_size) { int j, iter_cond=vf->map[i]; float p=0.5f; float q=0.5f; float two_cos_w=2.0f*cos(wstep*iter_cond); for(j=0;j<order;j+=2) { q *= lsp[j] -two_cos_w; p *= lsp[j+1]-two_cos_w; } if(j==order) { p *= p*(2.0f-two_cos_w); q *= q*(2.0f+two_cos_w); } else { q *= two_cos_w-lsp[j]; p *= p*(4.f-two_cos_w*two_cos_w); q *= q; } { int_fast32_t pow_of_two=2, exponent=vf->amplitude_bits; if ( vf->amplitude_bits ) { while ( --exponent ) { pow_of_two <<= 1; } } else { pow_of_two=1; } q=exp( ( ( (amplitude*vf->amplitude_offset)/ ((pow_of_two-1) * sqrt(p+q)) ) - vf->amplitude_offset ) * .11512925f ); } do { vec[i]=q; ++i; }while(vf->map[i]==iter_cond); } } } else { return 1; } AV_DEBUG(" Floor0 decoded\n"); return 0; }
1threat
static PXA2xxI2SState *pxa2xx_i2s_init(MemoryRegion *sysmem, hwaddr base, qemu_irq irq, qemu_irq rx_dma, qemu_irq tx_dma) { PXA2xxI2SState *s = (PXA2xxI2SState *) g_malloc0(sizeof(PXA2xxI2SState)); s->irq = irq; s->rx_dma = rx_dma; s->tx_dma = tx_dma; s->data_req = pxa2xx_i2s_data_req; pxa2xx_i2s_reset(s); memory_region_init_io(&s->iomem, NULL, &pxa2xx_i2s_ops, s, "pxa2xx-i2s", 0x100000); memory_region_add_subregion(sysmem, base, &s->iomem); vmstate_register(NULL, base, &vmstate_pxa2xx_i2s, s); return s; }
1threat
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
int udp_output(struct socket *so, struct mbuf *m, struct sockaddr_in *addr) { struct sockaddr_in saddr, daddr; saddr = *addr; if ((so->so_faddr.s_addr & htonl(0xffffff00)) == special_addr.s_addr) { if ((so->so_faddr.s_addr & htonl(0x000000ff)) == htonl(0xff)) saddr.sin_addr.s_addr = alias_addr.s_addr; else if (addr->sin_addr.s_addr == loopback_addr.s_addr || ((so->so_faddr.s_addr & htonl(CTL_DNS)) == htonl(CTL_DNS))) saddr.sin_addr.s_addr = so->so_faddr.s_addr; } daddr.sin_addr = so->so_laddr; daddr.sin_port = so->so_lport; return udp_output2(so, m, &saddr, &daddr, so->so_iptos); }
1threat
static int nvenc_upload_frame(AVCodecContext *avctx, const AVFrame *frame, NvencSurface *nvenc_frame) { NvencContext *ctx = avctx->priv_data; NvencDynLoadFunctions *dl_fn = &ctx->nvenc_dload_funcs; NV_ENCODE_API_FUNCTION_LIST *p_nvenc = &dl_fn->nvenc_funcs; int res; NVENCSTATUS nv_status; if (avctx->pix_fmt == AV_PIX_FMT_CUDA || avctx->pix_fmt == AV_PIX_FMT_D3D11) { int reg_idx = nvenc_register_frame(avctx, frame); if (reg_idx < 0) { av_log(avctx, AV_LOG_ERROR, "Could not register an input HW frame\n"); return reg_idx; } res = av_frame_ref(nvenc_frame->in_ref, frame); if (res < 0) return res; nvenc_frame->in_map.version = NV_ENC_MAP_INPUT_RESOURCE_VER; nvenc_frame->in_map.registeredResource = ctx->registered_frames[reg_idx].regptr; nv_status = p_nvenc->nvEncMapInputResource(ctx->nvencoder, &nvenc_frame->in_map); if (nv_status != NV_ENC_SUCCESS) { av_frame_unref(nvenc_frame->in_ref); return nvenc_print_error(avctx, nv_status, "Error mapping an input resource"); } ctx->registered_frames[reg_idx].mapped = 1; nvenc_frame->reg_idx = reg_idx; nvenc_frame->input_surface = nvenc_frame->in_map.mappedResource; nvenc_frame->format = nvenc_frame->in_map.mappedBufferFmt; nvenc_frame->pitch = frame->linesize[0]; return 0; } else { NV_ENC_LOCK_INPUT_BUFFER lockBufferParams = { 0 }; lockBufferParams.version = NV_ENC_LOCK_INPUT_BUFFER_VER; lockBufferParams.inputBuffer = nvenc_frame->input_surface; nv_status = p_nvenc->nvEncLockInputBuffer(ctx->nvencoder, &lockBufferParams); if (nv_status != NV_ENC_SUCCESS) { return nvenc_print_error(avctx, nv_status, "Failed locking nvenc input buffer"); } nvenc_frame->pitch = lockBufferParams.pitch; res = nvenc_copy_frame(avctx, nvenc_frame, &lockBufferParams, frame); nv_status = p_nvenc->nvEncUnlockInputBuffer(ctx->nvencoder, nvenc_frame->input_surface); if (nv_status != NV_ENC_SUCCESS) { return nvenc_print_error(avctx, nv_status, "Failed unlocking input buffer!"); } return res; } }
1threat
How To Configure Queue Name for Queue Trigger In Azure Function App : <p>I'm creating a function app in Azure and want to use a queue trigger. I know how to configure the queue name at design time, e.g:</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-html lang-html prettyprint-override"><code>[FunctionName("MyTestFunction")] public static void Run([QueueTrigger("myqueue-items", Connection = "testdelete")]string myQueueItem, TraceWriter log)</code></pre> </div> </div> </p> <p>However, I'd like to be able to define and reference it in a configuration file. I'm aware of the existence of function.json (Probably this one), host.json and local.settings.json, but I don't know how to set a queue name in there and have it be referenced in the function.</p> <p>If I deploy a freshly created function created in visual studio (With the new 15.3 update), I can see the following in the function.json file post deployment (even though the file doesn't exist when i develop locally):</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-html lang-html prettyprint-override"><code> "bindings": [ { "type": "queueTrigger", "queueName": "myqueue-items", "connection": "testdelete", "name": "myQueueItem" }</code></pre> </div> </div> </p> <p>I've found that if I create that file, and change the "queueName" to something that doesn't match the value in the actual function, it unfortunately doesn't override it (That would have been too easy I guess).</p> <p>How can I reference the bindings in the function.json in the functions QueueTrigger attribute?</p> <p>Presumably whatever the solution is will allow me to do the same with poison queue handling?</p> <p>The reason I want to do this, is because I need to deploy multiple instances of the exact same function, but pointing each one at a different queue (In order to get around max memory limitations).</p> <p>Thanks.</p>
0debug
static int add_shorts_metadata(int count, const char *name, const char *sep, TiffContext *s) { char *ap; int i; int16_t *sp; if (count >= INT_MAX / sizeof(int16_t) || count <= 0) return AVERROR_INVALIDDATA; if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int16_t)) return AVERROR_INVALIDDATA; sp = av_malloc(count * sizeof(int16_t)); if (!sp) return AVERROR(ENOMEM); for (i = 0; i < count; i++) sp[i] = tget_short(&s->gb, s->le); ap = shorts2str(sp, count, sep); av_freep(&sp); if (!ap) return AVERROR(ENOMEM); av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, ap, AV_DICT_DONT_STRDUP_VAL); return 0; }
1threat
Is there any function in html that displays data from a php file? : <p>I am making a html page.I also have a php file connected to a db(phpmyadmin).I need a function in html that takes data from this php file .Can sb help me?</p>
0debug
void replay_save_instructions(void) { if (replay_file && replay_mode == REPLAY_MODE_RECORD) { replay_mutex_lock(); int diff = (int)(replay_get_current_step() - replay_state.current_step); if (diff > 0) { replay_put_event(EVENT_INSTRUCTION); replay_put_dword(diff); replay_state.current_step += diff; } replay_mutex_unlock(); } }
1threat
static av_always_inline int dnxhd_decode_dct_block(const DNXHDContext *ctx, RowContext *row, int n, int index_bits, int level_bias, int level_shift, int dc_shift) { int i, j, index1, index2, len, flags; int level, component, sign; const int *scale; const uint8_t *weight_matrix; const uint8_t *ac_info = ctx->cid_table->ac_info; int16_t *block = row->blocks[n]; const int eob_index = ctx->cid_table->eob_index; int ret = 0; OPEN_READER(bs, &row->gb); ctx->bdsp.clear_block(block); if (!ctx->is_444) { if (n & 2) { component = 1 + (n & 1); scale = row->chroma_scale; weight_matrix = ctx->cid_table->chroma_weight; } else { component = 0; scale = row->luma_scale; weight_matrix = ctx->cid_table->luma_weight; } } else { component = (n >> 1) % 3; if (component) { scale = row->chroma_scale; weight_matrix = ctx->cid_table->chroma_weight; } else { scale = row->luma_scale; weight_matrix = ctx->cid_table->luma_weight; } } UPDATE_CACHE(bs, &row->gb); GET_VLC(len, bs, &row->gb, ctx->dc_vlc.table, DNXHD_DC_VLC_BITS, 1); if (len) { level = GET_CACHE(bs, &row->gb); LAST_SKIP_BITS(bs, &row->gb, len); sign = ~level >> 31; level = (NEG_USR32(sign ^ level, len) ^ sign) - sign; row->last_dc[component] += level * (1 << dc_shift); } block[0] = row->last_dc[component]; i = 0; UPDATE_CACHE(bs, &row->gb); GET_VLC(index1, bs, &row->gb, ctx->ac_vlc.table, DNXHD_VLC_BITS, 2); while (index1 != eob_index) { level = ac_info[2*index1+0]; flags = ac_info[2*index1+1]; sign = SHOW_SBITS(bs, &row->gb, 1); SKIP_BITS(bs, &row->gb, 1); if (flags & 1) { level += SHOW_UBITS(bs, &row->gb, index_bits) << 7; SKIP_BITS(bs, &row->gb, index_bits); } if (flags & 2) { UPDATE_CACHE(bs, &row->gb); GET_VLC(index2, bs, &row->gb, ctx->run_vlc.table, DNXHD_VLC_BITS, 2); i += ctx->cid_table->run[index2]; } if (++i > 63) { av_log(ctx->avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", n, i); ret = -1; break; } j = ctx->scantable.permutated[i]; level *= scale[i]; level += scale[i] >> 1; if (level_bias < 32 || weight_matrix[i] != level_bias) level += level_bias; level >>= level_shift; block[j] = (level ^ sign) - sign; UPDATE_CACHE(bs, &row->gb); GET_VLC(index1, bs, &row->gb, ctx->ac_vlc.table, DNXHD_VLC_BITS, 2); } CLOSE_READER(bs, &row->gb); return ret; }
1threat
MongoDB - shutting down with code 48 : <p>I am trying to start MongoDB but the terminal returns the following error:</p> <pre><code>2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] MongoDB starting : pid=25184 port=27017 dbpath=/data/db 64-bit host=Janiss-MacBook-Pro.local 2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] db version v3.4.1 2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] git version: 5e103c4f5583e2566a45d740225dc250baacfbd7 2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2k 26 Jan 2017 2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] allocator: system 2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] modules: none 2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] build environment: 2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] distarch: x86_64 2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] target_arch: x86_64 2017-02-06T16:26:27.037+0000 I CONTROL [initandlisten] options: {} 2017-02-06T16:26:27.038+0000 E NETWORK [initandlisten] listen(): bind() failed Address already in use for socket: 0.0.0.0:27017 2017-02-06T16:26:27.038+0000 E NETWORK [initandlisten] addr already in use 2017-02-06T16:26:27.038+0000 E NETWORK [initandlisten] Failed to set up sockets during startup. 2017-02-06T16:26:27.038+0000 E STORAGE [initandlisten] Failed to set up listener: InternalError: Failed to set up sockets 2017-02-06T16:26:27.038+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets... 2017-02-06T16:26:27.038+0000 I NETWORK [initandlisten] shutdown: going to flush diaglog... 2017-02-06T16:26:27.039+0000 I CONTROL [initandlisten] now exiting 2017-02-06T16:26:27.039+0000 I CONTROL [initandlisten] shutting down with code:48 </code></pre> <p>I am using Laravel Valet if that matters.</p>
0debug
Activity can still call unbinded service method. Is it normal? : Please forgive my unperfect English. I am studying services, and I have written a code to bind a service by clicking on a button, run a method of the service by clicking on another button and unbinding service by clicking on a third button. If I try to run the method of the service before binding I get, obviousy, an error message, while if I first bind the service the method is normally called. The question is, if I click on the third button to unbind the service, despite the service native method onUnbind(Intent intent) gives me a positive feedback, I am still able to call the service method from the main activity like if it should still be bound. Here is the Service code <pre> package com.antonello.tavolaccio4; import android.app.Service; import android.content.Intent; import android.os.Binder; import android.os.IBinder; import android.support.annotation.Nullable; /** * Created by Antonello on 14/05/2017. */ public class Servizio extends Service{ public IBinder binder=new MyBinder(); @Nullable @Override public IBinder onBind(Intent intent) { return binder; } @Override public boolean onUnbind(Intent intent){ System.out.println("unbinded"); return false; } public class MyBinder extends Binder{ Servizio getService(){ return Servizio.this; } } public void metodo(){ System.out.println("Metodo del service"); } } </pre> and here is the MainActivity code: <pre> package com.antonello.tavolaccio4; import android.app.Activity; import android.app.Service; import android.content.ComponentName; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.IBinder; import android.view.View; import android.widget.Button; public class MainActivity extends Activity { ServiceConnection serviceConnection; Servizio servizio; Button button; Button button2; Button button3; boolean bound; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button=(Button)findViewById(R.id.button); button2=(Button)findViewById(R.id.button2); button3=(Button)findViewById(R.id.button3); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(getApplicationContext(),Servizio.class); bindService(intent,serviceConnection, Service.BIND_AUTO_CREATE); } }); button2.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { servizio.metodo(); } }); button3.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { unbindService(serviceConnection); } }); serviceConnection = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { Servizio.MyBinder binder=(Servizio.MyBinder)service; servizio=binder.getService(); bound=true; System.out.println(bound); } @Override public void onServiceDisconnected(ComponentName name) { } }; } } </pre> Is there anything wrong in my <b>unbindService</b> method? Thank you for any help.
0debug
static int parse_chr(DeviceState *dev, Property *prop, const char *str) { CharDriverState **ptr = qdev_get_prop_ptr(dev, prop); *ptr = qemu_chr_find(str); if (*ptr == NULL) return -ENOENT; return 0; }
1threat
In React.js should I make my initial network request in componentWillMount or componentDidMount? : <p>In the react docs it recommends making initial network requests in the <code>componentDidMount</code> method:</p> <blockquote> <p><code>componentDidMount()</code> is invoked immediately after a component is mounted. Initialization that requires DOM nodes should go here. If you need to load data from a remote endpoint, <strong>this is a good place to instantiate the network request.</strong> Setting state in this method will trigger a re-rendering.</p> </blockquote> <p>If <code>componentWillMount</code> is called before rendering the component, isn't it better to make the request and set the state here? If I do so in <code>componentDidMount</code>, the component is rendered, the request is made, the state is changed, then the component is re-rendered. Why isn't it better to make the request before anything is rendered?</p>
0debug
How to limit SQL query to a number in a row (id-column)? : <p>How do I limit SQL data output to the "id" number? I want to fetch the up to the id of number 10 which is 14 rows. How would I do that? I tried with a sub query but I read that sub-queries are not supported after the LIMIT keyword.</p> <p>The picture shows what should be outputted in the SQL query.</p> <p><a href="https://i.stack.imgur.com/idIQx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/idIQx.png" alt="enter image description here"></a></p>
0debug
Thread.Sleep alternative in .NET Core : <p>I'm porting a library to .NET core and to maximize portability I need to eliminate the dependency on System.Threading.Thread, and therefore Thread.Sleep. Whats an alternative to this?</p>
0debug
I cant link my style.css to index.html? : I have just started learning to code so sorry for the stupid question. I have an index.html and style.css. I currently use the inline css but I want to use a stylesheet. I have this code in my index.html just before my </head> tag.`<link rel="stylesheet" href="/style.css"> and then i have this in my style.css `body { background-color: yellow; } note both of those files are located in public_html. But whenever I open the index.html the background stays white and does not change to yellow. Thanks for your help!`
0debug
Dividing Long with Double in Java producing wrong results : <p>I am trying to divide a <code>Long</code> in Java with a percentage like <code>0.99</code> and it keeps giving me crazy results.</p> <pre><code>long totalBytes = 5877062 long final = (long) (totalBytes / 0.99) // IT PRODUCES 5936426 &gt; totalBytes </code></pre> <p><a href="https://i.stack.imgur.com/ImfS9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ImfS9.png" alt="enter image description here"></a></p> <p>what am i doing wrong ? For <code>1.00</code> it works well , if i give <code>0.95 ++</code> it always produces something bigger than the <code>totalBytes</code>.</p> <p>Why am i loosing precision ?</p> <p><code>Java Version 10.0.2</code></p>
0debug
static void test_dispatch_cmd_error(void) { QDict *req = qdict_new(); QObject *resp; qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2"))); resp = qmp_dispatch(QOBJECT(req)); assert(resp != NULL); assert(qdict_haskey(qobject_to_qdict(resp), "error")); g_print("\nresp: %s\n", qstring_get_str(qobject_to_json_pretty(resp))); qobject_decref(resp); QDECREF(req); }
1threat
NuGet Server for .NET Core : <p>The <a href="https://www.nuget.org/packages/NuGet.Server/" rel="noreferrer">NuGet.Server</a> package is used to create a ASP.NET MVC NuGet server and it works just fine. There is another package <a href="https://www.nuget.org/packages/NuGet.Server.Core/" rel="noreferrer">NuGet.Server.Core</a> that is expected to do the same when hosted within a ASP.NET Core (perhaps 1.0 or 1.1?).</p> <p>The first one creates 'Packages' folder right beneath the main folder used as a package repository.<br> No such things happens after installing the Core version. I tried both root and a dedicated folder. Googling a bit, I found no info about installing the package and integrating it in a ASP.NET Core app.</p> <p>Has anyone succeeded in installing the Core version? Also, there's another version <a href="https://www.nuget.org/packages/NuGet.Server.V2/" rel="noreferrer">NuGet.Server.V2</a> which depends on NuGet.Server.Core, however it requires .NET Framework 4.6.1. This makes me think that <strong>NuGet.Server.Core is not targetting .NET Core</strong> at all. </p> <p>If so, the name must be somewhat misleading, I guess...</p>
0debug
Java - Do a line break in JTextPane without HTML : I've been for a while searching through here and other Java forums. Also googling it, but I haven't found anything that matches my expectations (a line break, basically). I've achieved this: public final void messageRoom (String message, Boolean bold, Color color) { StyledDocument document = new DefaultStyledDocument(); SimpleAttributeSet attributes = new SimpleAttributeSet(); if(bold) { attributes.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE); } attributes.addAttribute(StyleConstants.CharacterConstants.Foreground, color); try { document.insertString(document.getLength(), message, attributes); } catch (BadLocationException ex) { System.out.println("ex"); } chatArea.setStyledDocument(document); } That allows me to send messages to a chat room I'm creating, how can I make the line break to go to the next line? Thank you all! (Similar but not equal posts: [First post][1] and [The second one][2]) [1]: http://stackoverflow.com/questions/23883475/how-to-make-jtextpane-line-break [2]: http://stackoverflow.com/questions/27677123/jtextpane-line-break
0debug
Difference between Mixer and Pilot in Istio? : <p>I have read the docs, but seem not able to understand differences between them. Is there any overlap? I mean I would like to draw a definite boundary between them to understand their responsibilities and w.r.t their communication with the envoy proxies in the mesh. (with examples use-cases if possible)</p>
0debug
CPUState *cpu_create(const char *typename) { Error *err = NULL; CPUState *cpu = CPU(object_new(typename)); object_property_set_bool(OBJECT(cpu), true, "realized", &err); if (err != NULL) { error_report_err(err); object_unref(OBJECT(cpu)); return NULL; } return cpu; }
1threat
ColdFusion IPv6 to unsigned int 128-bits : I needed to create a function that could convert an IPv6 address to its numeric representation. Working with IPv4 is pretty straight forward as it uses an 32-bit unsigned int for its numerical representation. IPv6 is represented by an 128-bit unsigned int. That size of a number is too large for the builtin ColdFusion bit logic functions to use. This function must make use of the underlying Java system to make the conversion.
0debug
What do the TargetFramework settings mean in web.config in ASP .NET MVC? : <p>One of our ASP.NET MVC 5 web applications has the following web.config settings:</p> <pre><code>&lt;system.web&gt; &lt;compilation debug="true" targetFramework="4.6" /&gt; &lt;httpRuntime targetFramework="4.5" /&gt; &lt;!--... many other things --&gt; &lt;/system.web&gt; </code></pre> <p>It is not clear why are two targetFramework settings, and it seems to be wrong to compile targeting 4.6 then trying to run under 4.5...</p> <p>Obviously I am missing something, but what?</p>
0debug
How do center of anchor in div, responsive menu? : This is link : https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_topnav in this menu in left side, it should be in center of page (horizontal). How do this and what changes needed?
0debug
pipenv: get path of virtual enviremtnt in pipenv : <p>How to can get the <code>path</code> of <code>virtualenv</code> in pipenv?</p> <p>can configure it to use a custom path for newly created <code>virtualenv</code>?</p>
0debug
Proof if property quantity is > 1 then push price * quantity : the function below loops through the properties of the objects in `var input` which is for example `[ { name: 'Nagellack 15 ml 2 2', id: '1057290002', price: '1.9', brand: 'a.o.n.', quantity: 1 }, { name: 'Ceramic Nail Lacquer 6 ml Coral Reef Coral Reef', id: '1027410001', price: '6.9', brand: 'Artdeco', quantity: 1 } ]` and pushes new objects into `products_list []` I'm trying to set up a condition which proofs when the quantity of an object is > 1 and then multiplies the price with the quantity. The issue here is, that I only get the price of one product although there is a quantity of 2. I don't know which is the best place in the code set up the condition. function() { var input = {{dl_purchase_products}}; var products_list = []; for(i=0;i<input.length;i++){ products_list.push({ id: input[i].id.slice(0,6), price: input[i].price, <---- this should be the price for 2 quantity: input[i].quantity }); } return products_list; } Thanks a lot! Best regards, Anton
0debug
Use R to look for files in all sub-directories : <p>I am on a machine running Windows 10 with RStudio (0.99.893). I am running into a problem whereby I want to include ALL filetypes (.cnv) into one dataframe. In the past all the files have been in one directory so this following has worked fine:</p> <pre><code>setwd(directory path) df &lt;- c() for (x in list.files(pattern="*.cnv")) { u&lt;-read.table(x) u$Filename = factor(x) df &lt;- rbind(df, u) } </code></pre> <p>Now I am faced with a situation where there are several sub-directories with irregular names. Before I was telling R "move to this directory, look for all files with .cnv, then combine them into one dataframe". Now I need to tell R "move to this directory, look in this directory and all sub-directories for files with .cnv then combine them into a dataframe. </p> <p>Any idea how I might accomplish within R?</p>
0debug
static int v9fs_walk_marshal(V9fsPDU *pdu, uint16_t nwnames, V9fsQID *qids) { int i; size_t offset = 7; offset += pdu_marshal(pdu, offset, "w", nwnames); for (i = 0; i < nwnames; i++) { offset += pdu_marshal(pdu, offset, "Q", &qids[i]); } return offset; }
1threat
static int pad_count(const AVFilterPad *pads) { int count; if (!pads) return 0; for(count = 0; pads->name; count ++) pads ++; return count; }
1threat
void vm_stop(int reason) { QemuThread me; qemu_thread_self(&me); if (!qemu_thread_equal(&me, &io_thread)) { qemu_system_vmstop_request(reason); cpu_stop_current(); return; } do_vm_stop(reason); }
1threat
syntax error in array. javascript-codewars challenge-"who likes it kata" : Im having trouble with input array, attempting a javascript challenge on CodeWars. Here is the instruction: Implement a function likes :: [String] -> String, which must take in input array, containing the names of people who like an item. It must return the display text as shown in the examples: likes [] // must be "no one likes this" likes ["Peter"] // must be "Peter likes this" likes ["Jacob", "Alex"] // must be "Jacob and Alex like this" likes ["Max", "John", "Mark"] // must be "Max, John and Mark like this" likes ["Alex", "Jacob", "Mark", "Max"] // must be "Alex, Jacob and 2 others like this" basicliy its like the facebook like system. could someone please explain what im doing wrong. Here is my try code function likes (names) { var names[7]; if ( names.length=0) { return "nobody likes this" } else if (names.length=1) { return names[0]+"likes this"; } else if (names.length=2) { return names[0]+names[1]"like this" } else if (names.length=3) { return names[0]+''+names [1]+''+names[2]+''+ " likes this" } else (names.length >3) { return names[0]+''+names [1]+''+ names.length-1 + "likes this" }
0debug
Pointers in C - int array VS char array : <p>I know similar questions have been asked, but this one is specific to arrays. </p> <p>I can do this:</p> <pre><code>char *names[] = { "John", "Paul", "George", "Ringo" }; </code></pre> <p>and then:</p> <pre><code>printf("%s\n", names[0]); </code></pre> <p>So why does this not work?:</p> <pre><code>int *numbers[] = { 11, 12, 13, 14 }; printf("%d\n", numbers[0]); </code></pre> <p>Thanks</p>
0debug
How is this method using a parameter that is never given a value? : <p>I came across the .every() method today and found this example code to explain how it works:</p> <pre><code>var ages = [32, 33, 16, 40]; function checkAdult(age) { return age &gt;= 18; } function myFunction() { document.getElementById("demo").innerHTML = ages.every(checkAdult); } </code></pre> <p>The result of <code>myFunction()</code> is <code>false</code>, and I understand what the method is doing (going through each value of the array and checking if the value is <code>&gt;= 18</code>, but I don't understand how the <code>.every()</code> method is able to use the <code>age</code> parameter in its return statement without <code>age</code> being declared in the method call.</p> <p>Does the method somehow automatically know that it should be referencing the index of the array it's looking at? That's the only explanation I can come up with, but I can't find any explanation of this online.</p>
0debug
Remove suffix after file type windows : I have a folder full of CSV files which get stored with a time stamp and an identifier after the file type, meaning windows does not recognise the files as CSVs (and any VBA code to access them won't recognise them either). The file format is always: ABCDEFG.csv.20161205-071658 "ABCDEFG.csv" never changes. How do I remove all characters after the second "."? Thank you very much for any help, this is driving me nuts.
0debug
How can I share config file like appsettings.json across multiple ASP.NET CORE projects in one solution in Visual Studio 2015? : <p>I have 3 ASP.NET CORE projects in one solution and I want to share connection string information in one config file like appsettings.json across these projects.</p> <p>How can I do this in Visual Studio 2015 ?</p>
0debug
Google Map is not showing up : <p>I am working on this website <a href="http://dev5.99medialabtest2.com/carwash/" rel="nofollow noreferrer">http://dev5.99medialabtest2.com/carwash/</a> In the bottom, there is a section "Our Location". There is all code for the map, you can check it by inspect feature, but the map is not showing up on the front end.</p> <p>Can anyone help please?</p>
0debug
how to find the week which secured highest sales ..using map and reducer : how to find the week which secured highest sales ..using map and reducer this is my sample .csv file how can i find the week that has the highest sale train.csv Store,Dept,Date,Weekly_Sales,IsHoliday 1,1,2010-02-05,24924.5,FALSE 1,1,2010-02-12,46039.49,TRUE 1,1,2010-02-19,41595.55,FALSE 1,1,2010-02-26,19403.54,FALSE 1,1,2010-03-05,21827.9,FALSE 1,1,2010-03-12,21043.39,FALSE 1,1,2010-03-19,22136.64,FALSE 1,1,2010-03-26,26229.21,FALSE 1,1,2010-04-02,57258.43,FALSE thanks in Advance
0debug
float64 HELPER(recpe_f64)(float64 input, void *fpstp) { float_status *fpst = fpstp; float64 f64 = float64_squash_input_denormal(input, fpst); uint64_t f64_val = float64_val(f64); uint64_t f64_sbit = 0x8000000000000000ULL & f64_val; int64_t f64_exp = extract64(f64_val, 52, 11); float64 r64; uint64_t r64_val; int64_t r64_exp; uint64_t r64_frac; if (float64_is_any_nan(f64)) { float64 nan = f64; if (float64_is_signaling_nan(f64)) { float_raise(float_flag_invalid, fpst); nan = float64_maybe_silence_nan(f64); } if (fpst->default_nan_mode) { nan = float64_default_nan; } return nan; } else if (float64_is_infinity(f64)) { return float64_set_sign(float64_zero, float64_is_neg(f64)); } else if (float64_is_zero(f64)) { float_raise(float_flag_divbyzero, fpst); return float64_set_sign(float64_infinity, float64_is_neg(f64)); } else if ((f64_val & ~(1ULL << 63)) < (1ULL << 50)) { float_raise(float_flag_overflow | float_flag_inexact, fpst); if (round_to_inf(fpst, f64_sbit)) { return float64_set_sign(float64_infinity, float64_is_neg(f64)); } else { return float64_set_sign(float64_maxnorm, float64_is_neg(f64)); } } else if (f64_exp >= 1023 && fpst->flush_to_zero) { float_raise(float_flag_underflow, fpst); return float64_set_sign(float64_zero, float64_is_neg(f64)); } r64 = call_recip_estimate(f64, 2045, fpst); r64_val = float64_val(r64); r64_exp = extract64(r64_val, 52, 11); r64_frac = extract64(r64_val, 0, 52); return make_float64(f64_sbit | ((r64_exp & 0x7ff) << 52) | r64_frac); }
1threat
How do I reference and dereference different data types from void pointer? : <pre><code>void *ptr; int num = 13; char c = 'q'; </code></pre> <p>Without using struct, is it possible to reference 'num' and 'c' and then deference from the void pointer?</p>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
static void do_info_uuid(Monitor *mon) { monitor_printf(mon, UUID_FMT "\n", qemu_uuid[0], qemu_uuid[1], qemu_uuid[2], qemu_uuid[3], qemu_uuid[4], qemu_uuid[5], qemu_uuid[6], qemu_uuid[7], qemu_uuid[8], qemu_uuid[9], qemu_uuid[10], qemu_uuid[11], qemu_uuid[12], qemu_uuid[13], qemu_uuid[14], qemu_uuid[15]); }
1threat
ng-click is not working in angularjs. Please help some one. : <li> <a href="javascript:;"> <i class="fa fa-file-excel-o" ng-click="export()"></i> Export to Excel </a> </li> Here is the click function.but it is not working properly. pleas help.
0debug
C programming ASCII basic : <p>I have char like </p> <pre><code> char testniPodatak[14] = "1234567890"; </code></pre> <p>I want to test that every c in string is value from 0-9 according ascii table..</p> <p>I do like this:</p> <pre><code>for (int i = 0; i &lt; 9; i++) { if (ISBN10[i] &lt; 48 || ISBN10[i] &gt;57) { return 3; } } </code></pre> <p>If is out of range function need to return 3 , but in above string there is all chars 0-9, function return 3 on first iteration..</p> <p>Here is table with ascii values <a href="https://allrounder163.files.wordpress.com/2014/09/ascii.png" rel="nofollow">https://allrounder163.files.wordpress.com/2014/09/ascii.png</a></p> <p>Thanks</p>
0debug
Batch File SIP ALG test : <p>The below line has a program that runs like a batch file.</p> <p>I'm needing to create something similar that can run as just a batch file to test for SIP or ALG. </p> <p><a href="https://kb.iplogin.ca/hc/en-us/articles/360003299092-Prepare-Your-Network-for-Phones-line-test-ports-and-protocols-" rel="nofollow noreferrer">https://kb.iplogin.ca/hc/en-us/articles/360003299092-Prepare-Your-Network-for-Phones-line-test-ports-and-protocols-</a></p> <p>I work at for a Telecommunications company and it would be a great tool for us to use. - Many thanks </p> <p><a href="https://i.stack.imgur.com/ZG6bw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZG6bw.png" alt="enter image description here"></a></p>
0debug
Program will not run completely through code (no errors) Python 2.7.15 : <p>I am very new to programming (as in a few weeks ago - sorry in advance for any ignorant coding!) but I am trying to run a function defined and user input code that finds the minimum of 3 integers. It will properly ask for the 3 integers, but then returns nothing after that even though I have the minimum function written. <a href="https://i.stack.imgur.com/x4dQ3.png" rel="nofollow noreferrer">My code:</a></p>
0debug
static bool object_create_initial(const char *type) { if (g_str_equal(type, "rng-egd")) { /* * return false for concrete netfilters since * they depend on netdevs already existing if (g_str_equal(type, "filter-buffer") || g_str_equal(type, "filter-dump") || g_str_equal(type, "filter-mirror") || g_str_equal(type, "filter-redirector")) { return true;
1threat
static uint32_t virtio_blk_get_features(VirtIODevice *vdev) { VirtIOBlock *s = to_virtio_blk(vdev); uint32_t features = 0; features |= (1 << VIRTIO_BLK_F_SEG_MAX); features |= (1 << VIRTIO_BLK_F_GEOMETRY); if (bdrv_enable_write_cache(s->bs)) features |= (1 << VIRTIO_BLK_F_WCACHE); #ifdef __linux__ features |= (1 << VIRTIO_BLK_F_SCSI); #endif if (strcmp(s->serial_str, "0")) features |= 1 << VIRTIO_BLK_F_IDENTIFY; if (bdrv_is_read_only(s->bs)) features |= 1 << VIRTIO_BLK_F_RO; return features; }
1threat
How to set password to staging env for a django app on Heroku? : <p>I'd like to password-protect my staging environment so it's not accessible to the public. Also, the password protection should not be tied to Django's authentication backend, so that I can test features (e.g. creating an account for user, logging in / out, etc.). How best to achieve that?</p>
0debug
whats wrong with the function set_title() in my code : <p>I have created a function called set_title(), which is used to set the title and description in the database I don't know where I was wrong </p> <pre><code> function set_title($file,$title = "",$description = ""){ $pathinfo = pathinfo($file); $file = $pathinfo['basename']; if ($title == "") { $title = ucfirst($pathinfo['filename']); } if ($description !== "") { $description = mb_substr($description, 0, 150); } $sql = "SELECT file, title ,description FROM title WHERE file = '$file'"; $con = new mysqli('localhost','root','','jbstore'); $result = $con-&gt;query($sql); if($result-&gt;num_rows &gt; 0){ $data = $result-&gt;fetch_assoc(); if($data['description'] == ""){ $sql = "INSERT INTO title (description) VALUES('$description')"; $con-&gt;query($sql); } }elseif ($result-&gt;num_rows == 0) { $sql = "INSERT INTO title (file,title,description) VALUES ('$file','$title',$description)"; $result = $con-&gt;query($sql); } } </code></pre> <p>I expected it insert data into database but nothing happens</p>
0debug
void bdrv_aio_cancel(BlockDriverAIOCB *acb) { if (acb->cb == bdrv_aio_rw_vector_cb) { VectorTranslationState *s = acb->opaque; acb = s->aiocb; } acb->pool->cancel(acb); }
1threat
Custom grafana datasource plugin to wrap external REST API : <p>I'm trying to figure out a way to create a data-source plugin which can communicate with an external REST API and provide relevant data to draw a panel.</p> <p>Anyone with previous experience?</p>
0debug
Type macros in C++ : <pre><code> #define int double #define double int int a = 5.5; double f = 5.5; cout &lt;&lt; a &lt;&lt; " " &lt;&lt; f &lt;&lt; endl; </code></pre> <p>Following code snippet actually outputs 5 5.5, meaning int actually means int, and double actually means double.</p> <p>I am wondering how does that make sense? I could either believe both int and double meaning int, if defines are executed one after another, or two of them changing their meaning (if both of them are executed simultaneously), but I can't find proper explanation for this behaviour.</p> <p>Why does this happen?</p>
0debug
.NET Ulong to binary string representation? : <p>I now want to print on the screen the binary (base 2) representation of a ulong (i.e. something like 0000000000000000000000001, I know that's not enough zeroes)</p> <p>I just noticed that for some reason there's no Convert.ToString(ulong, base) overload, meaning that I <strong>can</strong> convert a <strong>long</strong> into a base2 string representation, but I can't do the same with <strong>ulong</strong>. </p> <p>Is there any other .net method to do this? Is there a reason why this method is not there? (the method is there for uint). Will casting it to a long yield the same results?</p> <p>Thanks a lot =)</p>
0debug
How can I improve the precision of a double in c++? : <p>I would like to improve the precision of a double. It seems the precision of double and float is the same. (I also need a better precision for my future c++ plans.)</p> <p>I have no clue how to do this.</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { double fraction1 = 0.123467890123456789; float fraction2 = 0.123467890123456789; cout &lt;&lt; fraction1 &lt;&lt; endl; cout &lt;&lt; fraction2 &lt;&lt; endl; return 0; } </code></pre> <p>This yields:</p> <p>0.123468 <br> 0.123468</p> <p>I would have expected something like a precision of 10 or more digits.</p>
0debug
static void config_parse(GAConfig *config, int argc, char **argv) { const char *sopt = "hVvdm:p:l:f:F::b:s:t:D"; int opt_ind = 0, ch; const struct option lopt[] = { { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, { "dump-conf", 0, NULL, 'D' }, { "logfile", 1, NULL, 'l' }, { "pidfile", 1, NULL, 'f' }, #ifdef CONFIG_FSFREEZE { "fsfreeze-hook", 2, NULL, 'F' }, #endif { "verbose", 0, NULL, 'v' }, { "method", 1, NULL, 'm' }, { "path", 1, NULL, 'p' }, { "daemonize", 0, NULL, 'd' }, { "blacklist", 1, NULL, 'b' }, #ifdef _WIN32 { "service", 1, NULL, 's' }, #endif { "statedir", 1, NULL, 't' }, { NULL, 0, NULL, 0 } }; config->log_level = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL; while ((ch = getopt_long(argc, argv, sopt, lopt, &opt_ind)) != -1) { switch (ch) { case 'm': g_free(config->method); config->method = g_strdup(optarg); break; case 'p': g_free(config->channel_path); config->channel_path = g_strdup(optarg); break; case 'l': g_free(config->log_filepath); config->log_filepath = g_strdup(optarg); break; case 'f': g_free(config->pid_filepath); config->pid_filepath = g_strdup(optarg); break; #ifdef CONFIG_FSFREEZE case 'F': g_free(config->fsfreeze_hook); config->fsfreeze_hook = g_strdup(optarg ?: QGA_FSFREEZE_HOOK_DEFAULT); break; #endif case 't': g_free(config->state_dir); config->state_dir = g_strdup(optarg); break; case 'v': config->log_level = G_LOG_LEVEL_MASK; break; case 'V': printf("QEMU Guest Agent %s\n", QEMU_VERSION); exit(EXIT_SUCCESS); case 'd': config->daemonize = 1; break; case 'D': config->dumpconf = 1; break; case 'b': { if (is_help_option(optarg)) { qmp_for_each_command(ga_print_cmd, NULL); exit(EXIT_SUCCESS); } config->blacklist = g_list_concat(config->blacklist, split_list(optarg, ",")); break; } #ifdef _WIN32 case 's': config->service = optarg; if (strcmp(config->service, "install") == 0) { if (ga_install_vss_provider()) { exit(EXIT_FAILURE); } if (ga_install_service(config->channel_path, config->log_filepath, config->state_dir)) { exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); } else if (strcmp(config->service, "uninstall") == 0) { ga_uninstall_vss_provider(); exit(ga_uninstall_service()); } else if (strcmp(config->service, "vss-install") == 0) { if (ga_install_vss_provider()) { exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); } else if (strcmp(config->service, "vss-uninstall") == 0) { ga_uninstall_vss_provider(); exit(EXIT_SUCCESS); } else { printf("Unknown service command.\n"); exit(EXIT_FAILURE); } break; #endif case 'h': usage(argv[0]); exit(EXIT_SUCCESS); case '?': g_print("Unknown option, try '%s --help' for more information.\n", argv[0]); exit(EXIT_FAILURE); } } }
1threat
int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) { if (lockmgr_cb) { lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY); lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY); lockmgr_cb = NULL; codec_mutex = NULL; avformat_mutex = NULL; } if (cb) { void *new_codec_mutex = NULL; void *new_avformat_mutex = NULL; int err; if (err = cb(&new_codec_mutex, AV_LOCK_CREATE)) { return err > 0 ? AVERROR_UNKNOWN : err; } if (err = cb(&new_avformat_mutex, AV_LOCK_CREATE)) { cb(&new_codec_mutex, AV_LOCK_DESTROY); return err > 0 ? AVERROR_UNKNOWN : err; } lockmgr_cb = cb; codec_mutex = new_codec_mutex; avformat_mutex = new_avformat_mutex; } return 0; }
1threat
How do I get the current action from within a controller? : <p>How do I get the current action from within a controller? <code>current_page?</code> works for views, but not controllers.</p> <pre><code>redirect_to step3_users_path unless current_page?(step3_users_path) </code></pre> <p>I also tried</p> <pre><code>controller.action_name == 'step3' </code></pre> <p>I also tried</p> <pre><code>params[:action_name] == 'step3' </code></pre>
0debug
hi i need to Read a txt file and then use the first column data as a parameter to create a matrix (c#) : txt, this are the first 10 columns of 210 total,the numbers are saparated by spaces and only the first column is diferent, the other 210 columns are similar 210 7 15.26 14.84 0.871 5.763 3.312 2.221 5.22 14.88 14.57 0.8811 5.554 3.333 1.018 4.956 14.29 14.09 0.905 5.291 3.337 2.699 4.825 13.84 13.94 0.8955 5.324 3.379 2.259 4.805 16.14 14.99 0.9034 5.658 3.562 1.355 5.175 14.38 14.21 0.8951 5.386 3.312 2.462 4.956 14.69 14.49 0.8799 5.563 3.259 3.586 5.219 14.11 14.1 0.8911 5.42 3.302 2.7 5 16.63 15.46 0.8747 6.053 3.465 2.04 5.877 i need to create a matrix using the first column data as a parameter 210 columns and 7 rows (this parameters could change like this 210 6 or 100 4) and then save the other columns in the matrix. i had this code in c++ and i just need the matrix to continue so can you please help me
0debug
static void unassigned_mem_writew(void *opaque, target_phys_addr_t addr, uint32_t val) { #ifdef DEBUG_UNASSIGNED printf("Unassigned mem write " TARGET_FMT_plx " = 0x%x\n", addr, val); #endif #if defined(TARGET_ALPHA) || defined(TARGET_SPARC) || defined(TARGET_MICROBLAZE) do_unassigned_access(addr, 1, 0, 0, 2); #endif }
1threat
static QObject *qdict_get_obj(const QDict *qdict, const char *key, QType type) { QObject *obj; obj = qdict_get(qdict, key); assert(obj != NULL); assert(qobject_type(obj) == type); return obj; }
1threat
pandas: find percentile stats of a given column : <p>I have a pandas data frame my_df, where I can find the mean(), median(), mode() of a given column:</p> <pre><code>my_df['field_A'].mean() my_df['field_A'].median() my_df['field_A'].mode() </code></pre> <p>I am wondering is it possible to find more detailed stats such as 90 percentile? Thanks!</p>
0debug
static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) { XlnxZynqMPState *s = XLNX_ZYNQMP(dev); MemoryRegion *system_memory = get_system_memory(); uint8_t i; uint64_t ram_size; const char *boot_cpu = s->boot_cpu ? s->boot_cpu : "apu-cpu[0]"; ram_addr_t ddr_low_size, ddr_high_size; qemu_irq gic_spi[GIC_NUM_SPI_INTR]; Error *err = NULL; ram_size = memory_region_size(s->ddr_ram); if (ram_size > XLNX_ZYNQMP_MAX_LOW_RAM_SIZE) { assert(ram_size <= XLNX_ZYNQMP_MAX_RAM_SIZE); ddr_low_size = XLNX_ZYNQMP_MAX_LOW_RAM_SIZE; ddr_high_size = ram_size - XLNX_ZYNQMP_MAX_LOW_RAM_SIZE; memory_region_init_alias(&s->ddr_ram_high, NULL, "ddr-ram-high", s->ddr_ram, ddr_low_size, ddr_high_size); memory_region_add_subregion(get_system_memory(), XLNX_ZYNQMP_HIGH_RAM_START, &s->ddr_ram_high); } else { assert(ram_size); ddr_low_size = ram_size; } memory_region_init_alias(&s->ddr_ram_low, NULL, "ddr-ram-low", s->ddr_ram, 0, ddr_low_size); memory_region_add_subregion(get_system_memory(), 0, &s->ddr_ram_low); for (i = 0; i < XLNX_ZYNQMP_NUM_OCM_BANKS; i++) { char *ocm_name = g_strdup_printf("zynqmp.ocm_ram_bank_%d", i); memory_region_init_ram(&s->ocm_ram[i], NULL, ocm_name, XLNX_ZYNQMP_OCM_RAM_SIZE, &error_fatal); vmstate_register_ram_global(&s->ocm_ram[i]); memory_region_add_subregion(get_system_memory(), XLNX_ZYNQMP_OCM_RAM_0_ADDRESS + i * XLNX_ZYNQMP_OCM_RAM_SIZE, &s->ocm_ram[i]); g_free(ocm_name); } qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", GIC_NUM_SPI_INTR + 32); qdev_prop_set_uint32(DEVICE(&s->gic), "revision", 2); qdev_prop_set_uint32(DEVICE(&s->gic), "num-cpu", XLNX_ZYNQMP_NUM_APU_CPUS); object_property_set_bool(OBJECT(&s->gic), true, "realized", &err); if (err) { error_propagate(errp, err); return; } assert(ARRAY_SIZE(xlnx_zynqmp_gic_regions) == XLNX_ZYNQMP_GIC_REGIONS); for (i = 0; i < XLNX_ZYNQMP_GIC_REGIONS; i++) { SysBusDevice *gic = SYS_BUS_DEVICE(&s->gic); const XlnxZynqMPGICRegion *r = &xlnx_zynqmp_gic_regions[i]; MemoryRegion *mr = sysbus_mmio_get_region(gic, r->region_index); uint32_t addr = r->address; int j; sysbus_mmio_map(gic, r->region_index, addr); for (j = 0; j < XLNX_ZYNQMP_GIC_ALIASES; j++) { MemoryRegion *alias = &s->gic_mr[i][j]; addr += XLNX_ZYNQMP_GIC_REGION_SIZE; memory_region_init_alias(alias, OBJECT(s), "zynqmp-gic-alias", mr, 0, XLNX_ZYNQMP_GIC_REGION_SIZE); memory_region_add_subregion(system_memory, addr, alias); } } for (i = 0; i < XLNX_ZYNQMP_NUM_APU_CPUS; i++) { qemu_irq irq; char *name; object_property_set_int(OBJECT(&s->apu_cpu[i]), QEMU_PSCI_CONDUIT_SMC, "psci-conduit", &error_abort); name = object_get_canonical_path_component(OBJECT(&s->apu_cpu[i])); if (strcmp(name, boot_cpu)) { object_property_set_bool(OBJECT(&s->apu_cpu[i]), true, "start-powered-off", &error_abort); } else { s->boot_cpu_ptr = &s->apu_cpu[i]; } g_free(name); object_property_set_bool(OBJECT(&s->apu_cpu[i]), s->secure, "has_el3", NULL); object_property_set_int(OBJECT(&s->apu_cpu[i]), GIC_BASE_ADDR, "reset-cbar", &error_abort); object_property_set_bool(OBJECT(&s->apu_cpu[i]), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_connect_irq(SYS_BUS_DEVICE(&s->gic), i, qdev_get_gpio_in(DEVICE(&s->apu_cpu[i]), ARM_CPU_IRQ)); irq = qdev_get_gpio_in(DEVICE(&s->gic), arm_gic_ppi_index(i, ARM_PHYS_TIMER_PPI)); qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), 0, irq); irq = qdev_get_gpio_in(DEVICE(&s->gic), arm_gic_ppi_index(i, ARM_VIRT_TIMER_PPI)); qdev_connect_gpio_out(DEVICE(&s->apu_cpu[i]), 1, irq); } for (i = 0; i < XLNX_ZYNQMP_NUM_RPU_CPUS; i++) { char *name; name = object_get_canonical_path_component(OBJECT(&s->rpu_cpu[i])); if (strcmp(name, boot_cpu)) { object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "start-powered-off", &error_abort); } else { s->boot_cpu_ptr = &s->rpu_cpu[i]; } g_free(name); object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "reset-hivecs", &error_abort); object_property_set_bool(OBJECT(&s->rpu_cpu[i]), true, "realized", &err); if (err) { error_propagate(errp, err); return; } } if (!s->boot_cpu_ptr) { error_setg(errp, "ZynqMP Boot cpu %s not found", boot_cpu); return; } for (i = 0; i < GIC_NUM_SPI_INTR; i++) { gic_spi[i] = qdev_get_gpio_in(DEVICE(&s->gic), i); } for (i = 0; i < XLNX_ZYNQMP_NUM_GEMS; i++) { NICInfo *nd = &nd_table[i]; if (nd->used) { qemu_check_nic_model(nd, TYPE_CADENCE_GEM); qdev_set_nic_properties(DEVICE(&s->gem[i]), nd); } object_property_set_bool(OBJECT(&s->gem[i]), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->gem[i]), 0, gem_addr[i]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->gem[i]), 0, gic_spi[gem_intr[i]]); } for (i = 0; i < XLNX_ZYNQMP_NUM_UARTS; i++) { object_property_set_bool(OBJECT(&s->uart[i]), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->uart[i]), 0, uart_addr[i]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->uart[i]), 0, gic_spi[uart_intr[i]]); } object_property_set_int(OBJECT(&s->sata), SATA_NUM_PORTS, "num-ports", &error_abort); object_property_set_bool(OBJECT(&s->sata), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->sata), 0, SATA_ADDR); sysbus_connect_irq(SYS_BUS_DEVICE(&s->sata), 0, gic_spi[SATA_INTR]); for (i = 0; i < XLNX_ZYNQMP_NUM_SDHCI; i++) { char *bus_name; object_property_set_bool(OBJECT(&s->sdhci[i]), true, "realized", &err); if (err) { error_propagate(errp, err); return; } sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci[i]), 0, sdhci_addr[i]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci[i]), 0, gic_spi[sdhci_intr[i]]); bus_name = g_strdup_printf("sd-bus%d", i); object_property_add_alias(OBJECT(s), bus_name, OBJECT(&s->sdhci[i]), "sd-bus", &error_abort); g_free(bus_name); } for (i = 0; i < XLNX_ZYNQMP_NUM_SPIS; i++) { gchar *bus_name; object_property_set_bool(OBJECT(&s->spi[i]), true, "realized", &err); sysbus_mmio_map(SYS_BUS_DEVICE(&s->spi[i]), 0, spi_addr[i]); sysbus_connect_irq(SYS_BUS_DEVICE(&s->spi[i]), 0, gic_spi[spi_intr[i]]); bus_name = g_strdup_printf("spi%d", i); object_property_add_alias(OBJECT(s), bus_name, OBJECT(&s->spi[i]), "spi0", &error_abort); g_free(bus_name); } }
1threat
Understanding Chapter 2 Q 22 of A Little Java, A Few Patterns : <p>In Chapter 2 of <em>A Little Java, A Few Patterns</em>, Question 22 is:</p> <blockquote> <p>Are there only Onions on this Shish^D:</p> <p><strong>new</strong> Skewer()?</p> </blockquote> <p>Answer is:</p> <blockquote> <p>true, because there is neither Lamb nor Tomato on <strong>new</strong> Skewer().</p> </blockquote> <p><a href="http://i.stack.imgur.com/nZuyv.png" rel="nofollow">definitions of classes</a></p> <p>Skewer is a subclass of Shish^D, Onion is also a subclass of Shish^D, I don't understand why there are onions on <code>new Skewer()</code>, could someone explain this a bit further?</p>
0debug
static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data, unsigned size) { int can_write; SuperIOConfig *superio_conf = opaque; DPRINTF("superio_ioport_writeb address 0x%x val 0x%x\n", addr, data); if (addr == 0x3f0) { superio_conf->index = data & 0xff; } else { switch (superio_conf->index) { case 0x00 ... 0xdf: case 0xe4: case 0xe5: case 0xe9 ... 0xed: case 0xf3: case 0xf5: case 0xf7: case 0xf9 ... 0xfb: case 0xfd ... 0xff: can_write = 0; break; default: can_write = 1; if (can_write) { switch (superio_conf->index) { case 0xe7: if ((data & 0xff) != 0xfe) { DPRINTF("chage uart 1 base. unsupported yet\n"); } break; case 0xe8: if ((data & 0xff) != 0xbe) { DPRINTF("chage uart 2 base. unsupported yet\n"); } break; default: superio_conf->config[superio_conf->index] = data & 0xff; } } } superio_conf->config[superio_conf->index] = data & 0xff; } }
1threat
How i can automaticcly turn on location? : <p>want to automatically turn on geolocation?</p> <p>thanks all</p> <p><a href="https://i.stack.imgur.com/tP9uj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tP9uj.png" alt="like this "></a></p>
0debug
Django Model Fields Indexing : <p>I only know that indexing is helpful and it queries faster.</p> <p>What is the difference between following two?</p> <pre><code>1. class Meta: indexes = [ models.Index(fields=['last_name', 'first_name',]), models.Index(fields=['-date_of_birth',]), ] 2. class Meta: indexes = [ models.Index(fields=['first_name',]), models.Index(fields=['last_name',]), models.Index(fields=['-date_of_birth',]), ] </code></pre>
0debug
def solution (a, b, n): i = 0 while i * a <= n: if (n - (i * a)) % b == 0: return ("x = ",i ,", y = ", int((n - (i * a)) / b)) return 0 i = i + 1 return ("No solution")
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
void qemu_put_byte(QEMUFile *f, int v) { if (!f->last_error && f->is_write == 0 && f->buf_index > 0) { fprintf(stderr, "Attempted to write to buffer while read buffer is not empty\n"); abort(); } f->buf[f->buf_index++] = v; f->is_write = 1; if (f->buf_index >= IO_BUF_SIZE) { int ret = qemu_fflush(f); qemu_file_set_if_error(f, ret); } }
1threat