problem
stringlengths
26
131k
labels
class label
2 classes
How to display tictactoe board using map and forEach? : <p>I want to display tic tac toe board. Something like that:</p> <pre><code>XXX XXX XXX </code></pre> <p>Is it possible to use for each to achieve that? I tried to do some:</p> <pre><code> Map&lt;Integer, Tile&gt; board = generateBoard(); for (Map.Entry&lt;Integer, Tile&gt; entry: board.entrySet()){ System.out.print(entry.getValue().getSign()); } board.forEach((k,v) -&gt; { int i = 1; if(i % 3 == 0){ System.out.println(); } System.out.print(v.getSign()); i++; }); </code></pre> <p>But my output is incorrect. Could you give me any output to achieve me this output?</p>
0debug
In Java, how can I convert a string to a double (not Double)? : <p>It's part of a school lab and I've researched and I can't find anything to accomplish this task. I'm reading in lines from a file using FileReader and BufferedReader. The data in the file is a name and an age in the following format:</p> <p>John doe 20 </p> <p>Jane doe 30</p> <p>etc. I already have code that will take each line and split as such: split[0] = {"John", "doe", "20"}</p> <p>I need to get the "20" and store in an array of doubles such as double[0] = 20;</p> <p>The reason it has to be a double and not Double is because that part of the code in the assignment is already written and I'm sure I cannot just decide to change everything and use a Double instead. How can I do this? Thank you in advance!</p>
0debug
Change class on first element with Jquery : <p>I have a certain amount of <code>divs</code> inside another <code>div</code>, I need to change the first child class.</p> <pre><code>&lt;div class="parent"&gt; &lt;div class="item"&gt;&lt;/div&gt; &lt;div class="item"&gt;&lt;/div&gt; &lt;div class="item"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>The idea is to change to <code>item</code> active the first item</p> <p>I tried:</p> <pre><code>$("parent").first("item").removeclass("item").addclass("item active"); </code></pre> <p>but is not working</p>
0debug
static int dirac_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt) { DiracContext *s = avctx->priv_data; AVFrame *picture = data; uint8_t *buf = pkt->data; int buf_size = pkt->size; int i, data_unit_size, buf_idx = 0; int ret; for (i = 0; i < MAX_FRAMES; i++) if (s->all_frames[i].avframe->data[0] && !s->all_frames[i].avframe->reference) { av_frame_unref(s->all_frames[i].avframe); memset(s->all_frames[i].interpolated, 0, sizeof(s->all_frames[i].interpolated)); } s->current_picture = NULL; *got_frame = 0; if (buf_size == 0) return get_delayed_pic(s, (AVFrame *)data, got_frame); for (;;) { for (; buf_idx + DATA_UNIT_HEADER_SIZE < buf_size; buf_idx++) { if (buf[buf_idx ] == 'B' && buf[buf_idx+1] == 'B' && buf[buf_idx+2] == 'C' && buf[buf_idx+3] == 'D') break; } if (buf_idx + DATA_UNIT_HEADER_SIZE >= buf_size) break; data_unit_size = AV_RB32(buf+buf_idx+5); if (data_unit_size > buf_size - buf_idx || !data_unit_size) { if(data_unit_size > buf_size - buf_idx) av_log(s->avctx, AV_LOG_ERROR, "Data unit with size %d is larger than input buffer, discarding\n", data_unit_size); buf_idx += 4; continue; } ret = dirac_decode_data_unit(avctx, buf+buf_idx, data_unit_size); if (ret < 0) { av_log(s->avctx, AV_LOG_ERROR,"Error in dirac_decode_data_unit\n"); return ret; } buf_idx += data_unit_size; } if (!s->current_picture) return buf_size; if (s->current_picture->avframe->display_picture_number > s->frame_number) { DiracFrame *delayed_frame = remove_frame(s->delay_frames, s->frame_number); s->current_picture->avframe->reference |= DELAYED_PIC_REF; if (add_frame(s->delay_frames, MAX_DELAY, s->current_picture)) { int min_num = s->delay_frames[0]->avframe->display_picture_number; av_log(avctx, AV_LOG_ERROR, "Delay frame overflow\n"); for (i = 1; s->delay_frames[i]; i++) if (s->delay_frames[i]->avframe->display_picture_number < min_num) min_num = s->delay_frames[i]->avframe->display_picture_number; delayed_frame = remove_frame(s->delay_frames, min_num); add_frame(s->delay_frames, MAX_DELAY, s->current_picture); } if (delayed_frame) { delayed_frame->avframe->reference ^= DELAYED_PIC_REF; if((ret=av_frame_ref(data, delayed_frame->avframe)) < 0) return ret; *got_frame = 1; } } else if (s->current_picture->avframe->display_picture_number == s->frame_number) { if((ret=av_frame_ref(data, s->current_picture->avframe)) < 0) return ret; *got_frame = 1; } if (*got_frame) s->frame_number = picture->display_picture_number + 1; return buf_idx; }
1threat
Why is angular.io using old version of Angular? : <p>If I read the source of <a href="https://angular.io/" rel="nofollow noreferrer">https://angular.io/</a> right, it looks to me that they are still using Angular 1 there i.e. 1.6 version. To me it is a hint that while the new version of Angular is very advanced there are still challenges when it comes to production deployments of sites that are publicly available?</p>
0debug
void hmp_sendkey(Monitor *mon, const QDict *qdict) { const char *keys = qdict_get_str(qdict, "keys"); KeyValueList *keylist, *head = NULL, *tmp = NULL; int has_hold_time = qdict_haskey(qdict, "hold-time"); int hold_time = qdict_get_try_int(qdict, "hold-time", -1); Error *err = NULL; char keyname_buf[16]; char *separator; int keyname_len; while (1) { separator = strchr(keys, '-'); keyname_len = separator ? separator - keys : strlen(keys); pstrcpy(keyname_buf, sizeof(keyname_buf), keys); if (!strncmp(keyname_buf, "<", 1) && keyname_len == 1) { pstrcpy(keyname_buf, sizeof(keyname_buf), "less"); keyname_len = 4; } keyname_buf[keyname_len] = 0; keylist = g_malloc0(sizeof(*keylist)); keylist->value = g_malloc0(sizeof(*keylist->value)); if (!head) { head = keylist; } if (tmp) { tmp->next = keylist; } tmp = keylist; if (strstart(keyname_buf, "0x", NULL)) { char *endp; int value = strtoul(keyname_buf, &endp, 0); if (*endp != '\0') { goto err_out; } keylist->value->type = KEY_VALUE_KIND_NUMBER; keylist->value->u.number = value; } else { int idx = index_from_key(keyname_buf); if (idx == Q_KEY_CODE__MAX) { goto err_out; } keylist->value->type = KEY_VALUE_KIND_QCODE; keylist->value->u.qcode = idx; } if (!separator) { break; } keys = separator + 1; } qmp_send_key(head, has_hold_time, hold_time, &err); hmp_handle_error(mon, &err); out: qapi_free_KeyValueList(head); return; err_out: monitor_printf(mon, "invalid parameter: %s\n", keyname_buf); goto out; }
1threat
Should I use a macro or a variable? : <p>I am rewriting a function and I noticed one particular variable is never reassigned after initialization. Is there any reason NOT to simply convert this variable to a macro? Is a macro ALWAYS preferable in this case?</p> <p>Thanks!</p>
0debug
What does ~ mean in Dart? : <p>Seen tilde in a few code examples in Dart. I've seen it used in C++ as a destructor where it can be called to delete the instance of a object Has it the same function in Dart? Is there an equivalent symbol in Java?</p>
0debug
Why is my constructor not initiliazing a variable correctly? : So I am trying to read in a file and create an arralist of those objects. The number of objects within the file is what I want my numItems variable to be set to, but I am getting an error. public class Warehouse { // instance variables (fields) private final static int MAX = 60; private ArrayList <Item> stock; private int numItems; // the constructor public Warehouse() { stock = new ArrayList<Item>(); numItems = loadData(); } public int loadData(File infile) throws IOException { Scanner in = new Scanner (infile); int number = 0; while(in.hasNext()) { String item = in.nextLine(); String [] items = item.split(" "); String itemNum = items[0]; String itemName = items[1]; int onHand = Integer.parseInt(items[2]); int committed = Integer.parseInt(items[3]); int onOrder = Integer.parseInt(items[4]); double price = Double.parseDouble(items[5]); int reOrderPt = Integer.parseInt(items[6]); int econOrder = Integer.parseInt(items[7]); stock.add(number, new Item(itemNum, itemName, onHand, committed, onOrder, price, reOrderPt, econOrder)); number++; } return number; }
0debug
Is function(){}() valid? : <p>In a Javascript programming community, someone asked "How to declare anonymous method and run it immediately?" then others answered <code>(function(){})()</code> and <code>(function(){}())</code>.<br> People who answered <code>(function(){}())</code> says that is correct and it's possible to run, but ideone says that is wrong and I think that is incorrect.<br> Following links are for comparison between SpiderMonkey and Rhino.<br> <a href="http://ideone.com/rKaYtW" rel="nofollow noreferrer">http://ideone.com/rKaYtW</a><br> <a href="http://ideone.com/Lblb7w" rel="nofollow noreferrer">http://ideone.com/Lblb7w</a> </p> <p>Is <code>(function(){}())</code> really correct on Javascript?</p>
0debug
static void *postcopy_ram_fault_thread(void *opaque) { MigrationIncomingState *mis = opaque; struct uffd_msg msg; int ret; RAMBlock *rb = NULL; RAMBlock *last_rb = NULL; trace_postcopy_ram_fault_thread_entry(); qemu_sem_post(&mis->fault_thread_sem); while (true) { ram_addr_t rb_offset; struct pollfd pfd[2]; pfd[0].fd = mis->userfault_fd; pfd[0].events = POLLIN; pfd[0].revents = 0; pfd[1].fd = mis->userfault_quit_fd; pfd[1].events = POLLIN; pfd[1].revents = 0; if (poll(pfd, 2, -1 ) == -1) { error_report("%s: userfault poll: %s", __func__, strerror(errno)); break; } if (pfd[1].revents) { trace_postcopy_ram_fault_thread_quit(); break; } ret = read(mis->userfault_fd, &msg, sizeof(msg)); if (ret != sizeof(msg)) { if (errno == EAGAIN) { continue; } if (ret < 0) { error_report("%s: Failed to read full userfault message: %s", __func__, strerror(errno)); break; } else { error_report("%s: Read %d bytes from userfaultfd expected %zd", __func__, ret, sizeof(msg)); break; } } if (msg.event != UFFD_EVENT_PAGEFAULT) { error_report("%s: Read unexpected event %ud from userfaultfd", __func__, msg.event); continue; } rb = qemu_ram_block_from_host( (void *)(uintptr_t)msg.arg.pagefault.address, true, &rb_offset); if (!rb) { error_report("postcopy_ram_fault_thread: Fault outside guest: %" PRIx64, (uint64_t)msg.arg.pagefault.address); break; } rb_offset &= ~(qemu_ram_pagesize(rb) - 1); trace_postcopy_ram_fault_thread_request(msg.arg.pagefault.address, qemu_ram_get_idstr(rb), rb_offset); if (rb != last_rb) { last_rb = rb; migrate_send_rp_req_pages(mis, qemu_ram_get_idstr(rb), rb_offset, qemu_ram_pagesize(rb)); } else { migrate_send_rp_req_pages(mis, NULL, rb_offset, qemu_ram_pagesize(rb)); } } trace_postcopy_ram_fault_thread_exit(); return NULL; }
1threat
Webview loadurl issue : I had created one activity along with webview and loaded some url in it.But when i loaded google url in webview it opens in device browser but when i loaded some other urls in it,it works fine for me. Permission added in manifest - For ex - This is open in device browser WebSettings webSettings = webVw.getSettings(); webSettings.setJavaScriptEnabled(true); webVw.loadUrl("http://www.google.com"); This is opens in webview - webVw = (WebView)findViewById(R.id.webVw); WebSettings webSettings = webVw.getSettings(); webSettings.setJavaScriptEnabled(true); webVw.loadUrl("https://stackoverflow.com"); Why this happens?Is there any other workaround to do it?
0debug
c++ create an object with constructor or wothout? : <p>I am new to c++. I have seen some example of classes. I have difficulty to understand when I have to call the costuctor (whith ()) when I create an object and when I don't have to create it with the consructor.</p>
0debug
What do tilda and caret signs do with HEAD in git? : <p>I see some people using caret and tilda sign with HEAD like HEAD^ or HEAD~(NUMBER VALUE) which i dont understand properly. </p>
0debug
static void memory_region_update_container_subregions(MemoryRegion *subregion) { hwaddr offset = subregion->addr; MemoryRegion *mr = subregion->container; MemoryRegion *other; memory_region_transaction_begin(); memory_region_ref(subregion); QTAILQ_FOREACH(other, &mr->subregions, subregions_link) { if (subregion->may_overlap || other->may_overlap) { continue; } if (int128_ge(int128_make64(offset), int128_add(int128_make64(other->addr), other->size)) || int128_le(int128_add(int128_make64(offset), subregion->size), int128_make64(other->addr))) { continue; } #if 0 printf("warning: subregion collision %llx/%llx (%s) " "vs %llx/%llx (%s)\n", (unsigned long long)offset, (unsigned long long)int128_get64(subregion->size), subregion->name, (unsigned long long)other->addr, (unsigned long long)int128_get64(other->size), other->name); #endif } QTAILQ_FOREACH(other, &mr->subregions, subregions_link) { if (subregion->priority >= other->priority) { QTAILQ_INSERT_BEFORE(other, subregion, subregions_link); goto done; } } QTAILQ_INSERT_TAIL(&mr->subregions, subregion, subregions_link); done: memory_region_update_pending |= mr->enabled && subregion->enabled; memory_region_transaction_commit(); }
1threat
Add extra properties in Custom Exception to return to AJAX function : <p>I have a custom exception class as follows:</p> <pre><code>&lt;Serializable&gt; Public Class SamException Inherits Exception Public Sub New() ' Add other code for custom properties here. End Sub Public Property OfferBugSend As Boolean = True Public Sub New(ByVal message As String) MyBase.New(message) ' Add other code for custom properties here. End Sub Public Sub New(ByVal message As String, ByVal inner As Exception) MyBase.New(message, inner) ' Add other code for custom properties here. End Sub End Class </code></pre> <p>I'm using this for certain cases in returns from AJAX responses.</p> <p>In the error function of my AJAX response I am determining that the error is of my custom type like this:</p> <pre><code>.... ajax code.... .error = function (xhr, text, message) { var parsed = JSON.parse(xhr.responseText); var isSamCustomError = (parsed.ExceptionType).toLowerCase().indexOf('samexception') &gt;= 0; .... etc.... </code></pre> <p>This allows me to post back a specific response to the client if the error is of my custom type.</p> <p>BUT... I can't seem to get it to post out the extra property <code>OfferBugSend</code> to the client for the AJAX code to handle this case differently.</p> <pre><code>console.log("OfferBugSend: " + parsed.OfferBugSend) </code></pre> <p>is showing undefined, and if I check the response, this is because <code>xhr.responseText</code> only contains the properties:</p> <pre><code>ExceptionType Message StackTrace </code></pre> <p>These properties are from the base class <code>Exception</code> but it is not passing my custom class properties...</p> <p>How can I make that happen?</p>
0debug
static int qcow_set_key(BlockDriverState *bs, const char *key) { BDRVQcowState *s = bs->opaque; uint8_t keybuf[16]; int len, i; Error *err; memset(keybuf, 0, 16); len = strlen(key); if (len > 16) len = 16; for(i = 0;i < len;i++) { keybuf[i] = key[i]; } assert(bs->encrypted); qcrypto_cipher_free(s->cipher); s->cipher = qcrypto_cipher_new( QCRYPTO_CIPHER_ALG_AES_128, QCRYPTO_CIPHER_MODE_CBC, keybuf, G_N_ELEMENTS(keybuf), &err); if (!s->cipher) { error_free(err); return -1; } return 0; }
1threat
static int tta_read_header(AVFormatContext *s, AVFormatParameters *ap) { TTAContext *c = s->priv_data; AVStream *st; int i, channels, bps, samplerate, datalen, framelen, start; start = url_ftell(&s->pb); if (get_le32(&s->pb) != ff_get_fourcc("TTA1")) return -1; url_fskip(&s->pb, 2); channels = get_le16(&s->pb); bps = get_le16(&s->pb); samplerate = get_le32(&s->pb); datalen = get_le32(&s->pb); url_fskip(&s->pb, 4); framelen = 1.04489795918367346939 * samplerate; c->totalframes = datalen / framelen + ((datalen % framelen) ? 1 : 0); c->currentframe = 0; c->seektable = av_mallocz(sizeof(uint32_t)*c->totalframes); if (!c->seektable) return AVERROR_NOMEM; for (i = 0; i < c->totalframes; i++) c->seektable[i] = get_le32(&s->pb); url_fskip(&s->pb, 4); st = av_new_stream(s, 0); if (!st) return AVERROR_NOMEM; st->codec->codec_type = CODEC_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_TTA; st->codec->channels = channels; st->codec->sample_rate = samplerate; st->codec->bits_per_sample = bps; st->codec->extradata_size = url_ftell(&s->pb) - start; if(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){ av_log(s, AV_LOG_ERROR, "extradata_size too large\n"); st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE); url_fseek(&s->pb, start, SEEK_SET); get_buffer(&s->pb, st->codec->extradata, st->codec->extradata_size); return 0;
1threat
How to create an overlay page in ionic 2? : <p>How to creating an transparent guide overlay page when i enter into new page </p> <p>How can i implement in ionic 2 ?</p> <p><a href="https://i.stack.imgur.com/zlu9a.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/zlu9a.jpg" alt="enter image description here"></a></p>
0debug
Error to load the Iran map in firefox? : Iran's map in Mozilla Firefox and other browsers other than Google Chrome does not work. There is a solution to this problem? [Link][1] [1]: https://github.com/10bestdesign/jqvmap/blob/master/examples/iran.html
0debug
How to find a cyclical python script on Ubuntu server : <p>I have a problem with the python script on the Ubuntu server. Scripts are performed every night. How can I find them? I mean their location. Crontab - empty crontab.d, .daily, .weekly - empty init.d - empty I have root access</p>
0debug
ERROR - ORA-06502: PL/SQL: numeric or value error: character string buffer too small : I am getting the ORA 06502 Error while calling this query from PL/SQL. However if i Try from sql prompt its working. ******An error was encountered - ERROR - ORA-06502: PL/SQL: numeric or value error: character string buffer too small****** SELECT * FROM ( SELECT COL.BAN, MAX (COL.COL_ACTV_CODE) AS COL_ACTV_CODE, MAX (TO_CHAR(COL.COL_ACTV_DATE,''MM'')) AS COL_ACTV_DATE FROM TABLE1 COL, TABLE2 CAC, ACD_DDR_CH ADC WHERE COL.BAN = ADC.BAN AND COL.COL_ACTV_CODE = CAC.COL_ACTIVITY_CODE AND (CAC.SEVERITY_LEVEL , TO_CHAR(COL.COL_ACTV_DATE,''YYYYMM'')) IN ( SELECT MAX(CAC.SEVERITY_LEVEL), MAX(TO_CHAR(COL.COL_ACTV_DATE, ''YYYYMM'')) FROM TABLE1 COL, TABLE2 CAC, ACD_DDR_CH ADC WHERE COL.BAN = ADC.BAN AND COL.COL_ACTV_CODE = CAC.COL_ACTIVITY_CODE AND COL.COL_ACTV_DATE <= TO_DATE(''&1'', ''YYYYMMDD'') AND COL.COL_ACTV_DATE >= TRUNC(ADD_MONTHS(TO_DATE(''&1'', ''YYYYMMDD''),-11),''MON'') GROUP BY TO_CHAR (COL.COL_ACTV_DATE , ''YYYYMM'') ) GROUP BY COL.BAN ORDER BY TO_CHAR (COL.COL_ACTV_DATE , ''YYYYMM'') DESC ) PIVOT ( MAX( COL_ACTV_CODE) FOR COL_ACTV_DATE in (''01'' as "JAN", ''02'' as "FEB", ''03'' as "MAR", ''04'' as "APR", ''05'' as "MAY", ''06'' as "JUN", ''07'' as "JUL", ''08'' as "AUG", ''09'' as "SEP", ''10'' as "OCT", ''11'' as "NOV", ''12'' as "DEC"))'; **The output from sql promt is as below:** BAN J F M A M J J A S O N D ---------- - - - - - - - - - - - - 90314228 W 90314009 K 90314748 E 90314568 E 90314328 W
0debug
static void shift_history(DCAEncContext *c, const int32_t *input) { int k, ch; for (k = 0; k < 512; k++) for (ch = 0; ch < c->channels; ch++) { const int chi = c->channel_order_tab[ch]; c->history[k][ch] = input[k * c->channels + chi]; } }
1threat
A pointer that does not print the first three words in a sentence : <p>Dont have any code get and i am stuck on how to solve this problem. I want the code to let the user input a long sentence and then a pointer that doesnt print the first 3 words of any given sentence. The tricky part for me is that the char is not defined at start so I cant just remove the words I wish. </p> <p>Exampel: </p> <p>Hello I neeed help with this code </p> <p>help with this code</p>
0debug
static void net_socket_send_dgram(void *opaque) { NetSocketState *s = opaque; int size; size = qemu_recv(s->fd, s->buf, sizeof(s->buf), 0); if (size < 0) return; if (size == 0) { net_socket_read_poll(s, false); net_socket_write_poll(s, false); return; } qemu_send_packet(&s->nc, s->buf, size); }
1threat
static int nvic_pending_prio(NVICState *s) { return s->vectpending ? s->vectors[s->vectpending].prio : NVIC_NOEXC_PRIO; }
1threat
Read txt file from drawable folder in android : <p>How to read .txt file from drawable or any other folder in android using FileInputStream?</p> <p>I have a .txt file in my drawable folder. How can i read the file and set it in Textview?</p>
0debug
static int aasc_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; AascContext *s = avctx->priv_data; int compr, i, stride, ret; s->frame.reference = 1; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if ((ret = avctx->reget_buffer(avctx, &s->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } compr = AV_RL32(buf); buf += 4; buf_size -= 4; switch (compr) { case 0: stride = (avctx->width * 3 + 3) & ~3; for (i = avctx->height - 1; i >= 0; i--) { memcpy(s->frame.data[0] + i * s->frame.linesize[0], buf, avctx->width * 3); buf += stride; } break; case 1: bytestream2_init(&s->gb, buf - 4, buf_size + 4); ff_msrle_decode(avctx, (AVPicture*)&s->frame, 8, &s->gb); break; default: av_log(avctx, AV_LOG_ERROR, "Unknown compression type %d\n", compr); return AVERROR_INVALIDDATA; } *got_frame = 1; *(AVFrame*)data = s->frame; return buf_size; }
1threat
void ff_eval_coefs(int *coefs, const int *refl) { int buffer[LPC_ORDER]; int *b1 = buffer; int *b2 = coefs; int i, j; for (i=0; i < LPC_ORDER; i++) { b1[i] = refl[i] * 16; for (j=0; j < i; j++) b1[j] = ((refl[i] * b2[i-j-1]) >> 12) + b2[j]; FFSWAP(int *, b1, b2); } for (i=0; i < LPC_ORDER; i++) coefs[i] >>= 4; }
1threat
void cpu_exec_init(CPUState *env) { CPUState **penv; int cpu_index; #if defined(CONFIG_USER_ONLY) cpu_list_lock(); #endif env->next_cpu = NULL; penv = &first_cpu; cpu_index = 0; while (*penv != NULL) { penv = &(*penv)->next_cpu; cpu_index++; } env->cpu_index = cpu_index; env->numa_node = 0; TAILQ_INIT(&env->breakpoints); TAILQ_INIT(&env->watchpoints); *penv = env; #if defined(CONFIG_USER_ONLY) cpu_list_unlock(); #endif #if defined(CPU_SAVE_VERSION) && !defined(CONFIG_USER_ONLY) vmstate_register(cpu_index, &vmstate_cpu_common, env); register_savevm("cpu", cpu_index, CPU_SAVE_VERSION, cpu_save, cpu_load, env); #endif }
1threat
Help me , i want to only call the id and need all the data like firstname,lastname,age etc in consol.log not like console.log(users.[0]); . : <p>[ { "id":1, "firstName":"Rahul", "lastName":"Kumar", "age":22, "gender":"Male", "qualification":"Btech", "mobileno":1234567891, "email":"r@xyz.com", "state":"Bihar" },</p> <p>{ "id":2, "firstName":"Ram", "lastName":"Kumar", "age":20, "gender":"Male", "qualification":"Btech", "mobileno":1234567892, "email":"ram@xyz.com", "state":"Assam" } ]</p>
0debug
Android development software for ubuntu linux : <p>I currently moved from windows to ubuntu-linux. So I want to know what would be the best software for making android applications aside from android-studio for ubuntu-linux OS</p>
0debug
How to rectify this error? : <pre><code> python serve.py /usr/local/lib/python3.4/dist-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.sqlalchemy is deprecated, use flask_sqlalchemy instead. .format(x=modname), ExtDeprecationWarning Traceback (most recent call last): File "serve.py", line 1, in &lt;module&gt; from CTFd import create_app File "/home/rajat/Downloads/CTFd/CTFd/__init__.py", line 7, in &lt;module&gt; from utils import get_config, set_config ImportError: cannot import name 'get_config' </code></pre> <p>Don't know what is causing this error</p> <p>Tried pip install utils</p> <p>Thanks in advance </p>
0debug
Edit XML Layouts Before Inflating Them : <p>I need to make changes to an XML layout file before I inflate it, but any change I try to make give a <code>null object error</code>. Is there any possible way to do this?</p>
0debug
I wants to add images in repeatbox : i m new in smartface.io software.I wants to add images in repeatbox, can someone help me to add images in repeatbox. Thanks
0debug
Find count of combination of 2 columns - Oracle SQL : <p>I have a table</p> <pre><code>table_user col1 col2 123 456 124 457 125 458 126 459 127 460 128 461 123 456 123 456 123 457 </code></pre> <p>I need to find out the combination of col1 and col2 with counts.</p> <p>In above example:</p> <pre><code>col1 col2 count_combination 123 456 3 123 457 1 124 457 1 125 458 1 126 459 1 127 460 1 128 461 1 </code></pre> <p>How can I find it?</p>
0debug
Override <ALT> to toggle menu bar on VS CODE : <p>What I want to achieve is as follows:</p> <ol> <li><p>Disable <code>ALT</code> to show menu bar by <code>toggle-menu-bar</code> completely.</p> <p>-> Potentially map <code>ALT</code> to a <code>NULL</code> action?</p></li> <li><p>Use a different shortcut to <code>toggle-menu-bar</code>. </p></li> </ol> <p>Is there a way to achieve this?</p>
0debug
How do I customise the color of HTML tags in Visual Studio Code? : <p>I'm using the Abyss theme which I like, but certain colors are too dark. I have customized some token colors using (for instance):</p> <pre><code>"editor.tokenColorCustomizations": { "[Abyss]": { "keywords": "#7ea4df", </code></pre> <p>but I can't figure out how to change the color of HTML tags in the editor. Can anyone help?</p>
0debug
static int ccid_card_init(DeviceState *qdev) { CCIDCardState *card = CCID_CARD(qdev); USBDevice *dev = USB_DEVICE(qdev->parent_bus->parent); USBCCIDState *s = USB_CCID_DEV(dev); int ret = 0; if (card->slot != 0) { error_report("Warning: usb-ccid supports one slot, can't add %d", card->slot); return -1; } if (s->card != NULL) { error_report("Warning: usb-ccid card already full, not adding"); return -1; } ret = ccid_card_initfn(card); if (ret == 0) { s->card = card; } return ret; }
1threat
picking a random char from an array : <p>I was wondering if there is a way of randomly picking a character from the following array in C but only picking each character once....</p> <pre><code>const char characters[13][4] = { 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' ,'M' , 'N' , 'O' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y', 'Z', 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' ,'O' , 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y', 'Z' }; </code></pre>
0debug
from itertools import combinations def sub_lists(my_list): subs = [] for i in range(0, len(my_list)+1): temp = [list(x) for x in combinations(my_list, i)] if len(temp)>0: subs.extend(temp) return subs
0debug
Translating HTML/JS/CSS to Ruby on Rails : <p>At the moment I have created a webpage that makes use of HTML, CSS, and Javascript but I need to implement ruby on rails next in order to do back end stuff as well as it's what my boss told me to utilize. Now I have never utilized Ruby on Rails so any guidance will be greatly appreciated. </p> <p>Now I know that CSS has pre-processors such as SASS and others but how exactly do I utilize these. I also understand the basic structure of Rails in that there are different controllers and each one corresponds to different things. </p> <p>Basically I would just like some guidance on how to implement a Ruby on Rails framework.</p> <p>If you need any other information, I would be glad to oblige you with it. </p>
0debug
soread(so) struct socket *so; { int n, nn, lss, total; struct sbuf *sb = &so->so_snd; int len = sb->sb_datalen - sb->sb_cc; struct iovec iov[2]; int mss = so->so_tcpcb->t_maxseg; DEBUG_CALL("soread"); DEBUG_ARG("so = %lx", (long )so); len = sb->sb_datalen - sb->sb_cc; iov[0].iov_base = sb->sb_wptr; if (sb->sb_wptr < sb->sb_rptr) { iov[0].iov_len = sb->sb_rptr - sb->sb_wptr; if (iov[0].iov_len > len) iov[0].iov_len = len; if (iov[0].iov_len > mss) iov[0].iov_len -= iov[0].iov_len%mss; n = 1; } else { iov[0].iov_len = (sb->sb_data + sb->sb_datalen) - sb->sb_wptr; if (iov[0].iov_len > len) iov[0].iov_len = len; len -= iov[0].iov_len; if (len) { iov[1].iov_base = sb->sb_data; iov[1].iov_len = sb->sb_rptr - sb->sb_data; if(iov[1].iov_len > len) iov[1].iov_len = len; total = iov[0].iov_len + iov[1].iov_len; if (total > mss) { lss = total%mss; if (iov[1].iov_len > lss) { iov[1].iov_len -= lss; n = 2; } else { lss -= iov[1].iov_len; iov[0].iov_len -= lss; n = 1; } } else n = 2; } else { if (iov[0].iov_len > mss) iov[0].iov_len -= iov[0].iov_len%mss; n = 1; } } #ifdef HAVE_READV nn = readv(so->s, (struct iovec *)iov, n); DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn)); #else nn = recv(so->s, iov[0].iov_base, iov[0].iov_len,0); #endif if (nn <= 0) { if (nn < 0 && (errno == EINTR || errno == EAGAIN)) return 0; else { DEBUG_MISC((dfd, " --- soread() disconnected, nn = %d, errno = %d-%s\n", nn, errno,strerror(errno))); sofcantrcvmore(so); tcp_sockclosed(sototcpcb(so)); return -1; } } #ifndef HAVE_READV if (n == 2 && nn == iov[0].iov_len) nn += recv(so->s, iov[1].iov_base, iov[1].iov_len,0); DEBUG_MISC((dfd, " ... read nn = %d bytes\n", nn)); #endif sb->sb_cc += nn; sb->sb_wptr += nn; if (sb->sb_wptr >= (sb->sb_data + sb->sb_datalen)) sb->sb_wptr -= sb->sb_datalen; return nn; }
1threat
static void ide_init1(IDEBus *bus, int unit) { static int drive_serial = 1; IDEState *s = &bus->ifs[unit]; s->bus = bus; s->unit = unit; s->drive_serial = drive_serial++; s->io_buffer = qemu_memalign(2048, IDE_DMA_BUF_SECTORS*512 + 4); s->io_buffer_total_len = IDE_DMA_BUF_SECTORS*512 + 4; s->smart_selftest_data = qemu_blockalign(s->bs, 512); s->sector_write_timer = qemu_new_timer_ns(vm_clock, ide_sector_write_timer_cb, s); }
1threat
How to speed up these R computations? : <p>I have to data frames with X, Y, and Z coordinates. I want to find the distance between all of the points in the two data frames. (Like the distance between entry A1 and every entry in B, A2 and every entry in B, and so on, and vice versa). I basically did this:</p> <p>1.) Wrote a function that calculates the distance between two points. 2.) Used the distanceFinder function to create a function that finds the distance between one point in a group, and every other point in the opposite group. 3.) Created a function called bigDistance() that calls filter() on every entry in one group, and appends the results to an empty data frame through a for loop until it's completed.</p> <p>This code takes about 2 minutes to run on the file I'm experimenting with, and I just found out that I have to translate this algorithm to PHP... so I guess this is kind of an optimization question, because I feel like PHP would be way slower at making these computations than R? Sorry if people find this "off-topic" but yeah, super new to programming and Big O notation and stuff, so any tips would be amazing! Thanks!</p>
0debug
void qpci_io_writew(QPCIDevice *dev, void *data, uint16_t value) { uintptr_t addr = (uintptr_t)data; if (addr < QPCI_PIO_LIMIT) { dev->bus->pio_writew(dev->bus, addr, value); } else { value = cpu_to_le16(value); dev->bus->memwrite(dev->bus, addr, &value, sizeof(value)); } }
1threat
int qcow2_update_header(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; QCowHeader *header; char *buf; size_t buflen = s->cluster_size; int ret; uint64_t total_size; uint32_t refcount_table_clusters; size_t header_length; Qcow2UnknownHeaderExtension *uext; buf = qemu_blockalign(bs, buflen); header = (QCowHeader*) buf; if (buflen < sizeof(*header)) { ret = -ENOSPC; goto fail; } header_length = sizeof(*header) + s->unknown_header_fields_size; total_size = bs->total_sectors * BDRV_SECTOR_SIZE; refcount_table_clusters = s->refcount_table_size >> (s->cluster_bits - 3); *header = (QCowHeader) { .magic = cpu_to_be32(QCOW_MAGIC), .version = cpu_to_be32(s->qcow_version), .backing_file_offset = 0, .backing_file_size = 0, .cluster_bits = cpu_to_be32(s->cluster_bits), .size = cpu_to_be64(total_size), .crypt_method = cpu_to_be32(s->crypt_method_header), .l1_size = cpu_to_be32(s->l1_size), .l1_table_offset = cpu_to_be64(s->l1_table_offset), .refcount_table_offset = cpu_to_be64(s->refcount_table_offset), .refcount_table_clusters = cpu_to_be32(refcount_table_clusters), .nb_snapshots = cpu_to_be32(s->nb_snapshots), .snapshots_offset = cpu_to_be64(s->snapshots_offset), .incompatible_features = cpu_to_be64(s->incompatible_features), .compatible_features = cpu_to_be64(s->compatible_features), .autoclear_features = cpu_to_be64(s->autoclear_features), .refcount_order = cpu_to_be32(s->refcount_order), .header_length = cpu_to_be32(header_length), }; switch (s->qcow_version) { case 2: ret = offsetof(QCowHeader, incompatible_features); break; case 3: ret = sizeof(*header); break; default: ret = -EINVAL; goto fail; } buf += ret; buflen -= ret; memset(buf, 0, buflen); if (s->unknown_header_fields_size) { if (buflen < s->unknown_header_fields_size) { ret = -ENOSPC; goto fail; } memcpy(buf, s->unknown_header_fields, s->unknown_header_fields_size); buf += s->unknown_header_fields_size; buflen -= s->unknown_header_fields_size; } if (*bs->backing_format) { ret = header_ext_add(buf, QCOW2_EXT_MAGIC_BACKING_FORMAT, bs->backing_format, strlen(bs->backing_format), buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; } Qcow2Feature features[] = { { .type = QCOW2_FEAT_TYPE_INCOMPATIBLE, .bit = QCOW2_INCOMPAT_DIRTY_BITNR, .name = "dirty bit", }, { .type = QCOW2_FEAT_TYPE_INCOMPATIBLE, .bit = QCOW2_INCOMPAT_CORRUPT_BITNR, .name = "corrupt bit", }, { .type = QCOW2_FEAT_TYPE_COMPATIBLE, .bit = QCOW2_COMPAT_LAZY_REFCOUNTS_BITNR, .name = "lazy refcounts", }, }; ret = header_ext_add(buf, QCOW2_EXT_MAGIC_FEATURE_TABLE, features, sizeof(features), buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; QLIST_FOREACH(uext, &s->unknown_header_ext, next) { ret = header_ext_add(buf, uext->magic, uext->data, uext->len, buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; } ret = header_ext_add(buf, QCOW2_EXT_MAGIC_END, NULL, 0, buflen); if (ret < 0) { goto fail; } buf += ret; buflen -= ret; if (*bs->backing_file) { size_t backing_file_len = strlen(bs->backing_file); if (buflen < backing_file_len) { ret = -ENOSPC; goto fail; } strncpy(buf, bs->backing_file, buflen); header->backing_file_offset = cpu_to_be64(buf - ((char*) header)); header->backing_file_size = cpu_to_be32(backing_file_len); } ret = bdrv_pwrite(bs->file, 0, header, s->cluster_size); if (ret < 0) { goto fail; } ret = 0; fail: qemu_vfree(header); return ret; }
1threat
static void monitor_qapi_event_emit(QAPIEvent event, QDict *qdict) { Monitor *mon; trace_monitor_protocol_event_emit(event, qdict); QLIST_FOREACH(mon, &mon_list, entry) { if (monitor_is_qmp(mon) && mon->qmp.in_command_mode) { monitor_json_emitter(mon, QOBJECT(qdict)); } } }
1threat
static void tcx_initfn(Object *obj) { SysBusDevice *sbd = SYS_BUS_DEVICE(obj); TCXState *s = TCX(obj); memory_region_init_ram(&s->rom, NULL, "tcx.prom", FCODE_MAX_ROM_SIZE, &error_abort); memory_region_set_readonly(&s->rom, true); sysbus_init_mmio(sbd, &s->rom); memory_region_init_io(&s->stip, OBJECT(s), &tcx_stip_ops, s, "tcx.stip", TCX_STIP_NREGS); sysbus_init_mmio(sbd, &s->stip); memory_region_init_io(&s->blit, OBJECT(s), &tcx_blit_ops, s, "tcx.blit", TCX_BLIT_NREGS); sysbus_init_mmio(sbd, &s->blit); memory_region_init_io(&s->rstip, OBJECT(s), &tcx_rstip_ops, s, "tcx.rstip", TCX_RSTIP_NREGS); sysbus_init_mmio(sbd, &s->rstip); memory_region_init_io(&s->rblit, OBJECT(s), &tcx_rblit_ops, s, "tcx.rblit", TCX_RBLIT_NREGS); sysbus_init_mmio(sbd, &s->rblit); memory_region_init_io(&s->tec, OBJECT(s), &tcx_dummy_ops, s, "tcx.tec", TCX_TEC_NREGS); sysbus_init_mmio(sbd, &s->tec); memory_region_init_io(&s->dac, OBJECT(s), &tcx_dac_ops, s, "tcx.dac", TCX_DAC_NREGS); sysbus_init_mmio(sbd, &s->dac); memory_region_init_io(&s->thc, OBJECT(s), &tcx_thc_ops, s, "tcx.thc", TCX_THC_NREGS); sysbus_init_mmio(sbd, &s->thc); memory_region_init_io(&s->dhc, OBJECT(s), &tcx_dummy_ops, s, "tcx.dhc", TCX_DHC_NREGS); sysbus_init_mmio(sbd, &s->dhc); memory_region_init_io(&s->alt, OBJECT(s), &tcx_dummy_ops, s, "tcx.alt", TCX_ALT_NREGS); sysbus_init_mmio(sbd, &s->alt); return; }
1threat
can someone help me to make my exit button work? (python) : Hey i want to make a exit button in my code, but it won't work. I would prefer to use exit() but if it is not possible with exit() then you could use an other way to make it work. Also pls explain me how you fixed it thanks in advance! Code in link [Code][1] [1]: https://paste.ee/p/rmdYd
0debug
ValueError: attempted relative import beyond top-level package : <p>I was playing the the Python's import system in order to understand better how it works, and I encountered another problem. I have the following structure </p> <pre><code>pkg/ __init__.py c.py d.py subpkg/ __init__.py a.py b.py </code></pre> <p>Inside <code>a.py</code> I have the following code:</p> <pre><code>from . import b from .. import d </code></pre> <p>And inside <code>c.py</code> I have the following:</p> <pre><code>import subpkg.a </code></pre> <p>Now I receive the following error:</p> <blockquote> <p>ValueError: attempted relative import beyond top-level package</p> </blockquote> <p>But <strong>why</strong>? How can I solve it? I am running <code>c.py</code> from the IDLE, and <code>pkg</code> should be considered a package, since it has the <code>__init__.py</code> file.</p> <p>The first import works fine, but it's the following that doesn't work:</p> <pre><code>from .. import d </code></pre> <p>Because I am attempting to import something from a parent package, but apparently I cannot, for some weird reason.</p>
0debug
uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg) { ARMCPU *cpu = arm_env_get_cpu(env); switch (reg) { case 0: return xpsr_read(env) & 0xf8000000; case 1: return xpsr_read(env) & 0xf80001ff; case 2: return xpsr_read(env) & 0xff00fc00; case 3: return xpsr_read(env) & 0xff00fdff; case 5: return xpsr_read(env) & 0x000001ff; case 6: return xpsr_read(env) & 0x0700fc00; case 7: return xpsr_read(env) & 0x0700edff; case 8: return env->v7m.current_sp ? env->v7m.other_sp : env->regs[13]; case 9: return env->v7m.current_sp ? env->regs[13] : env->v7m.other_sp; case 16: return (env->daif & PSTATE_I) != 0; case 17: case 18: return env->v7m.basepri; case 19: return (env->daif & PSTATE_F) != 0; case 20: return env->v7m.control; default: cpu_abort(CPU(cpu), "Unimplemented system register read (%d)\n", reg); return 0; } }
1threat
static void vmdk_free_extents(BlockDriverState *bs) { int i; BDRVVmdkState *s = bs->opaque; for (i = 0; i < s->num_extents; i++) { g_free(s->extents[i].l1_table); g_free(s->extents[i].l2_cache); g_free(s->extents[i].l1_backup_table); } g_free(s->extents); }
1threat
static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, uint8_t *dest, int dstW, int y) { int i; switch(c->dstFormat) { case IMGFMT_RGB32: case IMGFMT_BGR32: YSCALE_YUV_2_RGBX_C(uint32_t) ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1]; ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2]; } break; case IMGFMT_RGB24: YSCALE_YUV_2_RGBX_C(uint8_t) ((uint8_t*)dest)[0]= r[Y1]; ((uint8_t*)dest)[1]= g[Y1]; ((uint8_t*)dest)[2]= b[Y1]; ((uint8_t*)dest)[3]= r[Y2]; ((uint8_t*)dest)[4]= g[Y2]; ((uint8_t*)dest)[5]= b[Y2]; ((uint8_t*)dest)+=6; }
1threat
Remove Boarders From Xcode 'Iframe' 'web view' : I am looking to remove the white boarders from around the edge of the image attached when viewing my app on the Iphone X Emulator. Whats the best way to do this? Even to make them black will be a help. Many thanks, [Image 1][1] [1]: https://i.stack.imgur.com/T510h.jpg
0debug
How to daily rotate logs using Winston except the first day : <p>I need to rotate the logs daily except the file for current day. I'm using <strong>winston</strong> and <strong>winston-daily-rotate-file</strong> libraries.</p> <p>In the following example, a file "info.log.2016-08-09" is generated just the first time I execute node.</p> <p>But, I really need to generate the file "info.log", and after this day, should be renamed to "info.log.2016-08-09", and create a new "info.log" for the current day. I understant that this is the normal behaviour in other applications.</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 logger = new (winston.Logger)({ transports: [ new dailyRotateFile( { name: 'cronInfo', filename: path.join(__dirname,"log", "info.log"), level: 'info', timestamp: function(){ return utils.formatDate(new Date(), "yyyy-mm-dd'T'HH:MM:ss.l'Z'") }, formatter: function(options) { return options.timestamp() +' ['+ options.level.toUpperCase() +'] '+ (undefined !== options.message ? options.message : '') + (options.meta &amp;&amp; Object.keys(options.meta).length ? '\n\t'+ JSON.stringify(options.meta) : '' ); }, json:false, datePattern:".yyyy-MM-dd" }) ] }); </code></pre> </div> </div> </p>
0debug
def find_fixed_point(arr, n): for i in range(n): if arr[i] is i: return i return -1
0debug
Removing specific thing from multiple FOLDER names : <p>I'm trying to get info on trying to remove a specific thing from multiple folder names.. Preferably in such a way that it can be in a batch file.</p> <p>For example.</p> <p>Before:</p> <pre><code>Test1 [REMOVEME] Test2 [REMOVEME] Test3 [REMOVEME] Test4 [REMOVEME] </code></pre> <p>After:</p> <pre><code>Test1 Test2 Test3 Test4 </code></pre> <p>I've seen plenty of info about how to do this with files. But not folders. Is this doable with a batch file so it could be easily used later? Or will i need to use third party software?</p> <p>Also. Am using Windows 10.</p> <p>Thanks, Ben.</p>
0debug
How to access Plugin Data from Wordpress using Wordpress Rest API : <p>I'm creating a fundraising site similar to gofundme.com using Wordpress. I want to get the data stored from a WP Plugin via WP Rest API using ReactJS, Is there a way to access the data within the Plugin?</p>
0debug
How to set mode to development or production in the config file? : <p>We are migrating to webpack 4. We do have dev / prod config files already. We started getting this warning message:</p> <pre><code>WARNING in configuration The 'mode' option has not been set. Set 'mode' option to 'development' or 'production' to enable defaults for this environment. </code></pre> <p>We can get around this by passing --mode production in the cmdline like below:</p> <pre><code>npm run webpack --mode development ... </code></pre> <p>As is mentioned on the webpack documentation, blog and everywhere else on the internet. How can we set the config in the config file? Simply putting a mode: development under modules won't work. Just a bit frustrated why the documentation is just missing...</p>
0debug
Join table between Different Microservices : <p>I am still trying to make sense of micro service architecture.</p> <p>The idea to separate different application (include the database) excites me. But I am still confused if there are two micro-services e.g. Product and User. both product and user own table product and user respectively in their database. According to best practice in micro service, we only can access the database from the service. </p> <p>The problem is, let us suppose we have product table that has user_id column. We want to do search product which also return the name of the user who create the product. This requires join between product table in product micro-service and user table in user micro-service. How do you handle this? </p>
0debug
How to transform next text using regex in phpstrom's search and replace dialog : I need to transform text using regex TPI +2573<br> NM$ +719<br> Молоко +801<br> Прод. жизнь +6.5<br> Оплод-сть +3.6<br> Л. отела 6.3/3.9<br> Вымя +1.48<br> Ноги +1.61<br> to this one <strong>TPI</strong> +2573<br> <strong>NM$</strong> +719<br> <strong>Молоко</strong> +801<br> <strong>Прод. жизнь</strong> +6.5<br> <strong>Оплод-сть</strong> +3.6<br> <strong>Л. отела</strong> 6.3/3.9<br> <strong>Вымя</strong> +1.48<br> <strong>Ноги</strong> +1.61<br> Is it possible with regex in phpstorm's search and replace dialog?
0debug
Do not understand how loop is determining how many asterix to print : I am a beginner at learning Java. I have stumbled upon a problem that I can not figure out. How is the loop in the code determining how many asterisk to print out. I keep looking at this part of the code.. asterisk < myArray[counter] Could someone please explain in the simplest of terms how this works, because every time i think of the counter, i see it as nothing but the index that it is pointing to at that time in the loop. Thank you in advance. Full code below.. public class Main { public static void main(String[] args) { int[] myArray = {12, 7, 9, 11, 23}; System.out.println("Value Distribution"); //Start of outer for loop for( int counter = 0; counter < myArray.length; counter++){ //Start of inner for loop for( int asterisk = 0; asterisk < myArray[counter]; asterisk++) System.out.print("*"); System.out.println(); }//End of outer for loop
0debug
basic pyodbc bulk insert : <p>In a python script, I need to run a query on one datasource and insert each row from that query into a table on a different datasource. I'd normally do this with a single insert/select statement with a tsql linked server join but I don't have a linked server connection to this particular datasource.</p> <p>I'm having trouble finding a simple pyodbc example of this. Here's how I'd do it but I'm guessing executing an insert statement inside a loop is pretty slow.</p> <pre><code>result = ds1Cursor.execute(selectSql) for row in result: insertSql = "insert into TableName (Col1, Col2, Col3) values (?, ?, ?)" ds2Cursor.execute(insertSql, row[0], row[1], row[2]) ds2Cursor.commit() </code></pre> <p>Is there a better bulk way to insert records with pyodbc? Or is this a relatively efficient way to do this anyways. I'm using SqlServer 2012, and the latest pyodbc and python versions.</p>
0debug
void bt_device_done(struct bt_device_s *dev) { struct bt_device_s **p = &dev->net->slave; while (*p && *p != dev) p = &(*p)->next; if (*p != dev) { fprintf(stderr, "%s: bad bt device \"%s\"\n", __FUNCTION__, dev->lmp_name ?: "(null)"); exit(-1); } *p = dev->next; }
1threat
static void mb_cpu_class_init(ObjectClass *oc, void *data) { DeviceClass *dc = DEVICE_CLASS(oc); CPUClass *cc = CPU_CLASS(oc); MicroBlazeCPUClass *mcc = MICROBLAZE_CPU_CLASS(oc); mcc->parent_realize = dc->realize; dc->realize = mb_cpu_realizefn; mcc->parent_reset = cc->reset; cc->reset = mb_cpu_reset; cc->has_work = mb_cpu_has_work; cc->do_interrupt = mb_cpu_do_interrupt; cc->cpu_exec_interrupt = mb_cpu_exec_interrupt; cc->dump_state = mb_cpu_dump_state; cc->set_pc = mb_cpu_set_pc; cc->gdb_read_register = mb_cpu_gdb_read_register; cc->gdb_write_register = mb_cpu_gdb_write_register; #ifdef CONFIG_USER_ONLY cc->handle_mmu_fault = mb_cpu_handle_mmu_fault; #else cc->do_unassigned_access = mb_cpu_unassigned_access; cc->get_phys_page_debug = mb_cpu_get_phys_page_debug; #endif dc->vmsd = &vmstate_mb_cpu; dc->props = mb_properties; cc->gdb_num_core_regs = 32 + 5; cc->disas_set_info = mb_disas_set_info; }
1threat
static av_cold int rl2_read_header(AVFormatContext *s) { AVIOContext *pb = s->pb; AVStream *st; unsigned int frame_count; unsigned int audio_frame_counter = 0; unsigned int video_frame_counter = 0; unsigned int back_size; unsigned short sound_rate; unsigned short rate; unsigned short channels; unsigned short def_sound_size; unsigned int signature; unsigned int pts_den = 11025; unsigned int pts_num = 1103; unsigned int* chunk_offset = NULL; int* chunk_size = NULL; int* audio_size = NULL; int i; int ret = 0; avio_skip(pb,4); back_size = avio_rl32(pb); signature = avio_rb32(pb); avio_skip(pb, 4); frame_count = avio_rl32(pb); if(back_size > INT_MAX/2 || frame_count > INT_MAX / sizeof(uint32_t)) avio_skip(pb, 2); sound_rate = avio_rl16(pb); rate = avio_rl16(pb); channels = avio_rl16(pb); def_sound_size = avio_rl16(pb); st = avformat_new_stream(s, NULL); if(!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_RL2; st->codec->codec_tag = 0; st->codec->width = 320; st->codec->height = 200; st->codec->extradata_size = EXTRADATA1_SIZE; if(signature == RLV3_TAG && back_size > 0) st->codec->extradata_size += back_size; st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); if(!st->codec->extradata) return AVERROR(ENOMEM); if(avio_read(pb,st->codec->extradata,st->codec->extradata_size) != st->codec->extradata_size) return AVERROR(EIO); if(sound_rate){ pts_num = def_sound_size; pts_den = rate; st = avformat_new_stream(s, NULL); if (!st) return AVERROR(ENOMEM); st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = AV_CODEC_ID_PCM_U8; st->codec->codec_tag = 1; st->codec->channels = channels; st->codec->bits_per_coded_sample = 8; st->codec->sample_rate = rate; st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * st->codec->bits_per_coded_sample; st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample / 8; avpriv_set_pts_info(st,32,1,rate); avpriv_set_pts_info(s->streams[0], 32, pts_num, pts_den); chunk_size = av_malloc(frame_count * sizeof(uint32_t)); audio_size = av_malloc(frame_count * sizeof(uint32_t)); chunk_offset = av_malloc(frame_count * sizeof(uint32_t)); if(!chunk_size || !audio_size || !chunk_offset){ av_free(chunk_size); av_free(audio_size); av_free(chunk_offset); return AVERROR(ENOMEM); for(i=0; i < frame_count;i++) chunk_size[i] = avio_rl32(pb); for(i=0; i < frame_count;i++) chunk_offset[i] = avio_rl32(pb); for(i=0; i < frame_count;i++) audio_size[i] = avio_rl32(pb) & 0xFFFF; for(i=0;i<frame_count;i++){ if(chunk_size[i] < 0 || audio_size[i] > chunk_size[i]){ ret = AVERROR_INVALIDDATA; break; if(sound_rate && audio_size[i]){ av_add_index_entry(s->streams[1], chunk_offset[i], audio_frame_counter,audio_size[i], 0, AVINDEX_KEYFRAME); audio_frame_counter += audio_size[i] / channels; av_add_index_entry(s->streams[0], chunk_offset[i] + audio_size[i], video_frame_counter,chunk_size[i]-audio_size[i],0,AVINDEX_KEYFRAME); ++video_frame_counter; av_free(chunk_size); av_free(audio_size); av_free(chunk_offset); return ret;
1threat
how does cuda handle precisely a memory access : i would like to know how CUDA hardware/run-time system handles the following case. If a warp(warp1 in the following) instruction involves access to the memory (load/store); the run-time system schedules the next ready warp for execution. When the new warp is executed, 1- will warp1 "memory access" be conducted? 2- Will warp1 be put into a memory access waiting queue; once this operation is completed, the warp is then moved into the runnable queue? 3- will the Instruction pointer be incremented automatically to annotate that the memory access is done? I hope my questions are clear. Thank you
0debug
def sort_sublists(list1): list1.sort() list1.sort(key=len) return list1
0debug
Differentiate full name without spaces : <p>If i have Full name coming as an input from the user without any spaces, how would i be able to differentiate first name and last name. The Full name for the input could be any name (generic input).</p>
0debug
Split excel file in multiple workbooks and save in multiple folders of same name : To make the situation easily understandable I am taking example. I have a excel files with following worksheets in it. City1 City2 City3 City4 City5 and so on till 47 sheets The file destination is "C:\Users\Dell\Desktop\CityData\" I want a VB code which could split file into individual sheets and place them in the folders of same names as the name of sheets (The folders do not exist and i want that code create the folders automatically) (The folders should be created as subfolders of the above destination folder)
0debug
How to search By Id in js : <p>I am trying to select row from dataTable,but there is a problem occur in js code under PHP.code is given bellow.Here firstly I fetched data from my database and then added them to dataTable.The code work perfectly till here..but when I tried to select any row from the table it show an error sayin</p> <p><strong>Parse error: syntax error, unexpected 'getval' (T_STRING) in C:\xampp\htdocs\Trying\fetch.php on line 43</strong></p> <p>which is <code>var table = document.getElementById('getval');</code> almost at the end of the code.</p> <p>`</p> <pre><code> &lt;?php $connect = mysqli_connect("localhost","root","","ajmal"); $output = ''; $sql = "SELECT medicinName,pricerPerSheet,dealerID,availAbleAt,district,place FROM medicinalinfo WHERE medicinName LIKE '%".$_POST["search"]."%'"; $result = mysqli_query($connect,$sql); if(mysqli_num_rows($result) &gt; 0) { $output .= '&lt;h4 align="center" class="h4_search"&gt;Search Result&lt;/h4&gt;'; $output .= '&lt;div class="row"&gt;'; $output .= '&lt;div class="col-md-8 col-md-offset-1 well"&gt;'; $output .= '&lt;div class="table-responsive"&gt; &lt;table id="tbl" class="table table-bordered table- striped table-hover"&gt; &lt;tr&gt; &lt;th&gt;Medicin Name&lt;/th&gt; &lt;th&gt;Price Per Sheet&lt;/th&gt; &lt;th&gt;Availble At&lt;/th&gt; &lt;th&gt;District&lt;/th&gt; &lt;th&gt;Area&lt;/th&gt; &lt;/tr&gt;'; $output .= '&lt;/div&gt;'; $output .= '&lt;/div&gt;'; $output .= '&lt;/div&gt;'; while ($row = mysqli_fetch_array($result)) { $output .= ' &lt;tbody id="getval"&gt; &lt;tr&gt; &lt;td&gt;'.$row['medicinName'].'&lt;/td&gt; &lt;td&gt;'.$row['pricerPerSheet'].'&lt;/td&gt; &lt;td&gt;'.$row['availAbleAt'].'&lt;/td&gt; &lt;td&gt;'.$row['district'].'&lt;/td&gt; &lt;td&gt;'.$row['place'].'&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; '; } $output.='&lt;/table&gt;'; $output.='&lt;script&gt; var table = document.getElementById('getval'); for(var i=0; i&lt;table.rows.length; i++){ table.row[i].onclick = function(){ alert(this.cells[0].innerHTML); }; } &lt;/script&gt; '; echo $output; } else { echo '&lt;h4 align="center" class="h4_search"&gt;Data Not Found&lt;/h4&gt;'; } ?&gt; </code></pre> <p>`</p>
0debug
static void mov_metadata_creation_time(AVDictionary **metadata, int64_t time) { if (time) { if(time >= 2082844800) time -= 2082844800; avpriv_dict_set_timestamp(metadata, "creation_time", time * 1000000);
1threat
Google Fabric in Xcode 10 beta : <p>I installed Xcode 10 Beta 6 and I am updating everything and in this process I have run into a small issue with Fabric. Fabric's website has special instructions for Xcode 10 that says:</p> <p><a href="https://i.stack.imgur.com/9Y5aN.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/9Y5aN.jpg" alt="Xcode 10 Instructions"></a></p> <p>When I am in Xcode 10 I go to Build Phases an on the Run Script that has my Fabric key there is a + sign under the section <code>Input Fields</code></p> <p>When I click the + it automatically generates <code>$(SRCROOT)/newInputFile</code> where <code>newInputFile</code> is automatically highlighted.</p> <p>I'm not understanding Fabric's instructions. Do I copy the <code>$(BUILT_PRODUCTS_DIR)/$(INFOPLIST_PATH)</code> after <code>$(SRCROOT)/</code> Do I replace INFOPLIST_PATH with the file path to my info.plist?</p> <p>I've tried all these options but Fabric is still crashing in Xcode 10. I know it is Fabric because I've commented out <code>Fabric.with([Crashlytics.self])</code> in my App Delegate's <code>didFinishLaunchingWithOptions</code></p>
0debug
use npm package to validate a package name : <p>Is there a way to use the npm package to validate a package name?</p> <pre><code>const npm = require('npm'); const isValid = npm.validatePackageName('foobar'); // true const isValid = npm.validatePackageName('-4! *'); // false </code></pre> <p>I see a userland package that does this, but surely the npm package itself can do this? Is there a public utility exported from that package?</p>
0debug
Android Studio : Missing Strip Tool : <p>I am constantly getting this warning while building my android studio code using terminal command <code>gradle clean assembleRelease</code>:</p> <p><code>Unable to strip library 'lib.so' due to missing strip tool for ABI 'ARMEABI'. Packaging it as is.</code></p> <p>Please help me on how to get this warning resolved.</p> <p>Note: I know this won't affect the behaviour of my app, but my APK is too bulky and this will surely help me reduce APK size. So I need this resolved.</p>
0debug
Array index out of bounds exception. Please help if you can : <p>Extremely close to having this task finished but can't see which part of this is holding me back. If anybody could put me on the right track I'd be very thankful. the following is the error code that eclipse gives me each time I try to run this.</p> <p>**Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -2</p> <p>at lab01.EncodeDecode.backMap(EncodeDecode.java:162)</p> <p>at lab01.EncodeDecode.Decode(EncodeDecode.java:68)</p> <p>at lab01.EncodeDecode.(EncodeDecode.java:26)</p> <p>at lab01.EncodeDecodeTester.main(EncodeDecodeTester.java:14)**</p> <pre><code> package lab01; import java.util.*; /** * * @author David Bierbrauer, * */ public class EncodeDecode { //method declaration static String[] originalList,encodedList,decodedList; static int total; public EncodeDecode(String[] oL) { //instance variable declaration total = oL.length; originalList = new String[total]; encodedList = new String[total]; decodedList = new String[total]; originalList = oL; encodedList= Encode(originalList); decodedList = Decode(encodedList); } public static String[] Encode (String[] originalList) { //declare control variables String currentWord = "", codedWord = ""; char currentChar = ' '; int i = 0, j = 0, stringLength = 0; for (i=0; i &lt; total ; i++) { currentWord = originalList[i]; stringLength = currentWord.length(); for (j = 0; j &lt; stringLength; j++) { currentChar = currentWord.charAt(j); codedWord = codedWord +forwardMap(currentChar); } encodedList[i] = codedWord; codedWord = ""; } return encodedList; } public static String[] Decode (String[] encodedList) { String currentWord = "", encodedWord = ""; char currentChar = ' '; int i =0, j=0, stringLength = 0; for(i = 0; i &lt; total; i++) { currentWord = encodedList[i]; stringLength = currentWord.length(); for(j = 0; j &lt; stringLength; j++) { currentChar = currentWord.charAt(j); encodedWord = encodedWord + backMap(currentChar); } decodedList[i] = encodedWord; encodedWord = ""; } return decodedList; } public static char forwardMap(char currentChar) { char newChar = ' '; int i = 0; String encodeMapUpper = "CDEFGHIJKLMNOPQRSTUVWXYZAB"; String encodeMapLower = "cdefghijklmnopqrstuvwxyzab"; String encodeMapNumber = "2345678901"; char [] encodeArrayUpper = encodeMapUpper.toCharArray(); char [] encodeArrayLower = encodeMapLower.toCharArray(); char [] encodeArrayNumber = encodeMapNumber.toCharArray(); if(encodeMapUpper.indexOf(currentChar) != -1) { for( i = 0; i &lt; encodeArrayUpper.length; i++) { if(currentChar == encodeArrayUpper[i]) { newChar = encodeArrayUpper[(i+2) % 26]; } } } else if(encodeMapLower.indexOf(currentChar) != -1) { for( i = 0; i &lt; encodeArrayLower.length; i++) { if(currentChar == encodeArrayLower[i]) { newChar = encodeArrayLower[(i+2) % 26]; } } } else if(encodeMapNumber.indexOf(currentChar) != -1) { for( i = 0; i &lt; encodeArrayNumber.length; i++) { if(currentChar == encodeArrayNumber[i]) { newChar = encodeArrayNumber[(i+2) % 10]; } } } else { //element is a special character newChar = currentChar; } return newChar; } public static char backMap(char currentChar) { char newChar = ' '; int i = 0; String decodeMapUpper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; String decodeMapLower = "abcdefghijklmnopqrstuvwxyz"; String decodeMapNumber = "0123456789"; char[] decodeArrayUpper = decodeMapUpper.toCharArray(); char[] decodeArrayLower = decodeMapLower.toCharArray(); char[] decodeArrayNumber = decodeMapNumber.toCharArray(); if (decodeMapUpper.indexOf(currentChar) != -1) { for (i=0; i &lt; decodeArrayUpper.length; i++) { if (currentChar == decodeArrayUpper[i]) { newChar = decodeArrayUpper[(i - 2) % 26]; } } } else if(decodeMapLower.indexOf(currentChar) != -1) { for (i=0; i &lt; decodeArrayLower.length; i++) { if (currentChar == decodeArrayLower[i]) { newChar = decodeArrayLower[(i - 2) % 26]; } } } else if(decodeMapNumber.indexOf(currentChar) != -1) { for (i=0; i &lt; decodeArrayNumber.length; i++) { if (currentChar == decodeArrayNumber[i]) { newChar = decodeArrayNumber[(i - 2) % 10]; } } } else { newChar = currentChar; } return newChar; } //get methods public String[] getEncodedList() { return encodedList;} public String[] getDecodedList() { return decodedList;} } </code></pre> <p>This is the tester class bellow just in case.</p> <pre><code>package lab01; public class EncodeDecodeTester { public static void main(String[] args) { EncodeDecode testEncoder; int x = 0; String[] output = new String[5]; String[] oL = new String[] {"catdog","24","keys","Duck","PIZZA!"}; //create encoder testEncoder = new EncodeDecode(oL); System.out.println("Encoded list:"); for( x = 0; x &lt; output.length; x++) { output = testEncoder.getEncodedList(); System.out.println(output[x]); } System.out.println(); System.out.println("Decoded List:"); for(x = 0; x &lt; output.length; x++) { output = testEncoder.getDecodedList(); System.out.println(output[x] + " "); } System.out.println(); System.out.println("End"); } } </code></pre> <p>Please help I am completely lost for words on what I did wrong here.</p>
0debug
Adding offset to all elements in a structure : <p>Is there a way to add an offset to all elements in a structure in one go. </p> <pre><code>#include &lt;stdio.h&gt; struct date { /* global definition of type date */ int month; int day; int year; }; main() { struct date today; today.month = 10; today.day = 14; today.year = 1995; //I want to add 2 to month/day/year. today.month += 2; today.day += 2; today.year += 2; printf("Todays date is %d/%d/%d.\n", \ today.month, today.day, today.year ); } </code></pre>
0debug
Find the hightest value in a line of a file with multlines : <p>I have a file with different lines and would like to find and output the hightest value in each line starting from the second column. It is possible in bash or awk ?</p> <p>For instance the file has this format structure </p> <pre> 136 0.369326 0.004999 137 0.003199 0.140172 0.055189 0.047191 0.520696 0.172565 138 0.000400 0.021596 0.095381 0.179164 0.065187 ... and so on" </pre> <p>And I would like the following output </p> <pre> 136 0.369326 137 0.520696 138 0.179164 ... and so on </pre> <p>Thanks </p>
0debug
Recommendable UI framework for phonegap? : <p>Before posting my question here I have looked across many posts but nothing relevant found. I'm developing an application for both Iphone and Andriod using Phonegap.</p> <p>I came across with several UI related frameworks :</p> <p>1.Framework 7 2.Ionic 3.Twitter Bootstrap 4.jQuery Mobile 5.Materializecss 6.jQuery UI 7.Sencha Touch</p> <p>What is the recommended way of doing this? Meaning-designing a generic UI (tabbars, tables, navigation bars etc') for both Iphone,Android that will give the generic look and feel native?</p> <p>I need to include Push notification, Camera access, local storage and RSS Feed as a functionality in my application.</p> <p>Any leads will be appreciated and will be thankful to the core.</p>
0debug
static int net_socket_mcast_create(struct sockaddr_in *mcastaddr, struct in_addr *localaddr) { struct ip_mreq imr; int fd; int val, ret; if (!IN_MULTICAST(ntohl(mcastaddr->sin_addr.s_addr))) { fprintf(stderr, "qemu: error: specified mcastaddr \"%s\" (0x%08x) does not contain a multicast address\n", inet_ntoa(mcastaddr->sin_addr), (int)ntohl(mcastaddr->sin_addr.s_addr)); return -1; } fd = qemu_socket(PF_INET, SOCK_DGRAM, 0); if (fd < 0) { perror("socket(PF_INET, SOCK_DGRAM)"); return -1; } val = 1; ret=setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char *)&val, sizeof(val)); if (ret < 0) { perror("setsockopt(SOL_SOCKET, SO_REUSEADDR)"); goto fail; } ret = bind(fd, (struct sockaddr *)mcastaddr, sizeof(*mcastaddr)); if (ret < 0) { perror("bind"); goto fail; } imr.imr_multiaddr = mcastaddr->sin_addr; if (localaddr) { imr.imr_interface = *localaddr; } else { imr.imr_interface.s_addr = htonl(INADDR_ANY); } ret = setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char *)&imr, sizeof(struct ip_mreq)); if (ret < 0) { perror("setsockopt(IP_ADD_MEMBERSHIP)"); goto fail; } val = 1; ret=setsockopt(fd, IPPROTO_IP, IP_MULTICAST_LOOP, (const char *)&val, sizeof(val)); if (ret < 0) { perror("setsockopt(SOL_IP, IP_MULTICAST_LOOP)"); goto fail; } if (localaddr != NULL) { ret = setsockopt(fd, IPPROTO_IP, IP_MULTICAST_IF, (const char *)localaddr, sizeof(*localaddr)); if (ret < 0) { perror("setsockopt(IP_MULTICAST_IF)"); goto fail; } } socket_set_nonblock(fd); return fd; fail: if (fd >= 0) closesocket(fd); return -1; }
1threat
error : domain is already mapped to a project in google cloud platform : <p>i am having issue with mapping domain in google cloud platform so i have just verified my domain but then i am having this issue <a href="https://i.stack.imgur.com/kUPUq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kUPUq.png" alt=" i am having error &quot; mydomain.com is already mapped to my project&quot; "></a> </p> <p>but the thing is that i have not added my domain to my project yet as you can see below in picture </p> <p><a href="https://i.stack.imgur.com/sOXZN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sOXZN.png" alt="i have not added w3youtube.com to mapping "></a></p> <p>so i have not added "w3youtube.com" to mapping or created any dns records but still i am having <code>www.w3youtube.com is already mapped to a project.</code></p> <p><a href="https://i.stack.imgur.com/56TAg.png" rel="noreferrer"><img src="https://i.stack.imgur.com/56TAg.png" alt="enter image description here"></a></p> <p>what should i do? in order to remove mappings or to resolve this issue? </p>
0debug
static int rtsp_read_packet(AVFormatContext *s, AVPacket *pkt) { RTSPState *rt = s->priv_data; int ret; RTSPMessageHeader reply1, *reply = &reply1; char cmd[1024]; if (rt->server_type == RTSP_SERVER_REAL) { int i; enum AVDiscard cache[MAX_STREAMS]; for (i = 0; i < s->nb_streams; i++) cache[i] = s->streams[i]->discard; if (!rt->need_subscription) { if (memcmp (cache, rt->real_setup_cache, sizeof(enum AVDiscard) * s->nb_streams)) { snprintf(cmd, sizeof(cmd), "Unsubscribe: %s\r\n", rt->last_subscription); ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri, cmd, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) return AVERROR_INVALIDDATA; rt->need_subscription = 1; } } if (rt->need_subscription) { int r, rule_nr, first = 1; memcpy(rt->real_setup_cache, cache, sizeof(enum AVDiscard) * s->nb_streams); rt->last_subscription[0] = 0; snprintf(cmd, sizeof(cmd), "Subscribe: "); for (i = 0; i < rt->nb_rtsp_streams; i++) { rule_nr = 0; for (r = 0; r < s->nb_streams; r++) { if (s->streams[r]->priv_data == rt->rtsp_streams[i]) { if (s->streams[r]->discard != AVDISCARD_ALL) { if (!first) av_strlcat(rt->last_subscription, ",", sizeof(rt->last_subscription)); ff_rdt_subscribe_rule( rt->last_subscription, sizeof(rt->last_subscription), i, rule_nr); first = 0; } rule_nr++; } } } av_strlcatf(cmd, sizeof(cmd), "%s\r\n", rt->last_subscription); ff_rtsp_send_cmd(s, "SET_PARAMETER", rt->control_uri, cmd, reply, NULL); if (reply->status_code != RTSP_STATUS_OK) return AVERROR_INVALIDDATA; rt->need_subscription = 0; if (rt->state == RTSP_STATE_STREAMING) rtsp_read_play (s); } } ret = rtsp_fetch_packet(s, pkt); if (ret < 0) return ret; if ((rt->server_type == RTSP_SERVER_WMS || rt->server_type == RTSP_SERVER_REAL) && (av_gettime() - rt->last_cmd_time) / 1000000 >= rt->timeout / 2) { if (rt->server_type == RTSP_SERVER_WMS) { ff_rtsp_send_cmd_async(s, "GET_PARAMETER", rt->control_uri, NULL); } else { ff_rtsp_send_cmd_async(s, "OPTIONS", "*", NULL); } } return 0; }
1threat
git: why can't I delete my branch after a squash merge? : <p>I have a git repo with <code>mainline</code> (equivalent to <code>master</code>) and some local feature branches. For example:</p> <pre><code>$ git branch * mainline feature1 feature2 feature3 </code></pre> <p>When I do the following, I am able to squash merge all of my edits in a feature branch into one commit to <code>mainline</code>:</p> <pre><code>$ git checkout mainline $ git pull $ git checkout feature1 $ git rebase mainline $ git checkout mainline $ git merge --squash feature1 $ git commit $ git push </code></pre> <p>My question is, at this point, when I try to delete the <code>feature1</code> branch, it tells me it is not fully merged:</p> <pre><code>$ git branch -d feature1 error: The branch 'feature1' is not fully merged. If you are sure you want to delete it, run 'git branch -D feature1'. </code></pre> <p>What causes this error? I thought <code>git merge --squash feature1</code> merged <code>feature1</code> into <code>mainline</code>.</p>
0debug
Create blank image in Imagemagick : <p>How to create a blank new image in Imagemagick via command line?</p> <p>Using <code>-background</code> doesn't work:</p> <pre><code>$ convert -size 800x800 -background white x.png convert: no images defined `x.png' @ error/convert.c/ConvertImageCommand/3257. </code></pre>
0debug
Javascript regex everything after a period : <p>Need a javascipt regex that matches everything that comes after a period. Tried:</p> <pre><code>var myString="100.00"; var myRegexp = /\..*/; var match = myRegexp.exec(myString); if (match[1]!=null) {tail=match[1];} console.log(tail); </code></pre>
0debug
How to generate pdf report using thymeleaf as template engine? : <p>I want to create pdf report in a spring mvc application. I want to use themeleaf for designing the html report page and then convert into pdf file. I don't want to use xlst for styling the pdf. Is it possible to do that way? </p> <p>Note: It is a client requirement. </p>
0debug
web 2.0 sucks huge floppy disks? : <p>I was able to create a web site 10 years ago with Microsoft Frontpage without learning anything, today with a copy of Adobe Dreamweaver CS6, I can't even figure out a way to change the font size of a simple text. CSS is the thing, so I went through the CSS tutorials in w3 and I get it now. It's a good idea, but It is also a good idea to kill creativity, ie all sites like similar, see screenshot below. It sucks floppy disks.</p> <p><a href="https://i.stack.imgur.com/AZO2h.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AZO2h.jpg" alt="enter image description here"></a></p> <p>My questions will be:</p> <ol> <li><p>Does web 2.0 really kill creativity?</p></li> <li><p>Is there a "modern" web design application that I don't need to go into these CSS thing?</p></li> <li><p>Is there a way to create a circular navigation menu like this using css? I want to have this menu in the middle of the page, and with a button on the corner to activate it.</p></li> </ol> <p><img src="https://www.designinformer.com/wp-content/uploads/circular-menu-black.png" alt="a busy cat"></p>
0debug
Stil learning: "Why doesn't this work?" Javascript : <p>I am new to javascript, still learning on codecademy, but for some reason, in every editor I tried, this code doesn't seem to work.</p> <p>The latest editor I tried was <a href="http://jsfiddle.net" rel="nofollow noreferrer">jsfiddle</a></p> <pre><code>var cards = ["Diamond", "Spade", "Heart", "Club"]; var currentCard = "Heart"; for (var i = 0; i &lt; cards.length; i++) { console.log(cards[i]); } console.log("Found a Spade"); </code></pre> <p>Can anyone tell me what am I doing wrong?</p>
0debug
static void apply_unsharp( uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int width, int height, FilterParam *fp) { uint32_t **sc = fp->sc; uint32_t sr[(MAX_SIZE * MAX_SIZE) - 1], tmp1, tmp2; int32_t res; int x, y, z; const uint8_t *src2; if (!fp->amount) { if (dst_stride == src_stride) memcpy(dst, src, src_stride * height); else for (y = 0; y < height; y++, dst += dst_stride, src += src_stride) memcpy(dst, src, width); return; } for (y = 0; y < 2 * fp->steps_y; y++) memset(sc[y], 0, sizeof(sc[y][0]) * (width + 2 * fp->steps_x)); for (y = -fp->steps_y; y < height + fp->steps_y; y++) { if (y < height) src2 = src; memset(sr, 0, sizeof(sr[0]) * (2 * fp->steps_x - 1)); for (x = -fp->steps_x; x < width + fp->steps_x; x++) { tmp1 = x <= 0 ? src2[0] : x >= width ? src2[width-1] : src2[x]; for (z = 0; z < fp->steps_x * 2; z += 2) { tmp2 = sr[z + 0] + tmp1; sr[z + 0] = tmp1; tmp1 = sr[z + 1] + tmp2; sr[z + 1] = tmp2; } for (z = 0; z < fp->steps_y * 2; z += 2) { tmp2 = sc[z + 0][x + fp->steps_x] + tmp1; sc[z + 0][x + fp->steps_x] = tmp1; tmp1 = sc[z + 1][x + fp->steps_x] + tmp2; sc[z + 1][x + fp->steps_x] = tmp2; } if (x >= fp->steps_x && y >= fp->steps_y) { const uint8_t *srx = src - fp->steps_y * src_stride + x - fp->steps_x; uint8_t *dsx = dst - fp->steps_y * dst_stride + x - fp->steps_x; res = (int32_t)*srx + ((((int32_t) * srx - (int32_t)((tmp1 + fp->halfscale) >> fp->scalebits)) * fp->amount) >> 16); *dsx = av_clip_uint8(res); } } if (y >= 0) { dst += dst_stride; src += src_stride; } } }
1threat
c# - Cross-thread operation not valid : <p>i was facing the exception Cross-thread error on my methods (void) i solved them by :</p> <pre><code>public delegate void onitemAdd(ListViewItem client); public void OnItemAdd(ListViewItem itemtoadd) { if (this.InvokeRequired) { onitemAdd adder = new onitemAdd(OnItemAdd); this.Invoke(adder, new object[] { itemtoadd }); } else { if (itemtoadd != null) ClientsView.Items.Add(itemtoadd); } } </code></pre> <p>but i don't know how can i do the same but to return the value returned in :</p> <pre><code>public delegate ListViewItem ItemReturn(Client client); public ListViewItem OnReturnitem(Client client) { if (this.InvokeRequired) { ItemReturn itm = new Zserver.Form1.ItemReturn(OnReturnitem); this.Invoke(itm, new object[] { client }); // need to return a value of the invoked method } else { ListViewItem item = ClientsView.Items .Cast&lt;ListViewItem&gt;() .FirstOrDefault(x =&gt; x.SubItems[1].Text == client.IPadress); return item; } } </code></pre>
0debug
I have table like the following with 1 and null value by year. need to count the consecutive max count per Id, in access query. I am not good in VBA : I have table like the following with 1 and null value by year. need to count the consecutive max count per Id, in access query. I am not good in VBA so trying to get it done in Access query. ID 2001 2002 2004 2005 2006 2007 101 1 1 1 1 102 1 1 1 1 1 103 1 104 1 1 1 1 1 105 1 1 1 1 1 1 106 1 1 1
0debug
Editing a .csv file with a batch file : <p>this is my first question on here. I work as a meteorologist and have some coding experience, though it is far from professionally taught. Basically what I have is a .csv file from a weather station that is giving me data that is too detailed. (65.66 degrees and similar values) What I want to do is automate a way via a script file that would access the .csv file and get rid of values that were too detailed. (Take a temp from 65.66 to 66 (rounding up for anything above .5 and down for below) or for a pressure (29.8889) and making it (29.89) using the same rounding rules.) Is this possible to be done? If so how should I go about it. Again keep in mind that my coding skills for batch files are not the strongest. </p> <p>Any help would be much appreciated. </p> <p>Thanks,</p>
0debug
Program stuck after compilation when trying to acsses private multy-dimensional array : <p>After the code get compile my , while the program trying to access the private array it got stucked. i build a constructor and in this function i can print the array but after that if im trying to access the array from another function its not working.</p> <p>In this code it stuck while working on mat(1,2) - trying to return arr[1][2]:</p> <p>i tried to allocate the array in a different way, to make [] operator but nothing seems to work.</p> <p>main file :</p> <pre><code> #include "matrix.h" #include &lt;iostream&gt; int main() { Matrix&lt;4, 4&gt; mat; mat(1,2); std::cout &lt;&lt; mat &lt;&lt; std::endl; return 0; } </code></pre> <p>.h file :</p> <pre><code> #ifndef matrix_h #define matrix_h #include &lt;iostream&gt; template &lt;int row, int col ,typename T=int&gt; class Matrix { public: Matrix(int v = 0) { // constructor with deafault value of '0' int **arr = new int*[row]; //initializing place for rows for (int j = 0;j &lt; row;j++) { arr[j] = new int[col]; } for (int i = 0;i &lt; row;i++) for (int j = 0;j &lt; col;j++) arr[i][j] = v; } T&amp; operator () (int r, int c) const { return arr[r][c]; } friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out,const Matrix &lt;row,col,T&gt; mat) { for (int i = 0;i &lt; row;i++) { for (int j = 0;j &lt; col;j++) { out &lt;&lt; mat(i,j) &lt;&lt; " "; } out &lt;&lt; std::endl; } return out; } private: T** arr; }; #endif //matrix_h </code></pre>
0debug
MSSQL - How to Split a String to multiples rows? : can u help me with this situation? I have this String in a **DESCRIPTION** column (yes, that's the only field with the data for this case =/ ): "P.A. - Solicitação [945159][945171][944007][944836][944946][945065][945068][945074][945149][945087][946032][946139][947042][945552][945980][946194] - Chamado Tipo: SOLICITAÇÕES DE T.I. Sistema ou aplicação: SISTEMAS T.I. Sub-processo: REVOGAÇÃO DE ACESSOS DE TERCEIROS Solicitante" I need to put this numbers in separeted rows, like: Row 1 - 945159 Row 2 - 945171 Row 3 - 944007 Row 4 - 944836 Row 5 - 944946 I have no idea how to do it. Can anyone help me, please?
0debug
How to convert multidimensional array to List<List<double>>? : <p>I'm trying to convert a <code>double[,]</code> to a <code>List&lt;List&lt;double&gt;&gt;</code> what is the best possible way of doing this performance wise.</p>
0debug
Arduino (a function-definition is not allowed here before '{' token) i dont see the mistake : <p>im not seeing the problem pls help me there was more code for the button box originally but i trimmed the encoders out</p> <p>Arduino: 1.8.7 (Windows 10), Board: "Arduino/Genuino Micro"</p> <p>Build options changed, rebuilding all 28.01.2018\Arduino\ARDUINO_BUTTON_BOXV2a\ARDUINO_BUTTON_BOXV2a.ino: In function 'void setup()':</p> <p>ARDUINO_BUTTON_BOXV2a:103:13: error: a function-definition is not allowed here before '{' token</p> <p>void loop() { </p> <pre><code> ^ </code></pre> <p>ARDUINO_BUTTON_BOXV2a:111:29: error: a function-definition is not allowed here before '{' token</p> <p>void CheckAllButtons(void) {</p> <pre><code> ^ </code></pre> <p>ARDUINO_BUTTON_BOXV2a:133:1: error: expected '}' at end of input</p> <p>}</p> <p>^</p> <p>exit status 1 a function-definition is not allowed here before '{' token</p> <p>This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.</p> <pre><code>#include &lt;Keypad.h&gt; #include &lt;Joystick.h&gt; #define ENABLE_PULLUPS #define NUMROTARIES 0 #define NUMBUTTONS 16 #define NUMROWS 4 #define NUMCOLS 4 byte buttons[NUMROWS][NUMCOLS] = { {0,1,2,3}, {4,5,6,7}, {8,9,10,11}, {12,13,14,15}, }; byte rowPins[NUMROWS] = {15,14,16,10}; byte colPins[NUMCOLS] = {A3,A2,A1,A0}; Keypad buttbx = Keypad( makeKeymap(buttons), rowPins, colPins, NUMROWS, NUMCOLS); Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_JOYSTICK, 32, 0, false, false, false, false, false, false, false, false, false, false, false); void setup() { Joystick.begin(); // rotary_init();} void loop() { // CheckAllEncoders(); CheckAllButtons(); } void CheckAllButtons(void) { if (buttbx.getKeys()) { for (int i=0; i&lt;LIST_MAX; i++) { if ( buttbx.key[i].stateChanged ) { switch (buttbx.key[i].kstate) { case PRESSED: case HOLD: Joystick.setButton(buttbx.key[i].kchar, 1); break; case RELEASED: case IDLE: Joystick.setButton(buttbx.key[i].kchar, 0); break; } } } } } </code></pre>
0debug
R regular expression to parse call option code : <p>I have a call option code in the form of:</p> <p><code>.TSLA181012C100</code></p> <p>I'd like to parse it to pull out the 18, 10 and 12. However, I'm not quite sure how to do that as the letters after the period can be of variable length and so can the numbers after the C. </p> <p>Is there a regex way to find the "C" from the right and get the 6 digits to the left of that?</p>
0debug
C++ Beginner - While loop repeating first iteration : <p>All,</p> <p>So I've been really racking my brain about this one. I have a section of my program that needs to count spaces/vowels/characters in a user-specified string. This is one of those "teach you the way no one would do it because you can only used what we've covered in class already" kinds of assignments. So I have the user input a text, ending with a sentinel char, which in this case is '#'. The loop works wonderfully in regards to exiting when the sentinel is encountered, but it keeps iterating twice over string[0]. Here's the code: </p> <pre><code>i = 0; characterToBeProcessed = userInputText.at(i); while (characterToBeProcessed != LOOP_SENTINEL) { fout &lt;&lt; characterToBeProcessed; // Convert to lowercase characterToBeProcessed = static_cast&lt;char&gt; (tolower(characterToBeProcessed)); // Increment character counters switch (characterToBeProcessed) { case 'a': case 'e': case 'i': case 'o': case 'u': totalVowelCount++; totalCharacterCount++; break; case ' ': totalSpaceCount++; totalCharacterCount++; break; default: totalCharacterCount++; break; } characterToBeProcessed = userInputText.at(i++); } </code></pre> <p>So when I input at the prompt: </p> <pre><code>"Please input a text to be analyzed, ending with the # character: " Hi there, my friend!# </code></pre> <p>The output is: </p> <pre><code>Below is the text entered by the user: HHi there, my friend! Total characters: 21 Total vowels: 5 Total blank spaces: 3 </code></pre> <p>I've had the program output the chars for .at(0) and .at(1), and those give me the correct characters, I just can't figure out why the loop iterates twice for the first char and then works fine after that second time through. The counts/output are otherwise correct except for the first char being duplicated. Any appreciation would be greatly appreciated. </p>
0debug
PPC_OP(test_ctr) { T0 = regs->ctr; RETURN(); }
1threat