problem
stringlengths
26
131k
labels
class label
2 classes
static void prom_init(target_phys_addr_t addr, const char *bios_name) { DeviceState *dev; SysBusDevice *s; char *filename; int ret; dev = qdev_create(NULL, "openprom"); qdev_init(dev); s = sysbus_from_qdev(dev); sysbus_mmio_map(s, 0, addr); if (bios_name == NULL) { bios_name = PROM_FILENAME; } filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { ret = load_elf(filename, addr - PROM_VADDR, NULL, NULL, NULL, 1, ELF_MACHINE, 0); if (ret < 0 || ret > PROM_SIZE_MAX) { ret = load_image_targphys(filename, addr, PROM_SIZE_MAX); } qemu_free(filename); } else { ret = -1; } if (ret < 0 || ret > PROM_SIZE_MAX) { fprintf(stderr, "qemu: could not load prom '%s'\n", bios_name); exit(1); } }
1threat
print a number from a list that contains more than one number in an index : from the below list I want to get ONLY the number 8 how do I do that? listofnumbers2 = [[1,2],[3,4],[5,6],[7,[8,9]]] i have tried print listofnumbers2[3][1] but it returns [8,9] im trying to do this in python
0debug
printf the value of %n in the same call - senseless? : <p>I can't find out the intention of the following part of <code>printf</code> specification at <a href="http://en.cppreference.com/w/cpp/io/c/fprintf" rel="noreferrer">cppreference.com</a>:</p> <blockquote> <p>There is a sequence point after the action of each conversion specifier; this permits storing multiple %n results in the same variable and <strong>printing the value stored by %n earlier within the same call.</strong></p> </blockquote> <p>This reads as if the result of one (or even several) <code>%n</code> conversion specifier(s) could be printed out in the same <code>printf</code>-statement. But I can't find out how this could ever be achieved, because all arguments passed to a call of <code>printf</code> are evaluated before <code>printf</code>'s body is entered (there is a sequence point after argument evaluation). Hence, the value of a variable to which a <code>%n</code> would write is evaluated before <code>printf</code> has the chance to overwrite this variable's value with the "number of characters written so far":</p> <pre><code>#include &lt;stdio.h&gt; int main( int argc, char* argv[] ) { int n = 0; printf("Hello, world!%n (%d first n); %n (%d second n)", &amp;n ,n, &amp;n, n); // will print out "Hello, world! (0 first n); (0 second n)" return 0; } </code></pre> <p>My question: If there isn't any chance of "printing the value stored by %n earlier within the same call", isn't then the respective part of the <code>printf</code> specification senseless or misleading?</p> <p>What is the actual sense of the <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf" rel="noreferrer">c99 standard</a> statement:</p> <blockquote> <p>7.19.6 Formatted input/output functions (1) The formatted input/output functions shall behave as if there is a sequence point after the actions associated with each specifier.</p> </blockquote> <p>Is it to reduce the "chances" of getting undefined behaviour?</p> <p>The question is tagged with c++ and c, because I think that this topic applies the same way to both languages.</p>
0debug
How to go to another php file after the execution of one php file? : <p>I just a Noobie who`s trying to get clear on certatin topics regarding my project. I would like to know if there is a possibility of going to another php file after the execution of current php file. Thanks in Advance :-) </p>
0debug
How to Post a List of Users to an ASP.Core POST Action? : <p>want to post a List of User with details like Firstname, Lastname, email... to an ASP.Core POST Action method. What is the best way to do this?</p> <p>I've coded an HTML form with a jquery function to give the user feedback that a user was added to a list. But I have no idea except to put hidden inputs via jquery.</p> <p><a href="https://jsfiddle.net/uvoqedjh/4/" rel="nofollow noreferrer">https://jsfiddle.net/uvoqedjh/4/</a></p> <pre><code> &lt;form asp-action="Create"&gt; &lt;div class="form-group col"&gt; &lt;label class="col control-label" for="vorname"&gt;Vorname&lt;/label&gt; &lt;div class="col"&gt; &lt;input id="vorname" name="vorname" type="text" placeholder="Vorname" class="form-control input-md" required=""&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="form-group col"&gt; &lt;label class="col control-label" for="nachname"&gt;Nachname&lt;/label&gt; &lt;div class="col"&gt; &lt;input id="nachname" name="nachname" type="text" placeholder="Nachname" class="form-control input-md" required=""&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;button id="addAnsp" class="btn btn-primary"&gt;Add&lt;/button&gt; &lt;div id="ansprechpartnerliste"&gt;&lt;/div&gt; </code></pre>
0debug
javascript: difference in return value between operators -- and -= : <p>Given the following code:</p> <pre><code>var x = 0; function decrement(num) { return num--; } var y = decrement(x); console.log(y); // 0 </code></pre> <p>Versus the following:</p> <pre><code>var x = 0; function decrement(num) { return num -= 1; // this is the only difference between the functions } var y = decrement(x); console.log(y); // 0 </code></pre> <p>Why does <code>y--</code> return <code>0</code> from the function while <code>y -= 1</code> returns <code>-1</code>?</p>
0debug
How to customize the Date Picker UI? : <p>Is there any customized UI available for the Date picker control. Suggest me the code or links to refer.</p>
0debug
static int sockaddr_to_str(char *dest, int max_len, struct sockaddr_storage *ss, socklen_t ss_len, struct sockaddr_storage *ps, socklen_t ps_len, bool is_listen, bool is_telnet) { char shost[NI_MAXHOST], sserv[NI_MAXSERV]; char phost[NI_MAXHOST], pserv[NI_MAXSERV]; const char *left = "", *right = ""; switch (ss->ss_family) { #ifndef _WIN32 case AF_UNIX: return snprintf(dest, max_len, "unix:%s%s", ((struct sockaddr_un *)(ss))->sun_path, is_listen ? ",server" : ""); #endif case AF_INET6: left = "["; right = "]"; case AF_INET: getnameinfo((struct sockaddr *) ss, ss_len, shost, sizeof(shost), sserv, sizeof(sserv), NI_NUMERICHOST | NI_NUMERICSERV); getnameinfo((struct sockaddr *) ps, ps_len, phost, sizeof(phost), pserv, sizeof(pserv), NI_NUMERICHOST | NI_NUMERICSERV); return snprintf(dest, max_len, "%s:%s%s%s:%s%s <-> %s%s%s:%s", is_telnet ? "telnet" : "tcp", left, shost, right, sserv, is_listen ? ",server" : "", left, phost, right, pserv); default: return snprintf(dest, max_len, "unknown"); } }
1threat
void restore_state_to_opc(CPUARMState *env, TranslationBlock *tb, int pc_pos) { if (is_a64(env)) { env->pc = tcg_ctx.gen_opc_pc[pc_pos]; } else { env->regs[15] = tcg_ctx.gen_opc_pc[pc_pos]; } env->condexec_bits = gen_opc_condexec_bits[pc_pos]; }
1threat
How to append a string in C# dynamically? : <p>Thank you in Advance:</p> <p>I have a parameter which gives the row_count after loading the data.</p> <p>i need to insert that value into a file, which i am able to do it.</p> <p>But I need the format in this manner:</p> <p>if the row_count is 150 then </p> <p>I am getting only <em>Param name='INPUT_NUM_RECS value=150/</em></p> <p>But I need the <strong>output</strong> as </p> <p><strong>Param name='INPUT_NUM_RECS value=000000150/</strong></p> <p>Thank you.</p>
0debug
int kvm_arch_put_registers(CPUState *env, int level) { int ret; assert(cpu_is_stopped(env) || qemu_cpu_self(env)); ret = kvm_getput_regs(env, 1); if (ret < 0) { return ret; } ret = kvm_put_xsave(env); if (ret < 0) { return ret; } ret = kvm_put_xcrs(env); if (ret < 0) { return ret; } ret = kvm_put_sregs(env); if (ret < 0) { return ret; } ret = kvm_put_msrs(env, level); if (ret < 0) { return ret; } if (level >= KVM_PUT_RESET_STATE) { ret = kvm_put_mp_state(env); if (ret < 0) { return ret; } } ret = kvm_put_vcpu_events(env, level); if (ret < 0) { return ret; } ret = kvm_put_debugregs(env); if (ret < 0) { return ret; } ret = kvm_guest_debug_workarounds(env); if (ret < 0) { return ret; } return 0; }
1threat
How to call strings inside a list in Python : <p>So, I'm making a chat bot, and I want to enable it so if the user inputs a word/phrase thats in the dictionary (a pickled file), it will reply with a suitable message to what the user input. It might make more sense if you see the code:</p> <pre><code>""" startup """ import pickle '''opening the dictionary''' inFile = open('words.txt', 'rb') dictionary = pickle.load(inFile) '''printing the dictionary''' print("PRE TESTS...") print("-") print("Pickle protocol import:") print(dictionary) print("END OF PRE TESTS...") print("-") print(" ") """ end of startup """ print("Hello! My name is Pinnochio. I'm currently very young, and my communication is extremely limited.") print("-") ''' handling the replies ''' reply = input() if reply != dictionary: print("Sorry, I don't know that word.") reply = input() if reply == dictionary[0] | dictionary[1] | dictionary[2]: print("Hey there") reply = input() if reply == dictionary[3]: print("I'm feeling great!") reply = input() if reply == dictionary[4] | dictionary[5]: print("It is, isn't it?") reply = input() </code></pre> <p>The dictionary is a list inside another file, which I've pickled:</p> <pre><code>import pickle dictionary = ["hello", "hi", "hey", "how are you?", "good morning", "good afternoon"] outFile = open('words.txt', 'wb') pickle.dump(dictionary, outFile) outFile.close() </code></pre> <p>Thanks in advance!</p>
0debug
static void build_append_notify_target(GArray *method, GArray *target_name, uint32_t value, int size) { GArray *notify = build_alloc_array(); uint8_t op = 0xA0; build_append_byte(notify, 0x93); build_append_byte(notify, 0x68); build_append_value(notify, value, size); build_append_byte(notify, 0x86); build_append_array(notify, target_name); build_append_byte(notify, 0x69); build_package(notify, op, 1); build_append_array(method, notify); build_free_array(notify); }
1threat
How to make VSCode to replace the word when accepting autocomplete hint? : <p>JetBrains IDE platform have very useful feature, which I am using a lot and I find it a performance booster. When I have a word in editor, and I want to change or update that word, I do the following.</p> <ul> <li>Place cursor in front of the word (or in middle, ex. when I want to change only last part.)</li> <li>Start typing until I got autocomplete I want to use.</li> <li>Press TAB or ENTER. <ul> <li>On TAB - Old word is completely replaced by new word. This is especially useful when I update some names, in which beginning of word is the same, but ending is different. For example, change <code>getTimeInSeconds()</code> to <code>getTimeInMinutes()</code> - I put cursor after <code>getTimeIn</code>, get autocomplete, and press TAB. Nothing left to delete, everything is replaced.</li> <li>On ENTER - New word is replaced from the start of old word, but right part from the cursor stays on screen.</li> </ul></li> </ul> <p>By default VSCode supports only "ENTER" use case. Does it support "TAB" use case? If so, how to enable it?</p>
0debug
static inline uint32_t get_hwc_address(SM501State *state, int crt) { uint32_t addr = crt ? state->dc_crt_hwc_addr : state->dc_panel_hwc_addr; return (addr & 0x03FFFFF0); }
1threat
static int dnxhd_decode_macroblock(const DNXHDContext *ctx, RowContext *row, AVFrame *frame, int x, int y) { int shift1 = ctx->bit_depth >= 10; int dct_linesize_luma = frame->linesize[0]; int dct_linesize_chroma = frame->linesize[1]; uint8_t *dest_y, *dest_u, *dest_v; int dct_y_offset, dct_x_offset; int qscale, i, act; int interlaced_mb = 0; if (ctx->mbaff) { interlaced_mb = get_bits1(&row->gb); qscale = get_bits(&row->gb, 10); } else { qscale = get_bits(&row->gb, 11); } act = get_bits1(&row->gb); if (act) { static int warned = 0; if (!warned) { warned = 1; av_log(ctx->avctx, AV_LOG_ERROR, "Unsupported adaptive color transform, patch welcome.\n"); } } if (qscale != row->last_qscale) { for (i = 0; i < 64; i++) { row->luma_scale[i] = qscale * ctx->cid_table->luma_weight[i]; row->chroma_scale[i] = qscale * ctx->cid_table->chroma_weight[i]; } row->last_qscale = qscale; } for (i = 0; i < 8 + 4 * ctx->is_444; i++) { if (ctx->decode_dct_block(ctx, row, i) < 0) return AVERROR_INVALIDDATA; } if (frame->interlaced_frame) { dct_linesize_luma <<= 1; dct_linesize_chroma <<= 1; } dest_y = frame->data[0] + ((y * dct_linesize_luma) << 4) + (x << (4 + shift1)); dest_u = frame->data[1] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444)); dest_v = frame->data[2] + ((y * dct_linesize_chroma) << 4) + (x << (3 + shift1 + ctx->is_444)); if (frame->interlaced_frame && ctx->cur_field) { dest_y += frame->linesize[0]; dest_u += frame->linesize[1]; dest_v += frame->linesize[2]; } if (interlaced_mb) { dct_linesize_luma <<= 1; dct_linesize_chroma <<= 1; } dct_y_offset = interlaced_mb ? frame->linesize[0] : (dct_linesize_luma << 3); dct_x_offset = 8 << shift1; if (!ctx->is_444) { ctx->idsp.idct_put(dest_y, dct_linesize_luma, row->blocks[0]); ctx->idsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, row->blocks[1]); ctx->idsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, row->blocks[4]); ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, row->blocks[5]); if (!(ctx->avctx->flags & AV_CODEC_FLAG_GRAY)) { dct_y_offset = interlaced_mb ? frame->linesize[1] : (dct_linesize_chroma << 3); ctx->idsp.idct_put(dest_u, dct_linesize_chroma, row->blocks[2]); ctx->idsp.idct_put(dest_v, dct_linesize_chroma, row->blocks[3]); ctx->idsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, row->blocks[6]); ctx->idsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, row->blocks[7]); } } else { ctx->idsp.idct_put(dest_y, dct_linesize_luma, row->blocks[0]); ctx->idsp.idct_put(dest_y + dct_x_offset, dct_linesize_luma, row->blocks[1]); ctx->idsp.idct_put(dest_y + dct_y_offset, dct_linesize_luma, row->blocks[6]); ctx->idsp.idct_put(dest_y + dct_y_offset + dct_x_offset, dct_linesize_luma, row->blocks[7]); if (!(ctx->avctx->flags & AV_CODEC_FLAG_GRAY)) { dct_y_offset = interlaced_mb ? frame->linesize[1] : (dct_linesize_chroma << 3); ctx->idsp.idct_put(dest_u, dct_linesize_chroma, row->blocks[2]); ctx->idsp.idct_put(dest_u + dct_x_offset, dct_linesize_chroma, row->blocks[3]); ctx->idsp.idct_put(dest_u + dct_y_offset, dct_linesize_chroma, row->blocks[8]); ctx->idsp.idct_put(dest_u + dct_y_offset + dct_x_offset, dct_linesize_chroma, row->blocks[9]); ctx->idsp.idct_put(dest_v, dct_linesize_chroma, row->blocks[4]); ctx->idsp.idct_put(dest_v + dct_x_offset, dct_linesize_chroma, row->blocks[5]); ctx->idsp.idct_put(dest_v + dct_y_offset, dct_linesize_chroma, row->blocks[10]); ctx->idsp.idct_put(dest_v + dct_y_offset + dct_x_offset, dct_linesize_chroma, row->blocks[11]); } } return 0; }
1threat
Can anybody explain why int x=1_000_000 is a valid and prints 1000000 instead throwing an error? : <p>int x = 100_000_5; System.out.println(x);</p> <p>Instead of throwing an error it prints the result 1000005. If this is a valid case what other abnormalities are there with Integer?</p>
0debug
def diff_consecutivenums(nums): result = [b-a for a, b in zip(nums[:-1], nums[1:])] return result
0debug
MySQL Incorrect datetime value: '0000-00-00 00:00:00' : <p>I've recently taken over an old project that was created 10 years ago. It uses MySQL 5.1.</p> <p>Among other things, I need to change the default character set from latin1 to utf8.</p> <p>As an example, I have tables such as this: </p> <pre><code> CREATE TABLE `users` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `first_name` varchar(45) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT NULL, `last_name` varchar(45) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT NULL, `username` varchar(127) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL, `email` varchar(127) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL, `pass` varchar(20) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL, `active` char(1) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT 'Y', `created` datetime NOT NULL, `last_login` datetime DEFAULT NULL, `author` varchar(1) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT 'N', `locked_at` datetime DEFAULT NULL, `created_at` datetime DEFAULT NULL, `updated_at` datetime DEFAULT NULL, `ripple_token` varchar(36) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT NULL, `ripple_token_expires` datetime DEFAULT '2014-10-31 08:03:55', `authentication_token` varchar(255) CHARACTER SET latin1 COLLATE latin1_general_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `index_users_on_reset_password_token` (`reset_password_token`), UNIQUE KEY `index_users_on_confirmation_token` (`confirmation_token`), UNIQUE KEY `index_users_on_unlock_token` (`unlock_token`), KEY `users_active` (`active`), KEY `users_username` (`username`), KEY `index_users_on_email` (`email`) ) ENGINE=InnoDB AUTO_INCREMENT=1677 DEFAULT CHARSET=utf8 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC </code></pre> <p>I set up my own Mac to work on this. Without thinking too much about it, I ran "brew install mysql" which installed MySQL 5.7. So I have some version conflicts.</p> <p>I downloaded a copy of this database and imported it. </p> <p>If I try to run a query like this: </p> <pre><code> ALTER TABLE users MODIFY first_name varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL </code></pre> <p>I get this error: </p> <pre><code> ERROR 1292 (22007): Incorrect datetime value: '0000-00-00 00:00:00' for column 'created' at row 1 </code></pre> <p>I thought I could fix this with: </p> <pre><code> ALTER TABLE users MODIFY created datetime NULL DEFAULT '1970-01-01 00:00:00'; Query OK, 0 rows affected (0.06 sec) Records: 0 Duplicates: 0 Warnings: 0 </code></pre> <p>but I get: </p> <pre><code> ALTER TABLE users MODIFY first_name varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ; ERROR 1292 (22007): Incorrect datetime value: '0000-00-00 00:00:00' for column 'created' at row 1 </code></pre> <p>Do I have to update every value? </p>
0debug
I want to display sequence of weekday according to country. How can I achieve this using SAP UI5 and Javascript or JQuery : Sequence according to country should be India: Mon, Tue, Wed, Thur, Fri, Sat, Sun Dubai: Sun, Mon, ...
0debug
What is the best HTML layout technique? DIVs vs Tables : <p>I find using tables as the backbone easier to manipulate, specially when aligning things vertically. But I only seem to find code samples using DIV with heaps of CSS that looks like hacks into the inner workings of CSS.</p>
0debug
It is safe to use lvh.me instead of localhost for testing? : <p>I wonder whether is safe to use <code>lvh.me</code> instead of <code>localhost</code> when developing locally, since <code>lvh.me</code> must be resolved and the IP may change over time.</p> <p>The goal of using <code>lvh.me</code> is to be able to handle subdomains, since <code>localhost</code> does not have top level domain.</p>
0debug
I have an issue with my if statement it generates warning? : Hello im trying to make a calculator, but my if statement generate warnings. Im am also new to c. int main(){ float num1; float num2; char input[5]; printf("Hello my name is baymax\n"); printf("Enter either add, sub, mult, div:\n"); scanf("%4s", input); printf("Enter first number\n"); scanf("%f", &num1); printf("Enter second number\n"); scanf("%f", &num2); if(input == 'add'){ printf("%.1f + %.1f = %.1f",num1, num2, num1+num2); .... } return 0; } if the string entered is add it will add the two numbers.
0debug
static av_cold int aacPlus_encode_init(AVCodecContext *avctx) { aacPlusAudioContext *s = avctx->priv_data; aacplusEncConfiguration *aacplus_cfg; if (avctx->channels < 1 || avctx->channels > 2) { av_log(avctx, AV_LOG_ERROR, "encoding %d channel(s) is not allowed\n", avctx->channels); return -1; } s->aacplus_handle = aacplusEncOpen(avctx->sample_rate, avctx->channels, &s->samples_input, &s->max_output_bytes); if(!s->aacplus_handle) { av_log(avctx, AV_LOG_ERROR, "can't open encoder\n"); return -1; } aacplus_cfg = aacplusEncGetCurrentConfiguration(s->aacplus_handle); if(avctx->profile != FF_PROFILE_AAC_LOW && avctx->profile != FF_PROFILE_UNKNOWN) { av_log(avctx, AV_LOG_ERROR, "invalid AAC profile: %d, only LC supported\n", avctx->profile); aacplusEncClose(s->aacplus_handle); return -1; } aacplus_cfg->bitRate = avctx->bit_rate; aacplus_cfg->bandWidth = avctx->cutoff; aacplus_cfg->outputFormat = !(avctx->flags & CODEC_FLAG_GLOBAL_HEADER); aacplus_cfg->inputFormat = avctx->sample_fmt == AV_SAMPLE_FMT_FLT ? AACPLUS_INPUT_FLOAT : AACPLUS_INPUT_16BIT; if (!aacplusEncSetConfiguration(s->aacplus_handle, aacplus_cfg)) { av_log(avctx, AV_LOG_ERROR, "libaacplus doesn't support this output format!\n"); return -1; } avctx->frame_size = s->samples_input / avctx->channels; avctx->extradata_size = 0; if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) { unsigned char *buffer = NULL; unsigned long decoder_specific_info_size; if (aacplusEncGetDecoderSpecificInfo(s->aacplus_handle, &buffer, &decoder_specific_info_size) == 1) { avctx->extradata = av_malloc(decoder_specific_info_size + FF_INPUT_BUFFER_PADDING_SIZE); avctx->extradata_size = decoder_specific_info_size; memcpy(avctx->extradata, buffer, avctx->extradata_size); } free(buffer); } return 0; }
1threat
Any functions that need the std:: prefix : <p>What are all the functions (ex std::cout, std::cin, etc.) that need the std:: when not using namespace std?It would be useful to know so I don’t run into problems, thanks!</p>
0debug
Password Verification PHP Form : Here i have some php code which allows me to update User information in my students table. <?php $page_title = 'Update Info'; require ('mysqli_connect.php'); session_start(); if(isset($_SESSION["UserID"])){ }else{ header('Location: login.php'); } ?> <?php $User = $_SESSION["UserID"]; $result = $conn->query("SELECT * FROM students WHERE UserID ='$User'"); $row = $result -> fetch_array(MYSQLI_BOTH); $_SESSION["FirstName"] = $row['FName']; $_SESSION["LastName"] = $row['LName']; $_SESSION["Email"] = $row['Email']; $_SESSION["PW"] = $row['Password']; ?> <?php if(isset($_POST['Update'])){ $UpdateFName = $_POST['FirstName']; $UpdateLName = $_POST['LastName']; $UpdateEmail = $_POST['Email']; $UpdateFPassword = $_POST['Password']; $SQL = $conn->query("UPDATE students SET FName='{$UpdateFName}',LName='{$UpdateLName}',Email='{$UpdateEmail}',Password='{$UpdateFPassword}' WHERE UserID = $User"); header('Location:updateinfo.php'); } header ('Location: myaccount.php') ?> I am trying to figure out how am i able to check if the password for the user that is currently logged in matches the password stored in the database before allowing information can be updated. Help would be appreciated! thank you.
0debug
static char *addr_to_string(const char *format, struct sockaddr_storage *sa, socklen_t salen) { char *addr; char host[NI_MAXHOST]; char serv[NI_MAXSERV]; int err; if ((err = getnameinfo((struct sockaddr *)sa, salen, host, sizeof(host), serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV)) != 0) { VNC_DEBUG("Cannot resolve address %d: %s\n", err, gai_strerror(err)); return NULL; } if (asprintf(&addr, format, host, serv) < 0) return NULL; return addr; }
1threat
My buttons are not displaying as i want(in a way it shows in calculator ) : //here public class myform : Form { public myform() { //setting size of form this.Text = "Calculator"; this.Height = 600; this.Width = 400; //creating buttons from 0-9 Button[] b = new Button[10]; int x = 0; int y = 0; string ch; for (int i = 0; i < b.Length; i++) { ch = Convert.ToString(i); x = 0; y = y + 50; b[i] = new Button(); b[i].Height = 40; b[i].Width = 40; b[i].Text = ch; for (int j = 0; j < 3; j++) { x = x + 50; b[i].Location = new Point(x, y); } } for (int i = 0; i < b.Length; i++) { this.Controls.Add(b[i]); } } } //here is the form class , //in which i am creating the object of myform class described above. public partial class Form1 : Form { public Form1() { InitializeComponent(); myform mf = new myform(); mf.Show(); } } [1]: https://i.stack.imgur.com/Zat67.png
0debug
Is there a dict.update(sub_dict) function for list in Python? : Suppose a list in Python -> mylist: mylist = [["X","Y",12], ["A","B",23]] I want to add another sub-list of elements like: mylist = [["X","Y",12], ["A","B",23], ["L","M",56]] Is there a function like update() for list too just like for dictionary?
0debug
C# Get computer name from IP : <p>I'm using Xamarin Studio to develop to iOS and I need a couple of functions to get the Computer Name from the IP and vice-versa</p> <p>I've tried this code to get the machine name from IP</p> <pre><code>string machineName = string.Empty; try { IPHostEntry hostEntry = Dns.GetHostEntry(ipAdress); machineName = hostEntry.HostName; } catch (Exception ex) { // Machine not found... } return machineName; </code></pre> <p>But I keep getting the machine IP Address, so it's useless because I input the IP Address and get the IP Address.</p> <p>I've tried something alike to get the IP Address from the HostName I always get the exception "Unable to resolve hostname <em>HITMAN-DESKTOP</em>" being the <em>HITMAN-DESKTOP</em> my remote machine that is accessible from any point in the network and online during the tests.</p> <p>Any ideas?</p>
0debug
static int write_packet(AVFormatContext *s, AVPacket *pkt) { WVMuxContext *wc = s->priv_data; AVCodecContext *codec = s->streams[0]->codec; AVIOContext *pb = s->pb; uint64_t size; uint32_t flags; uint32_t left = pkt->size; uint8_t *ptr = pkt->data; int off = codec->channels > 2 ? 4 : 0; wc->duration += pkt->duration; ffio_wfourcc(pb, "wvpk"); if (off) { size = AV_RL32(pkt->data); if (size <= 12) return AVERROR_INVALIDDATA; size -= 12; } else { size = pkt->size; } if (size + off > left) return AVERROR_INVALIDDATA; avio_wl32(pb, size + 12); avio_wl16(pb, 0x410); avio_w8(pb, 0); avio_w8(pb, 0); avio_wl32(pb, -1); avio_wl32(pb, pkt->pts); ptr += off; left -= off; flags = AV_RL32(ptr + 4); avio_write(pb, ptr, size); ptr += size; left -= size; while (!(flags & WV_END_BLOCK) && (left >= 4 + WV_EXTRA_SIZE)) { ffio_wfourcc(pb, "wvpk"); size = AV_RL32(ptr); ptr += 4; left -= 4; if (size < 24 || size - 24 > left) return AVERROR_INVALIDDATA; avio_wl32(pb, size); avio_wl16(pb, 0x410); avio_w8(pb, 0); avio_w8(pb, 0); avio_wl32(pb, -1); avio_wl32(pb, pkt->pts); flags = AV_RL32(ptr + 4); avio_write(pb, ptr, WV_EXTRA_SIZE); ptr += WV_EXTRA_SIZE; left -= WV_EXTRA_SIZE; avio_write(pb, ptr, size - 24); ptr += size - 24; left -= size - 24; } return 0; }
1threat
static int libopenjpeg_copy_packed16(AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image) { int compno; int x; int y; int *image_line; int frame_index; const int numcomps = image->numcomps; uint16_t *frame_ptr = (uint16_t*)frame->data[0]; for (compno = 0; compno < numcomps; ++compno) { if (image->comps[compno].w > frame->linesize[0] / numcomps) { av_log(avctx, AV_LOG_ERROR, "Error: frame's linesize is too small for the image\n"); return 0; } } for (compno = 0; compno < numcomps; ++compno) { for (y = 0; y < avctx->height; ++y) { image_line = image->comps[compno].data + y * image->comps[compno].w; frame_index = y * (frame->linesize[0] / 2) + compno; for (x = 0; x < avctx->width; ++x) { image_line[x] = frame_ptr[frame_index]; frame_index += numcomps; } for (; x < image->comps[compno].w; ++x) { image_line[x] = image_line[x - 1]; } } for (; y < image->comps[compno].h; ++y) { image_line = image->comps[compno].data + y * image->comps[compno].w; for (x = 0; x < image->comps[compno].w; ++x) { image_line[x] = image_line[x - image->comps[compno].w]; } } } return 1; }
1threat
How do I specify the name of the file I want to read, as a variable? : I'm trying to write a program that can store the contents of a file into a variable chosen by the user. For example, the user would choose a file located in the current directory and would then choose the variable he/she wanted to store it in. This is a segment of my code so far. ``` print("What .antonio file do you want to load?") loadfile = input("") open(loadfile, "r") print("Which variable do you want to load it for? - list_1, list_2, list_3") whichvariable = input("") if whichvariable == "list_1": list_1 = loadfile.read() elif whichvariable == "list_2": list_2 = loadfile.read() elif whichvariable == "list_3": list_3 = loadfile.read() else: print("ERROR") ``` When I input that `loadfile = list1.antonio` (which is an existing file) and `whichvariable = list_1` it throws me this error: ``` Traceback (most recent call last): File "D:\Antonio\Projetos\Python\hello.py", line 29, in <module> list_1 = loadfile.read() AttributeError: 'str' object has no attribute 'read' ``` I have tried all sorts of things and I haven't find a solution. I'm from a non-english speaking country, so plz forgive me if my grammar is bad. Anyways, please help me. -A random programmer
0debug
What is the difference between in_array() and @in_array() in php? : <p>can you please help i just want to know why we use @in_array function.</p> <pre><code>$name = array("ravi", "ram", "rani", 87); if (in_array("ravi", $name, TRUE)){ } if (@in_array("ravi", $name, TRUE)){ } </code></pre>
0debug
static int mmf_probe(AVProbeData *p) { if (p->buf_size <= 32) return 0; if (p->buf[0] == 'M' && p->buf[1] == 'M' && p->buf[2] == 'M' && p->buf[3] == 'D' && p->buf[8] == 'C' && p->buf[9] == 'N' && p->buf[10] == 'T' && p->buf[11] == 'I') return AVPROBE_SCORE_MAX; else return 0; }
1threat
Async in Android Studio : <p><a href="http://i.stack.imgur.com/qfKYL.png" rel="nofollow">enter image description here</a></p> <p>Hi everyone, I tried to insert an image from Internet to Android Studio using Async. But seem like some problem happened and I can not call the runOnUIThread to enable the function for Async. How can I fix it? Thank you so much.</p>
0debug
static int decode_block_coeffs_internal(VP56RangeCoder *r, int16_t block[16], uint8_t probs[16][3][NUM_DCT_TOKENS - 1], int i, uint8_t *token_prob, int16_t qmul[2]) { VP56RangeCoder c = *r; goto skip_eob; do { int coeff; if (!vp56_rac_get_prob_branchy(&c, token_prob[0])) break; skip_eob: if (!vp56_rac_get_prob_branchy(&c, token_prob[1])) { if (++i == 16) break; token_prob = probs[i][0]; goto skip_eob; } if (!vp56_rac_get_prob_branchy(&c, token_prob[2])) { coeff = 1; token_prob = probs[i + 1][1]; } else { if (!vp56_rac_get_prob_branchy(&c, token_prob[3])) { coeff = vp56_rac_get_prob_branchy(&c, token_prob[4]); if (coeff) coeff += vp56_rac_get_prob(&c, token_prob[5]); coeff += 2; } else { if (!vp56_rac_get_prob_branchy(&c, token_prob[6])) { if (!vp56_rac_get_prob_branchy(&c, token_prob[7])) { coeff = 5 + vp56_rac_get_prob(&c, vp8_dct_cat1_prob[0]); } else { coeff = 7; coeff += vp56_rac_get_prob(&c, vp8_dct_cat2_prob[0]) << 1; coeff += vp56_rac_get_prob(&c, vp8_dct_cat2_prob[1]); } } else { int a = vp56_rac_get_prob(&c, token_prob[8]); int b = vp56_rac_get_prob(&c, token_prob[9 + a]); int cat = (a << 1) + b; coeff = 3 + (8 << cat); coeff += vp8_rac_get_coeff(&c, ff_vp8_dct_cat_prob[cat]); } } token_prob = probs[i + 1][2]; } block[zigzag_scan[i]] = (vp8_rac_get(&c) ? -coeff : coeff) * qmul[!!i]; } while (++i < 16); *r = c; return i; }
1threat
AWK script to C script _converting. How? : <p>is it possible to convert a awk script (Linux) ,</p> <p>to a C language script ?</p> <p>WBR</p> <p>Zabo</p>
0debug
static int get_last_needed_nal(H264Context *h) { int nals_needed = 0; int i; for (i = 0; i < h->pkt.nb_nals; i++) { H2645NAL *nal = &h->pkt.nals[i]; GetBitContext gb; switch (nal->type) { case NAL_SPS: case NAL_PPS: nals_needed = i; break; case NAL_DPA: case NAL_IDR_SLICE: case NAL_SLICE: init_get_bits(&gb, nal->data + 1, (nal->size - 1) * 8); if (!get_ue_golomb(&gb)) nals_needed = i; } } return nals_needed; }
1threat
Delete Query Not working from android Sq-lite Database : public void deleteEntity(int id ) { db = this.getWritableDatabase(); try{ db.beginTransaction(); /*String s = "DELETE FROM entity_save WHERE _id=" + id; db.execSQL(s);*/ int i=db.delete("entity_save", "save_id = ?", new String[]{ String.valueOf(id) }); }catch(Exception e) {e.printStackTrace();}finally{ db.endTransaction(); db.close();}} }
0debug
int configure_accelerator(MachineState *ms) { const char *p; char buf[10]; int ret; bool accel_initialised = false; bool init_failed = false; AccelClass *acc = NULL; p = qemu_opt_get(qemu_get_machine_opts(), "accel"); if (p == NULL) { p = "tcg"; } while (!accel_initialised && *p != '\0') { if (*p == ':') { p++; } p = get_opt_name(buf, sizeof(buf), p, ':'); acc = accel_find(buf); if (!acc) { fprintf(stderr, "\"%s\" accelerator not found.\n", buf); continue; } if (acc->available && !acc->available()) { printf("%s not supported for this target\n", acc->name); continue; } ret = accel_init_machine(acc, ms); if (ret < 0) { init_failed = true; fprintf(stderr, "failed to initialize %s: %s\n", acc->name, strerror(-ret)); } else { accel_initialised = true; } } if (!accel_initialised) { if (!init_failed) { fprintf(stderr, "No accelerator found!\n"); } exit(1); } if (init_failed) { fprintf(stderr, "Back to %s accelerator.\n", acc->name); } return !accel_initialised; }
1threat
Something I'm misunderstanding about rand() % i? : <pre><code>int main() { const int n = 5; int A[n][n]; // value of each cell int V[n][n]; // total value of each cell for (int i = 0; i &lt; n; i++) { for (int j = 0; j &lt; n; j++) { V[i][j] = 0; // initialize total value of each cell equal to zero A[i][j] = rand() % 10; // set each cell's value equal to some number 0-9 printf("%i ", A[i][j]); } printf("\n"); } for (int i = 0; i &lt; n; i++) { for (int j = 0; j &lt; n; j++) { if (i == 0 &amp;&amp; j == 0) { V[i][j] = A[i][j]; } else if (i == 0) { V[i][j] = V[i][j - 1] + A[i][j]; } else if (j == 0) { V[i][j] = V[i - 1][j] + A[i][j]; } else { if (V[i][j - 1] &gt; V[i - 1][j]) { V[i][j] = V[i][j - 1] + A[i][j]; } else { V[i][j] = V[i - 1][j] + A[i][j]; } } } } printf("\n"); for (int i = 0; i &lt; n; i++) { for (int j = 0; j &lt; n; j++) { if (V[i][j] &lt; 10) printf(" %i ", V[i][j]); else printf("%i ", V[i][j]); } printf("\n"); } cin.get(); </code></pre> <p>}</p> <p>This outputs <a href="http://i.imgur.com/Ak3KpPr.png" rel="nofollow">http://i.imgur.com/Ak3KpPr.png</a></p> <p>What I don't understand is why V[0][2] outputs 12 when it should output V[0][1] + A[0][2], or 7+4.</p> <p>Context: At a garage sale one day, you stumble upon an old school video game. In this video game, your character must take a journey along an n × n grid, collecting rewards along the way. Specifically, there is an n × n matrix A with nonnegative entries, and your character collects a reward equal to Aij if he visits the cell (i, j) of the grid. Your objective is to maximize the sum of rewards collected by your character. (a) [4 points]. The rules of level one of the game are as follows. Your character starts at the top-left corner — i.e., cell (1, 1) — of the grid, and must travel to the the bottom-right corner — i.e., cell (n, n) — in sequence of steps. At each step, your character is allowed to move either one cell to the right or one cell down in the grid; stepping upwards, to the left, or diagonally is not 2 allowed. Show how to compute the optimal journey in O(n 2 ) time.</p>
0debug
void qbus_create_inplace(BusState *bus, const char *typename, DeviceState *parent, const char *name) { object_initialize(bus, typename); qbus_realize(bus, parent, name); }
1threat
Why is "" necessary for this for loop to run? : <p>The code is below - </p> <pre><code>for (let n = 1; n &lt;= 100; n++) { let output = ""; if (n % 3 == 0) output += "Fizz"; if (n % 5 == 0) output += "Buzz"; console.log(output || n); } </code></pre> <p>If I do not have let output = "" the code will not run. Why is that statement required?</p>
0debug
SqlDataReader Cant Proceed into While : I have a problem in SqlDataReader it cannot proceed into while and cannot while. Here is my code ` List<tmp_WatchList> data = new List<tmp_WatchList>(); using (SqlConnection con = new SqlConnection(conStr)){ using (SqlCommand cmd = new SqlCommand("sp_CheckPersonList", con)) { try { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Name", SqlDbType.NVarChar).Value = name; SqlDataReader oReader = cmd.ExecuteReader(); while (oReader.Read()) { //data.Add(new tmp_WatchList //{ tmp_WatchList l = new tmp_WatchList(); l.id = int.Parse(oReader["id"].ToString()); l.Name = oReader.GetValue(1).ToString(); l.Crime = int.Parse(oReader.GetValue(2).ToString()); data.Add(l); ///}); } } catch (Exception ex) { throw new Exception(ex.Message); } finally { con.Close(); } } }` and my SP is: <code> ALTER PROCEDURE [dbo].[sp_CheckPersonList] ( @Name NVARCHAR(MAX) NULL ) AS BEGIN SELECT REPLACE(Name, '.', ''), Crime FROM [dbo].[tmp_WatchList] WHERE [Name] LIKE CONCAT('%', REPLACE(@Name, ' ', '%'), '%') END </code> Can you tell me how it is done. or something is wrong with my structure. Thanks
0debug
static int get_cox(J2kDecoderContext *s, J2kCodingStyle *c) { if (s->buf_end - s->buf < 5) return AVERROR(EINVAL); c->nreslevels = bytestream_get_byte(&s->buf) + 1; c->log2_cblk_width = bytestream_get_byte(&s->buf) + 2; c->log2_cblk_height = bytestream_get_byte(&s->buf) + 2; c->cblk_style = bytestream_get_byte(&s->buf); if (c->cblk_style != 0){ av_log(s->avctx, AV_LOG_WARNING, "extra cblk styles %X\n", c->cblk_style); } c->transform = bytestream_get_byte(&s->buf); if (c->csty & J2K_CSTY_PREC) { int i; for (i = 0; i < c->nreslevels; i++) bytestream_get_byte(&s->buf); } return 0; }
1threat
How do I make a regular HTML audio play with a thumbnailed audio track here's my Code : This is my code so if you can help me it'd be great thank's StackExchange <DOCTYPE! html> <body> <script> function play(){ var audio = document.getElementById("audio"); audio.play(); } </script> <img src="SoundWave.gif" width="200" height="200"value="play" onclick="play()"> <audio id="audio" src="01.mp3"> </audio> </body>
0debug
static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, const QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2) { DECLARE_ALIGNED(8, PPContext, c)= *c2; int x,y; #ifdef TEMPLATE_PP_TIME_MODE const int mode= TEMPLATE_PP_TIME_MODE; #else const int mode= isColor ? c.ppMode.chromMode : c.ppMode.lumMode; #endif int black=0, white=255; int QPCorrecture= 256*256; int copyAhead; #if TEMPLATE_PP_MMX int i; #endif const int qpHShift= isColor ? 4-c.hChromaSubSample : 4; const int qpVShift= isColor ? 4-c.vChromaSubSample : 4; uint64_t * const yHistogram= c.yHistogram; uint8_t * const tempSrc= srcStride > 0 ? c.tempSrc : c.tempSrc - 23*srcStride; uint8_t * const tempDst= (dstStride > 0 ? c.tempDst : c.tempDst - 23*dstStride) + 32; if (mode & VISUALIZE){ if(!(mode & (V_A_DEBLOCK | H_A_DEBLOCK)) || TEMPLATE_PP_MMX) { av_log(c2, AV_LOG_WARNING, "Visualization is currently only supported with the accurate deblock filter without SIMD\n"); } } #if TEMPLATE_PP_MMX for(i=0; i<57; i++){ int offset= ((i*c.ppMode.baseDcDiff)>>8) + 1; int threshold= offset*2 + 1; c.mmxDcOffset[i]= 0x7F - offset; c.mmxDcThreshold[i]= 0x7F - threshold; c.mmxDcOffset[i]*= 0x0101010101010101LL; c.mmxDcThreshold[i]*= 0x0101010101010101LL; } #endif if(mode & CUBIC_IPOL_DEINT_FILTER) copyAhead=16; else if( (mode & LINEAR_BLEND_DEINT_FILTER) || (mode & FFMPEG_DEINT_FILTER) || (mode & LOWPASS5_DEINT_FILTER)) copyAhead=14; else if( (mode & V_DEBLOCK) || (mode & LINEAR_IPOL_DEINT_FILTER) || (mode & MEDIAN_DEINT_FILTER) || (mode & V_A_DEBLOCK)) copyAhead=13; else if(mode & V_X1_FILTER) copyAhead=11; else if(mode & DERING) copyAhead=9; else copyAhead=8; copyAhead-= 8; if(!isColor){ uint64_t sum= 0; int i; uint64_t maxClipped; uint64_t clipped; double scale; c.frameNum++; if(c.frameNum == 1) yHistogram[0]= width*(uint64_t)height/64*15/256; for(i=0; i<256; i++){ sum+= yHistogram[i]; } maxClipped= (uint64_t)(sum * c.ppMode.maxClippedThreshold); clipped= sum; for(black=255; black>0; black--){ if(clipped < maxClipped) break; clipped-= yHistogram[black]; } clipped= sum; for(white=0; white<256; white++){ if(clipped < maxClipped) break; clipped-= yHistogram[white]; } scale= (double)(c.ppMode.maxAllowedY - c.ppMode.minAllowedY) / (double)(white-black); #if TEMPLATE_PP_MMXEXT c.packedYScale= (uint16_t)(scale*256.0 + 0.5); c.packedYOffset= (((black*c.packedYScale)>>8) - c.ppMode.minAllowedY) & 0xFFFF; #else c.packedYScale= (uint16_t)(scale*1024.0 + 0.5); c.packedYOffset= (black - c.ppMode.minAllowedY) & 0xFFFF; #endif c.packedYOffset|= c.packedYOffset<<32; c.packedYOffset|= c.packedYOffset<<16; c.packedYScale|= c.packedYScale<<32; c.packedYScale|= c.packedYScale<<16; if(mode & LEVEL_FIX) QPCorrecture= (int)(scale*256*256 + 0.5); else QPCorrecture= 256*256; }else{ c.packedYScale= 0x0100010001000100LL; c.packedYOffset= 0; QPCorrecture= 256*256; } y=-BLOCK_SIZE; { const uint8_t *srcBlock= &(src[y*srcStride]); uint8_t *dstBlock= tempDst + dstStride; for(x=0; x<width; x+=BLOCK_SIZE){ #if TEMPLATE_PP_MMXEXT && HAVE_6REGS __asm__( "mov %4, %%"REG_a" \n\t" "shr $2, %%"REG_a" \n\t" "and $6, %%"REG_a" \n\t" "add %5, %%"REG_a" \n\t" "mov %%"REG_a", %%"REG_d" \n\t" "imul %1, %%"REG_a" \n\t" "imul %3, %%"REG_d" \n\t" "prefetchnta 32(%%"REG_a", %0) \n\t" "prefetcht0 32(%%"REG_d", %2) \n\t" "add %1, %%"REG_a" \n\t" "add %3, %%"REG_d" \n\t" "prefetchnta 32(%%"REG_a", %0) \n\t" "prefetcht0 32(%%"REG_d", %2) \n\t" :: "r" (srcBlock), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride), "g" ((x86_reg)x), "g" ((x86_reg)copyAhead) : "%"REG_a, "%"REG_d ); #elif TEMPLATE_PP_3DNOW #endif RENAME(blockCopy)(dstBlock + dstStride*8, dstStride, srcBlock + srcStride*8, srcStride, mode & LEVEL_FIX, &c.packedYOffset); RENAME(duplicate)(dstBlock + dstStride*8, dstStride); if(mode & LINEAR_IPOL_DEINT_FILTER) RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride); else if(mode & LINEAR_BLEND_DEINT_FILTER) RENAME(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + x); else if(mode & MEDIAN_DEINT_FILTER) RENAME(deInterlaceMedian)(dstBlock, dstStride); else if(mode & CUBIC_IPOL_DEINT_FILTER) RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride); else if(mode & FFMPEG_DEINT_FILTER) RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x); else if(mode & LOWPASS5_DEINT_FILTER) RENAME(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + x, c.deintTemp + width + x); dstBlock+=8; srcBlock+=8; } if(width==FFABS(dstStride)) linecpy(dst, tempDst + 9*dstStride, copyAhead, dstStride); else{ int i; for(i=0; i<copyAhead; i++){ memcpy(dst + i*dstStride, tempDst + (9+i)*dstStride, width); } } } for(y=0; y<height; y+=BLOCK_SIZE){ const uint8_t *srcBlock= &(src[y*srcStride]); uint8_t *dstBlock= &(dst[y*dstStride]); #if TEMPLATE_PP_MMX uint8_t *tempBlock1= c.tempBlocks; uint8_t *tempBlock2= c.tempBlocks + 8; #endif const int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride]; int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*FFABS(QPStride)]; int QP=0; if(y+15 >= height){ int i; linecpy(tempSrc + srcStride*copyAhead, srcBlock + srcStride*copyAhead, FFMAX(height-y-copyAhead, 0), srcStride); for(i=FFMAX(height-y, 8); i<copyAhead+8; i++) memcpy(tempSrc + srcStride*i, src + srcStride*(height-1), FFABS(srcStride)); linecpy(tempDst, dstBlock - dstStride, FFMIN(height-y+1, copyAhead+1), dstStride); for(i=height-y+1; i<=copyAhead; i++) memcpy(tempDst + dstStride*i, dst + dstStride*(height-1), FFABS(dstStride)); dstBlock= tempDst + dstStride; srcBlock= tempSrc; } for(x=0; x<width; x+=BLOCK_SIZE){ const int stride= dstStride; #if TEMPLATE_PP_MMX uint8_t *tmpXchg; #endif if(isColor){ QP= QPptr[x>>qpHShift]; c.nonBQP= nonBQPptr[x>>qpHShift]; }else{ QP= QPptr[x>>4]; QP= (QP* QPCorrecture + 256*128)>>16; c.nonBQP= nonBQPptr[x>>4]; c.nonBQP= (c.nonBQP* QPCorrecture + 256*128)>>16; yHistogram[ srcBlock[srcStride*12 + 4] ]++; } c.QP= QP; #if TEMPLATE_PP_MMX __asm__ volatile( "movd %1, %%mm7 \n\t" "packuswb %%mm7, %%mm7 \n\t" "packuswb %%mm7, %%mm7 \n\t" "packuswb %%mm7, %%mm7 \n\t" "movq %%mm7, %0 \n\t" : "=m" (c.pQPb) : "r" (QP) ); #endif #if TEMPLATE_PP_MMXEXT && HAVE_6REGS __asm__( "mov %4, %%"REG_a" \n\t" "shr $2, %%"REG_a" \n\t" "and $6, %%"REG_a" \n\t" "add %5, %%"REG_a" \n\t" "mov %%"REG_a", %%"REG_d" \n\t" "imul %1, %%"REG_a" \n\t" "imul %3, %%"REG_d" \n\t" "prefetchnta 32(%%"REG_a", %0) \n\t" "prefetcht0 32(%%"REG_d", %2) \n\t" "add %1, %%"REG_a" \n\t" "add %3, %%"REG_d" \n\t" "prefetchnta 32(%%"REG_a", %0) \n\t" "prefetcht0 32(%%"REG_d", %2) \n\t" :: "r" (srcBlock), "r" ((x86_reg)srcStride), "r" (dstBlock), "r" ((x86_reg)dstStride), "g" ((x86_reg)x), "g" ((x86_reg)copyAhead) : "%"REG_a, "%"REG_d ); #elif TEMPLATE_PP_3DNOW #endif RENAME(blockCopy)(dstBlock + dstStride*copyAhead, dstStride, srcBlock + srcStride*copyAhead, srcStride, mode & LEVEL_FIX, &c.packedYOffset); if(mode & LINEAR_IPOL_DEINT_FILTER) RENAME(deInterlaceInterpolateLinear)(dstBlock, dstStride); else if(mode & LINEAR_BLEND_DEINT_FILTER) RENAME(deInterlaceBlendLinear)(dstBlock, dstStride, c.deintTemp + x); else if(mode & MEDIAN_DEINT_FILTER) RENAME(deInterlaceMedian)(dstBlock, dstStride); else if(mode & CUBIC_IPOL_DEINT_FILTER) RENAME(deInterlaceInterpolateCubic)(dstBlock, dstStride); else if(mode & FFMPEG_DEINT_FILTER) RENAME(deInterlaceFF)(dstBlock, dstStride, c.deintTemp + x); else if(mode & LOWPASS5_DEINT_FILTER) RENAME(deInterlaceL5)(dstBlock, dstStride, c.deintTemp + x, c.deintTemp + width + x); if(y + 8 < height){ if(mode & V_X1_FILTER) RENAME(vertX1Filter)(dstBlock, stride, &c); else if(mode & V_DEBLOCK){ const int t= RENAME(vertClassify)(dstBlock, stride, &c); if(t==1) RENAME(doVertLowPass)(dstBlock, stride, &c); else if(t==2) RENAME(doVertDefFilter)(dstBlock, stride, &c); }else if(mode & V_A_DEBLOCK){ RENAME(do_a_deblock)(dstBlock, stride, 1, &c, mode); } } #if TEMPLATE_PP_MMX RENAME(transpose1)(tempBlock1, tempBlock2, dstBlock, dstStride); #endif if(x - 8 >= 0){ #if TEMPLATE_PP_MMX if(mode & H_X1_FILTER) RENAME(vertX1Filter)(tempBlock1, 16, &c); else if(mode & H_DEBLOCK){ const int t= RENAME(vertClassify)(tempBlock1, 16, &c); if(t==1) RENAME(doVertLowPass)(tempBlock1, 16, &c); else if(t==2) RENAME(doVertDefFilter)(tempBlock1, 16, &c); }else if(mode & H_A_DEBLOCK){ RENAME(do_a_deblock)(tempBlock1, 16, 1, &c, mode); } RENAME(transpose2)(dstBlock-4, dstStride, tempBlock1 + 4*16); #else if(mode & H_X1_FILTER) horizX1Filter(dstBlock-4, stride, QP); else if(mode & H_DEBLOCK){ #if TEMPLATE_PP_ALTIVEC DECLARE_ALIGNED(16, unsigned char, tempBlock)[272]; int t; transpose_16x8_char_toPackedAlign_altivec(tempBlock, dstBlock - (4 + 1), stride); t = vertClassify_altivec(tempBlock-48, 16, &c); if(t==1) { doVertLowPass_altivec(tempBlock-48, 16, &c); transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride); } else if(t==2) { doVertDefFilter_altivec(tempBlock-48, 16, &c); transpose_8x16_char_fromPackedAlign_altivec(dstBlock - (4 + 1), tempBlock, stride); } #else const int t= RENAME(horizClassify)(dstBlock-4, stride, &c); if(t==1) RENAME(doHorizLowPass)(dstBlock-4, stride, &c); else if(t==2) RENAME(doHorizDefFilter)(dstBlock-4, stride, &c); #endif }else if(mode & H_A_DEBLOCK){ RENAME(do_a_deblock)(dstBlock-8, 1, stride, &c, mode); } #endif if(mode & DERING){ if(y>0) RENAME(dering)(dstBlock - stride - 8, stride, &c); } if(mode & TEMP_NOISE_FILTER) { RENAME(tempNoiseReducer)(dstBlock-8, stride, c.tempBlurred[isColor] + y*dstStride + x, c.tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256, c.ppMode.maxTmpNoise); } } dstBlock+=8; srcBlock+=8; #if TEMPLATE_PP_MMX tmpXchg= tempBlock1; tempBlock1= tempBlock2; tempBlock2 = tmpXchg; #endif } if(mode & DERING){ if(y > 0) RENAME(dering)(dstBlock - dstStride - 8, dstStride, &c); } if((mode & TEMP_NOISE_FILTER)){ RENAME(tempNoiseReducer)(dstBlock-8, dstStride, c.tempBlurred[isColor] + y*dstStride + x, c.tempBlurredPast[isColor] + (y>>3)*256 + (x>>3) + 256, c.ppMode.maxTmpNoise); } if(y+15 >= height){ uint8_t *dstBlock= &(dst[y*dstStride]); if(width==FFABS(dstStride)) linecpy(dstBlock, tempDst + dstStride, height-y, dstStride); else{ int i; for(i=0; i<height-y; i++){ memcpy(dstBlock + i*dstStride, tempDst + (i+1)*dstStride, width); } } } } #if TEMPLATE_PP_3DNOW __asm__ volatile("femms"); #elif TEMPLATE_PP_MMX __asm__ volatile("emms"); #endif #ifdef DEBUG_BRIGHTNESS if(!isColor){ int max=1; int i; for(i=0; i<256; i++) if(yHistogram[i] > max) max=yHistogram[i]; for(i=1; i<256; i++){ int x; int start=yHistogram[i-1]/(max/256+1); int end=yHistogram[i]/(max/256+1); int inc= end > start ? 1 : -1; for(x=start; x!=end+inc; x+=inc) dst[ i*dstStride + x]+=128; } for(i=0; i<100; i+=2){ dst[ (white)*dstStride + i]+=128; dst[ (black)*dstStride + i]+=128; } } #endif *c2= c; }
1threat
static bool pc_machine_get_vmport(Object *obj, Error **errp) { PCMachineState *pcms = PC_MACHINE(obj); return pcms->vmport; }
1threat
static void ide_device_class_init(ObjectClass *klass, void *data) { DeviceClass *k = DEVICE_CLASS(klass); k->init = ide_qdev_init; set_bit(DEVICE_CATEGORY_STORAGE, k->categories); k->bus_type = TYPE_IDE_BUS; k->props = ide_props; }
1threat
Why i need decision tree to predict my test data when i'm giving large training data to Train computer? : I'm a student of BSCS, I'm learning data mining. 1 question in mind has totally confused me. If I had made or written my coding for decision tree then why I need Large training data to predict answers of my test data? How training data is helping me when I am checking my each test data line through some lines of codes? Passing them through step by step, if at any step they are not matching my conditions I'm writing no in answer if they are passing all conditions successfully then I'm writing Yes in answer using my code. Now how training data is helping ? if it help computer to predict then why I need my decision tree or model to answer my data??
0debug
static void multi_serial_pci_realize(PCIDevice *dev, Error **errp) { PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); PCIMultiSerialState *pci = DO_UPCAST(PCIMultiSerialState, dev, dev); SerialState *s; Error *err = NULL; int i; switch (pc->device_id) { case 0x0003: pci->ports = 2; break; case 0x0004: pci->ports = 4; break; } assert(pci->ports > 0); assert(pci->ports <= PCI_SERIAL_MAX_PORTS); pci->dev.config[PCI_CLASS_PROG] = pci->prog_if; pci->dev.config[PCI_INTERRUPT_PIN] = 0x01; memory_region_init(&pci->iobar, OBJECT(pci), "multiserial", 8 * pci->ports); pci_register_bar(&pci->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &pci->iobar); pci->irqs = qemu_allocate_irqs(multi_serial_irq_mux, pci, pci->ports); for (i = 0; i < pci->ports; i++) { s = pci->state + i; s->baudbase = 115200; serial_realize_core(s, &err); if (err != NULL) { error_propagate(errp, err); return; } s->irq = pci->irqs[i]; pci->name[i] = g_strdup_printf("uart #%d", i+1); memory_region_init_io(&s->io, OBJECT(pci), &serial_io_ops, s, pci->name[i], 8); memory_region_add_subregion(&pci->iobar, 8 * i, &s->io); } }
1threat
Angular/Material mat-form-field input - Floating label issues : <p>Is there any way in which I can stop the placeholder from floating as a label for the following snippet of code?</p> <pre><code>&lt;form class="search-form"&gt; &lt;mat-form-field class="example-full-width"&gt; &lt;input class="toolbar-search" type="text" matInput&gt; &lt;mat-placeholder&gt;Search&lt;/mat-placeholder&gt; &lt;mat-icon matSuffix style="font-size: 1.2em"&gt;search&lt;/mat-icon&gt; &lt;/mat-form-field&gt; &lt;/form&gt; </code></pre> <p><a href="https://i.stack.imgur.com/jE7CK.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/jE7CK.gif" alt="enter image description here"></a></p> <p>I have looked at the official documentation for angular/material, but it seems this feature is now deprecated?</p>
0debug
static char **breakline(char *input, int *count) { int c = 0; char *p; char **rval = g_malloc0(sizeof(char *)); char **tmp; while (rval && (p = qemu_strsep(&input, " ")) != NULL) { if (!*p) { continue; } c++; tmp = g_realloc(rval, sizeof(*rval) * (c + 1)); if (!tmp) { g_free(rval); rval = NULL; c = 0; break; } else { rval = tmp; } rval[c - 1] = p; rval[c] = NULL; } *count = c; return rval; }
1threat
static uint32_t qpi_mem_readb(void *opaque, target_phys_addr_t addr) { return 0; }
1threat
static gboolean register_signal_handlers(void) { struct sigaction sigact, sigact_chld; int ret; memset(&sigact, 0, sizeof(struct sigaction)); sigact.sa_handler = quit_handler; ret = sigaction(SIGINT, &sigact, NULL); if (ret == -1) { g_error("error configuring signal handler: %s", strerror(errno)); return false; } ret = sigaction(SIGTERM, &sigact, NULL); if (ret == -1) { g_error("error configuring signal handler: %s", strerror(errno)); return false; } memset(&sigact_chld, 0, sizeof(struct sigaction)); sigact_chld.sa_handler = child_handler; sigact_chld.sa_flags = SA_NOCLDSTOP; ret = sigaction(SIGCHLD, &sigact_chld, NULL); if (ret == -1) { g_error("error configuring signal handler: %s", strerror(errno)); } return true; }
1threat
Javascript - How to get string element from json object : I have a variable that defines the integer. Example: var integer = x //11111, 222222, 333333, etc. Then, I have a JSON object: Object { 111111: "string1", 222222: "string2", 333333: "string3", etc } How to get a specific string element based on the integer variable I have? Example: If Selected Variable `22222` is how to get `string2`?
0debug
gcloud docker push hanging : <p>When I try to push new docker images to <code>gcr.io</code> using <code>gcloud docker push</code>, it frequently makes some progress before stalling out:</p> <pre><code>$ gcloud docker push gcr.io/foo-bar-1225/baz-quux:2016-03-23 The push refers to a repository [gcr.io/foo-bar-1225/baz-quux] 762ab2ceaa70: Pushing [&gt; ] 556 kB/154.4 MB 2220ee6c7534: Pushing [===&gt; ] 4.82 MB/66.11 MB f99917176817: Layer already exists 8c1b4a49167b: Layer already exists 5f70bf18a086: Layer already exists 1967867932fe: Layer already exists 6b4fab929601: Layer already exists 550f16cd8ed1: Layer already exists 44267ec3aa94: Layer already exists bd750002938c: Layer already exists 917c0fc99b35: Layer already exists </code></pre> <p>The push stays in this state indefinitely (I've left it for an hour without a byte of progress). If I Ctrl-C kill this process and rerun it, it gets to the exact same point and again makes no progress.</p> <p>The only workaround I've found is to restart my computer and re-run "Docker Quickstart Terminal". Then the push succeeds.</p> <p>Is there a workaround for stalled pushes that doesn't require frequently rebooting my computer? (I'm on Mac OS X.)</p>
0debug
void HELPER(divu)(CPUM68KState *env, uint32_t word) { uint32_t num; uint32_t den; uint32_t quot; uint32_t rem; num = env->div1; den = env->div2; if (den == 0) { raise_exception(env, EXCP_DIV0); } quot = num / den; rem = num % den; env->cc_v = (word && quot > 0xffff ? -1 : 0); env->cc_z = quot; env->cc_n = quot; env->cc_c = 0; env->div1 = quot; env->div2 = rem; }
1threat
How to sum time in php from a json file? : <p>I have an API from a .json url that gives me an ID, the distance, and the duration in HH:MM format.</p> <pre><code>[ { "id": "210", "distance": "299", "duration": "01:31" }, { "id": "209", "distance": "279", "duration": "01:22" }, { "id": "209", "distance": "261", "duration": "01:15" } ] </code></pre> <p>I'd like to make the sum of an ID's duration so that here 01:22 + 01:15 would give me 02:37 but I have no idea how to do that.</p> <p>Any help ?</p> <p>Thanks,<br> Snax</p>
0debug
Embedded Postgres for Spring Boot Tests : <p>I'm building a Spring Boot app, backed by Postgres, using Flyway for database migrations. I've been bumping up against issues where I cannot produce a migration that generates the desired outcome in both Postgres, and the embedded unit test database (even with Postgres compatibility mode enabled). So I am looking at using embedded Postgres for unit tests.</p> <p>I came across <a href="https://github.com/opentable/otj-pg-embedded" rel="noreferrer">an embedded postgres</a> implementation that looks promising, but don't really see how to set it up to run within Spring Boot's unit test framework only (for testing Spring Data repositories). How would one set this up using the mentioned tool or an alternative embedded version of Postgres?</p>
0debug
MySQL - Products names where name contains specific words : <p>I have a MySQL table <code>products(id, name, sku)</code> and I have an array of strings: <code>$words = ['1' =&gt; 'Carlsberg', '2' =&gt; 'Premium', '3' =&gt; '250ml'];</code></p> <p>How to get from database names of products where product name includes one, two or all words of $words array?</p> <p>I need some help with writing a sql query to get these products from the database</p>
0debug
Jquery don't work inside php echo : value of $qty is in my database. I've read few similar questions and I already added $(document).ready(function() but still not working. echo " <div class='sp-quantity'> <div class='sp-minus fff'><a class='ddd' href='#' data-multi='-1'>-</a></div> <div class='col-xs-3 sp-input'> <input type='text' class='quntity-input form-control qty' pid='$bookid' id='qty-$bookid' value='$qty'/> </div> <div class='sp-plus fff'><a class='ddd' href='#' data-multi='1'>+</a></div> </div> "; echo "<script>"; echo "$(document).ready(function(){"; echo "$('.ddd').on('click', function() {"; echo "var $button = $(this);"; echo "var $input = $button.closest('.sp-quantity').find('input.quntity-input');"; echo "$input.val(function(i, value) {"; echo "return +value + (1 * +$button.data('multi'));"; echo "});"; echo "});"; echo "});"; echo "</script>";
0debug
Get current URL address by javascript : <p>How can I get current URL like this.</p> <p>For example, if the url is:</p> <p><a href="http://www.test.com/app/one.bc" rel="nofollow noreferrer">http://www.test.com/app/one.bc</a></p> <p>I want to get the path without the address the main page so like:</p> <p>/app/one.bc</p>
0debug
How to get text, using Selenium Python XPATH : <p>I try to find and get element(text), using</p> <p><a href="https://i.stack.imgur.com/vhlfT.png" rel="nofollow noreferrer">enter image description here</a></p> <pre><code>elem = driver.find_element(By.XPATH,'//*[@id="t3_9kxrv6"]/div/div/div[3]/span/h2') </code></pre> <p>If I print it, I get:</p> <pre><code>&lt;selenium.webdriver.remote.webelement.WebElement (session="2c3430395624712686d8cbfe1824c18e", element="0.06192509533309787-1")&gt; </code></pre> <p>and I want: "The problems of a dutchman in China."</p>
0debug
VBA to Remove specfic reference created from file : I put together the following SQL to add a reference to a workbook. Sub Add_Reference() Dim vbProj As Object Set vbProj = ActiveWorkbook.VBProject vbProj.References.AddFromFile "C:\User\documents\Master_file.xlsm" CleanUp: Set vbProj = Nothing End Sub I thought I would be ale to do the same to `remove` by switching out the `AddFromfile` with `Remove` as follows: Sub Remove_Reference() Dim vbProj As Object Set vbProj = ActiveWorkbook.VBProject vbProj.References.Remove "C:\User\documents\Master_file.xlsm" CleanUp: Set vbProj = Nothing End Sub When I run `Remove_Reference` I get a `Type mismatch` error on the `vbProj.References.Remove "C:\User\documents\Master_file.xlsm"` line. Im guessing I need to call it something else but I am not sure what it should be. Any ideas?
0debug
int print_insn_xtensa(bfd_vma memaddr, struct disassemble_info *info) { xtensa_isa isa = info->private_data; xtensa_insnbuf insnbuf = xtensa_insnbuf_alloc(isa); xtensa_insnbuf slotbuf = xtensa_insnbuf_alloc(isa); bfd_byte *buffer = g_malloc(1); int status = info->read_memory_func(memaddr, buffer, 1, info); xtensa_format fmt; unsigned slot, slots; unsigned len; if (status) { info->memory_error_func(status, memaddr, info); len = -1; goto out; } len = xtensa_isa_length_from_chars(isa, buffer); if (len == XTENSA_UNDEFINED) { info->fprintf_func(info->stream, ".byte 0x%02x", buffer[0]); len = 1; goto out; } buffer = g_realloc(buffer, len); status = info->read_memory_func(memaddr + 1, buffer + 1, len - 1, info); if (status) { info->fprintf_func(info->stream, ".byte 0x%02x", buffer[0]); info->memory_error_func(status, memaddr + 1, info); len = 1; goto out; } xtensa_insnbuf_from_chars(isa, insnbuf, buffer, len); fmt = xtensa_format_decode(isa, insnbuf); if (fmt == XTENSA_UNDEFINED) { unsigned i; for (i = 0; i < len; ++i) { info->fprintf_func(info->stream, "%s 0x%02x", i ? ", " : ".byte ", buffer[i]); } goto out; } slots = xtensa_format_num_slots(isa, fmt); if (slots > 1) { info->fprintf_func(info->stream, "{ "); } for (slot = 0; slot < slots; ++slot) { xtensa_opcode opc; unsigned opnd, vopnd, opnds; if (slot) { info->fprintf_func(info->stream, "; "); } xtensa_format_get_slot(isa, fmt, slot, insnbuf, slotbuf); opc = xtensa_opcode_decode(isa, fmt, slot, slotbuf); if (opc == XTENSA_UNDEFINED) { info->fprintf_func(info->stream, "???"); continue; } opnds = xtensa_opcode_num_operands(isa, opc); info->fprintf_func(info->stream, "%s", xtensa_opcode_name(isa, opc)); for (opnd = vopnd = 0; opnd < opnds; ++opnd) { if (xtensa_operand_is_visible(isa, opc, opnd)) { uint32_t v = 0xbadc0de; int rc; info->fprintf_func(info->stream, vopnd ? ", " : "\t"); xtensa_operand_get_field(isa, opc, opnd, fmt, slot, slotbuf, &v); rc = xtensa_operand_decode(isa, opc, opnd, &v); if (rc == XTENSA_UNDEFINED) { info->fprintf_func(info->stream, "???"); } else if (xtensa_operand_is_register(isa, opc, opnd)) { xtensa_regfile rf = xtensa_operand_regfile(isa, opc, opnd); info->fprintf_func(info->stream, "%s%d", xtensa_regfile_shortname(isa, rf), v); } else if (xtensa_operand_is_PCrelative(isa, opc, opnd)) { xtensa_operand_undo_reloc(isa, opc, opnd, &v, memaddr); info->fprintf_func(info->stream, "0x%x", v); } else { info->fprintf_func(info->stream, "%d", v); } ++vopnd; } } } if (slots > 1) { info->fprintf_func(info->stream, " }"); } out: g_free(buffer); xtensa_insnbuf_free(isa, insnbuf); xtensa_insnbuf_free(isa, slotbuf); return len; }
1threat
static int rm_read_header_old(AVFormatContext *s, AVFormatParameters *ap) { RMContext *rm = s->priv_data; AVStream *st; rm->old_format = 1; st = av_new_stream(s, 0); if (!st) goto fail; rm_read_audio_stream_info(s, st, 1); return 0; fail: return -1; }
1threat
How to calculate duration & distance with setAvoid() : I receive the same duration & distance whether or not I am expecting to avoid highways or tolls I suspect the issue is either in my order of operations, or the way I am calculating distance & duration I have tried setting up setAvoid in two different ways (see code), as well as changed my if statements to accommodate what the HTML form (check box) might return. I have also tried switching the if statement to "return formObject.avoid1" this showed me that the if statement is functioning properly - so either the .setAvoid is not working the way I have written it, or the distance & duration calculations are not considering the setAvoid if (formObject.avoid1 == "TRUE"){ mapObj.setAvoid(Maps.DirectionFinder.Avoid.HIGHWAYS); } if (formObject.avoid2 == "yes"){ mapObj.setAvoid("tolls"); } var directions = mapObj.getDirections(); var bestRoute = directions["routes"][0]; var numLegs = bestRoute["legs"].length; for (var c=0; c<numLegs; ++c){ var legNum = directions["routes"][0]["legs"][c]; var legDistance = legNum["distance"]["value"]; var legDuration = legNum["duration"]["value"]; totalDistance += legDistance; totalDuration += legDuration; } If we are in fact avoiding highways, I expect the duration to increase, but I get the same duration whether or not we avoid highways
0debug
Picking unique records in SQL : <p>Say I have a table with multiple records of peoples name, I draw out a prize winner every month. What is a query in SQL that I can use so that I pick up a unique record every month and the person does not get picked on the next month. I do not want to delete the record of that person.</p>
0debug
static int decode_block(MJpegDecodeContext *s, DCTELEM *block, int component, int dc_index, int ac_index, int16_t *quant_matrix) { int code, i, j, level, val; VLC *ac_vlc; val = mjpeg_decode_dc(s, dc_index); if (val == 0xffff) { dprintf("error dc\n"); return -1; } val = val * quant_matrix[0] + s->last_dc[component]; s->last_dc[component] = val; block[0] = val; ac_vlc = &s->vlcs[1][ac_index]; i = 0; {OPEN_READER(re, &s->gb) for(;;) { UPDATE_CACHE(re, &s->gb); GET_VLC(code, re, &s->gb, s->vlcs[1][ac_index].table, 9, 2) if (code == 0x10) break; if (code == 0x100) { i += 16; } else { i += ((unsigned)code) >> 4; code &= 0xf; if(code > MIN_CACHE_BITS - 16){ UPDATE_CACHE(re, &s->gb) } { int cache=GET_CACHE(re,gb); int sign=(~cache)>>31; level = (NEG_USR32(sign ^ cache,code) ^ sign) - sign; } LAST_SKIP_BITS(re, &s->gb, code) if (i >= 63) { if(i == 63){ j = s->scantable.permutated[63]; block[j] = level * quant_matrix[j]; break; } dprintf("error count: %d\n", i); return -1; } j = s->scantable.permutated[i]; block[j] = level * quant_matrix[j]; } } CLOSE_READER(re, &s->gb)} return 0; }
1threat
int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared){ const int big_mb_num= s->mb_stride*(s->mb_height+1) + 1; const int mb_array_size= s->mb_stride*s->mb_height; const int b8_array_size= s->b8_stride*s->mb_height*2; const int b4_array_size= s->b4_stride*s->mb_height*4; int i; int r= -1; if(shared){ assert(pic->data[0]); assert(pic->type == 0 || pic->type == FF_BUFFER_TYPE_SHARED); pic->type= FF_BUFFER_TYPE_SHARED; }else{ assert(!pic->data[0]); if (alloc_frame_buffer(s, pic) < 0) return -1; s->linesize = pic->linesize[0]; s->uvlinesize= pic->linesize[1]; } if(pic->qscale_table==NULL){ if (s->encoding) { FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_var , mb_array_size * sizeof(int16_t) , fail) FF_ALLOCZ_OR_GOTO(s->avctx, pic->mc_mb_var, mb_array_size * sizeof(int16_t) , fail) FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_mean , mb_array_size * sizeof(int8_t ) , fail) } FF_ALLOCZ_OR_GOTO(s->avctx, pic->mbskip_table , mb_array_size * sizeof(uint8_t)+2, fail) FF_ALLOCZ_OR_GOTO(s->avctx, pic->qscale_table , mb_array_size * sizeof(uint8_t) , fail) FF_ALLOCZ_OR_GOTO(s->avctx, pic->mb_type_base , (big_mb_num + s->mb_stride) * sizeof(uint32_t), fail) pic->mb_type= pic->mb_type_base + 2*s->mb_stride+1; if(s->out_format == FMT_H264){ for(i=0; i<2; i++){ FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], 2 * (b4_array_size+4) * sizeof(int16_t), fail) pic->motion_val[i]= pic->motion_val_base[i]+4; FF_ALLOCZ_OR_GOTO(s->avctx, pic->ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail) } pic->motion_subsample_log2= 2; }else if(s->out_format == FMT_H263 || s->encoding || (s->avctx->debug&FF_DEBUG_MV) || (s->avctx->debug_mv)){ for(i=0; i<2; i++){ FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], 2 * (b8_array_size+4) * sizeof(int16_t), fail) pic->motion_val[i]= pic->motion_val_base[i]+4; FF_ALLOCZ_OR_GOTO(s->avctx, pic->ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail) } pic->motion_subsample_log2= 3; } if(s->avctx->debug&FF_DEBUG_DCT_COEFF) { FF_ALLOCZ_OR_GOTO(s->avctx, pic->dct_coeff, 64 * mb_array_size * sizeof(DCTELEM)*6, fail) } pic->qstride= s->mb_stride; FF_ALLOCZ_OR_GOTO(s->avctx, pic->pan_scan , 1 * sizeof(AVPanScan), fail) } memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1); s->prev_pict_types[0]= s->dropable ? AV_PICTURE_TYPE_B : s->pict_type; if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == AV_PICTURE_TYPE_B) pic->age= INT_MAX; pic->owner2 = NULL; return 0; fail: if(r>=0) free_frame_buffer(s, pic); return -1; }
1threat
difference between npm run and nmp start? : <p>we have a lot of ts code which we can compile and run via "npm run dev". This allows us to hit the test js code via localhost. however, in the chrome debugger, 90% of the code is not visible (anonymous), and code which is not is too generic (such as find) to figure out how the thing which the debugger is showing as being slow or called a lot relates to our source code.</p>
0debug
Save content of Spark DataFrame as a single CSV file : <p>Say I have a Spark DataFrame which I want to save as CSV file. After <strong>Spark 2.0.0</strong> , <strong>DataFrameWriter</strong> class directly supports saving it as a CSV file.</p> <p>The default behavior is to save the output in multiple <strong>part-*.csv</strong> files inside the path provided. </p> <p>How would I save a DF with :</p> <ol> <li>Path mapping to the exact file name instead of folder</li> <li>Header available in first line</li> <li>Save as a single file instead of multiple files.</li> </ol> <p>One way to deal with it, is to coalesce the DF and then save the file. </p> <pre><code>df.coalesce(1).write.option("header", "true").csv("sample_file.csv") </code></pre> <p>However this has disadvantage in collecting it on Master machine and needs to have a master with enough memory. </p> <p>Is it possible to write a single CSV file without using <strong>coalesce</strong> ? If not, is there a efficient way than the above code ?</p>
0debug
JS Count words in a string WITHOUT using a regex : There are many posts on the topic of how to count the number of words in a string in JS already, just wanted to make it clear I looked at these. http://stackoverflow.com/questions/18679576/counting-words-in-string http://stackoverflow.com/questions/6543917/count-number-of-words-in-string-using-javascript As a very new programmer I would like to perform this function without the use of any regular expressions. I don't know anything about regex and so I want to use regular code, even if it is not the most effective way in the real world, for the sake of learning. I cannot find any answer to my question elsewhere, so I thought I would ask here before I default to just using a regex.
0debug
Spring 5 WebClient using ssl : <p>I'm trying to find examples of WebClient use. My goal is to use Spring 5 WebClient to query a REST service using https and self signed certificate</p> <p>Any example ?</p>
0debug
Python Django Errno 54 'Connection reset by peer' : <p>Having some trouble debugging this. I get this error always when i first start my app up, then intermittently thereafter. Could someone please help me by throwing out some debugging techniques? I've tried using a proxy inspector - to no avail, i didn't see anything useful. I've tried the suggestions about setting my SITE_URL in my django settings. I've tried with and without http:// with and without the port... Here's the unhelpful error:</p> <pre><code>Exception happened during processing of request from ('127.0.0.1', 57917) Traceback (most recent call last): File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socketserver.py", line 720, in __init__ self.handle() File "/Users/ryan/.local/share/virtualenvs/portal-2PUjdB8V/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 171, in handle self.handle_one_request() File "/Users/ryan/.local/share/virtualenvs/portal-2PUjdB8V/lib/python3.7/site-packages/django/core/servers/basehttp.py", line 179, in handle_one_request self.raw_requestline = self.rfile.readline(65537) File "/usr/local/Cellar/python/3.7.4/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py", line 589, in readinto return self._sock.recv_into(b) ConnectionResetError: [Errno 54] Connection reset by peer </code></pre> <p>The app seems to function properly even with this connection reset but it's been driving me crazy trying to debug.</p>
0debug
static int bdrv_qed_open(BlockDriverState *bs, int flags) { BDRVQEDState *s = bs->opaque; QEDHeader le_header; int64_t file_size; int ret; s->bs = bs; QSIMPLEQ_INIT(&s->allocating_write_reqs); ret = bdrv_pread(bs->file, 0, &le_header, sizeof(le_header)); if (ret < 0) { return ret; } qed_header_le_to_cpu(&le_header, &s->header); if (s->header.magic != QED_MAGIC) { return -EINVAL; } if (s->header.features & ~QED_FEATURE_MASK) { char buf[64]; snprintf(buf, sizeof(buf), "%" PRIx64, s->header.features & ~QED_FEATURE_MASK); qerror_report(QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, bs->device_name, "QED", buf); return -ENOTSUP; } if (!qed_is_cluster_size_valid(s->header.cluster_size)) { return -EINVAL; } file_size = bdrv_getlength(bs->file); if (file_size < 0) { return file_size; } s->file_size = qed_start_of_cluster(s, file_size); if (!qed_is_table_size_valid(s->header.table_size)) { return -EINVAL; } if (!qed_is_image_size_valid(s->header.image_size, s->header.cluster_size, s->header.table_size)) { return -EINVAL; } if (!qed_check_table_offset(s, s->header.l1_table_offset)) { return -EINVAL; } s->table_nelems = (s->header.cluster_size * s->header.table_size) / sizeof(uint64_t); s->l2_shift = ffs(s->header.cluster_size) - 1; s->l2_mask = s->table_nelems - 1; s->l1_shift = s->l2_shift + ffs(s->table_nelems) - 1; if ((s->header.features & QED_F_BACKING_FILE)) { if ((uint64_t)s->header.backing_filename_offset + s->header.backing_filename_size > s->header.cluster_size * s->header.header_size) { return -EINVAL; } ret = qed_read_string(bs->file, s->header.backing_filename_offset, s->header.backing_filename_size, bs->backing_file, sizeof(bs->backing_file)); if (ret < 0) { return ret; } if (s->header.features & QED_F_BACKING_FORMAT_NO_PROBE) { pstrcpy(bs->backing_format, sizeof(bs->backing_format), "raw"); } } if ((s->header.autoclear_features & ~QED_AUTOCLEAR_FEATURE_MASK) != 0 && !bdrv_is_read_only(bs->file) && !(flags & BDRV_O_INCOMING)) { s->header.autoclear_features &= QED_AUTOCLEAR_FEATURE_MASK; ret = qed_write_header_sync(s); if (ret) { return ret; } bdrv_flush(bs->file); } s->l1_table = qed_alloc_table(s); qed_init_l2_cache(&s->l2_cache); ret = qed_read_l1_table_sync(s); if (ret) { goto out; } if (s->header.features & QED_F_NEED_CHECK) { if (!bdrv_is_read_only(bs->file) && !(flags & BDRV_O_INCOMING)) { BdrvCheckResult result = {0}; ret = qed_check(s, &result, true); if (ret) { goto out; } } } s->need_check_timer = qemu_new_timer_ns(vm_clock, qed_need_check_timer_cb, s); out: if (ret) { qed_free_l2_cache(&s->l2_cache); qemu_vfree(s->l1_table); } return ret; }
1threat
How to run a python script on Go : <p>I have got a python script (that's fairly complicated, but i'll just put the bare minimum here) that is something like this </p> <pre><code>from cassandra.cluster import Cluster cluster = Cluster() session = cluster.connect('mykeyspace') ta = session.execute(somecqlstatement) print("The column names of the table are: ", ta.column_names) </code></pre> <p>I want to run this on Go - preferably not being read as a file but storing it as a string and executing it. </p> <p>I looked into the following source </p> <ol> <li><a href="https://stackoverflow.com/questions/27021517/go-run-external-python-script">Go: Run External Python script</a></li> <li><a href="https://forum.golangbridge.org/t/how-to-execute-python-code-without-having-to-write-it-to-a-file/6359/2" rel="nofollow noreferrer">https://forum.golangbridge.org/t/how-to-execute-python-code-without-having-to-write-it-to-a-file/6359/2</a></li> </ol> <p>Nothing seems to be working, as they throw a <code>FATA[0000] exit status 1</code></p>
0debug
static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque) { CURLState *s = ((CURLState*)opaque); size_t realsize = size * nmemb; int i; DPRINTF("CURL: Just reading %zd bytes\n", realsize); if (!s || !s->orig_buf) goto read_end; memcpy(s->orig_buf + s->buf_off, ptr, realsize); s->buf_off += realsize; for(i=0; i<CURL_NUM_ACB; i++) { CURLAIOCB *acb = s->acb[i]; if (!acb) continue; if ((s->buf_off >= acb->end)) { qemu_iovec_from_buf(acb->qiov, 0, s->orig_buf + acb->start, acb->end - acb->start); acb->common.cb(acb->common.opaque, 0); qemu_aio_release(acb); s->acb[i] = NULL; read_end: return realsize;
1threat
Docker node js issues: npm@latest not found : I am having issues with the with building my docker file with AzureDevops. Here is a a copy of my docker file: FROM node:10-alpine # Create app directory WORKDIR /usr/src/app # Copy app COPY . . # #install sudo # RUN apk-install sudo # install packages RUN apk --no-cache --virtual build-dependencies add \ sudo \ git \ python \ make \ g++ \ && sudo npm@latest -g wait-on concurrently truffle \ && npm install \ && apk del build-dependencies \ && truffle compile --all # Expose the right ports, the commands below are irrelevant when using a docker-compose file. EXPOSE 3000 CMD ["npm", "run", "server” ] it was working recently now I am getting the following error message: > npm@latest not found. Would appreiciate pointers on this
0debug
static int nsv_read_header(AVFormatContext *s) { NSVContext *nsv = s->priv_data; int i, err; av_dlog(s, "%s()\n", __FUNCTION__); av_dlog(s, "filename '%s'\n", s->filename); nsv->state = NSV_UNSYNC; nsv->ahead[0].data = nsv->ahead[1].data = NULL; for (i = 0; i < NSV_MAX_RESYNC_TRIES; i++) { if (nsv_resync(s) < 0) return -1; if (nsv->state == NSV_FOUND_NSVF) err = nsv_parse_NSVf_header(s); if (nsv->state == NSV_FOUND_NSVS) { err = nsv_parse_NSVs_header(s); break; } } if (s->nb_streams < 1) return -1; err = nsv_read_chunk(s, 1); av_dlog(s, "parsed header\n"); return err; }
1threat
static int execute_code(AVCodecContext * avctx, int c) { AnsiContext *s = avctx->priv_data; int ret, i, width, height; switch(c) { case 'A': s->y = FFMAX(s->y - (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), 0); break; case 'B': s->y = FFMIN(s->y + (s->nb_args > 0 ? s->args[0]*s->font_height : s->font_height), avctx->height - s->font_height); break; case 'C': s->x = FFMIN(s->x + (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), avctx->width - FONT_WIDTH); break; case 'D': s->x = FFMAX(s->x - (s->nb_args > 0 ? s->args[0]*FONT_WIDTH : FONT_WIDTH), 0); break; case 'H': case 'f': s->y = s->nb_args > 0 ? av_clip((s->args[0] - 1)*s->font_height, 0, avctx->height - s->font_height) : 0; s->x = s->nb_args > 1 ? av_clip((s->args[1] - 1)*FONT_WIDTH, 0, avctx->width - FONT_WIDTH) : 0; break; case 'h': case 'l': if (s->nb_args < 2) s->args[0] = DEFAULT_SCREEN_MODE; width = avctx->width; height = avctx->height; switch(s->args[0]) { case 0: case 1: case 4: case 5: case 13: case 19: s->font = avpriv_cga_font; s->font_height = 8; width = 40<<3; height = 25<<3; break; case 2: case 3: s->font = avpriv_vga16_font; s->font_height = 16; width = 80<<3; height = 25<<4; break; case 6: case 14: s->font = avpriv_cga_font; s->font_height = 8; width = 80<<3; height = 25<<3; break; case 7: break; case 15: case 16: s->font = avpriv_cga_font; s->font_height = 8; width = 80<<3; height = 43<<3; break; case 17: case 18: s->font = avpriv_cga_font; s->font_height = 8; width = 80<<3; height = 60<<4; break; default: av_log_ask_for_sample(avctx, "unsupported screen mode\n"); } if (width != avctx->width || height != avctx->height) { if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); avcodec_set_dimensions(avctx, width, height); ret = avctx->get_buffer(avctx, &s->frame); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } s->frame.pict_type = AV_PICTURE_TYPE_I; s->frame.palette_has_changed = 1; set_palette((uint32_t *)s->frame.data[1]); erase_screen(avctx); } else if (c == 'l') { erase_screen(avctx); } break; case 'J': switch (s->args[0]) { case 0: erase_line(avctx, s->x, avctx->width - s->x); if (s->y < avctx->height - s->font_height) memset(s->frame.data[0] + (s->y + s->font_height)*s->frame.linesize[0], DEFAULT_BG_COLOR, (avctx->height - s->y - s->font_height)*s->frame.linesize[0]); break; case 1: erase_line(avctx, 0, s->x); if (s->y > 0) memset(s->frame.data[0], DEFAULT_BG_COLOR, s->y * s->frame.linesize[0]); break; case 2: erase_screen(avctx); } break; case 'K': switch(s->args[0]) { case 0: erase_line(avctx, s->x, avctx->width - s->x); break; case 1: erase_line(avctx, 0, s->x); break; case 2: erase_line(avctx, 0, avctx->width); } break; case 'm': if (s->nb_args == 0) { s->nb_args = 1; s->args[0] = 0; } for (i = 0; i < FFMIN(s->nb_args, MAX_NB_ARGS); i++) { int m = s->args[i]; if (m == 0) { s->attributes = 0; s->fg = DEFAULT_FG_COLOR; s->bg = DEFAULT_BG_COLOR; } else if (m == 1 || m == 2 || m == 4 || m == 5 || m == 7 || m == 8) { s->attributes |= 1 << (m - 1); } else if (m >= 30 && m <= 37) { s->fg = ansi_to_cga[m - 30]; } else if (m == 38 && i + 2 < s->nb_args && s->args[i + 1] == 5 && s->args[i + 2] < 256) { int index = s->args[i + 2]; s->fg = index < 16 ? ansi_to_cga[index] : index; i += 2; } else if (m == 39) { s->fg = ansi_to_cga[DEFAULT_FG_COLOR]; } else if (m >= 40 && m <= 47) { s->bg = ansi_to_cga[m - 40]; } else if (m == 48 && i + 2 < s->nb_args && s->args[i + 1] == 5 && s->args[i + 2] < 256) { int index = s->args[i + 2]; s->bg = index < 16 ? ansi_to_cga[index] : index; i += 2; } else if (m == 49) { s->fg = ansi_to_cga[DEFAULT_BG_COLOR]; } else { av_log_ask_for_sample(avctx, "unsupported rendition parameter\n"); } } break; case 'n': case 'R': break; case 's': s->sx = s->x; s->sy = s->y; break; case 'u': s->x = av_clip(s->sx, 0, avctx->width - FONT_WIDTH); s->y = av_clip(s->sy, 0, avctx->height - s->font_height); break; default: av_log_ask_for_sample(avctx, "unsupported escape code\n"); break; } return 0; }
1threat
some issue with string in C : <p>i'm reading the C programming language, question 2-4 asks to write a function called squeeze to delete all char in s1 which is in s2, so i write the code, but it can't run at all.</p> <p>here is my code</p> <pre><code>#include &lt;stdio.h&gt; void squeeze(char s1[], char s2[]); int main() { squeeze("tabcdge", "abc"); } void squeeze(char s1[], char s2[]) { int i, j, k; for (i = k = 0; s1[i] != '\0'; i++) { for (j = 0; s2[j] != '\0' &amp;&amp; s2[j] != s1[i]; j++) ; if (s2[j] == '\0') s1[k++] = s1[i]; } s1[k] = '\0'; for (i = 0; s1[i] != '\0'; i++) printf("%c", s1[i]); } </code></pre>
0debug
Python3: How to make a function that can set a max size in stack : My native language is not English so there is an error with my sentences. I made a stack below. Now I want to add a function or method that allows you to specify the maximum size of the stack. How do I need to change or add? ``` class MyStack: def __init__(self): self.myList = [] self.top = -1 self.size = 0 ``` def isEmpty(self): if (self.size > 0): return False else: return True def push(self, item): self.myList.append(item) self.size = self.size + 1 self.top = self.top + 1 def pop(self): if self.isEmpty(): return None else: self.ret = self.myList.pop(self.top) self.size = self.top - 1 self.top = self.top - 1 return self.ret def peek(self): if self.isEmpty(): return None else: return self.myList[self.top]
0debug
int ffurl_register_protocol(URLProtocol *protocol, int size) { URLProtocol **p; if (size < sizeof(URLProtocol)) { URLProtocol *temp = av_mallocz(sizeof(URLProtocol)); memcpy(temp, protocol, size); protocol = temp; } p = &first_protocol; while (*p != NULL) p = &(*p)->next; *p = protocol; protocol->next = NULL; return 0; }
1threat
static int find_unused_picture(MpegEncContext *s, int shared) { int i; if (shared) { for (i = 0; i < MAX_PICTURE_COUNT; i++) { if (s->picture[i].f.data[0] == NULL) return i; } } else { for (i = 0; i < MAX_PICTURE_COUNT; i++) { if (pic_is_unused(s, &s->picture[i])) return i; } } av_log(s->avctx, AV_LOG_FATAL, "Internal error, picture buffer overflow\n"); abort(); return -1; }
1threat
asp.net mvc : How to Create razor view form dynamically at run time according to html fields deyails stored in database table : [Image of Table Structure with Data][1] [1]: https://i.stack.imgur.com/4OAHz.jpg ---------- Table structure is as bellow :<br/> ###Id|Category|DisplayName|FieldName|FieldType|FieldLength|IsRequired<br/> Please see image for details. On selection of a category all HTML fields defined in table against that category should populate in view.<br/> And how to validate on form submit.<br/> I have more than 400 categories.
0debug
Is there a way to time things in Python? : <p>Is there a way to time the amount of time that happened between (for example) button a being pressed and button b being pressed in Python? If so, how?</p> <p>Thanks for any help.</p>
0debug
Chrome is hanging due to my website : <p>I have a website and lot of my clients complaining that some time chrome hangs due to my website, cursor moves slowly, it takes a lot of time if I open link or new chrome tab. If I restart the Chrome then it fix problem for some time. I have checked with other websites also and this issue only arrises due to my website.</p> <p>What is the possible cause/reason for this how can I debug the issue? </p> <p>My website is built on Ruby On Rails 5.0, I am using Action Cables, React.Js, JQuery.</p>
0debug
componentDidMount and constructor : <pre><code> class ProductsIndex extends Component { constructor (props){ super(props); console.log(this) // #1. this logs ProductsIndex component fetch('someUrl') .then(res =&gt; res.json()) .then(res =&gt; console.log(this)) // #2. this logs ProductsIndex component fetch('someUrl') .then(res =&gt; res.json()) .then(console.log) // #3. this logs [{..},{..},{..},{..}] } componentDidMount(){ fetch('someUrl') .then(res =&gt; res.json()) .then(console.log) // #4. this logs [{..},{..},{..},{..}] } </code></pre> <p>As shown in the code above, both #1 and #2 point to same <strong><em>this</em></strong>. And also as shown, both #3 and #4 returns <strong>same</strong> array. However, why the code below doesn't work??</p> <pre><code> class ProductsIndex extends Component { constructor (props){ super(props); fetch('someUrl') .then(res =&gt; res.json()) .then(arr =&gt; { this.state = { array: arr } }) } </code></pre> <p>It throws an error saying that <strong>this.state</strong> is <strong>null</strong> and I really don't understand why.</p> <p>Below code is the solution. could anyone please explain what exactly the difference is??</p> <pre><code> class ProductsIndex extends Component { constructor (props){ super(props); this.state = { array: [] } } componentDidMount(){ fetch('someUrl') .then(res =&gt; res.json()) .then(arr =&gt; { this.setState({ array: arr }) }) } </code></pre>
0debug
void qemu_set_log(int log_flags, bool use_own_buffers) { qemu_loglevel = log_flags; if (qemu_loglevel && !qemu_logfile) { qemu_logfile = fopen(logfilename, log_append ? "a" : "w"); if (!qemu_logfile) { perror(logfilename); _exit(1); } if (use_own_buffers) { static char logfile_buf[4096]; setvbuf(qemu_logfile, logfile_buf, _IOLBF, sizeof(logfile_buf)); } else { #if defined(_WIN32) setvbuf(qemu_logfile, NULL, _IONBF, 0); #else setvbuf(qemu_logfile, NULL, _IOLBF, 0); #endif log_append = 1; } } if (!qemu_loglevel && qemu_logfile) { fclose(qemu_logfile); qemu_logfile = NULL; } }
1threat
Json version of XMLElements choice : <p>For a Java code with the following annotation:</p> <pre><code>@JsonProperty(value="Contact") @NotNull(message = "ContactUser or CompanyName is required.") @Valid @XmlElements(value = { @XmlElement(name = "ContactUser", type = ContactUser.class, required = true), @XmlElement(name = "CompanyName", type = String.class, required = true) }) private Object contactInfo; </code></pre> <p>Result set when I use the object for GET is :</p> <pre><code>"Contact":{ "ContactUser":{ "Title": "Miss", "LastName": "Hello" } } </code></pre> <p>or </p> <pre><code>"Contact": "Hello Company" </code></pre> <p>Is there a way so it returns:</p> <pre><code>"ContactUser":{ "Title": "Miss", "LastName": "Hello" } </code></pre> <p>or </p> <pre><code>"CompanyName": "Hello Company" </code></pre> <p>instead? In xml, with the code, you can do:</p> <pre><code> &lt;CompanyName&gt;Hello Company&lt;/CompanyName&gt; </code></pre> <p>or </p> <pre><code>&lt;ContactUser&gt; &lt;Title&gt;Miss&lt;/Title&gt; &lt;LastName&gt;Hello&lt;/LastName&gt; &lt;/ContactUser&gt; </code></pre> <p>I have tried using JsonTypeInfo but it doesnt seem to handle String.class:</p> <pre><code> @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include =JsonTypeInfo.As.WRAPPER_OBJECT, visible=true) @JsonSubTypes({ @JsonSubTypes.Type(name = "ContactUserJ", value = ContactUser.class), @JsonSubTypes.Type(name = "CompanyNameJ" , value = String.class) }) </code></pre>
0debug
How i over come with name error in python : <p>i wrote following code but during run its gives name error in 'raw_input' please help me to out of this</p> <p>my code is:<code>fname = raw_input('enter a file name: ') print (fname)</code></p> <p>Error is= name error:name 'raw_input'is not define</p>
0debug
Read text of selected option [materialize] : <p>i'm using materialize framework.</p> <p>I'm trying to implement the materialize select: <a href="https://materializecss.com/select.html" rel="nofollow noreferrer">https://materializecss.com/select.html</a></p> <p>and this is a sample code:</p> <pre><code> &lt;div class="input-field col s12"&gt; &lt;select id="mySelect"&gt; &lt;option value="" disabled selected&gt;Choose your option&lt;/option&gt; &lt;option value="1"&gt; text of option 1&lt;/option&gt; &lt;option value="2"&gt;text of option2&lt;/option&gt; &lt;option value="3"&gt; text of option 3Option 3&lt;/option&gt; &lt;/select&gt; &lt;label&gt;Materialize Select&lt;/label&gt; &lt;/div&gt; </code></pre> <p>I'm trying to read the text of the selected option but I can't. Any suggestions?</p> <p>the only thing I managed to take is the value of the option with this:</p> <pre><code>$("#MySelect").change(function() { console.log($('#MySelect').val()); }); </code></pre>
0debug
Meaning of ~ in import of scss files : <p>I have a npm library that I use for styling which uses the following syntax to import scss files. I am not sure what this means and could not find any documentation online. I use grunt with webpack during my build process. </p> <pre><code>@import '~bourbon/app/assets/stylesheets/bourbon'; @import '~bourbon-neat'; </code></pre>
0debug
static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush) { GXFContext *gxf = s->priv_data; AVPacket new_pkt; int i; for (i = 0; i < s->nb_streams; i++) { if (s->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) { GXFStreamContext *sc = &gxf->streams[i]; if (pkt && pkt->stream_index == i) { av_fifo_write(&sc->audio_buffer, pkt->data, pkt->size); pkt = NULL; } if (flush || av_fifo_size(&sc->audio_buffer) >= GXF_AUDIO_PACKET_SIZE) { if (!pkt && gxf_new_audio_packet(gxf, sc, &new_pkt, flush) > 0) { pkt = &new_pkt; break; } } } } return av_interleave_packet_per_dts(s, out, pkt, flush); }
1threat
static inline void set_fsr(CPUSPARCState *env) { int rnd_mode; switch (env->fsr & FSR_RD_MASK) { case FSR_RD_NEAREST: rnd_mode = float_round_nearest_even; break; default: case FSR_RD_ZERO: rnd_mode = float_round_to_zero; break; case FSR_RD_POS: rnd_mode = float_round_up; break; case FSR_RD_NEG: rnd_mode = float_round_down; break; } set_float_rounding_mode(rnd_mode, &env->fp_status); }
1threat
What is the best way to implement 2 dimensional array in javascript whose size is not fixed? : <p>For example if we have a list of topics and each topic has a list of questions and later on i want to iterate through all the questions..</p>
0debug
golang Read(p []byte) doesnot read full byte? : Recently I use golang Read(p []byte),intending to read full len(p) bytes. However I find that Read does not guarantee read len(p) bytes.That's,I need read 4 bytes but actually it gives me only 1.At last I use io.ReadFull instead.Now I am confused, what's the meaning of the function? What's the proper scene using Read?It may just read less bytes than you need.
0debug