problem
stringlengths
26
131k
labels
class label
2 classes
static int ccid_handle_data(USBDevice *dev, USBPacket *p) { USBCCIDState *s = DO_UPCAST(USBCCIDState, dev, dev); int ret = 0; uint8_t *data = p->data; int len = p->len; switch (p->pid) { case USB_TOKEN_OUT: ret = ccid_handle_bulk_out(s, p); break; case USB_TOKEN_IN: switch (p->devep & 0xf) { case CCID_BULK_IN_EP: if (!len) { ret = USB_RET_NAK; } else { ret = ccid_bulk_in_copy_to_guest(s, data, len); } break; case CCID_INT_IN_EP: if (s->notify_slot_change) { data[0] = CCID_MESSAGE_TYPE_RDR_to_PC_NotifySlotChange; data[1] = s->bmSlotICCState; ret = 2; s->notify_slot_change = false; s->bmSlotICCState &= ~SLOT_0_CHANGED_MASK; DPRINTF(s, D_INFO, "handle_data: int_in: notify_slot_change %X, " "requested len %d\n", s->bmSlotICCState, len); } break; default: DPRINTF(s, 1, "Bad endpoint\n"); break; } break; default: DPRINTF(s, 1, "Bad token\n"); ret = USB_RET_STALL; break; } return ret; }
1threat
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout) { int i; if (nb_channels <= 0) nb_channels = av_get_channel_layout_nb_channels(channel_layout); for (i = 0; channel_layout_map[i].name; i++) if (nb_channels == channel_layout_map[i].nb_channels && channel_layout == channel_layout_map[i].layout) { av_strlcpy(buf, channel_layout_map[i].name, buf_size); return; } snprintf(buf, buf_size, "%d channels", nb_channels); if (channel_layout) { int i, ch; av_strlcat(buf, " (", buf_size); for (i = 0, ch = 0; i < 64; i++) { if ((channel_layout & (1L << i))) { const char *name = get_channel_name(i); if (name) { if (ch > 0) av_strlcat(buf, "|", buf_size); av_strlcat(buf, name, buf_size); } ch++; } } av_strlcat(buf, ")", buf_size); } }
1threat
Do raw strings in python disable meta characters such as \w or \d just as they do with \n? : <p>I am new to Python. Can someone tell me what is the difference between these two regex statements (re.findall(r"\d+","i am aged 35")) and (re.findall("\d+","i am aged 35")).</p> <p>I had the understanding that the raw string in the first statement will make "\d+" inactive because that is the primarily role of a raw string - to make escape characters inactive. In other words "\d+" will not be a meta character for finding/searching/matching digits if a raw string is used. However, I now see that both statements return the same result. </p>
0debug
View function prototypes in C : <p>Often during programming contests I forget which library contains which function. Hence I require some C code which can print the available functions with a specific library. eg. usage:</p> <p><code>showAvailFunctions("stdlib.h")</code></p> <p>and it would print all the available functions with <code>stdlib.h</code> library</p>
0debug
MySQL query result is giving wrong values : <p>guys! I'm in trouble with my MySQL database. When I try to access the fields it doesn't return the exact value. Here is the code.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php $host = "localhost"; $user = "******"; $pass = "******"; $db = mysql_connect($host, $user, $pass) or die("Unable to connect. Check your connection parameters."); mysql_select_db("*****") or die("Unable to select database!"); $form_username=$_POST["username"]; $form_password=$_POST["password"]; $query=" SELECT username, password FROM users "; $result=mysql_query($query,$db) or die("Unable to send the query".mysql_error()); $index=0; while($row=mysql_fetch_row($result)) { $username[$index]=row[0]; $password[$index]=row[1]; $index++; } for($i=0; $i&lt;=$index; $i++) { if($form_username==$username[$i]&amp;&amp; $form_password==$password[$i]) { session_start(); $_SESSION["login"]="OK"; header("Location: ************"); die(); } }</code></pre> </div> </div> </p> <p>The <strong>if</strong> statement inside the <strong>for</strong> operator returns false for every given value. When I <strong>echo</strong> every username and password like this:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>echo $form_username." ".$username[0]." ".$form_password." ".$password[0]."&lt;br&gt;"; echo $form_username." ".$username[1]." ".$form_password." ".$password[1]."&lt;br&gt;"; echo $form_username." ".$username[2]." ".$form_password." ".$password[2]."&lt;br&gt;";</code></pre> </div> </div> </p> <p>It <strong>echo</strong> me this:</p> <p>admin r 12345 o</p> <p>admin r 12345 o</p> <p>admin r 12345 o</p> <p>I really don't know where the problem is. I'll really appreciate your help.</p>
0debug
Android how to set image to imageview from ulr : try { URL newurl = new URL("here my image url"); Bitmap bmp= BitmapFactory.decodeStream(newurl.openConnection() .getInputStream()); img_View.setImageBitmap(bmp); } catch(Exception e) { } I used above this code But still I cannot load this image to imageview, Nothing is getting loaded. could help me ?
0debug
program that determines if array is ascending, descending, or random(C language) : <p>i have to build a program that scans "size", then array in the size of "size". returns 1 if ascending, -1 if descending, and 0 if neither.</p> <p>so for I've came up with this, and its not working.</p> <pre><code>int UpOrDown(int *arr,int size) { int i,j,flag; if(arr[0]&lt;arr[1])// ascending or random { flag=1; { for(i=1;i&lt;size;i++) if(arr[i]&gt;arr[i+1]) flag=0; } if (flag=0) return 0; else return 1; } else //descending or random { flag=-1; if(arr[0]&gt;arr[1]) { for(i=1;i&lt;size;i++) if(arr[i]&lt;arr[i+1]) flag=0; } if (flag=0) return 0; else return -1; } </code></pre> <p>i'd appreciate some guidance.</p>
0debug
Error: No toolchains found in the NDK toolchains folder for ABI with prefix: llvm : <p>I want to compile an open source android project (Netguard) using gradel (<code>gradlew clean build</code>) But I encountered this Error:</p> <pre><code>A problem occurred configuring project ':app'. &gt; Exception thrown while executing model rule: NdkComponentModelPlugin.Rules#cre ateToolchains &gt; No toolchains found in the NDK toolchains folder for ABI with prefix: llvm </code></pre> <p>I serached but didn't find enything helping. Here is the main <code>build.gradle</code>:</p> <pre><code>buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle-experimental:0.6.0-alpha1' } } allprojects { repositories { jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } </code></pre> <p>And here is the <code>build.gradle</code> of the <code>app</code> project:</p> <pre><code>apply plugin: 'com.android.model.application' model { android { compileSdkVersion = 23 buildToolsVersion = "23.0.2" defaultConfig.with { applicationId = "eu.faircode.netguard" minSdkVersion.apiLevel = 21 targetSdkVersion.apiLevel = 23 versionCode = 2016011801 versionName = "0.76" archivesBaseName = "NetGuard-v$versionName-$versionCode" } } android.ndk { moduleName = "netguard" toolchain = "clang" ldLibs.add("log") } android.sources { main { jni { source { srcDir "src/main/jni/netguard" } exportedHeaders { } } } } android.buildTypes { release { minifyEnabled = true proguardFiles.add(file('proguard-rules.pro')) ndk.with { debuggable = true } } } android.buildTypes { debug { ndk.with { debuggable = true } } } android.productFlavors { create("all") { } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.1.+' compile 'com.android.support:recyclerview-v7:23.1.+' compile 'com.squareup.picasso:picasso:2.5.+' } </code></pre> <p>And I'm using <code>gradle-2.9-all</code> and <code>android-ndk-r10e</code>. I don't know if I should mention anything else, so comment if you need any information.</p>
0debug
im a big c++ noob and I need help starting out a block of code for my program : <p>so i am making a code that takes data from a txt file and gets its variance. The formula that my teacher required us to use needs the program to square the decimals in the txt file and then gets its sum. unfortunately i do not have a sample of code because I do not know where to start. I was only able to store the data in the text file into a vector.</p> <pre><code>ifstream dataInput("D:\\Users\\Rodolfo Obre\\Documents\\Ateneo De Manila\\Intersession 2019\\Engg 21\\Programs\\Text Files\\Data Set.txt"); double readNumber; vector&lt;double&gt; dataSet; if (!dataInput.is_open()) { cerr &lt;&lt; "The file can not be opened\n"; exit(1);//exits the program } while (dataInput &gt;&gt; readNumber){ dataSet.push_back(readNumber); } cout &lt;&lt; "n is equal to " &lt;&lt; dataSet.size() &lt;&lt; endl; double sum=0; for (int i=0; i &lt; dataSet.size(); i++){ sum += dataSet[i]; } cout &lt;&lt; "The sum of the data is " &lt;&lt; sum &lt;&lt; endl; </code></pre> <p>This block of code takes the data from the txt file, counts how many there are and then takes its sum.</p> <p>I have no idea how I to do the part where i need to take each decimal in the text file, raise it to the power 2 and then get the sum of all of the values.</p>
0debug
static void formant_postfilter(G723_1_Context *p, int16_t *lpc, int16_t *buf) { int16_t filter_coef[2][LPC_ORDER], *buf_ptr; int filter_signal[LPC_ORDER + FRAME_LEN], *signal_ptr; int i, j, k; memcpy(buf, p->fir_mem, LPC_ORDER * sizeof(*buf)); memcpy(filter_signal, p->iir_mem, LPC_ORDER * sizeof(*filter_signal)); for (i = LPC_ORDER, j = 0; j < SUBFRAMES; i += SUBFRAME_LEN, j++) { for (k = 0; k < LPC_ORDER; k++) { filter_coef[0][k] = (-lpc[k] * postfilter_tbl[0][k] + (1 << 14)) >> 15; filter_coef[1][k] = (-lpc[k] * postfilter_tbl[1][k] + (1 << 14)) >> 15; } iir_filter(filter_coef[0], filter_coef[1], buf + i, filter_signal + i); lpc += LPC_ORDER; } memcpy(p->fir_mem, buf + FRAME_LEN, LPC_ORDER * sizeof(*p->fir_mem)); memcpy(p->iir_mem, filter_signal + FRAME_LEN, LPC_ORDER * sizeof(*p->iir_mem)); buf_ptr = buf + LPC_ORDER; signal_ptr = filter_signal + LPC_ORDER; for (i = 0; i < SUBFRAMES; i++) { int16_t temp_vector[SUBFRAME_LEN]; int temp; int auto_corr[2]; int scale, energy; memcpy(temp_vector, buf_ptr, SUBFRAME_LEN * sizeof(*temp_vector)); scale = scale_vector(temp_vector, SUBFRAME_LEN); auto_corr[0] = dot_product(temp_vector, temp_vector + 1, SUBFRAME_LEN - 1, 1); auto_corr[1] = dot_product(temp_vector, temp_vector, SUBFRAME_LEN, 1); temp = auto_corr[1] >> 16; if (temp) { temp = (auto_corr[0] >> 2) / temp; } p->reflection_coef = (3 * p->reflection_coef + temp + 2) >> 2; temp = -p->reflection_coef >> 1 & ~3; for (j = 0; j < SUBFRAME_LEN; j++) { buf_ptr[j] = av_clipl_int32(signal_ptr[j] + ((signal_ptr[j - 1] >> 16) * temp << 1)) >> 16; } temp = 2 * scale + 4; if (temp < 0) { energy = av_clipl_int32((int64_t)auto_corr[1] << -temp); } else energy = auto_corr[1] >> temp; gain_scale(p, buf_ptr, energy); buf_ptr += SUBFRAME_LEN; signal_ptr += SUBFRAME_LEN; } }
1threat
static void decode_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) { int32_t offset; int rs, rt, rd, sa; uint32_t op, op1, op2; int16_t imm; if (ctx->pc & 0x3) { env->CP0_BadVAddr = ctx->pc; generate_exception(ctx, EXCP_AdEL); return; } if ((ctx->hflags & MIPS_HFLAG_BMASK_BASE) == MIPS_HFLAG_BL) { int l1 = gen_new_label(); MIPS_DEBUG("blikely condition (" TARGET_FMT_lx ")", ctx->pc + 4); tcg_gen_brcondi_tl(TCG_COND_NE, bcond, 0, l1); tcg_gen_movi_i32(hflags, ctx->hflags & ~MIPS_HFLAG_BMASK); gen_goto_tb(ctx, 1, ctx->pc + 4); gen_set_label(l1); } if (unlikely(qemu_loglevel_mask(CPU_LOG_TB_OP | CPU_LOG_TB_OP_OPT))) { tcg_gen_debug_insn_start(ctx->pc); } op = MASK_OP_MAJOR(ctx->opcode); rs = (ctx->opcode >> 21) & 0x1f; rt = (ctx->opcode >> 16) & 0x1f; rd = (ctx->opcode >> 11) & 0x1f; sa = (ctx->opcode >> 6) & 0x1f; imm = (int16_t)ctx->opcode; switch (op) { case OPC_SPECIAL: op1 = MASK_SPECIAL(ctx->opcode); switch (op1) { case OPC_SLL: case OPC_SRA: gen_shift_imm(ctx, op1, rd, rt, sa); break; case OPC_SRL: switch ((ctx->opcode >> 21) & 0x1f) { case 1: if (ctx->insn_flags & ISA_MIPS32R2) { op1 = OPC_ROTR; } case 0: gen_shift_imm(ctx, op1, rd, rt, sa); break; default: generate_exception(ctx, EXCP_RI); break; } break; case OPC_MOVN: case OPC_MOVZ: check_insn(ctx, ISA_MIPS4 | ISA_MIPS32 | INSN_LOONGSON2E | INSN_LOONGSON2F); gen_cond_move(ctx, op1, rd, rs, rt); break; case OPC_ADD ... OPC_SUBU: gen_arith(ctx, op1, rd, rs, rt); break; case OPC_SLLV: case OPC_SRAV: gen_shift(ctx, op1, rd, rs, rt); break; case OPC_SRLV: switch ((ctx->opcode >> 6) & 0x1f) { case 1: if (ctx->insn_flags & ISA_MIPS32R2) { op1 = OPC_ROTRV; } case 0: gen_shift(ctx, op1, rd, rs, rt); break; default: generate_exception(ctx, EXCP_RI); break; } break; case OPC_SLT: case OPC_SLTU: gen_slt(ctx, op1, rd, rs, rt); break; case OPC_AND: case OPC_OR: case OPC_NOR: case OPC_XOR: gen_logic(ctx, op1, rd, rs, rt); break; case OPC_MULT ... OPC_DIVU: if (sa) { check_insn(ctx, INSN_VR54XX); op1 = MASK_MUL_VR54XX(ctx->opcode); gen_mul_vr54xx(ctx, op1, rd, rs, rt); } else gen_muldiv(ctx, op1, rs, rt); break; case OPC_JR ... OPC_JALR: gen_compute_branch(ctx, op1, 4, rs, rd, sa); *is_branch = 1; break; case OPC_TGE ... OPC_TEQ: case OPC_TNE: gen_trap(ctx, op1, rs, rt, -1); break; case OPC_MFHI: case OPC_MFLO: gen_HILO(ctx, op1, rd); break; case OPC_MTHI: case OPC_MTLO: gen_HILO(ctx, op1, rs); break; case OPC_PMON: #ifdef MIPS_STRICT_STANDARD MIPS_INVAL("PMON / selsl"); generate_exception(ctx, EXCP_RI); #else gen_helper_0e0i(pmon, sa); #endif break; case OPC_SYSCALL: generate_exception(ctx, EXCP_SYSCALL); ctx->bstate = BS_STOP; break; case OPC_BREAK: generate_exception(ctx, EXCP_BREAK); break; case OPC_SPIM: #ifdef MIPS_STRICT_STANDARD MIPS_INVAL("SPIM"); generate_exception(ctx, EXCP_RI); #else MIPS_INVAL("spim (unofficial)"); generate_exception(ctx, EXCP_RI); #endif break; case OPC_SYNC: break; case OPC_MOVCI: check_insn(ctx, ISA_MIPS4 | ISA_MIPS32); if (env->CP0_Config1 & (1 << CP0C1_FP)) { check_cp1_enabled(ctx); gen_movci(ctx, rd, rs, (ctx->opcode >> 18) & 0x7, (ctx->opcode >> 16) & 1); } else { generate_exception_err(ctx, EXCP_CpU, 1); } break; #if defined(TARGET_MIPS64) case OPC_DSLL: case OPC_DSRA: case OPC_DSLL32: case OPC_DSRA32: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); gen_shift_imm(ctx, op1, rd, rt, sa); break; case OPC_DSRL: switch ((ctx->opcode >> 21) & 0x1f) { case 1: if (ctx->insn_flags & ISA_MIPS32R2) { op1 = OPC_DROTR; } case 0: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); gen_shift_imm(ctx, op1, rd, rt, sa); break; default: generate_exception(ctx, EXCP_RI); break; } break; case OPC_DSRL32: switch ((ctx->opcode >> 21) & 0x1f) { case 1: if (ctx->insn_flags & ISA_MIPS32R2) { op1 = OPC_DROTR32; } case 0: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); gen_shift_imm(ctx, op1, rd, rt, sa); break; default: generate_exception(ctx, EXCP_RI); break; } break; case OPC_DADD ... OPC_DSUBU: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); gen_arith(ctx, op1, rd, rs, rt); break; case OPC_DSLLV: case OPC_DSRAV: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); gen_shift(ctx, op1, rd, rs, rt); break; case OPC_DSRLV: switch ((ctx->opcode >> 6) & 0x1f) { case 1: if (ctx->insn_flags & ISA_MIPS32R2) { op1 = OPC_DROTRV; } case 0: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); gen_shift(ctx, op1, rd, rs, rt); break; default: generate_exception(ctx, EXCP_RI); break; } break; case OPC_DMULT ... OPC_DDIVU: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); gen_muldiv(ctx, op1, rs, rt); break; #endif default: MIPS_INVAL("special"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_SPECIAL2: op1 = MASK_SPECIAL2(ctx->opcode); switch (op1) { case OPC_MADD ... OPC_MADDU: case OPC_MSUB ... OPC_MSUBU: check_insn(ctx, ISA_MIPS32); gen_muldiv(ctx, op1, rs, rt); break; case OPC_MUL: gen_arith(ctx, op1, rd, rs, rt); break; case OPC_CLO: case OPC_CLZ: check_insn(ctx, ISA_MIPS32); gen_cl(ctx, op1, rd, rs); break; case OPC_SDBBP: check_insn(ctx, ISA_MIPS32); if (!(ctx->hflags & MIPS_HFLAG_DM)) { generate_exception(ctx, EXCP_DBp); } else { generate_exception(ctx, EXCP_DBp); } break; case OPC_DIV_G_2F: case OPC_DIVU_G_2F: case OPC_MULT_G_2F: case OPC_MULTU_G_2F: case OPC_MOD_G_2F: case OPC_MODU_G_2F: check_insn(ctx, INSN_LOONGSON2F); gen_loongson_integer(ctx, op1, rd, rs, rt); break; #if defined(TARGET_MIPS64) case OPC_DCLO: case OPC_DCLZ: check_insn(ctx, ISA_MIPS64); check_mips_64(ctx); gen_cl(ctx, op1, rd, rs); break; case OPC_DMULT_G_2F: case OPC_DMULTU_G_2F: case OPC_DDIV_G_2F: case OPC_DDIVU_G_2F: case OPC_DMOD_G_2F: case OPC_DMODU_G_2F: check_insn(ctx, INSN_LOONGSON2F); gen_loongson_integer(ctx, op1, rd, rs, rt); break; #endif default: MIPS_INVAL("special2"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_SPECIAL3: op1 = MASK_SPECIAL3(ctx->opcode); switch (op1) { case OPC_EXT: case OPC_INS: check_insn(ctx, ISA_MIPS32R2); gen_bitops(ctx, op1, rt, rs, sa, rd); break; case OPC_BSHFL: check_insn(ctx, ISA_MIPS32R2); op2 = MASK_BSHFL(ctx->opcode); gen_bshfl(ctx, op2, rt, rd); break; case OPC_RDHWR: gen_rdhwr(ctx, rt, rd); break; case OPC_FORK: check_insn(ctx, ASE_MT); { TCGv t0 = tcg_temp_new(); TCGv t1 = tcg_temp_new(); gen_load_gpr(t0, rt); gen_load_gpr(t1, rs); gen_helper_fork(t0, t1); tcg_temp_free(t0); tcg_temp_free(t1); } break; case OPC_YIELD: check_insn(ctx, ASE_MT); { TCGv t0 = tcg_temp_new(); save_cpu_state(ctx, 1); gen_load_gpr(t0, rs); gen_helper_yield(t0, cpu_env, t0); gen_store_gpr(t0, rd); tcg_temp_free(t0); } break; case OPC_DIV_G_2E ... OPC_DIVU_G_2E: case OPC_MOD_G_2E ... OPC_MODU_G_2E: case OPC_MULT_G_2E ... OPC_MULTU_G_2E: if ((ctx->insn_flags & ASE_DSPR2) && (op1 == OPC_MULT_G_2E)) { op2 = MASK_ADDUH_QB(ctx->opcode); switch (op2) { case OPC_ADDUH_QB: case OPC_ADDUH_R_QB: case OPC_ADDQH_PH: case OPC_ADDQH_R_PH: case OPC_ADDQH_W: case OPC_ADDQH_R_W: case OPC_SUBUH_QB: case OPC_SUBUH_R_QB: case OPC_SUBQH_PH: case OPC_SUBQH_R_PH: case OPC_SUBQH_W: case OPC_SUBQH_R_W: gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt); break; case OPC_MUL_PH: case OPC_MUL_S_PH: case OPC_MULQ_S_W: case OPC_MULQ_RS_W: gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 1); break; default: MIPS_INVAL("MASK ADDUH.QB"); generate_exception(ctx, EXCP_RI); break; } } else if (ctx->insn_flags & INSN_LOONGSON2E) { gen_loongson_integer(ctx, op1, rd, rs, rt); } else { generate_exception(ctx, EXCP_RI); } break; case OPC_LX_DSP: op2 = MASK_LX(ctx->opcode); switch (op2) { #if defined(TARGET_MIPS64) case OPC_LDX: #endif case OPC_LBUX: case OPC_LHX: case OPC_LWX: gen_mipsdsp_ld(ctx, op2, rd, rs, rt); break; default: MIPS_INVAL("MASK LX"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_ABSQ_S_PH_DSP: op2 = MASK_ABSQ_S_PH(ctx->opcode); switch (op2) { case OPC_ABSQ_S_QB: case OPC_ABSQ_S_PH: case OPC_ABSQ_S_W: case OPC_PRECEQ_W_PHL: case OPC_PRECEQ_W_PHR: case OPC_PRECEQU_PH_QBL: case OPC_PRECEQU_PH_QBR: case OPC_PRECEQU_PH_QBLA: case OPC_PRECEQU_PH_QBRA: case OPC_PRECEU_PH_QBL: case OPC_PRECEU_PH_QBR: case OPC_PRECEU_PH_QBLA: case OPC_PRECEU_PH_QBRA: gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt); break; case OPC_BITREV: case OPC_REPL_QB: case OPC_REPLV_QB: case OPC_REPL_PH: case OPC_REPLV_PH: gen_mipsdsp_bitinsn(ctx, op1, op2, rd, rt); break; default: MIPS_INVAL("MASK ABSQ_S.PH"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_ADDU_QB_DSP: op2 = MASK_ADDU_QB(ctx->opcode); switch (op2) { case OPC_ADDQ_PH: case OPC_ADDQ_S_PH: case OPC_ADDQ_S_W: case OPC_ADDU_QB: case OPC_ADDU_S_QB: case OPC_ADDU_PH: case OPC_ADDU_S_PH: case OPC_SUBQ_PH: case OPC_SUBQ_S_PH: case OPC_SUBQ_S_W: case OPC_SUBU_QB: case OPC_SUBU_S_QB: case OPC_SUBU_PH: case OPC_SUBU_S_PH: case OPC_ADDSC: case OPC_ADDWC: case OPC_MODSUB: case OPC_RADDU_W_QB: gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt); break; case OPC_MULEU_S_PH_QBL: case OPC_MULEU_S_PH_QBR: case OPC_MULQ_RS_PH: case OPC_MULEQ_S_W_PHL: case OPC_MULEQ_S_W_PHR: case OPC_MULQ_S_PH: gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 1); break; default: MIPS_INVAL("MASK ADDU.QB"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_CMPU_EQ_QB_DSP: op2 = MASK_CMPU_EQ_QB(ctx->opcode); switch (op2) { case OPC_PRECR_SRA_PH_W: case OPC_PRECR_SRA_R_PH_W: gen_mipsdsp_arith(ctx, op1, op2, rt, rs, rd); break; case OPC_PRECR_QB_PH: case OPC_PRECRQ_QB_PH: case OPC_PRECRQ_PH_W: case OPC_PRECRQ_RS_PH_W: case OPC_PRECRQU_S_QB_PH: gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt); break; case OPC_CMPU_EQ_QB: case OPC_CMPU_LT_QB: case OPC_CMPU_LE_QB: case OPC_CMP_EQ_PH: case OPC_CMP_LT_PH: case OPC_CMP_LE_PH: gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 0); break; case OPC_CMPGU_EQ_QB: case OPC_CMPGU_LT_QB: case OPC_CMPGU_LE_QB: case OPC_CMPGDU_EQ_QB: case OPC_CMPGDU_LT_QB: case OPC_CMPGDU_LE_QB: case OPC_PICK_QB: case OPC_PICK_PH: case OPC_PACKRL_PH: gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 1); break; default: MIPS_INVAL("MASK CMPU.EQ.QB"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_SHLL_QB_DSP: gen_mipsdsp_shift(ctx, op1, rd, rs, rt); break; case OPC_DPA_W_PH_DSP: op2 = MASK_DPA_W_PH(ctx->opcode); switch (op2) { case OPC_DPAU_H_QBL: case OPC_DPAU_H_QBR: case OPC_DPSU_H_QBL: case OPC_DPSU_H_QBR: case OPC_DPA_W_PH: case OPC_DPAX_W_PH: case OPC_DPAQ_S_W_PH: case OPC_DPAQX_S_W_PH: case OPC_DPAQX_SA_W_PH: case OPC_DPS_W_PH: case OPC_DPSX_W_PH: case OPC_DPSQ_S_W_PH: case OPC_DPSQX_S_W_PH: case OPC_DPSQX_SA_W_PH: case OPC_MULSAQ_S_W_PH: case OPC_DPAQ_SA_L_W: case OPC_DPSQ_SA_L_W: case OPC_MAQ_S_W_PHL: case OPC_MAQ_S_W_PHR: case OPC_MAQ_SA_W_PHL: case OPC_MAQ_SA_W_PHR: case OPC_MULSA_W_PH: gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 0); break; default: MIPS_INVAL("MASK DPAW.PH"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_INSV_DSP: op2 = MASK_INSV(ctx->opcode); switch (op2) { case OPC_INSV: check_dsp(ctx); { TCGv t0, t1; if (rt == 0) { MIPS_DEBUG("NOP"); break; } t0 = tcg_temp_new(); t1 = tcg_temp_new(); gen_load_gpr(t0, rt); gen_load_gpr(t1, rs); gen_helper_insv(cpu_gpr[rt], cpu_env, t1, t0); tcg_temp_free(t0); tcg_temp_free(t1); break; } default: MIPS_INVAL("MASK INSV"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_APPEND_DSP: check_dspr2(ctx); op2 = MASK_APPEND(ctx->opcode); gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rt, rs, rd, 1); break; case OPC_EXTR_W_DSP: op2 = MASK_EXTR_W(ctx->opcode); switch (op2) { case OPC_EXTR_W: case OPC_EXTR_R_W: case OPC_EXTR_RS_W: case OPC_EXTR_S_H: case OPC_EXTRV_S_H: case OPC_EXTRV_W: case OPC_EXTRV_R_W: case OPC_EXTRV_RS_W: case OPC_EXTP: case OPC_EXTPV: case OPC_EXTPDP: case OPC_EXTPDPV: gen_mipsdsp_accinsn(ctx, op1, op2, rt, rs, rd, 1); break; case OPC_RDDSP: gen_mipsdsp_accinsn(ctx, op1, op2, rd, rs, rt, 1); break; case OPC_SHILO: case OPC_SHILOV: case OPC_MTHLIP: case OPC_WRDSP: gen_mipsdsp_accinsn(ctx, op1, op2, rd, rs, rt, 0); break; default: MIPS_INVAL("MASK EXTR.W"); generate_exception(ctx, EXCP_RI); break; } break; #if defined(TARGET_MIPS64) case OPC_DEXTM ... OPC_DEXT: case OPC_DINSM ... OPC_DINS: check_insn(ctx, ISA_MIPS64R2); check_mips_64(ctx); gen_bitops(ctx, op1, rt, rs, sa, rd); break; case OPC_DBSHFL: check_insn(ctx, ISA_MIPS64R2); check_mips_64(ctx); op2 = MASK_DBSHFL(ctx->opcode); gen_bshfl(ctx, op2, rt, rd); break; case OPC_DDIV_G_2E ... OPC_DDIVU_G_2E: case OPC_DMULT_G_2E ... OPC_DMULTU_G_2E: case OPC_DMOD_G_2E ... OPC_DMODU_G_2E: check_insn(ctx, INSN_LOONGSON2E); gen_loongson_integer(ctx, op1, rd, rs, rt); break; case OPC_ABSQ_S_QH_DSP: op2 = MASK_ABSQ_S_QH(ctx->opcode); switch (op2) { case OPC_PRECEQ_L_PWL: case OPC_PRECEQ_L_PWR: case OPC_PRECEQ_PW_QHL: case OPC_PRECEQ_PW_QHR: case OPC_PRECEQ_PW_QHLA: case OPC_PRECEQ_PW_QHRA: case OPC_PRECEQU_QH_OBL: case OPC_PRECEQU_QH_OBR: case OPC_PRECEQU_QH_OBLA: case OPC_PRECEQU_QH_OBRA: case OPC_PRECEU_QH_OBL: case OPC_PRECEU_QH_OBR: case OPC_PRECEU_QH_OBLA: case OPC_PRECEU_QH_OBRA: case OPC_ABSQ_S_OB: case OPC_ABSQ_S_PW: case OPC_ABSQ_S_QH: gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt); break; case OPC_REPL_OB: case OPC_REPL_PW: case OPC_REPL_QH: case OPC_REPLV_OB: case OPC_REPLV_PW: case OPC_REPLV_QH: gen_mipsdsp_bitinsn(ctx, op1, op2, rd, rt); break; default: MIPS_INVAL("MASK ABSQ_S.QH"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_ADDU_OB_DSP: op2 = MASK_ADDU_OB(ctx->opcode); switch (op2) { case OPC_RADDU_L_OB: case OPC_SUBQ_PW: case OPC_SUBQ_S_PW: case OPC_SUBQ_QH: case OPC_SUBQ_S_QH: case OPC_SUBU_OB: case OPC_SUBU_S_OB: case OPC_SUBU_QH: case OPC_SUBU_S_QH: case OPC_SUBUH_OB: case OPC_SUBUH_R_OB: case OPC_ADDQ_PW: case OPC_ADDQ_S_PW: case OPC_ADDQ_QH: case OPC_ADDQ_S_QH: case OPC_ADDU_OB: case OPC_ADDU_S_OB: case OPC_ADDU_QH: case OPC_ADDU_S_QH: case OPC_ADDUH_OB: case OPC_ADDUH_R_OB: gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt); break; case OPC_MULEQ_S_PW_QHL: case OPC_MULEQ_S_PW_QHR: case OPC_MULEU_S_QH_OBL: case OPC_MULEU_S_QH_OBR: case OPC_MULQ_RS_QH: gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 1); break; default: MIPS_INVAL("MASK ADDU.OB"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_CMPU_EQ_OB_DSP: op2 = MASK_CMPU_EQ_OB(ctx->opcode); switch (op2) { case OPC_PRECR_SRA_QH_PW: case OPC_PRECR_SRA_R_QH_PW: gen_mipsdsp_arith(ctx, op1, op2, rt, rs, rd); break; case OPC_PRECR_OB_QH: case OPC_PRECRQ_OB_QH: case OPC_PRECRQ_PW_L: case OPC_PRECRQ_QH_PW: case OPC_PRECRQ_RS_QH_PW: case OPC_PRECRQU_S_OB_QH: gen_mipsdsp_arith(ctx, op1, op2, rd, rs, rt); break; case OPC_CMPU_EQ_OB: case OPC_CMPU_LT_OB: case OPC_CMPU_LE_OB: case OPC_CMP_EQ_QH: case OPC_CMP_LT_QH: case OPC_CMP_LE_QH: case OPC_CMP_EQ_PW: case OPC_CMP_LT_PW: case OPC_CMP_LE_PW: gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 0); break; case OPC_CMPGDU_EQ_OB: case OPC_CMPGDU_LT_OB: case OPC_CMPGDU_LE_OB: case OPC_CMPGU_EQ_OB: case OPC_CMPGU_LT_OB: case OPC_CMPGU_LE_OB: case OPC_PACKRL_PW: case OPC_PICK_OB: case OPC_PICK_PW: case OPC_PICK_QH: gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rd, rs, rt, 1); break; default: MIPS_INVAL("MASK CMPU_EQ.OB"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_DAPPEND_DSP: check_dspr2(ctx); op2 = MASK_DAPPEND(ctx->opcode); gen_mipsdsp_add_cmp_pick(ctx, op1, op2, rt, rs, rd, 1); break; case OPC_DEXTR_W_DSP: op2 = MASK_DEXTR_W(ctx->opcode); switch (op2) { case OPC_DEXTP: case OPC_DEXTPDP: case OPC_DEXTPDPV: case OPC_DEXTPV: case OPC_DEXTR_L: case OPC_DEXTR_R_L: case OPC_DEXTR_RS_L: case OPC_DEXTR_W: case OPC_DEXTR_R_W: case OPC_DEXTR_RS_W: case OPC_DEXTR_S_H: case OPC_DEXTRV_L: case OPC_DEXTRV_R_L: case OPC_DEXTRV_RS_L: case OPC_DEXTRV_S_H: case OPC_DEXTRV_W: case OPC_DEXTRV_R_W: case OPC_DEXTRV_RS_W: gen_mipsdsp_accinsn(ctx, op1, op2, rt, rs, rd, 1); break; case OPC_DMTHLIP: case OPC_DSHILO: case OPC_DSHILOV: gen_mipsdsp_accinsn(ctx, op1, op2, rd, rs, rt, 0); break; default: MIPS_INVAL("MASK EXTR.W"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_DPAQ_W_QH_DSP: op2 = MASK_DPAQ_W_QH(ctx->opcode); switch (op2) { case OPC_DPAU_H_OBL: case OPC_DPAU_H_OBR: case OPC_DPSU_H_OBL: case OPC_DPSU_H_OBR: case OPC_DPA_W_QH: case OPC_DPAQ_S_W_QH: case OPC_DPS_W_QH: case OPC_DPSQ_S_W_QH: case OPC_MULSAQ_S_W_QH: case OPC_DPAQ_SA_L_PW: case OPC_DPSQ_SA_L_PW: case OPC_MULSAQ_S_L_PW: gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 0); break; case OPC_MAQ_S_W_QHLL: case OPC_MAQ_S_W_QHLR: case OPC_MAQ_S_W_QHRL: case OPC_MAQ_S_W_QHRR: case OPC_MAQ_SA_W_QHLL: case OPC_MAQ_SA_W_QHLR: case OPC_MAQ_SA_W_QHRL: case OPC_MAQ_SA_W_QHRR: case OPC_MAQ_S_L_PWL: case OPC_MAQ_S_L_PWR: case OPC_DMADD: case OPC_DMADDU: case OPC_DMSUB: case OPC_DMSUBU: gen_mipsdsp_multiply(ctx, op1, op2, rd, rs, rt, 0); break; default: MIPS_INVAL("MASK DPAQ.W.QH"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_DINSV_DSP: op2 = MASK_INSV(ctx->opcode); switch (op2) { case OPC_DINSV: { TCGv t0, t1; if (rt == 0) { MIPS_DEBUG("NOP"); break; } check_dsp(ctx); t0 = tcg_temp_new(); t1 = tcg_temp_new(); gen_load_gpr(t0, rt); gen_load_gpr(t1, rs); gen_helper_dinsv(cpu_gpr[rt], cpu_env, t1, t0); break; } default: MIPS_INVAL("MASK DINSV"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_SHLL_OB_DSP: gen_mipsdsp_shift(ctx, op1, rd, rs, rt); break; #endif default: MIPS_INVAL("special3"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_REGIMM: op1 = MASK_REGIMM(ctx->opcode); switch (op1) { case OPC_BLTZ ... OPC_BGEZL: case OPC_BLTZAL ... OPC_BGEZALL: gen_compute_branch(ctx, op1, 4, rs, -1, imm << 2); *is_branch = 1; break; case OPC_TGEI ... OPC_TEQI: case OPC_TNEI: gen_trap(ctx, op1, rs, -1, imm); break; case OPC_SYNCI: check_insn(ctx, ISA_MIPS32R2); break; case OPC_BPOSGE32: #if defined(TARGET_MIPS64) case OPC_BPOSGE64: #endif check_dsp(ctx); gen_compute_branch(ctx, op1, 4, -1, -2, (int32_t)imm << 2); *is_branch = 1; break; default: MIPS_INVAL("regimm"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_CP0: check_cp0_enabled(ctx); op1 = MASK_CP0(ctx->opcode); switch (op1) { case OPC_MFC0: case OPC_MTC0: case OPC_MFTR: case OPC_MTTR: #if defined(TARGET_MIPS64) case OPC_DMFC0: case OPC_DMTC0: #endif #ifndef CONFIG_USER_ONLY gen_cp0(env, ctx, op1, rt, rd); #endif break; case OPC_C0_FIRST ... OPC_C0_LAST: #ifndef CONFIG_USER_ONLY gen_cp0(env, ctx, MASK_C0(ctx->opcode), rt, rd); #endif break; case OPC_MFMC0: #ifndef CONFIG_USER_ONLY { TCGv t0 = tcg_temp_new(); op2 = MASK_MFMC0(ctx->opcode); switch (op2) { case OPC_DMT: check_insn(ctx, ASE_MT); gen_helper_dmt(t0); gen_store_gpr(t0, rt); break; case OPC_EMT: check_insn(ctx, ASE_MT); gen_helper_emt(t0); gen_store_gpr(t0, rt); break; case OPC_DVPE: check_insn(ctx, ASE_MT); gen_helper_dvpe(t0, cpu_env); gen_store_gpr(t0, rt); break; case OPC_EVPE: check_insn(ctx, ASE_MT); gen_helper_evpe(t0, cpu_env); gen_store_gpr(t0, rt); break; case OPC_DI: check_insn(ctx, ISA_MIPS32R2); save_cpu_state(ctx, 1); gen_helper_di(t0, cpu_env); gen_store_gpr(t0, rt); ctx->bstate = BS_STOP; break; case OPC_EI: check_insn(ctx, ISA_MIPS32R2); save_cpu_state(ctx, 1); gen_helper_ei(t0, cpu_env); gen_store_gpr(t0, rt); ctx->bstate = BS_STOP; break; default: MIPS_INVAL("mfmc0"); generate_exception(ctx, EXCP_RI); break; } tcg_temp_free(t0); } #endif break; case OPC_RDPGPR: check_insn(ctx, ISA_MIPS32R2); gen_load_srsgpr(rt, rd); break; case OPC_WRPGPR: check_insn(ctx, ISA_MIPS32R2); gen_store_srsgpr(rt, rd); break; default: MIPS_INVAL("cp0"); generate_exception(ctx, EXCP_RI); break; } break; case OPC_ADDI: case OPC_ADDIU: gen_arith_imm(ctx, op, rt, rs, imm); break; case OPC_SLTI: case OPC_SLTIU: gen_slt_imm(ctx, op, rt, rs, imm); break; case OPC_ANDI: case OPC_LUI: case OPC_ORI: case OPC_XORI: gen_logic_imm(ctx, op, rt, rs, imm); break; case OPC_J ... OPC_JAL: offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2; gen_compute_branch(ctx, op, 4, rs, rt, offset); *is_branch = 1; break; case OPC_BEQ ... OPC_BGTZ: case OPC_BEQL ... OPC_BGTZL: gen_compute_branch(ctx, op, 4, rs, rt, imm << 2); *is_branch = 1; break; case OPC_LB ... OPC_LWR: case OPC_LL: gen_ld(ctx, op, rt, rs, imm); break; case OPC_SB ... OPC_SW: case OPC_SWR: gen_st(ctx, op, rt, rs, imm); break; case OPC_SC: gen_st_cond(ctx, op, rt, rs, imm); break; case OPC_CACHE: check_cp0_enabled(ctx); check_insn(ctx, ISA_MIPS3 | ISA_MIPS32); break; case OPC_PREF: check_insn(ctx, ISA_MIPS4 | ISA_MIPS32); break; case OPC_LWC1: case OPC_LDC1: case OPC_SWC1: case OPC_SDC1: gen_cop1_ldst(env, ctx, op, rt, rs, imm); break; case OPC_CP1: if (env->CP0_Config1 & (1 << CP0C1_FP)) { check_cp1_enabled(ctx); op1 = MASK_CP1(ctx->opcode); switch (op1) { case OPC_MFHC1: case OPC_MTHC1: check_insn(ctx, ISA_MIPS32R2); case OPC_MFC1: case OPC_CFC1: case OPC_MTC1: case OPC_CTC1: gen_cp1(ctx, op1, rt, rd); break; #if defined(TARGET_MIPS64) case OPC_DMFC1: case OPC_DMTC1: check_insn(ctx, ISA_MIPS3); gen_cp1(ctx, op1, rt, rd); break; #endif case OPC_BC1ANY2: case OPC_BC1ANY4: check_cop1x(ctx); check_insn(ctx, ASE_MIPS3D); case OPC_BC1: gen_compute_branch1(ctx, MASK_BC1(ctx->opcode), (rt >> 2) & 0x7, imm << 2); *is_branch = 1; break; case OPC_S_FMT: case OPC_D_FMT: case OPC_W_FMT: case OPC_L_FMT: case OPC_PS_FMT: gen_farith(ctx, ctx->opcode & FOP(0x3f, 0x1f), rt, rd, sa, (imm >> 8) & 0x7); break; default: MIPS_INVAL("cp1"); generate_exception (ctx, EXCP_RI); break; } } else { generate_exception_err(ctx, EXCP_CpU, 1); } break; case OPC_LWC2: case OPC_LDC2: case OPC_SWC2: case OPC_SDC2: generate_exception_err(ctx, EXCP_CpU, 2); break; case OPC_CP2: check_insn(ctx, INSN_LOONGSON2F); gen_loongson_multimedia(ctx, sa, rd, rt); break; case OPC_CP3: if (env->CP0_Config1 & (1 << CP0C1_FP)) { check_cp1_enabled(ctx); op1 = MASK_CP3(ctx->opcode); switch (op1) { case OPC_LWXC1: case OPC_LDXC1: case OPC_LUXC1: case OPC_SWXC1: case OPC_SDXC1: case OPC_SUXC1: gen_flt3_ldst(ctx, op1, sa, rd, rs, rt); break; case OPC_PREFX: break; case OPC_ALNV_PS: case OPC_MADD_S: case OPC_MADD_D: case OPC_MADD_PS: case OPC_MSUB_S: case OPC_MSUB_D: case OPC_MSUB_PS: case OPC_NMADD_S: case OPC_NMADD_D: case OPC_NMADD_PS: case OPC_NMSUB_S: case OPC_NMSUB_D: case OPC_NMSUB_PS: gen_flt3_arith(ctx, op1, sa, rs, rd, rt); break; default: MIPS_INVAL("cp3"); generate_exception (ctx, EXCP_RI); break; } } else { generate_exception_err(ctx, EXCP_CpU, 1); } break; #if defined(TARGET_MIPS64) case OPC_LWU: case OPC_LDL ... OPC_LDR: case OPC_LLD: case OPC_LD: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); gen_ld(ctx, op, rt, rs, imm); break; case OPC_SDL ... OPC_SDR: case OPC_SD: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); gen_st(ctx, op, rt, rs, imm); break; case OPC_SCD: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); gen_st_cond(ctx, op, rt, rs, imm); break; case OPC_DADDI: case OPC_DADDIU: check_insn(ctx, ISA_MIPS3); check_mips_64(ctx); gen_arith_imm(ctx, op, rt, rs, imm); break; #endif case OPC_JALX: check_insn(ctx, ASE_MIPS16 | ASE_MICROMIPS); offset = (int32_t)(ctx->opcode & 0x3FFFFFF) << 2; gen_compute_branch(ctx, op, 4, rs, rt, offset); *is_branch = 1; break; case OPC_MDMX: check_insn(ctx, ASE_MDMX); default: MIPS_INVAL("major opcode"); generate_exception(ctx, EXCP_RI); break; } }
1threat
void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size) { RTPMuxContext *s = s1->priv_data; const uint8_t *qtables = NULL; int nb_qtables = 0; uint8_t type = 1; uint8_t w, h; uint8_t *p; int off = 0; int len; int i; s->buf_ptr = s->buf; s->timestamp = s->cur_timestamp; w = s1->streams[0]->codec->width >> 3; h = s1->streams[0]->codec->height >> 3; if (s1->streams[0]->codec->pix_fmt == AV_PIX_FMT_YUVJ422P) { type = 0; } else if (s1->streams[0]->codec->pix_fmt == AV_PIX_FMT_YUVJ420P) { type = 1; } else { av_log(s1, AV_LOG_ERROR, "Unsupported pixel format\n"); return; } for (i = 0; i < size; i++) { if (buf[i] != 0xff) continue; if (buf[i + 1] == DQT) { if (buf[i + 4]) av_log(s1, AV_LOG_WARNING, "Only 8-bit precision is supported.\n"); nb_qtables = AV_RB16(&buf[i + 2]) / 65; if (i + 4 + nb_qtables * 65 > size) { av_log(s1, AV_LOG_ERROR, "Too short JPEG header. Aborted!\n"); return; } qtables = &buf[i + 4]; } else if (buf[i + 1] == SOF0) { if (buf[i + 14] != 17 || buf[i + 17] != 17) { av_log(s1, AV_LOG_ERROR, "Only 1x1 chroma blocks are supported. Aborted!\n"); return; } } else if (buf[i + 1] == SOS) { i += AV_RB16(&buf[i + 2]) + 2; break; } } buf += i; size -= i; for (i = size - 2; i >= 0; i--) { if (buf[i] == 0xff && buf[i + 1] == EOI) { size = i; break; } } p = s->buf_ptr; while (size > 0) { int hdr_size = 8; if (off == 0 && nb_qtables) hdr_size += 4 + 64 * nb_qtables; len = FFMIN(size, s->max_payload_size - hdr_size); bytestream_put_byte(&p, 0); bytestream_put_be24(&p, off); bytestream_put_byte(&p, type); bytestream_put_byte(&p, 255); bytestream_put_byte(&p, w); bytestream_put_byte(&p, h); if (off == 0 && nb_qtables) { bytestream_put_byte(&p, 0); bytestream_put_byte(&p, 0); bytestream_put_be16(&p, 64 * nb_qtables); for (i = 0; i < nb_qtables; i++) bytestream_put_buffer(&p, &qtables[65 * i + 1], 64); } memcpy(p, buf, len); ff_rtp_send_data(s1, s->buf, len + hdr_size, size == len); buf += len; size -= len; off += len; p = s->buf; } }
1threat
Ask a question about swift, about array type conversion, thank you! : class Model: NSObject { var numbers : Array<Int> = [] } internal func test() { let model : Model = Model.init() model.setValue([1,2,3], forKey: "numbers") print(model.numbers) } test()//[1, 2, 3] But if I change the above "var numbers : [Int] = []" to "var numbers :[Int64] = []", it will crash. Why is that? How can I solve it?
0debug
sorting list by specific property : <p>I need to sort list of items by its priority(ascending order) ?</p> <pre><code> var priorityIssuesList = [ { name: "Danger", status: "RED", priority:4}, { name: "Moderate", status: "BLUE", priority:2}, { name: "Safe", status: "GREEN",priority:1}, {name: "Warning", status: "Yellow",priority:3} ] </code></pre> <p>sorting should be in ascending order or status</p> <pre><code>[ {"name":"Safe","status":"GREEN","priority":1}, {"name":"Moderate","status":"BLUE","priority":2}, {"name":"Warning","status":"Yellow","priority":3}, {"name":"Danger","status":"RED","priority":4} ] </code></pre> <p>what is the best way to do this?</p>
0debug
stylesheet_pack_tag not finding app/javascript/src/application.css in rails 5.1 with webpacker gem : <p>I am receiving this error when I try to load a page in my new rails 5.1 app using webpacker. I would like webpacker to handle CSS as well. </p> <pre><code>Started GET "/" for ::1 at 2017-09-01 12:20:23 -0400 Processing by HomeController#welcome as HTML Rendering home/welcome.html.erb within layouts/application Rendered home/welcome.html.erb within layouts/application (0.4ms) Completed 500 Internal Server Error in 28ms ActionView::Template::Error (Webpacker can't find application.css in /Users/myusername/Documents/testing-ground/myapp/public/packs/manifest.json. Possible causes: 1. You want to set wepbacker.yml value of compile to true for your environment unless you are using the `webpack -w` or the webpack-dev-server. 2. Webpack has not yet re-run to reflect updates. 3. You have misconfigured Webpacker's config/webpacker.yml file. 4. Your Webpack configuration is not creating a manifest. Your manifest contains: { "application.js": "/packs/application-1ba6db9cf5c0fb48c785.js", "hello_react.js": "/packs/hello_react-812cbb4d606734bec7a9.js" } ): 7: &lt;%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %&gt; 8: &lt;%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %&gt; 9: &lt;%= javascript_pack_tag 'application' %&gt; 10: &lt;%= stylesheet_pack_tag 'application' %&gt; 11: &lt;/head&gt; 12: 13: &lt;body&gt; app/views/layouts/application.html.erb:10:in `_app_views_layouts_application_html_erb__1178607493020013329_70339213085820' </code></pre> <p>I am running the <code>./bin/webpack-dev-server</code> alongside the <code>rails server</code>. I created the app using: </p> <p><code>rails new myapp --webpack</code> <code>bundle</code> <code>bundle exec rails webpacker:install:react</code></p> <p>I have a single CSS file <code>app/javascript/src/application.css</code>. (Writing that makes me feel something is wrong. Putting css inside of a javascript directory seems improper.)</p> <p>I just have single root route defined <code>root to: 'home#welcome'</code>.</p> <p>Here is <code>app/views/layouts/application.html.erb</code></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Myapp&lt;/title&gt; &lt;%= csrf_meta_tags %&gt; &lt;%= javascript_pack_tag 'application' %&gt; &lt;%= stylesheet_pack_tag 'application' %&gt; &lt;/head&gt; &lt;body&gt; &lt;%= yield %&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Here is my <code>config/webpacker.yml</code> (I have tried also setting compile to <code>false</code> in development.</p> <pre><code># Note: You must restart bin/webpack-dev-server for changes to take effect default: &amp;default source_path: app/javascript source_entry_path: packs public_output_path: packs cache_path: tmp/cache/webpacker # Additional paths webpack should lookup modules # ['app/assets', 'engine/foo/app/assets'] resolved_paths: [] # Reload manifest.json on all requests so we reload latest compiled packs cache_manifest: false extensions: - .coffee - .erb - .js - .jsx - .ts - .vue - .sass - .scss - .css - .png - .svg - .gif - .jpeg - .jpg development: &lt;&lt;: *default compile: true dev_server: host: localhost port: 3035 hmr: false https: false test: &lt;&lt;: *default compile: true # Compile test packs to a separate directory public_output_path: packs-test production: &lt;&lt;: *default # Production demands on precompilation of packs prior to booting for performance. compile: false # Cache manifest.json for performance cache_manifest: true </code></pre> <p>I don't want to add too many details up-front incase they are more distracting then helpful. Please ask for anything else and I'll add to my question. Thanks!</p>
0debug
static int get_high_utility_cell(elbg_data *elbg) { int i=0; int r = av_lfg_get(elbg->rand_state)%elbg->utility_inc[elbg->numCB-1] + 1; while (elbg->utility_inc[i] < r) i++; av_assert2(elbg->cells[i]); return i; }
1threat
static int ram_save_host_page(RAMState *rs, PageSearchStatus *pss, bool last_stage) { int tmppages, pages = 0; size_t pagesize_bits = qemu_ram_pagesize(pss->block) >> TARGET_PAGE_BITS; do { tmppages = ram_save_target_page(rs, pss, last_stage); if (tmppages < 0) { return tmppages; } pages += tmppages; pss->page++; } while (pss->page & (pagesize_bits - 1)); pss->page--; return pages; }
1threat
Sum keys with the same value : I have this object: obj = {1: 2, 4: 1, 5: 2}; How can I find and multiply only the keys with value 2 on other independent variables ? I want to compare in this case 1*2 with 5*2. var1 = 1*2; var2 = 5*2; Thank you!
0debug
GCC: 'multiple definition' Issue with gcc 4.8 version : <p>Recently we have moved our gcc version from 4.1.x to 4.8.3. Some of my team mates are working on RH5.X and others are working on RH6.5 Versioned machines.</p> <p>I notice that, on RH 5.X machine. when we try to build the code we are facing following issue while creating dynamic library.</p> <p><strong>PS:-</strong> We are not hitting this issue on RH6.X machines.</p> <p><strong>Log:-</strong></p> <p>codec_main.c.text+0x0): multiple definition of <code>vprintf' /local/workspace/first/branch/dsc/cmd_parse.o:cmd_parse.c.text+0x510): first defined here /local/workspace/first/branch/dsc/codec_main.o: In function</code>getchar': codec_main.c.text+0x40): multiple definition of <code>getchar' /local/workspace/first/dsc/cmd_parse.o:cmd_parse.c.text+0x550): first defined here /local/workspace/first/branch/lpddr5_branch/src/main/cvip/build/Linux/Release/lib/extlibs/dsc/codec_main.o: In function</code>fgetc_unlocked': codec_main.c.text+0x70): multiple definition of `fgetc_unlocked'</p> <p>Can you please help?</p>
0debug
static int indeo3_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) { Indeo3DecodeContext *s=avctx->priv_data; uint8_t *src, *dest; int y; iv_decode_frame(s, buf, buf_size); if(s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); s->frame.reference = 0; if(avctx->get_buffer(avctx, &s->frame) < 0) { av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } src = s->cur_frame->Ybuf; dest = s->frame.data[0]; for (y = 0; y < s->height; y++) { memcpy(dest, src, s->cur_frame->y_w); src += s->cur_frame->y_w; dest += s->frame.linesize[0]; } if (!(s->avctx->flags & CODEC_FLAG_GRAY)) { src = s->cur_frame->Ubuf; dest = s->frame.data[1]; for (y = 0; y < s->height / 4; y++) { memcpy(dest, src, s->cur_frame->uv_w); src += s->cur_frame->uv_w; dest += s->frame.linesize[1]; } src = s->cur_frame->Vbuf; dest = s->frame.data[2]; for (y = 0; y < s->height / 4; y++) { memcpy(dest, src, s->cur_frame->uv_w); src += s->cur_frame->uv_w; dest += s->frame.linesize[2]; } } *data_size=sizeof(AVFrame); *(AVFrame*)data= s->frame; return buf_size; }
1threat
static int sd_snapshot_delete(BlockDriverState *bs, const char *snapshot_id) { return 0; }
1threat
underscore to fill an array with large numbers : <p>A Meteor server code using underscore to get the number sequence 2002,2003,2004,2005 when 2002 and 2005 are given <code>_.range(2002,2005-2002)</code><br> returns an empty array. Also tried: `_.range(2002,3)<br> Any ideas? thx</p>
0debug
please help me to find the error in codeigniter : from my side every thing is ok but it is not working, email or password is not fetching from db for verification. (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) model: class Login_model extends CI_Model { public function login_valid($email,$password) { $q = $this->db-> select('*') ->where(['email'=>'$email','password'=>'$password']) ->get('admin'); } } controller: class Adminlogin extends CI_controller { public function login_form() { $this->load->view('common/login_form'); } public function login_check() { $this->form_validation->set_rules('email','email','required|valid_email'); $this->form_validation->set_rules('password','password','required|min_length[8]|max_length[15]'); if ($this->form_validation->run()) { $email = $this->input->post('email'); $password = $this->input->post('password'); $this->load->model('Login_model'); $admin_id = $this->Login_model->login_valid($email,$password); if($this->load->model('Login_model')){ $this->load->library('session'); $this->session->set_userdata('Id',$admin_id); $this->load->view('admin/admin_dashboard'); } else { echo "model not loaded"; } } else { $this->load->view('common/login_form'); } }
0debug
How to make one of child view of nestedscrollview to sticky header? : <p>Below is my code snipet.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/coordinate" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/background_light" tools:context="com.ajinkyabadve.mywatchlist.movie_detail_new.MovieActivity"&gt; &lt;ProgressBar android:id="@+id/progressBar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:visibility="gone" /&gt; &lt;include android:id="@+id/retryLayoutNoInternet" layout="@layout/no_internet_retry_layout" android:visibility="gone" /&gt; &lt;android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="400dp" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&gt; &lt;android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsingToolbarLayout" android:layout_width="match_parent" android:layout_height="match_parent" app:contentScrim="?attr/colorPrimary" app:expandedTitleMarginEnd="64dp" app:expandedTitleMarginStart="48dp" app:layout_scrollFlags="scroll|enterAlwaysCollapsed"&gt; &lt;ImageView android:id="@+id/poster" android:layout_width="match_parent" android:layout_height="match_parent" android:contentDescription="@string/poster_of_movie" android:fitsSystemWindows="true" android:scaleType="centerCrop" app:layout_collapseMode="parallax" /&gt; &lt;/android.support.design.widget.CollapsingToolbarLayout&gt; &lt;/android.support.design.widget.AppBarLayout&gt; &lt;include android:id="@+id/content" layout="@layout/content_movie" /&gt; &lt;android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="112dp" android:background="@color/colorPrimary" android:elevation="4dp" app:layout_anchor="@id/appbar" app:layout_anchorGravity="bottom" app:layout_collapseMode="pin" app:theme="@style/ThemeOverlay.AppCompat.Light"&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginBottom="8dp" android:minHeight="?android:attr/actionBarSize" android:orientation="vertical"&gt; &lt;TextView android:id="@+id/movieTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Title" android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse" /&gt; &lt;TextView android:id="@+id/movieOrignalTitle" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="4dp" android:text="subtitle" android:textAppearance="@style/TextAppearance.AppCompat.Widget.ActionBar.Subtitle.Inverse" /&gt; &lt;/LinearLayout&gt; &lt;/android.support.v7.widget.Toolbar&gt; </code></pre> <p></p> <p>And below is content_movie.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/content_movie" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" app:layout_behavior="@string/appbar_scrolling_view_behavior" tools:context="com.ajinkyabadve.mywatchlist.movie_detail_new.MovieActivity" tools:showIn="@layout/activity_movie"&gt; &lt;LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"&gt; &lt;include layout="@layout/overview" /&gt; &lt;include layout="@layout/cast" /&gt; &lt;include layout="@layout/facts" /&gt; &lt;!-- Below tablayout I want to work as a sticky header --&gt; &lt;!--&lt;android.support.design.widget.TabLayout--&gt; &lt;!--android:layout_width="match_parent"--&gt; &lt;!--android:layout_height="100dp"--&gt; &lt;!--android:background="@color/colorPrimary" /&gt;--&gt; &lt;/LinearLayout&gt; &lt;/android.support.v4.widget.NestedScrollView&gt; </code></pre> <p>The commented tablayout should work as a sticky header(meaning it should not scroll when it reaches to top while scrolling).How to achive this effect using the coordinate layout?OR In any other way.Can we use custom behavior or something?</p>
0debug
Erreur de segmentation (core dumped) when trying to print %s : I follow an online course about intrusion at https://www.root-me.org/fr/Documentation/Applicatif/Chaine-de-format-lecture-en-memoire and it gives a segmentation error when I'm trying to print %s
0debug
Alert from os: app may slow down your iPhone : <p>Hy,</p> <p>I have uploaded the app to App Store with both architecture. Please see the attached image for <code>Build Settings</code> of <code>TARGETS</code> in <code>Architectures</code>. And luckily it get Ready for sale, but iPhone 5s giving alert.</p> <p><a href="https://i.stack.imgur.com/9ZqjW.png"><img src="https://i.stack.imgur.com/9ZqjW.png" alt="enter image description here"></a></p> <p>The alert is: "APP" may slow down your iPhone. The developer of this app needs to update it to improve its compatibility.</p> <p>I googled but do not found solution to get rid off this alert. On other hand i also need to support iPhone5 and prior (32 bit architectures). Please help.</p>
0debug
Why can't delete the right node? : <p>i have some code here. I'm using linked list in this code. We can add note, displas it and also delete. The problem occur when i want to delete something. 1. create one node, then try to delete it. It can detect and delete the node. 2. create two node, then i try to delete the 1st one. but it delete the second. I really run out of idea right now. Hopefully anyone can help me. Thank you</p> <pre><code>#include &lt;iostream&gt; #include &lt;string.h&gt; using namespace std; const int SIZE = 10; //1st class class SportShoe { private: struct nodeSport { int ShoeID; char BrandShoe[SIZE]; char TypeShoe[SIZE]; char ColourShoe[SIZE]; int SizeShoe; float PriceShoe; nodeSport *last; }; nodeSport *first = NULL; public: int MenuSportShoe(); void AddSportShoe(); void DisplaySportShoe(); void DeleteSportShoe(); static void ExitSportShoe(); }; //2nd class class HighHeel { private: struct nodeHeel { int ProductCode; char BrandHeel[SIZE]; char MaterialHeel[SIZE]; char ColourHeel[SIZE]; int HeightHeel; float PriceHeel; nodeHeel *next; }; nodeHeel *start = NULL; public: int MenuHighHeel(); void AddHighHeel(); void DisplayHighHeel(); void DeleteHighHeel(); static void ExitHighHeel() { SportShoe::ExitSportShoe(); } }; int SportShoe::MenuSportShoe() { int OptionSportShoe = 0; cout &lt;&lt; endl; cout &lt;&lt; "&gt;&gt; Please select from the menu below &lt;&lt;" &lt;&lt; endl; cout &lt;&lt; ":: 1 :: Add item to shoe list" &lt;&lt; endl; cout &lt;&lt; ":: 2 :: Display shoes list" &lt;&lt; endl; cout &lt;&lt; ":: 3 :: Delete item from the list" &lt;&lt; endl; cout &lt;&lt; ":: 4 :: Back" &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin &gt;&gt; OptionSportShoe; while (OptionSportShoe == 1){ AddSportShoe(); } while (OptionSportShoe == 2){ DisplaySportShoe(); } while (OptionSportShoe == 3){ DeleteSportShoe(); } while (OptionSportShoe == 4){ ExitSportShoe(); } return 0; } int HighHeel::MenuHighHeel() { int OptionHighHeel = 0; cout &lt;&lt; endl; cout &lt;&lt; "&gt;&gt; Please select from the menu below &lt;&lt;" &lt;&lt; endl; cout &lt;&lt; ":: 1 :: Add item to the Heel List" &lt;&lt; endl; cout &lt;&lt; ":: 2 :: Display the Heel List" &lt;&lt; endl; cout &lt;&lt; ":: 3 :: Delete item from the list" &lt;&lt; endl; cout &lt;&lt; ":: 4 :: Back" &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin &gt;&gt; OptionHighHeel; while (OptionHighHeel == 1){ AddHighHeel(); } while (OptionHighHeel == 2){ DisplayHighHeel(); } while (OptionHighHeel == 3){ DeleteHighHeel(); } while (OptionHighHeel == 4){ SportShoe::ExitSportShoe(); } return 0; } void SportShoe::AddSportShoe() { nodeSport *tempShoe1, *tempShoe2; tempShoe1 = new nodeSport; cout &lt;&lt; "Sport Shoe Section." &lt;&lt; endl; cout &lt;&lt; "Please enter the Shoe ID : (eg. 43210) " &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin &gt;&gt; tempShoe1-&gt;ShoeID; cout &lt;&lt; "Please enter the Shoe Brand: (eg. Adidas) " &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin.sync(); cin.getline(tempShoe1-&gt;BrandShoe,SIZE); cout &lt;&lt; "Please enter the Shoe Type : (eg. Running) " &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin.sync(); cin.getline(tempShoe1-&gt;TypeShoe,SIZE); cout &lt;&lt; "What is the Shoe Colour : (eg. Grey) " &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin.sync(); cin.getline(tempShoe1-&gt;ColourShoe,SIZE); cout &lt;&lt; "Please enter Shoe Size : (eg. 9) " &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin &gt;&gt; tempShoe1-&gt;SizeShoe; cout &lt;&lt; "Please enter the price of the Shoe : (eg. RM123.45) " &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; RM "; cin &gt;&gt; tempShoe1-&gt;PriceShoe; tempShoe1-&gt;last = NULL; if (first == NULL) first = tempShoe1; else { tempShoe2 = first; while (tempShoe2-&gt;last != NULL) tempShoe2 = tempShoe2-&gt;last; tempShoe2-&gt;last = tempShoe1; } system("PAUSE"); MenuSportShoe(); } void HighHeel::AddHighHeel() { nodeHeel *tempHeel1, *tempHeel2; tempHeel1 = new nodeHeel; cout &lt;&lt; "Heel Section." &lt;&lt; endl; cout &lt;&lt; "Please enter Heel Code : (eg. 98765) " &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin &gt;&gt; tempHeel1-&gt;ProductCode; cout &lt;&lt; "Please enter Heel Brand: (eg. Gucci) " &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin.sync(); cin.getline(tempHeel1-&gt;BrandHeel,SIZE); cout &lt;&lt; "Please enter Heel Material : (eg. Leather) " &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin.sync(); cin.getline(tempHeel1-&gt;MaterialHeel,SIZE); cout &lt;&lt; "What is the Heel Colour : (eg. Red) " &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin.sync(); cin.getline(tempHeel1-&gt;ColourHeel,SIZE); cout &lt;&lt; "Please enter Heel Height (cm) : (eg. 2.25) " &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin &gt;&gt; tempHeel1-&gt;HeightHeel; cout &lt;&lt; "Please enter the Heel Price : (eg. RM123.45) " &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; RM "; cin &gt;&gt; tempHeel1-&gt;PriceHeel; tempHeel1-&gt;next = NULL; if (start == NULL) start = tempHeel1; else { tempHeel2 = start; while (tempHeel2-&gt;next != NULL) tempHeel2 = tempHeel2-&gt;next; tempHeel2-&gt;next = tempHeel1; } system("PAUSE"); MenuHighHeel(); } void SportShoe::DisplaySportShoe() { nodeSport *tempShoe1; tempShoe1 = first; if (tempShoe1 == NULL){ cout &lt;&lt; "List empty." &lt;&lt; endl; cout &lt;&lt; endl; system("PAUSE"); MenuSportShoe(); } else{ while(tempShoe1){ cout &lt;&lt; "Sport Shoe Section." &lt;&lt; endl; cout &lt;&lt; "ID =&gt;&gt; " &lt;&lt; tempShoe1-&gt;ShoeID &lt;&lt; endl; cout &lt;&lt; "Brand =&gt;&gt; " &lt;&lt; tempShoe1-&gt;BrandShoe &lt;&lt; endl; cout &lt;&lt; "Type =&gt;&gt; " &lt;&lt; tempShoe1-&gt;TypeShoe &lt;&lt; endl; cout &lt;&lt; "Colour =&gt;&gt; " &lt;&lt; tempShoe1-&gt;ColourShoe &lt;&lt; endl; cout &lt;&lt; "Size =&gt;&gt; " &lt;&lt; tempShoe1-&gt;SizeShoe &lt;&lt; endl; cout &lt;&lt; "Price =&gt;&gt; " &lt;&lt; tempShoe1-&gt;PriceShoe &lt;&lt; endl; cout &lt;&lt; endl; tempShoe1 = tempShoe1-&gt;last; } system("PAUSE"); MenuSportShoe(); } } void HighHeel::DisplayHighHeel() { nodeHeel *tempHeel1; tempHeel1 = start; if (tempHeel1 == NULL){ cout &lt;&lt; " List empty." &lt;&lt; endl; cout &lt;&lt; endl; system("PAUSE"); MenuHighHeel(); } else{ while(tempHeel1){ cout &lt;&lt; "Heel Section." &lt;&lt; endl; cout &lt;&lt; "Heel Code =&gt;&gt; " &lt;&lt; tempHeel1-&gt;ProductCode &lt;&lt; endl; cout &lt;&lt; "Brand =&gt;&gt; " &lt;&lt; tempHeel1-&gt;BrandHeel &lt;&lt; endl; cout &lt;&lt; "Material =&gt;&gt; " &lt;&lt; tempHeel1-&gt;MaterialHeel &lt;&lt; endl; cout &lt;&lt; "Colour =&gt;&gt; " &lt;&lt; tempHeel1-&gt;ColourHeel &lt;&lt; endl; cout &lt;&lt; "Height (cm) =&gt;&gt; " &lt;&lt; tempHeel1-&gt;HeightHeel &lt;&lt; endl; cout &lt;&lt; "Price =&gt;&gt; " &lt;&lt; tempHeel1-&gt;PriceHeel &lt;&lt; endl; cout &lt;&lt; endl; tempHeel1 = tempHeel1-&gt;next; } system("PAUSE"); MenuHighHeel(); } } void SportShoe::DeleteSportShoe(){ nodeSport *tempShoe1, *tempShoe2; int DataShoe; cout &lt;&lt; "Sport Shoe Section." &lt;&lt; endl; cout &lt;&lt; "\nEnter the Shoes ID to be deleted: (eg. 123) "&lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin &gt;&gt; DataShoe; tempShoe2 = tempShoe1 = first; while((tempShoe1 != NULL) &amp;&amp; (DataShoe == tempShoe1-&gt; ShoeID)) { tempShoe2 = tempShoe1; tempShoe1 = tempShoe1-&gt;last; } if(tempShoe1 == NULL) { cout &lt;&lt; "\nRecord not Found!!!" &lt;&lt; endl; system("PAUSE"); MenuSportShoe(); } if((tempShoe1 == first) &amp;&amp; (DataShoe == tempShoe1-&gt; ShoeID)) { first = first-&gt;last; cout &lt;&lt; "\nData found " &lt;&lt; endl; } else{ tempShoe2-&gt;last = tempShoe1-&gt;last; if(tempShoe1-&gt;last == NULL){ tempShoe2 = tempShoe2; } cout &lt;&lt; "\nData deleted "&lt;&lt; endl; } delete(tempShoe1); cout &lt;&lt; endl; system("PAUSE"); MenuSportShoe(); } void HighHeel::DeleteHighHeel(){ nodeHeel *tempHeel1, *tempHeel2; int DataHeel; cout &lt;&lt; "Heel Section." &lt;&lt; endl; cout &lt;&lt; "\nEnter the Heel Code to be deleted: (eg. 123) "&lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin &gt;&gt; DataHeel; tempHeel2 = tempHeel1 = start; while((tempHeel1 != NULL) &amp;&amp; (DataHeel == tempHeel1-&gt;ProductCode)) { tempHeel2 = tempHeel1; tempHeel1 = tempHeel1-&gt;next; } if(tempHeel1 == NULL) { cout &lt;&lt; "\nRecord not Found!!!" &lt;&lt; endl; system("PAUSE"); MenuHighHeel(); } if(tempHeel1 == start) { start = start-&gt;next; cout &lt;&lt; "\nData deleted "&lt;&lt; endl; } else{ tempHeel2-&gt;next = tempHeel1-&gt;next; if(tempHeel1-&gt;next == NULL){ tempHeel2 = tempHeel2; } cout &lt;&lt; "\nData deleted "&lt;&lt; endl; } delete(tempHeel1); cout &lt;&lt; endl; system("PAUSE"); MenuHighHeel(); } void SportShoe::ExitSportShoe(){ int sepatu; cout &lt;&lt; endl; cout &lt;&lt; "&gt;&gt; Please choose the option below &lt;&lt;"&lt;&lt;endl; cout &lt;&lt; ":: 1 :: Sport Shoe." &lt;&lt; endl; cout &lt;&lt; ":: 2 :: Ladies High Heel." &lt;&lt; endl; cout &lt;&lt; ":: 3 :: Exit" &lt;&lt; endl; cout &lt;&lt; "=&gt;&gt; "; cin &gt;&gt; sepatu; while(sepatu == 1){ SportShoe listShoe; listShoe.MenuSportShoe(); } while(sepatu == 2){ HighHeel listShoe; listShoe.MenuHighHeel(); } while(sepatu == 3){ cout &lt;&lt; "&gt;&gt; Have a nice day. See you soon! &lt;&lt;"&lt;&lt; endl; exit(1); } } main() { cout &lt;&lt; "&gt;&gt; Hello! Welcome to MySepatu Online (Administrator Site) &lt;&lt;"; cout &lt;&lt; endl; SportShoe::ExitSportShoe(); return 0; } </code></pre>
0debug
Learning how to use pointers in c++ running into Error 'variable not declared in scope' : <p>As the title says, I am learning how to use pointers in C++. I have been tasked with writing a program that gets data about countries from a text file, loads them into an array of class objects, then lets the user view the data, remove an entry or quit.</p> <p>I'm running into a problem with class accessor functions. I am getting the error 'variable not declared in scope.' I get what this error is trying to tell me, but I can't figure out how to get the accessors to function properly. </p> <p>The requirements for the assignment are to use char-pointers to store strings, so I think that's adding an extra level of complexity. I want the accessor function to just return a single variable, e.g. country name, capital and surface area.</p> <p>I am using CodeBlocks and running on Ubunutu. I have the compiler set to c++11.</p> <p>Anyways, here is the code:</p> <pre><code>//This is the main.cpp file #include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;string&gt; #include &lt;cstdlib&gt; #include "Country.h" const int FILE_PATH_SZ = 512; Country** g_countryArray; int g_arrsz = 0; using namespace std; void openFile(ifstream&amp; inFile, string pathName); void getArrSize(ifstream&amp; inFile, string pathName, string&amp; countriesData); void fillCountryArr(ifstream&amp; inFile, string pathName, string&amp; countryName, string&amp; capitalName, string&amp; tempSurfaceArea); void printCountryData(Country** g_countryArray, int g_arrsz); int main() { char menuChoice, startingLetter; string pathName, countriesData, countryName, capitalName, tempSurfaceArea; ifstream inFile; do { cout &lt;&lt; "Choose one of the following:" &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; "Menu options" &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; "a) Read a text file:" &lt;&lt; endl; cout &lt;&lt; "b) Remove countries starting with given letter" &lt;&lt; endl; cout &lt;&lt; "c) Print all data to console" &lt;&lt; endl; cout &lt;&lt; "d) Quit" &lt;&lt; endl; cin &gt;&gt; menuChoice; switch (menuChoice) { case 'a': { cout &lt;&lt; "Please enter the full path name of the file you wish to open: " &lt;&lt; endl; cin &gt;&gt; pathName; openFile(inFile, pathName); getArrSize(inFile, pathName, countriesData); fillCountryArr(inFile, pathName, countryName, capitalName, tempSurfaceArea); } case 'b': { cout &lt;&lt; "Enter the starting letter: " &lt;&lt; endl; cin &gt;&gt; startingLetter; toupper(startingLetter); } case 'c': { printCountryData(g_countryArray, g_arrsz); } } }while (menuChoice != 'd'); return 0; } void openFile(ifstream&amp; inFile, string pathName) { inFile.open(pathName.c_str()); if (!inFile) { cout &lt;&lt; "Cannot open file." &lt;&lt; endl; } inFile.close(); inFile.clear(std::ios_base::goodbit); } void getArrSize(ifstream&amp; inFile, string pathName, string&amp; countriesData) { inFile.open(pathName.c_str()); while (getline(inFile, countriesData)) { ++g_arrsz; } g_countryArray = new Country* [g_arrsz]; //declares g_countryArray to be an array of pointers of size [g_arrsz]. The array holds pointers to Country class objects } void fillCountryArr(ifstream&amp; inFile, string pathName, string&amp; countryName, string&amp; capitalName, string&amp; tempSurfaceArea) { long int surfaceArea; //closes and reopens the file cleanly inFile.close(); inFile.clear(std::ios_base::goodbit); inFile.open(pathName.c_str()); for (int i = 0; i &lt; g_arrsz; i++) { getline(inFile, countryName, ','); //gets the name of the country from the input file getline(inFile, capitalName, ','); //gets the name of the capital of the country from the input file getline(inFile, tempSurfaceArea); //gets the surface area of the country in the form of a string surfaceArea = stol(tempSurfaceArea); //converts the string version of surface area to an integer g_countryArray[i] = new Country(countryName.c_str(), capitalName.c_str(), surfaceArea); //creates new Country class and stores address in the i'th element of g_countryArray } //passes the name of the country and capital of the country in to the constructor as //c-strings and passes surfaceArea as an int } void printCountryData(Country** g_countryArray, int g_arrsz) { for (int i = 0; i &lt; g_arrsz; ++i) { cout &lt;&lt; g_countryArray[i]-&gt;GetCountryName() &lt;&lt; ", "; cout &lt;&lt; g_countryArray[i]-&gt;GetCapital() &lt;&lt; ", "; cout &lt;&lt; g_countryArray[i]-&gt;GetSurfaceArea() &lt;&lt; endl; } } </code></pre> <p>The function just above here printCountryData is where I want to pass the array of class objects and array size variables, then call the accessor functions.</p> <pre><code>//here is the Country.h file #include &lt;iostream&gt; #include &lt;string&gt; #include &lt;cstring&gt; using namespace std; class Country { private: char* name_; char* capital_; long surfaceArea_; public: Country (const char* country, const char* capital, long surfaceArea); ~Country (); char* GetCountryName(); char* GetCapital(); long GetSurfaceArea(); }; Country::Country(const char* country, const char* capital, long surfaceArea) { int countryLen, capitalLen; //variables to store length of c-strings country and capital for dynamically allocating arrays of the right length countryLen = strlen(country); //gets length of country name capitalLen = strlen(capital); //gets length of capital name name_ = new char[countryLen + 1]; //dyanmically creates a new character array of size countryLen and stores base address of array in name_ pointer for (int i = 0; i &lt; countryLen; i++)//transfers storage of country name to the name_ array { name_[i] = country[i]; } capital_ = new char[capitalLen + 1]; //creates a new character array of size capitalLen and stores base address of array in capital_ pointer for (int i = 0; i &lt; countryLen; i++) { capital_[i] = capital[i]; } surfaceArea_ = surfaceArea; } char* GetCountryName() { return name_; } char* GetCapital() { return capital_; } long GetSurfaceArea() { return surfaceArea_; } </code></pre> <p>It's these 3 accessor functions at the bottom that are generating the error 'name_ is not declared in this scope, etc.'</p>
0debug
Swift: Programmatically make UILabel bold without changing its size? : <p>I have a UILabel created programmatically. I would like to make the text of the label bold without specifying font size. So far I have only found:</p> <pre><code>UIFont.boldSystemFont(ofSize: CGFloat) </code></pre> <p>This is what I have exactly:</p> <pre><code>let titleLabel = UILabel() let fontSize: CGFloat = 26 titleLabel.font = UIFont.boldSystemFont(ofSize: titleLabelFontSize) </code></pre> <p>But this way I am also setting the size. I would like to avoid that. Is there a way?</p> <p>If there is no way, what would be a good workaround in Swift?</p> <p>Thank you!</p>
0debug
Determine List.IndexOf ignoring case : <p>Is there a way to get the index of a item within a List with case insensitive search?</p> <pre><code>List&lt;string&gt; sl = new List&lt;string&gt;() { "a","b","c"}; int result = sl.IndexOf("B"); // should be 1 instead of -1 </code></pre>
0debug
static coroutine_fn void nbd_trip(void *opaque) { NBDClient *client = opaque; NBDExport *exp = client->exp; NBDRequestData *req; NBDRequest request = { 0 }; int ret; int flags; int reply_data_len = 0; Error *local_err = NULL; char *msg = NULL; trace_nbd_trip(); if (client->closing) { nbd_client_put(client); return; } req = nbd_request_get(client); ret = nbd_co_receive_request(req, &request, &local_err); client->recv_coroutine = NULL; nbd_client_receive_next_request(client); if (ret == -EIO) { goto disconnect; } if (ret < 0) { goto reply; } if (client->closing) { goto done; } switch (request.type) { case NBD_CMD_READ: if (request.flags & NBD_CMD_FLAG_FUA) { ret = blk_co_flush(exp->blk); if (ret < 0) { error_setg_errno(&local_err, -ret, "flush failed"); break; } } ret = blk_pread(exp->blk, request.from + exp->dev_offset, req->data, request.len); if (ret < 0) { error_setg_errno(&local_err, -ret, "reading from file failed"); break; } reply_data_len = request.len; break; case NBD_CMD_WRITE: if (exp->nbdflags & NBD_FLAG_READ_ONLY) { error_setg(&local_err, "Export is read-only"); ret = -EROFS; break; } flags = 0; if (request.flags & NBD_CMD_FLAG_FUA) { flags |= BDRV_REQ_FUA; } ret = blk_pwrite(exp->blk, request.from + exp->dev_offset, req->data, request.len, flags); if (ret < 0) { error_setg_errno(&local_err, -ret, "writing to file failed"); } break; case NBD_CMD_WRITE_ZEROES: if (exp->nbdflags & NBD_FLAG_READ_ONLY) { error_setg(&local_err, "Export is read-only"); ret = -EROFS; break; } flags = 0; if (request.flags & NBD_CMD_FLAG_FUA) { flags |= BDRV_REQ_FUA; } if (!(request.flags & NBD_CMD_FLAG_NO_HOLE)) { flags |= BDRV_REQ_MAY_UNMAP; } ret = blk_pwrite_zeroes(exp->blk, request.from + exp->dev_offset, request.len, flags); if (ret < 0) { error_setg_errno(&local_err, -ret, "writing to file failed"); } break; case NBD_CMD_DISC: abort(); case NBD_CMD_FLUSH: ret = blk_co_flush(exp->blk); if (ret < 0) { error_setg_errno(&local_err, -ret, "flush failed"); } break; case NBD_CMD_TRIM: ret = blk_co_pdiscard(exp->blk, request.from + exp->dev_offset, request.len); if (ret < 0) { error_setg_errno(&local_err, -ret, "discard failed"); } break; default: error_setg(&local_err, "invalid request type (%" PRIu32 ") received", request.type); ret = -EINVAL; } reply: if (local_err) { assert(ret < 0); msg = g_strdup(error_get_pretty(local_err)); error_report_err(local_err); local_err = NULL; } if (client->structured_reply && (ret < 0 || request.type == NBD_CMD_READ)) { if (ret < 0) { ret = nbd_co_send_structured_error(req->client, request.handle, -ret, msg, &local_err); } else { ret = nbd_co_send_structured_read(req->client, request.handle, request.from, req->data, reply_data_len, &local_err); } } else { ret = nbd_co_send_simple_reply(req->client, request.handle, ret < 0 ? -ret : 0, req->data, reply_data_len, &local_err); } g_free(msg); if (ret < 0) { error_prepend(&local_err, "Failed to send reply: "); goto disconnect; } if (!req->complete) { error_setg(&local_err, "Request handling failed in intermediate state"); goto disconnect; } done: nbd_request_put(req); nbd_client_put(client); return; disconnect: if (local_err) { error_reportf_err(local_err, "Disconnect client, due to: "); } nbd_request_put(req); client_close(client, true); nbd_client_put(client); }
1threat
Migrate Laravel 4.0 to 5.7 : Actually , I have a System done in Laravel 4.0. It’s possible migrate to Laravel 5.7? What are the impact of this on the system and how I could do it? É possível migrar o Laravel 4.0 para 0 5.6 e qual o passo a passo para fazer da maneira certa?
0debug
void helper_done(void) { env->pc = env->tsptr->tpc; env->npc = env->tsptr->tnpc + 4; PUT_CCR(env, env->tsptr->tstate >> 32); env->asi = (env->tsptr->tstate >> 24) & 0xff; change_pstate((env->tsptr->tstate >> 8) & 0xf3f); PUT_CWP64(env, env->tsptr->tstate & 0xff); env->tl--; env->tsptr = &env->ts[env->tl & MAXTL_MASK]; }
1threat
void fdt_build_clock_node(void *host_fdt, void *guest_fdt, uint32_t host_phandle, uint32_t guest_phandle) { char *node_path = NULL; char *nodename; const void *r; int ret, node_offset, prop_len, path_len = 16; node_offset = fdt_node_offset_by_phandle(host_fdt, host_phandle); if (node_offset <= 0) { error_setg(&error_fatal, "not able to locate clock handle %d in host device tree", host_phandle); } node_path = g_malloc(path_len); while ((ret = fdt_get_path(host_fdt, node_offset, node_path, path_len)) == -FDT_ERR_NOSPACE) { path_len += 16; node_path = g_realloc(node_path, path_len); } if (ret < 0) { error_setg(&error_fatal, "not able to retrieve node path for clock handle %d", host_phandle); } r = qemu_fdt_getprop(host_fdt, node_path, "compatible", &prop_len, &error_fatal); if (strcmp(r, "fixed-clock")) { error_setg(&error_fatal, "clock handle %d is not a fixed clock", host_phandle); } nodename = strrchr(node_path, '/'); qemu_fdt_add_subnode(guest_fdt, nodename); copy_properties_from_host(clock_copied_properties, ARRAY_SIZE(clock_copied_properties), host_fdt, guest_fdt, node_path, nodename); qemu_fdt_setprop_cell(guest_fdt, nodename, "phandle", guest_phandle); g_free(node_path); }
1threat
An attempt to attach an auto-named database for file D:\Stra.mdf failed. : [we are doing project in our collage while we are executing we getting this error we have registration page while we are click on register we getting this error ][1] [1]: http://i.stack.imgur.com/fAtKN.jpg
0debug
How to have a transparent gradient over an Image in React Native iOS? : <p>I have been dealing with the a gradient rectangle over an Image that has a black and a transparent sides, I have been looking about a gradient object in react native and I didn't found, but there is a react-native module that does this, but the problem is that it does work in android the transparency, but in iOS, it doesn't work, it shows white in place of the transparent side</p> <p><a href="https://i.stack.imgur.com/mBE9O.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/mBE9O.jpg" alt="transparent gradient"></a> </p> <p>and than I was looking about a native iOS solution, I did but it's a bit complex, and I can't implement in react native this the snippet </p> <pre><code>CAGradientLayer *gradientMask = [CAGradientLayer layer]; gradientMask.frame = self.imageView.bounds; gradientMask.colors = @[(id)[UIColor whiteColor].CGColor, (id)[UIColor clearColor].CGColor]; self.imageView.layer.mask = gradientMask; &lt;-- // looking for a way to achieve this in react native </code></pre> <p>this is my react native code</p> <pre><code> &lt;Image ref={r =&gt; this.image = r} style={styles.container} source={require('../assets/default_profile_picture.jpg')}&gt; &lt;LinearGradient ref={r =&gt; this.gradiant = r} locations={[0, 1.0]} colors={['rgba(0,0,0,0.00)', 'rgba(0,0,0,0.80)']} style={styles.linearGradient}&gt; &lt;/LinearGradient&gt; &lt;/Image&gt; </code></pre> <p>I don't know how to pass <code>LinearGradient</code> to <code>Image</code> as a mask</p>
0debug
Flutter: Get passed arguments from Navigator in Widget's state's initState : <p>I have a <code>StatefulWidget</code> which I want to use in named route. I have to pass some arguments which I am doing as suggested in <a href="https://flutter.dev/docs/cookbook/navigation/navigate-with-arguments" rel="noreferrer">https://flutter.dev/docs/cookbook/navigation/navigate-with-arguments</a> i.e.</p> <pre><code>Navigator.pushNamed( context, routeName, arguments: &lt;args&gt;, ); </code></pre> <p>Now, I need to access these argument's in the state's <code>initState</code> method as the arguments are needed to subscribe to some external events. If I put the <code>args = ModalRoute.of(context).settings.arguments;</code> call in <code>initState</code>, I get a runtime exception.</p> <pre><code>20:49:44.129 4 info flutter.tools I/flutter ( 2680): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ 20:49:44.129 5 info flutter.tools I/flutter ( 2680): The following assertion was thrown building Builder: 20:49:44.129 6 info flutter.tools I/flutter ( 2680): inheritFromWidgetOfExactType(_ModalScopeStatus) or inheritFromElement() was called before 20:49:44.130 7 info flutter.tools I/flutter ( 2680): _CourseCohortScreenState.initState() completed. 20:49:44.130 8 info flutter.tools I/flutter ( 2680): When an inherited widget changes, for example if the value of Theme.of() changes, its dependent 20:49:44.131 9 info flutter.tools I/flutter ( 2680): widgets are rebuilt. If the dependent widget's reference to the inherited widget is in a constructor 20:49:44.131 10 info flutter.tools I/flutter ( 2680): or an initState() method, then the rebuilt dependent widget will not reflect the changes in the 20:49:44.131 11 info flutter.tools I/flutter ( 2680): inherited widget. 20:49:44.138 12 info flutter.tools I/flutter ( 2680): Typically references to inherited widgets should occur in widget build() methods. Alternatively, 20:49:44.138 13 info flutter.tools I/flutter ( 2680): initialization based on inherited widgets can be placed in the didChangeDependencies method, which 20:49:44.138 14 info flutter.tools I/flutter ( 2680): is called after initState and whenever the dependencies change thereafter. 20:49:44.138 15 info flutter.tools I/flutter ( 2680): 20:49:44.138 16 info flutter.tools I/flutter ( 2680): When the exception was thrown, this was the stack: 20:49:44.147 17 info flutter.tools I/flutter ( 2680): #0 StatefulElement.inheritFromElement.&lt;anonymous closure&gt; (package:flutter/src/widgets/framework.dart:3936:9) 20:49:44.147 18 info flutter.tools I/flutter ( 2680): #1 StatefulElement.inheritFromElement (package:flutter/src/widgets/framework.dart:3969:6) 20:49:44.147 19 info flutter.tools I/flutter ( 2680): #2 Element.inheritFromWidgetOfExactType (package:flutter/src/widgets/framework.dart:3285:14) 20:49:44.147 20 info flutter.tools I/flutter ( 2680): #3 ModalRoute.of (package:flutter/src/widgets/routes.dart:698:46) 20:49:44.147 21 info flutter.tools I/flutter ( 2680): #4 _CourseCohortScreenState.initState.&lt;anonymous closure&gt; (package:esk2/cohort_screen.dart:57:23) </code></pre> <p>I do not want to put that logic in <code>build</code> method as <code>build</code> could be called multiple times and the initialization needs to happen only once. I could put the entire logic in a block with a boolean isInitialized flag, but that does not seem like the right way of doing this. Is this requirement/case not supported in flutter as of now?</p>
0debug
check id jquery object is empty : <p>I'm trying to check if a jquery object is null to use it this way</p> <pre><code>var reminder_history_div = $(".history-container"); if(reminder_history_div) reminder_history_div.scrollTop(reminder_history_div[0].scrollHeight); </code></pre> <p>but <code>reminder_history_div</code> is not null or empty its and object ,with some info ,what is the correct way to check if is empty?maybe:</p> <pre><code>if(reminder_history_div.length &gt; 0) </code></pre>
0debug
How to write this decorator? : <p>HELP Please . How Write This Decorator (Take a validator if the validator return "True" send args to func :</p> <pre><code>#define decorator here ... def validator(x): return x&gt;=0 @decorator(validator) def f(x): return x**0.5 print(f(4)) #should print 2 print(f(-4)) #should print error </code></pre>
0debug
Timespan function to convert minutes into 8 hour working days : <p>Need to count in C# app, minutes in SLA to show in format : </p> <pre><code>N working days, N working hours, N working minutes </code></pre> <p>current code show up only hours:minutes format:</p> <pre><code>TimeSpan spWorkMin = TimeSpan.FromMinutes(12534); string workHours = string.Format("{0}:{1:00}", (int)spWorkMin.TotalHours, spWorkMin.Minutes); Console.WriteLine(workHours); </code></pre>
0debug
How to have a sequence of output using While Loop in Java? : <p>I was confused on how to apply code for while, my input would be;</p> <pre><code>input: 5 </code></pre> <p>I was expecting to have this kind of sequence output using while loop;</p> <pre><code>input: 5 output: ***** **** *** ** * </code></pre> <p>I applied this code;</p> <pre><code>int input ; String output = "*"; Scanner sc = new Scanner(System.in); System.out.println ("input:"); input = sc.nextInt(); System.out.println ("output: "); while (input!=0){ System.out.print (output); input--; } </code></pre> <p>But the output was;</p> <pre><code>input: 3 output: *** </code></pre>
0debug
Not sure why this Java Null Pointer Exception is happening : <p>I have a method that return an array of files in a given directory that is giving me a null pointer exception when executed. I can't figure out why.</p> <pre><code>private ArrayList&lt;File&gt; getFiles(String path) { File f = new File(path); ArrayList&lt;File&gt; files = new ArrayList&lt;&gt;(Arrays.asList(f.listFiles())); return files; } </code></pre> <p>thanks for your help</p>
0debug
Organization proxy self signed certificate not trusted in cent os VM : <p>I am having a VM created out of Cent OS 7.6 ISO. when I try to CURL <a href="https://xxxxxxx" rel="nofollow noreferrer">https://xxxxxxx</a> it shows "(60) CURl Peer certificate issuer has been marked as not trusted by the user. This happens even after I downloaded the certificate and aded it to the store using update-ca-certificate command (ref: <a href="https://manuals.gfi.com/en/kerio/connect/content/server-configuration/ssl-certificates/adding-trusted-root-certificates-to-the-server-1605.html" rel="nofollow noreferrer">https://manuals.gfi.com/en/kerio/connect/content/server-configuration/ssl-certificates/adding-trusted-root-certificates-to-the-server-1605.html</a>). The only doubt I have is that the client system is behind my organization network proxy. Is there any suggestion to solve the problem?</p>
0debug
static int64_t get_pts(const char *buf, int *duration) { int i, hour, min, sec, hsec; int he, me, se, mse; for (i=0; i<2; i++) { int64_t start, end; if (sscanf(buf, "%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d", &hour, &min, &sec, &hsec, &he, &me, &se, &mse) == 8) { min += 60*hour; sec += 60*min; start = sec*1000+hsec; me += 60*he; se += 60*me; end = se*1000+mse; *duration = end - start; return start; } buf += strcspn(buf, "\n") + 1; } return AV_NOPTS_VALUE; }
1threat
Retrive data Firebase from DateTime node : I want to retrive data from `Firebase` but my problem is that one of the node is date for each day and I don't know how to get inside of it. That's my `JSON` : { "jsonData": { "11-30-2017": { "Clau": { "-L-BmanPPTqqXxOivGZs": [ { "cantitate": "18", "pret": "140", "produs": "Camasa", "produsId": "-L-BjnaA-Uizg9mI7J3l", "qty": 2, "subTotal": 280 } ] } } } } I want to get objects inside of the `jsonData` (**cantitate,pret,produsID etc.**). I don't know how to get inside, that's all what I've tried. mDatabaseReference = FirebaseDatabase.getInstance().getReference("jsonData") I don't know what to do next. Hope you can help me.
0debug
void bdrv_info(Monitor *mon, QObject **ret_data) { QList *bs_list; BlockDriverState *bs; bs_list = qlist_new(); QTAILQ_FOREACH(bs, &bdrv_states, list) { QObject *bs_obj; bs_obj = qobject_from_jsonf("{ 'device': %s, 'type': 'unknown', " "'removable': %i, 'locked': %i }", bs->device_name, bs->removable, bdrv_dev_is_medium_locked(bs)); if (bs->drv) { QObject *obj; QDict *bs_dict = qobject_to_qdict(bs_obj); obj = qobject_from_jsonf("{ 'file': %s, 'ro': %i, 'drv': %s, " "'encrypted': %i }", bs->filename, bs->read_only, bs->drv->format_name, bdrv_is_encrypted(bs)); if (bs->backing_file[0] != '\0') { QDict *qdict = qobject_to_qdict(obj); qdict_put(qdict, "backing_file", qstring_from_str(bs->backing_file)); } qdict_put_obj(bs_dict, "inserted", obj); } qlist_append_obj(bs_list, bs_obj); } *ret_data = QOBJECT(bs_list); }
1threat
'str'object has not attribute 'subs' : Here is my python code written in vim editor;whenever i run it via command prompt i get the error 'str'object has not attribute 'subs' from sympy import * x,a_test,b_test,fa_test,fb_test=symbols('x a_test b_test fa_test fb_test') expr=raw_input("enter the equation") print expr print "hello" try: print "hello" inc=0 a=inc fa=expr.subs(x,inc) print "hello" if(fa<0): print "hello" inc+=1 fb=expr.subs(x,inc) if(fb<=0): while(fb<=0): inc+=1 else: print "hello" inc+=1 fb=expr.subs(x,inc) if(fb<=0): while(fb<=0): inc+=1 b=inc print a print b print fa print fb except Exception,e: print e
0debug
Need help fixing Alexa Skill (urgent!) : Now getting an error in js.do that reads "ReferenceError: Can't find variable:exports on line 22" Line 22 reads "exports.handler = function (event, context) { When I test it in the service simulator on developer.amazon, it responds "the remote endpoint could not be called, or the response it returned was invalid" ---- What does this mean, and what can I do to fix it? By the way, this is not homework!
0debug
media query does not switch below 768 when resize window : <pre><code>@media(min-width:768px){body:border:1px solid red;} </code></pre> <p>if i resize the window below 768px , it does not switch to iphone6+ media query</p> <pre><code>@media only screen and (min-device-width: 414px) and (max-device-width: 736px) and (-webkit-min-device-pixel-ratio: 3) and (orientation: landscape) { body:border:1px solid red;} </code></pre> <p>Please suggest</p>
0debug
(Android) I have questions about ListView and SharedPreference : I am a beginner developer who is studying Android. The function I want to develop is "Save the data entered in EditText as JSON, save it as SharedPreference, and output it to ListView". To save it as SharedPreference is OK, but, To output it to ListView is not working now. Please give a lot of advice. MainActivity.java : public class MainActivity extends AppCompatActivity { private ListView listView; private Button save_btn; private ArrayList<List> data = new ArrayList<List>(); ListAdapter adapter; String title=""; String info=""; int img = R.drawable.man; String jsondata; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); listView = (ListView) findViewById(R.id.listView); save_btn = (Button) findViewById(R.id.button1); loadArrayList(getApplicationContext()); adapter = new ListAdapter(this, R.layout.row, data); listView.setAdapter(adapter); registerForContextMenu(listView); save_btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { View dlgview = View.inflate(MainActivity.this, R.layout.adds, null); //adds.xml final EditText et_title = (EditText) dlgview.findViewById(R.id.editText1); final EditText et_info = (EditText) dlgview.findViewById(R.id.editText2); ImageView img1 = (ImageView) dlgview.findViewById(R.id.imageView2); AlertDialog.Builder dlg = new AlertDialog.Builder(MainActivity.this); dlg.setTitle("ADD"); dlg.setView(dlgview); dlg.setNegativeButton("Save", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { JSONObject jsonObject = new JSONObject(); JSONArray jsonArray = new JSONArray(); try{ jsonObject.put("title", et_title.getText().toString()); jsonObject.put("info", et_info.getText().toString()); jsonObject.put("image",img); jsonArray.put(jsonObject); } catch (JSONException e){ e.printStackTrace(); } jsondata = jsonArray.toString(); saveArrayList(); adapter.notifyDataSetChanged(); } }); dlg.setPositiveButton("Cancel",null); dlg.show(); } }); }//End of onCreate private void saveArrayList(){ SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences.Editor editor = sharedPrefs.edit(); editor.putString("jsonData", jsondata); Log.i("moi","get Data test : " + "jsonData"); editor.apply(); } private void loadArrayList(Context context){ SharedPreferences sharedPrefs2 = PreferenceManager.getDefaultSharedPreferences(context); int size = sharedPrefs2.getInt("appreciation_size",0); String strJson = sharedPrefs2.getString("jsonData", "fail"); Log.i("moi","get SharedPreferences test : " + strJson); if (strJson != "fail") { try { JSONArray response = new JSONArray(strJson); for (int i=0; i<size; i++) { JSONObject jsonobject = response.getJSONObject(i); title = jsonobject.getString("title"); Log.i("moi","title test : " + "title"); info = jsonobject.getString("info"); Log.i("moi","info test : " + "info"); data.add(new List(title, info, img)); } adapter = new ListAdapter(getApplicationContext(), R.layout.row, data); listView.setAdapter(adapter); } catch (JSONException e){ e.printStackTrace(); } } } }//End of class
0debug
def add_tuple(test_list, test_tup): test_list += test_tup return (test_list)
0debug
how to parse this type of json format in swift 4 with decodable? : {"type":"Success","message":"","fitting":{"fitterID":"96ba096c-f0aa-11e7-a67a-76478bc72e4d","fitID":"09d399c0-7d74-4578-a138-5f4b02ba2e80","leftNotesJSON":"[{\"class\":\"FitNote\",\"text\":\"Saddle Down\",\"leftfoot\":false},{\"class\":\"FitNote\",\"text\":\"Saddle Down\",\"leftfoot\":false},{\"class\":\"FootBottomNote\",\"leftfoot\":false}]","rightNotesJSON":"[{\"s3Bucket\":\"8190ba10-d310-11e3-9c1a-0800200c9a66\",\"angle\":0,\"leftfoot\":false,\"shoulderAngle\":0,\"hipAngle\":0,\"s3Key\":\"FD0F5AE6-8193-4980-AD11-C42FEF064B8B\",\"class\":\"AngleNote\",\"kneeAngle\":0}]"}}
0debug
uint32_t HELPER(neon_min_f32)(uint32_t a, uint32_t b) { float32 f0 = make_float32(a); float32 f1 = make_float32(b); return (float32_compare_quiet(f0, f1, NFS) == -1) ? a : b; }
1threat
static void put_pci_irq_state(QEMUFile *f, void *pv, size_t size) { int i; PCIDevice *s = container_of(pv, PCIDevice, config); for (i = 0; i < PCI_NUM_PINS; ++i) { qemu_put_be32(f, pci_irq_state(s, i)); } }
1threat
static void sigbus_handler(int signal) { siglongjmp(sigjump, 1); }
1threat
static void net_socket_cleanup(NetClientState *nc) { NetSocketState *s = DO_UPCAST(NetSocketState, nc, nc); qemu_set_fd_handler(s->fd, NULL, NULL, NULL); close(s->fd); }
1threat
How is StaticLayout used in Android? : <p>I need to build my own custom <code>TextView</code> so I have been learning about <code>StaticLayout</code> to draw text on a canvas. This is preferable to using <code>Canvas.drawText()</code> directly, or so the <a href="https://developer.android.com/reference/android/text/StaticLayout.html" rel="noreferrer">documentation</a> says. However, the documentation doesn't give any examples for how do it. There is only a vague reference to <a href="https://developer.android.com/reference/android/text/StaticLayout.Builder.html" rel="noreferrer"><code>StaticLayout.Builder</code></a> being the newer way to do it.</p> <p>I found an example <a href="http://ivankocijan.xyz/android-drawing-multiline-text-on-canvas/" rel="noreferrer">here</a> but it seems a little dated.</p> <p>I finally worked though how to do it so I am adding my explanation below.</p>
0debug
int kvm_cpu_exec(CPUState *cpu) { struct kvm_run *run = cpu->kvm_run; int ret, run_ret; DPRINTF("kvm_cpu_exec()\n"); if (kvm_arch_process_async_events(cpu)) { cpu->exit_request = 0; return EXCP_HLT; } qemu_mutex_unlock_iothread(); do { MemTxAttrs attrs; if (cpu->kvm_vcpu_dirty) { kvm_arch_put_registers(cpu, KVM_PUT_RUNTIME_STATE); cpu->kvm_vcpu_dirty = false; } kvm_arch_pre_run(cpu, run); if (cpu->exit_request) { DPRINTF("interrupt exit requested\n"); qemu_cpu_kick_self(); } run_ret = kvm_vcpu_ioctl(cpu, KVM_RUN, 0); attrs = kvm_arch_post_run(cpu, run); if (run_ret < 0) { if (run_ret == -EINTR || run_ret == -EAGAIN) { DPRINTF("io window exit\n"); ret = EXCP_INTERRUPT; break; } fprintf(stderr, "error: kvm run failed %s\n", strerror(-run_ret)); #ifdef TARGET_PPC if (run_ret == -EBUSY) { fprintf(stderr, "This is probably because your SMT is enabled.\n" "VCPU can only run on primary threads with all " "secondary threads offline.\n"); } #endif ret = -1; break; } trace_kvm_run_exit(cpu->cpu_index, run->exit_reason); switch (run->exit_reason) { case KVM_EXIT_IO: DPRINTF("handle_io\n"); kvm_handle_io(run->io.port, attrs, (uint8_t *)run + run->io.data_offset, run->io.direction, run->io.size, run->io.count); ret = 0; break; case KVM_EXIT_MMIO: DPRINTF("handle_mmio\n"); address_space_rw(&address_space_memory, run->mmio.phys_addr, attrs, run->mmio.data, run->mmio.len, run->mmio.is_write); ret = 0; break; case KVM_EXIT_IRQ_WINDOW_OPEN: DPRINTF("irq_window_open\n"); ret = EXCP_INTERRUPT; break; case KVM_EXIT_SHUTDOWN: DPRINTF("shutdown\n"); qemu_system_reset_request(); ret = EXCP_INTERRUPT; break; case KVM_EXIT_UNKNOWN: fprintf(stderr, "KVM: unknown exit, hardware reason %" PRIx64 "\n", (uint64_t)run->hw.hardware_exit_reason); ret = -1; break; case KVM_EXIT_INTERNAL_ERROR: ret = kvm_handle_internal_error(cpu, run); break; case KVM_EXIT_SYSTEM_EVENT: switch (run->system_event.type) { case KVM_SYSTEM_EVENT_SHUTDOWN: qemu_system_shutdown_request(); ret = EXCP_INTERRUPT; break; case KVM_SYSTEM_EVENT_RESET: qemu_system_reset_request(); ret = EXCP_INTERRUPT; break; case KVM_SYSTEM_EVENT_CRASH: qemu_mutex_lock_iothread(); qemu_system_guest_panicked(); qemu_mutex_unlock_iothread(); ret = 0; break; default: DPRINTF("kvm_arch_handle_exit\n"); ret = kvm_arch_handle_exit(cpu, run); break; } break; default: DPRINTF("kvm_arch_handle_exit\n"); ret = kvm_arch_handle_exit(cpu, run); break; } } while (ret == 0); qemu_mutex_lock_iothread(); if (ret < 0) { cpu_dump_state(cpu, stderr, fprintf, CPU_DUMP_CODE); vm_stop(RUN_STATE_INTERNAL_ERROR); } cpu->exit_request = 0; return ret; }
1threat
Error: Expected resource of type styleable [ResourceType] error : <p>Take a look at this code snippet. I am getting an error with the last line, because I am passing an 'index' instead of a resource. I thought it was a lint issue and tried to suppress it. Then I noticed I am getting this error only when I building for release. It works fine when building for debug. I am totally clueless. Can anyone throw some light into what I am doing wrong.</p> <pre><code>//Get paddingLeft, paddingRight int[] attrsArray = new int[]{ android.R.attr.paddingLeft, // 0 android.R.attr.paddingRight, // 1 }; TypedArray ta = context.obtainStyledAttributes(attrs, attrsArray); if (ta == null) return; mPaddingLeft = ta.getDimensionPixelSize(0, 0); mPaddingRight = ta.getDimensionPixelSize(1/*error here*/, 0); </code></pre>
0debug
How To Use State In function Componet in React.js : <p>I Create Function Component In React And I Want to use state in it like class Component </p>
0debug
Adding comma's to animated counting function : I've tried everything I can find online about this but they all seam to deal with static numbers, not animated numbers. Is it possible to have comma's added to my values ad the number increases using this by modifying this function? $('.counter').each(function() { var $this = $(this), countTo = $this.attr('data-count'); $({ countNum: $this.text()}).animate({ countNum: countTo }, { duration: 500, easing:'linear', step: function() { $this.text(Math.floor(this.countNum)); }, complete: function() { $this.text(this.countNum); //alert('finished'); } });
0debug
Expo React-Native iOS Simulator not working : <p>Hello I'm facing a problem with Expo React-Native. Whenever I try to launch the iOS Simulator. I get this error:</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>Simulator is installed but is identified as 'com.apple.CoreSimulator.SimulatorTrampoline'; don't know what that is. Simulator not installed. Please visit https://developer.apple.com/xcode/download/ to download Xcode and the iOS simulator. If you already have the latest version of Xcode installed, you may have to run the command `sudo xcode-select -s /Applications/Xcode.app`.</code></pre> </div> </div> </p> <p><a href="https://i.stack.imgur.com/h0EJO.png" rel="noreferrer">Screenshot of Expo Results</a></p> <p>My NPM Version is <strong>6.7.0</strong> react-native-cli: <strong>2.0.1</strong> react-native: <strong>0.57.1</strong> Expo Version <strong>2.11.9</strong></p> <p>Also I made sure my Command Line tools on Xcode is setup perfectly <a href="https://i.stack.imgur.com/Zk0bd.png" rel="noreferrer">Xcode CommandLineTools</a></p> <p>Finally, I also tried to run the command <code>sudo xcode-select -s /Applications/Xcode.app</code></p> <p>Nothing works..</p>
0debug
static int nfs_parse_uri(const char *filename, QDict *options, Error **errp) { URI *uri = NULL; QueryParams *qp = NULL; int ret = -EINVAL, i; uri = uri_parse(filename); if (!uri) { error_setg(errp, "Invalid URI specified"); goto out; } if (strcmp(uri->scheme, "nfs") != 0) { error_setg(errp, "URI scheme must be 'nfs'"); goto out; } if (!uri->server) { error_setg(errp, "missing hostname in URI"); goto out; } if (!uri->path) { error_setg(errp, "missing file path in URI"); goto out; } qp = query_params_parse(uri->query); if (!qp) { error_setg(errp, "could not parse query parameters"); goto out; } qdict_put(options, "server.host", qstring_from_str(uri->server)); qdict_put(options, "server.type", qstring_from_str("inet")); qdict_put(options, "path", qstring_from_str(uri->path)); for (i = 0; i < qp->n; i++) { if (!qp->p[i].value) { error_setg(errp, "Value for NFS parameter expected: %s", qp->p[i].name); goto out; } if (parse_uint_full(qp->p[i].value, NULL, 0)) { error_setg(errp, "Illegal value for NFS parameter: %s", qp->p[i].name); goto out; } if (!strcmp(qp->p[i].name, "uid")) { qdict_put(options, "user", qstring_from_str(qp->p[i].value)); } else if (!strcmp(qp->p[i].name, "gid")) { qdict_put(options, "group", qstring_from_str(qp->p[i].value)); } else if (!strcmp(qp->p[i].name, "tcp-syncnt")) { qdict_put(options, "tcp-syn-count", qstring_from_str(qp->p[i].value)); } else if (!strcmp(qp->p[i].name, "readahead")) { qdict_put(options, "readahead-size", qstring_from_str(qp->p[i].value)); } else if (!strcmp(qp->p[i].name, "pagecache")) { qdict_put(options, "page-cache-size", qstring_from_str(qp->p[i].value)); } else if (!strcmp(qp->p[i].name, "debug")) { qdict_put(options, "debug", qstring_from_str(qp->p[i].value)); } else { error_setg(errp, "Unknown NFS parameter name: %s", qp->p[i].name); goto out; } } ret = 0; out: if (qp) { query_params_free(qp); } if (uri) { uri_free(uri); } return ret; }
1threat
static int init_input(AVFormatContext *s, const char *filename, AVDictionary **options) { int ret; AVProbeData pd = {filename, NULL, 0}; if(s->iformat && !strlen(filename)) return 0; if (s->pb) { s->flags |= AVFMT_FLAG_CUSTOM_IO; if (!s->iformat) return av_probe_input_buffer(s->pb, &s->iformat, filename, s, 0, 0); else if (s->iformat->flags & AVFMT_NOFILE) av_log(s, AV_LOG_WARNING, "Custom AVIOContext makes no sense and " "will be ignored with AVFMT_NOFILE format.\n"); return 0; } if ( (s->iformat && s->iformat->flags & AVFMT_NOFILE) || (!s->iformat && (s->iformat = av_probe_input_format(&pd, 0)))) return 0; if ((ret = avio_open2(&s->pb, filename, AVIO_FLAG_READ, &s->interrupt_callback, options)) < 0) return ret; if (s->iformat) return 0; return av_probe_input_buffer(s->pb, &s->iformat, filename, s, 0, 0); }
1threat
Passing pointers (matrix) to a function in c : <p>I have dynamically created a matrix using calloc in the usual way:</p> <pre><code>int **matrix; int dim,r; scanf("%d",&amp;dim); matrix=(int **)calloc(dim, sizeof(int *)); for(r=0; r&lt;dim; r++) { matrix[r]=(int *)calloc(dim, sizeof(int)); } </code></pre> <p>Now if I wanted to create a function to just print the elements of this matrix, I should write something like:</p> <pre><code>void stampmatrix(int **matrix, int dim) { int r=0, c=0; for(r=0; r&lt;dim; r++) { printf("("); for(c=0;c&lt;dim;c++) { printf(" %d , ",matrix[r][c]); } printf(")"); } } </code></pre> <p>And this works fine. Now I add this line to the previous function</p> <pre><code>`...` matrix[r][c]=1; printf(" %d , ",matrix[r][c]); ... </code></pre> <p>If i call this function in my main function, stampmatrix(matrix,dim) once i run the program, the compiler should create a copy of my matrix, fill it with 1, and then print them, and then return to my main function <strong>without changing the actual matrix</strong>. But if I do this and then i check in my main function the values of my matrix elements, they are changed to 1. In class i was told that if I pass values to a function, the program creates a copy of the values, works with them and then cancel the copy, so I need to pass addresses to a function in order to actually change the contents of my variables in my main function. Why in this case it doesn't work, and changes my matrix values? It's because I still pass pointers to the function stampmatrix? I really don't understand. Shouldn't the function be something like:</p> <pre><code>void stampfunction(int dim, int ***matrix) </code></pre> <p>Or it's because i used a void function? Thanks for the attention!</p>
0debug
Does git gc execute at deterministic intervals? : <p>I've been reading up on git, and I have a very particular question I am struggling to answer.</p> <p><strong>When</strong> does <code>git gc</code> execute autonomously?</p> <p>I've been hearing through the grape-vine of various forums that it occurs by default on a push or a fetch/pull - but I cannot find any source that verifies this. Even <a href="https://www.kernel.org/pub/software/scm/git/docs/git-gc.html" rel="noreferrer">the documentation itself</a> only gets this specific (emphasis mine):</p> <blockquote> <p><strong>Some</strong> git commands <strong>may</strong> automatically run git gc; see the --auto flag below for details</p> </blockquote> <p>and the <code>--auto</code> flag specifies</p> <blockquote> <p><strong>Some</strong> git commands run git gc --auto after performing operations that could create many loose objects.</p> </blockquote> <p>I want to be able to deterministically say:</p> <p>"Loose tree and blob files will not have been cleaned up by git until one of the following commands is run: <strong>{mystery list here}</strong>. When running one of these commands, if the number of loose objects exceeds the value of <code>gc.auto</code>, git will automatically compress the objects into a packfile".</p>
0debug
Xcode : The file “XXX.entitlements” couldn’t be opened because there is no such file : <p>Cause my old machine was damaged so I copied the project to another machine and build&amp;run it but xcode return error : </p> <blockquote> <p>warning: Falling back to contents of entitlements file "XXX.entitlements" because it was modified during the build process. Modifying the entitlements file during the build is unsupported.error: The file “XXX.entitlements” couldn’t be opened because there is no such file.</p> </blockquote> <p>Does anyone have any suggestions? </p>
0debug
Why isn't my future value available now? : <p>My ajax call is not returning anything! Here is my code:</p> <pre><code>var answer; $.getJSON('/foo.json') . done(function(response) { answer = response.data; }); console.log(answer); </code></pre> <p>Even though the network call is succeeding, and I can see that the response contains data, the console logs "undefined"! What is happening?</p>
0debug
Failed resolution of: Lcom/google/devtools/build/android/desugar/runtime/ThrowableExtension; : <p>I'm using RxJava with Retrofit on the newest preview of AndroidStudio. My project has java 1.8 suport enabled like this: </p> <pre><code>compileOptions { targetCompatibility 1.8 sourceCompatibility 1.8 } </code></pre> <p>But when the code is compiled and run I'm getting this error, as soon as the request is made, even if I have the <code>onError</code> handler:</p> <pre><code>java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/devtools/build/android/desugar/runtime/ThrowableExtension; at io.reactivex.plugins.RxJavaPlugins.onError(RxJavaPlugins.java:281) at retrofit2.adapter.rxjava2.CallExecuteObservable.subscribeActual(CallExecuteObservable.java:58) at io.reactivex.Observable.subscribe(Observable.java:10179) at retrofit2.adapter.rxjava2.BodyObservable.subscribeActual(BodyObservable.java:34) at io.reactivex.Observable.subscribe(Observable.java:10179) at io.reactivex.internal.operators.flowable.FlowableFromObservable.subscribeActual(FlowableFromObservable.java:31) at io.reactivex.Flowable.subscribe(Flowable.java:12218) at io.reactivex.internal.operators.flowable.FlowableOnBackpressureLatest.subscribeActual(FlowableOnBackpressureLatest.java:31) at io.reactivex.Flowable.subscribe(Flowable.java:12218) </code></pre> <p>This happens even if I use Maybe, Single or Observable. How can this issue be resolved?</p>
0debug
angular 1 js, there are no way to remove class : I trying search many to many here but i can not find result for `removeClass` in angular js. here my example code <form name="myform" ng-class="plus"> //... <button ng-click="save()">click</button> </form> and my angular $scope.add_page = function(){ $scope.myform.removeClass(plus);//what i try but not work } any suggest how to removed class or remove attribute ?
0debug
Does the details of login will be stored in database by php? : <p>As an example,in gmail the total data regarding login page i.e email and password are stored in DB and when we enter our email and password,it will be compared with the data in database and ours will get logged.This complete process of extraction of data from sql will be done by php.I am i right? </p>
0debug
Assignment to expression with array type AND request for member in something not a structure or union : <p>Im trying to declarate this variables of the type of my struct and having this errors, code is about a elections. CANDIDATO is a portuguese word and means candidates, i think i dont need do translate so much of this </p> <pre><code>struct candidatos{ int numCandidato; char nomeCandidado[10]; char partidoCandidato[3]; char cargoCandidato[1]; int votos; float porcentagem; }; struct candidatos listar[11]; int main(){ //CANDIDATO 01 listar[0].numCandidato = 111; strcpy(listar[0].nomeCandidado, "ABC"); strcpy(listar[0].partidoCandidato, "ABC"); strcpy(listar[0].cargoCandidato, "ABC"); listar[0].votos = 0; } ////ERROR START'S HERE int iniciarVotacao(){ struct candidatos presidente; struct candidatos deputado; int votoPresidente = 0; int votoDeputado = 0; int i = 0; presidente.nomeCandidado = 0; //°1 erro deputado.numCandidato = 0; // erro printf("Número do candidato para a Presidência =&gt; "); scanf("%d", &amp;votoPresidente); printf("\nNúmero do candidato para Deputado =&gt; "); scanf("%d", &amp;votoDeputado); for(i = 0 ; i &lt; 11 ; i++){ if(listar[i].numCandidato == votoPresidente &amp;&amp; listar.numCandidato &lt; 50){ presidente = listar[i]; }// 2° erro acontece if(listar[i].numCandidato == votoPresidente &amp;&amp; listar.numCandidato &gt; 1000){ deputado = listar[i]; } } </code></pre>
0debug
OnLongClickListiner is not working in android : The code throws compile time error: Class 'Anonymous class derived from OnLongClickLister' is not abstract and does not override abstract method onLongClick(View) in OnLongClickListener _______ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Button amitsbutton = (Button) findViewById(R.id.amitsbutton); amitsbutton.setOnClickListener( new Button.OnClickListener() { public void onClick(View v) { TextView amitstext = (TextView) findViewById(R.id.amitstext); amitstext.setText("Small click is working"); } } ); amitsbutton.setOnLongClickListener( new Button.OnLongClickListener() { public boolean OnLongClick(View v) { TextView amitstext = (TextView) findViewById(R.id.amitstext); amitstext.setText("long click is also working "); return true; } } );
0debug
Regular expression Regex to extract a string : <p>Please can somebody help me, I`m new to regex and have no idea how to do this!.</p> <p>I`m trying to extract from a list which looks like this...</p> <p><strong>Joe-Age23-46737-251.aspx<br> Tim-Age18-46909-451.aspx<br> Roger-Age41-59768-251.aspx</strong> </p> <p>What I want is this...</p> <p><strong>46737-251.aspx<br> 46909-451.aspx<br> 59768-251.aspx</strong> </p> <p>so basically anything after the second to last hyphen.</p> <p>Cheers </p>
0debug
Correct S3 Policy For Pre-Signed URLs : <p>I need to issue pre-signed URLs for allowing users to GET and PUT files into a specific S3 bucket. I created an IAM user and use its keys to create the pre-signed URLs, and added a custom policy embedded in that user (see below). When I use the generated URL, I get an <code>AccessDenied</code> error with my policy. If I add the <code>FullS3Access</code> policy to the IAM user, the file can be GET or PUT with the same URL, so obviously, my custom policy is lacking. What is wrong with it?</p> <p>Here's the custom policy I am using that is not working:</p> <pre><code>{ "Statement": [ { "Action": [ "s3:ListBucket" ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::MyBucket" ] }, { "Action": [ "s3:AbortMultipartUpload", "s3:CreateBucket", "s3:DeleteBucket", "s3:DeleteBucketPolicy", "s3:DeleteObject", "s3:GetBucketPolicy", "s3:GetLifecycleConfiguration", "s3:GetObject", "s3:ListBucket", "s3:ListBucketMultipartUploads", "s3:ListMultipartUploadParts", "s3:PutBucketPolicy", "s3:PutLifecycleConfiguration", "s3:PutObject" ], "Effect": "Allow", "Resource": [ "arn:aws:s3:::MyBucket/*" ] } ] } </code></pre>
0debug
Array of arrays with #include<array> in C++ : how can I create array of arrays with #include <array>? My solution is array<array<int, sze>, sze> arcpp { 0, 1, 2, 3 , 4, 5, 6, 7, 8, 9, 10, 11 ,12, 13, 14, 15 }; for (auto i = 0; i < sze; i++) { cout << "\n"; for (auto j = 0; j < sze; j++) { cout << "\t" << arcpp[i][j]; } } But I would like something like that: int matrix[][sze] = { {0, 1, 2, 3}, {4, 5, 6, 7}, {8, 9, 10, 11}, {12, 13, 14, 15} };
0debug
static inline void _t_gen_mov_env_TN(int offset, TCGv tn) { if (offset > sizeof(CPUCRISState)) { fprintf(stderr, "wrong store to env at off=%d\n", offset); } tcg_gen_st_tl(tn, cpu_env, offset); }
1threat
replace a string in localizable.strings file (ios files) using command line : <p>I have to replace a string in all places in a file Localizable.strings ( a iOS file).</p> <p>Please download this file <a href="https://www.dropbox.com/s/m692njpkyubftd9/localizable.strings?dl=0" rel="nofollow noreferrer">here</a></p> <p>For example: I need to replace "terms" with "xxxx"</p> <p>I tried all possibilities:</p> <pre> perl -ps 's/terms/xxxx/g' localizable.strings sed -i "" "s/terms/xxxx/g' localizable.strings cat localizable.strings | awk '{gsub(/terms/,"xxxx")}1' </pre> <p>I think this localizable.strings file contains "unicode" character, so I add:</p> <pre> LANG=C LC_ALL=C </pre> <p>before perl, sed, and awk. But it doesn't work.</p>
0debug
Error with firebaseUI when building the porject : I am a beginner with firebase .i try to use firebaseUI ,but there is An error occurred like this .how can i solve it:[enter image description here][1] [1]: https://i.stack.imgur.com/G7Ci9.jpg
0debug
Integrate Spring Boot with JBOSS EAP Server : <p>1) Can Spring-boot use JBOSS EAP 7.0 server as an embedded server?</p> <p>2) please let us know, if any one can the sample code for the above. </p>
0debug
static bool virtio_blk_sect_range_ok(VirtIOBlock *dev, uint64_t sector, size_t size) { uint64_t nb_sectors = size >> BDRV_SECTOR_BITS; uint64_t total_sectors; if (nb_sectors > INT_MAX) { return false; } if (sector & dev->sector_mask) { return false; } if (size % dev->conf.conf.logical_block_size) { return false; } blk_get_geometry(dev->blk, &total_sectors); if (sector > total_sectors || nb_sectors > total_sectors - sector) { return false; } return true; }
1threat
Can anyone tell me why this function is not adding node to last and how can i solve it? : <p>here is the c language code:</p> <pre><code>struct node { int num; struct node* next; }; void add_last(struct node* head,struct node* new_node) { new_node-&gt;next=head; head=new_node; } </code></pre> <p>I dont need code , I only want to understand why this is not working thanks in advance.</p>
0debug
static inline void softusb_read_dmem(MilkymistSoftUsbState *s, uint32_t offset, uint8_t *buf, uint32_t len) { if (offset + len >= s->dmem_size) { error_report("milkymist_softusb: read dmem out of bounds " "at offset 0x%x, len %d", offset, len); return; } memcpy(buf, s->dmem_ptr + offset, len); }
1threat
how I filter the input result from some words like kill, gun using simple python if statement : <p>I want to filter the x result to know which category would be appended to </p> <pre><code>def bot(): kids = [] adults = [] index = 0 x = input("enter movie name ") for side in x: if x == "gun" or x == "kill": kids.append(x) else: adults.append(x) print(kids) print(adults) </code></pre> <p>what if x == "top gun" it will ignore it </p> <p>I need to make it if x has "kill or gun, etc" don't add it to category less than 16 years old recommends</p>
0debug
See size of Kafka Topics in Bytes : <p>For Metrics we meed to see the total size of a Kafka Topic in bytes across all partitions and brokers. </p> <p>I have been searching for quite a while on how to do this and I haven't worked out if this is possible and how to do it.</p> <p>We are on V0.82 of Kafka.</p>
0debug
How to style FormControlLabel font size : <p>How do you set the in-line font size on a Material-UI FormControlLabel? The below attempt does not work.</p> <pre><code>const styles: any = createStyles({ formControlLabel: { fontSize: '0.6rem', '&amp; label': { fontSize: '0.6rem' } } }); &lt;FormControlLabel style={styles.formControlLabel} control={&lt;Checkbox value="Hello" color="primary" /&gt;} label="World" /&gt; </code></pre>
0debug
ImportError: No module named ssl_match_hostname when importing the docker SDK for Python : <p>In order to use the <a href="https://docker-py.readthedocs.io/en/stable/client.html" rel="noreferrer">Docker SDK for Python</a>, I'm trying to <code>import docker</code> in a Python script, but it's resulting in an <code>ImportError</code> with the following traceback:</p> <pre><code>Traceback (most recent call last): File "/home/kurt/dev/clones8/ipercron-compose/furion/iclib/tests/test_utils/docker_utils.py", line 1, in &lt;module&gt; import docker File "/home/kurt/.local/lib/python2.7/site-packages/docker/__init__.py", line 6, in &lt;module&gt; from .client import Client, AutoVersionClient, from_env # flake8: noqa File "/home/kurt/.local/lib/python2.7/site-packages/docker/client.py", line 11, in &lt;module&gt; from . import api File "/home/kurt/.local/lib/python2.7/site-packages/docker/api/__init__.py", line 2, in &lt;module&gt; from .build import BuildApiMixin File "/home/kurt/.local/lib/python2.7/site-packages/docker/api/build.py", line 9, in &lt;module&gt; from .. import utils File "/home/kurt/.local/lib/python2.7/site-packages/docker/utils/__init__.py", line 2, in &lt;module&gt; from .utils import ( File "/home/kurt/.local/lib/python2.7/site-packages/docker/utils/utils.py", line 19, in &lt;module&gt; from .. import tls File "/home/kurt/.local/lib/python2.7/site-packages/docker/tls.py", line 5, in &lt;module&gt; from .ssladapter import ssladapter File "/home/kurt/.local/lib/python2.7/site-packages/docker/ssladapter/__init__.py", line 1, in &lt;module&gt; from .ssladapter import SSLAdapter # flake8: noqa File "/home/kurt/.local/lib/python2.7/site-packages/docker/ssladapter/ssladapter.py", line 21, in &lt;module&gt; from backports.ssl_match_hostname import match_hostname ImportError: No module named ssl_match_hostname [Finished in 0.2s with exit code 1] [shell_cmd: python -u "/home/kurt/dev/clones8/ipercron-compose/furion/iclib/tests/test_utils/docker_utils.py"] [dir: /home/kurt/dev/clones8/ipercron-compose/furion/iclib/tests/test_utils] [path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin] </code></pre> <p>The strange thing is that the import does work in other places, for example in an iPython prompt:</p> <pre><code>Python 2.7.12 (default, Nov 19 2016, 06:48:10) Type "copyright", "credits" or "license" for more information. IPython 2.4.1 -- An enhanced Interactive Python. ? -&gt; Introduction and overview of IPython's features. %quickref -&gt; Quick reference. help -&gt; Python's own help system. object? -&gt; Details about 'object', use 'object??' for extra details. In [1]: import docker In [2]: </code></pre> <p>Why is the import not working in the first case?</p>
0debug
void helper_ldf_asi(target_ulong addr, int asi, int size, int rd) { unsigned int i; target_ulong val; helper_check_align(addr, 3); addr = asi_address_mask(env, asi, addr); switch (asi) { case 0xf0: case 0xf1: case 0xf8: LE case 0xf9: LE *(uint32_t *)&env->fpr[rd++] = helper_ld_asi(addr, asi & 0x8f, 4, default: break; val = helper_ld_asi(addr, asi, size, 0); switch(size) { default: case 4: *((uint32_t *)&env->fpr[rd]) = val; break; case 8: *((int64_t *)&DT0) = val; break; case 16: break;
1threat
How to fix "NullPointerException" in viewmodel.setText? : <p>I'm trying to pass the user information from MainActivity to one of the fragments in my NavigationHeader and i keep getting a NullPointerException everytime i try to setText in the Fragment.</p> <p>I tried using the Bundle and Interface approach before trying ViewModel. Also getActivity() warns me that it's null.</p> <pre><code>public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener { private DrawerLayout drawer; //NavHeader private TextView header_name, header_email; //SessionManager SessionManager sessionManager; //maps private static final String TAG = "MainActivity"; private static final int ERROR_DIALOG_REQUEST = 9001; private static final String FINELOCATION = Manifest.permission.ACCESS_FINE_LOCATION; private static final String COURSELOCATION = Manifest.permission.ACCESS_COARSE_LOCATION; private Boolean mLocationPermissionsGranted = false; private static final int LOCATION_PERMISSION_REQUEST_CODE = 1234; private static final float DEFAULT_ZOOM = 15f; private FusedLocationProviderClient mFusedLocationProviderClient; private GoogleMap mMap; String pontopartida, pontochegada; private EditText ponto_partidaInput, ponto_chegadaInput; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //GET USER DATA sessionManager = new SessionManager(this); sessionManager.checkLogin(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); View headerView = navigationView.getHeaderView(0); header_name = (TextView) headerView.findViewById(R.id.header_name); header_email = (TextView) headerView.findViewById(R.id.header_email); HashMap&lt;String, String&gt; user = sessionManager.getUserDetail(); String mName = user.get(sessionManager.NAME); String mEmail = user.get(sessionManager.EMAIL); header_name.setText(mName); header_email.setText(mEmail); //Navigation Drawer Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); drawer = findViewById(R.id.drawer_layout); navigationView.setNavigationItemSelectedListener(this); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.addDrawerListener(toggle); toggle.syncState(); @Override public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) { switch (menuItem.getItemId()){ case R.id.nav_myaccount: getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyAccountFragment()).commit(); break; case R.id.nav_settings: getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new SettingsFragment()).commit(); break; case R.id.nav_logout: sessionManager.logout(); break; case R.id.nav_share: Toast.makeText(this, "Shared", Toast.LENGTH_SHORT).show(); break; } drawer.closeDrawer(GravityCompat.START); return true; } @Override public void onBackPressed() { if(drawer.isDrawerOpen(GravityCompat.START)){ drawer.closeDrawer(GravityCompat.START); }else{ super.onBackPressed(); } } } </code></pre> <p>and MyAccountFragment</p> <pre><code> public class MyAccountFragment extends Fragment { private SharedViewModel viewModel; private EditText account_name; private EditText account_email; protected FragmentActivity mActivity; @Nullable @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_myaccount, container, false); account_name = (EditText) view.findViewById(R.id.name_accountfrag); account_email = (EditText) view.findViewById(R.id.email_accountfrag); viewModel.setText(account_name.getText().toString()); return view; } @Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); viewModel = ViewModelProviders.of(getActivity()).get(SharedViewModel.class); viewModel.getText().observe(getViewLifecycleOwner(), new Observer&lt;String&gt;() { @Override public void onChanged(@Nullable String s) { account_name.setText(s); } }); } } </code></pre> <p>Also here is my error log</p> <pre><code> E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.tiago.teleperformance, PID: 9236 java.lang.NullPointerException: Attempt to invoke virtual method 'void com.example.tiago.teleperformance.SharedViewModel.setText(java.lang.String)' on a null object reference at com.example.tiago.teleperformance.MyAccountFragment.onCreateView(MyAccountFragment.java:42) at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411) at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366) at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273) at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:733) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6541) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767) </code></pre> <p>I was expecting it to update the information in the Fragment with the same Name and Email in the MainActivity as soon as i opened it. Instead it crashes. Can anyone help me?</p>
0debug
Why are my breakpoints not hit in CLion? : <p>I'm trying to debug an executable which has been created with CMake configuration</p> <pre><code>SET(CMAKE_BUILD_TYPE Debug) </code></pre> <p>However, CLion does not hit any breakpoints. What could be the problem?</p>
0debug
How to use @HostBinding with @Input properties in Angular 2? : <p>(Angular 2 RC4)</p> <p>With <a href="https://angular.io/docs/ts/latest/api/core/index/HostBinding-var.html">@HostBinding</a> we should be able to modify properties of the host, right? My question is, does this apply to @Input() properties as well and if so, what is the correct usage? If not, is there another way to achieve this?</p> <p>I made a Plunker here to illustrate my problem: <a href="https://embed.plnkr.co/kQEKbT/">https://embed.plnkr.co/kQEKbT/</a></p> <p>Suppose I have a custom component:</p> <pre><code>@Component({ selector: 'custom-img', template: ` &lt;img src="{{src}}"&gt; ` }) export class CustomImgComponent { @Input() src: string; } </code></pre> <p>And I want to feed the src property with an attribute directive:</p> <pre><code>@Directive({ selector: '[srcKey]' }) export class SrcKeyDirective implements OnChanges { @Input() srcKey: string; @HostBinding() src; ngOnChanges() { this.src = `https://www.google.com.mt/images/branding/googlelogo/2x/${this.srcKey}_color_272x92dp.png`; } } </code></pre> <p>Why can't this directive change the [src] input property of the custom component?</p> <pre><code>@Component({ selector: 'my-app', directives: [CustomImgComponent, SrcKeyDirective], template: `&lt;custom-img [srcKey]="imageKey"&gt;&lt;/custom-img&gt;` }) export class AppComponent { imageKey = "googlelogo"; } </code></pre> <p>Thanks!</p>
0debug
C/C++ : Using both implementations of string in the same code : I would like to know whether the following code is "valid": <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-c++ --> #include <iostream> using namespace std; int main(void) { string s="Hello World!\n"; for (int i=0;i<s.size();++i) { for (int j=0;j<s[i];++j) { cout << "+"; } cout << ".>\n"; } } <!-- end snippet --> I made this code but I don't know if I should add some ".c_str" or else, to make it better code. Thanks in advance. See you.
0debug
How to match a word in regex : <p>(//.[com]{3,3})</p> <p>After trying the code it see both :. com &amp; moc Please is there way to make it see only com</p>
0debug
int ff_h264_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) { H264Context *h = dst->priv_data, *h1 = src->priv_data; int inited = h->context_initialized, err = 0; int context_reinitialized = 0; int i, ret; if (dst == src) return 0; if (inited && (h->width != h1->width || h->height != h1->height || h->mb_width != h1->mb_width || h->mb_height != h1->mb_height || h->sps.bit_depth_luma != h1->sps.bit_depth_luma || h->sps.chroma_format_idc != h1->sps.chroma_format_idc || h->sps.colorspace != h1->sps.colorspace)) { h->avctx->bits_per_raw_sample = h->sps.bit_depth_luma; h->width = h1->width; h->height = h1->height; h->mb_height = h1->mb_height; h->mb_width = h1->mb_width; h->mb_num = h1->mb_num; h->mb_stride = h1->mb_stride; h->b_stride = h1->b_stride; if ((ret = copy_parameter_set((void **)h->sps_buffers, (void **)h1->sps_buffers, MAX_SPS_COUNT, sizeof(SPS))) < 0) return ret; h->sps = h1->sps; if ((ret = copy_parameter_set((void **)h->pps_buffers, (void **)h1->pps_buffers, MAX_PPS_COUNT, sizeof(PPS))) < 0) return ret; h->pps = h1->pps; if ((err = h264_slice_header_init(h, 1)) < 0) { av_log(h->avctx, AV_LOG_ERROR, "h264_slice_header_init() failed\n"); return err; } context_reinitialized = 1; #if 0 h264_set_parameter_from_sps(h); h->cur_chroma_format_idc = h1->cur_chroma_format_idc; #endif } memcpy(h->block_offset, h1->block_offset, sizeof(h->block_offset)); if (!inited) { H264SliceContext *orig_slice_ctx = h->slice_ctx; for (i = 0; i < MAX_SPS_COUNT; i++) av_freep(h->sps_buffers + i); for (i = 0; i < MAX_PPS_COUNT; i++) av_freep(h->pps_buffers + i); ff_h264_unref_picture(h, &h->last_pic_for_ec); memcpy(h, h1, sizeof(H264Context)); memset(h->sps_buffers, 0, sizeof(h->sps_buffers)); memset(h->pps_buffers, 0, sizeof(h->pps_buffers)); memset(&h->cur_pic, 0, sizeof(h->cur_pic)); memset(&h->last_pic_for_ec, 0, sizeof(h->last_pic_for_ec)); h->slice_ctx = orig_slice_ctx; memset(&h->slice_ctx[0].er, 0, sizeof(h->slice_ctx[0].er)); memset(&h->slice_ctx[0].mb, 0, sizeof(h->slice_ctx[0].mb)); memset(&h->slice_ctx[0].mb_luma_dc, 0, sizeof(h->slice_ctx[0].mb_luma_dc)); memset(&h->slice_ctx[0].mb_padding, 0, sizeof(h->slice_ctx[0].mb_padding)); h->avctx = dst; h->DPB = NULL; h->qscale_table_pool = NULL; h->mb_type_pool = NULL; h->ref_index_pool = NULL; h->motion_val_pool = NULL; h->intra4x4_pred_mode= NULL; h->non_zero_count = NULL; h->slice_table_base = NULL; h->slice_table = NULL; h->cbp_table = NULL; h->chroma_pred_mode_table = NULL; memset(h->mvd_table, 0, sizeof(h->mvd_table)); h->direct_table = NULL; h->list_counts = NULL; h->mb2b_xy = NULL; h->mb2br_xy = NULL; if (h1->context_initialized) { h->context_initialized = 0; memset(&h->cur_pic, 0, sizeof(h->cur_pic)); av_frame_unref(&h->cur_pic.f); h->cur_pic.tf.f = &h->cur_pic.f; ret = ff_h264_alloc_tables(h); if (ret < 0) { av_log(dst, AV_LOG_ERROR, "Could not allocate memory\n"); return ret; } ret = ff_h264_slice_context_init(h, &h->slice_ctx[0]); if (ret < 0) { av_log(dst, AV_LOG_ERROR, "context_init() failed.\n"); return ret; } } h->context_initialized = h1->context_initialized; } h->avctx->coded_height = h1->avctx->coded_height; h->avctx->coded_width = h1->avctx->coded_width; h->avctx->width = h1->avctx->width; h->avctx->height = h1->avctx->height; h->coded_picture_number = h1->coded_picture_number; h->first_field = h1->first_field; h->picture_structure = h1->picture_structure; h->droppable = h1->droppable; h->low_delay = h1->low_delay; for (i = 0; h->DPB && i < H264_MAX_PICTURE_COUNT; i++) { ff_h264_unref_picture(h, &h->DPB[i]); if (h1->DPB && h1->DPB[i].f.buf[0] && (ret = ff_h264_ref_picture(h, &h->DPB[i], &h1->DPB[i])) < 0) return ret; } h->cur_pic_ptr = REBASE_PICTURE(h1->cur_pic_ptr, h, h1); ff_h264_unref_picture(h, &h->cur_pic); if (h1->cur_pic.f.buf[0]) { ret = ff_h264_ref_picture(h, &h->cur_pic, &h1->cur_pic); if (ret < 0) return ret; } h->workaround_bugs = h1->workaround_bugs; h->low_delay = h1->low_delay; h->droppable = h1->droppable; h->is_avc = h1->is_avc; if ((ret = copy_parameter_set((void **)h->sps_buffers, (void **)h1->sps_buffers, MAX_SPS_COUNT, sizeof(SPS))) < 0) return ret; h->sps = h1->sps; if ((ret = copy_parameter_set((void **)h->pps_buffers, (void **)h1->pps_buffers, MAX_PPS_COUNT, sizeof(PPS))) < 0) return ret; h->pps = h1->pps; copy_fields(h, h1, dequant4_buffer, dequant4_coeff); for (i = 0; i < 6; i++) h->dequant4_coeff[i] = h->dequant4_buffer[0] + (h1->dequant4_coeff[i] - h1->dequant4_buffer[0]); for (i = 0; i < 6; i++) h->dequant8_coeff[i] = h->dequant8_buffer[0] + (h1->dequant8_coeff[i] - h1->dequant8_buffer[0]); h->dequant_coeff_pps = h1->dequant_coeff_pps; copy_fields(h, h1, poc_lsb, default_ref_list); copy_fields(h, h1, short_ref, current_slice); copy_picture_range(h->short_ref, h1->short_ref, 32, h, h1); copy_picture_range(h->long_ref, h1->long_ref, 32, h, h1); copy_picture_range(h->delayed_pic, h1->delayed_pic, MAX_DELAYED_PIC_COUNT + 2, h, h1); h->frame_recovered = h1->frame_recovered; if (context_reinitialized) ff_h264_set_parameter_from_sps(h); if (!h->cur_pic_ptr) return 0; if (!h->droppable) { err = ff_h264_execute_ref_pic_marking(h, h->mmco, h->mmco_index); h->prev_poc_msb = h->poc_msb; h->prev_poc_lsb = h->poc_lsb; } h->prev_frame_num_offset = h->frame_num_offset; h->prev_frame_num = h->frame_num; h->outputed_poc = h->next_outputed_poc; h->recovery_frame = h1->recovery_frame; return err; }
1threat
C++ How to create a class template that allows no argument list in its constructor : I apologize if my title is confusing. What I'm trying to do is create a class template implementing the std::map from scratch. What I want to achieve is to not use specific data types in the argument list of my constructor. Please see the code below: #include "pch.h" #include <iostream> #include <string> using namespace std; template<typename T, typename N> class MyCustomMap { public: MyCustomMap(); T* keys; N* values; }; template<typename T, typename N> MyCustomMap<T, N>::MyCustomMap() { this->keys = new T[10]; this->values = new N[10]; } .... .... int main() { MyCustomMap<int,string> map; //This works because I specified the argument list MyCustomMap map; //This is my goal return 0; } Is this possible? Any help is appreciated, thank you.
0debug
Generate random equations with random numbers : <p>I want to generate random equations in JavaScriptp and then output them into an HTML tag. This is the code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;body&gt; &lt;p&gt;Click the button below to generate a random equation.&lt;/p&gt; &lt;button onclick="change();"&gt;Generate&lt;/button&gt; &lt;p id="generate"&gt;&lt;/p&gt; &lt;script&gt; function getRandomizer(bottom, top) { return function() { return Math.floor( Math.random() * ( 1 + top - bottom ) ) + bottom; } } function getRandomNumber(results) { var rollDie = getRandomizer( 1, 10 ); for ( var i = 0; i &lt; 3; i++ ) { results += rollDie() + ""; } getRandomNumber.result = results; } function getRandomEquation(num1, num2, num3, num4, num5, num6, num7, output) { var num_7, num_6, num_5, num_4, num_3, num_2, num_1 getRandomNumber(num1).result = num_7; getRandomNumber(num2).result = num_6; getRandomNumber(num3).result = num_5; getRandomNumber(num4).result = num_4; getRandomNumber(num5).result = num_3; getRandomNumber(num6).result = num_2; getRandomNumber(num7).result = num_1; var equation1 = "" + num_1 + " x " + num_2 + " + {" + num_3 + " x [(" + num_4 + " x " + num_5 + ") - " + num_6 + "] + " + num_7 + "} = x", equation2 = "" + num_1 + " x " + num_2 + " = y", equation3 = "" + num_1 + "s x " + num_2 + " = z, s = " + num_3, equation4 = "" + num_1 + " + {" + num_2 + " x [" + num_3 + " + (" + num_4 + " x " + num_5 + ") + " + num_6 + "] + " + num_7 + "} = x", equation5 = "" + num_1 + "e + " + num_2 + "l x " + num_3 + " + " + num_4 + "a, e = " + num_5 + ", l = " + num_6 + ", a = " + num_7, equation6 = "[" + num_1 + " x " + num_2 + "z] + {" + num_3 + " - " + num_4 + "} + (" + num_5 + " + " + num_6 + ") = e, z = " + num_7, equation7 = "p" + " x " + num_1 + " / " + num_2 + " - " + num_3 + " + " + num_4 + " = e, p = " + num_5 var values = [ // there is an easier way to do this, too lazy "" + equation1, "" + equation2, "" + equation3, "" + equation4, "" + equation5, "" + equation6, "" + equation7 ] var i = 0; var e; if (i &gt; values.length) { i = 0; } var randomEquation = values[i]; i++; e = values[i]; this.output = randomEquation; this.e = e; } function getEquation() { var bl1, bl2, bl3, bl4, bl5, bl6, bl7, equationOutput; var eq = getRandomEquation(bl1, bl2, bl3, bl4, bl5, bl6, bl7, equationOutput).e; getEquation.equation = eq; } function change() { var final = getEquation().equation; document.getElementById("generate").innerHTML = final; } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>But it dosen't work. Any help?</p> <p>P.S. My teacher assigned this to me. Please respond as soon as possible. Thanks.</p>
0debug
Creating a new variable in R : <p>The data set contains four columns (id, x1, x2, and y1). Notice that there are some multiple records (by id).</p> <p>Here is the data:</p> <pre><code>id &lt;- c(1, 1, 1, 1, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 6) x1 &lt;- c("a","b","c","a","a","a","c","c","b", "e", "w", "r", "b", "c", "w", "r") x2 &lt;- c(0.12, 0.76, 0.08, 0.11, 0.80, 0.24, 0.19, 0.07, 0.70, 0.64, 0.97, 0.04, 0.40, 0.67, 0.25, 0.01) y1 &lt;- c(1132, 1464, 454, 1479, 167, 335, 280, 391, 973, 1343, 777, 1333, 293, 694, 76, 114) mdat &lt;- data.frame(id, x1, x2, y1) </code></pre> <p>I want to create a new column (let's call it y2). ys is defined as</p> <p>y2(i) = y1(i-1) for the same id. Not that for data with onlu one id, then y2=NA.</p> <p>Here is the output:</p> <pre><code>id x1 x2 y1 y2 1 a 0.12 1132 1 b 0.76 1464 1132 1 c 0.08 454 1464 1 a 0.11 1479 454 2 a 0.8 167 3 a 0.24 335 3 c 0.19 280 335 3 c 0.07 391 280 4 b 0.7 973 4 e 0.64 1343 973 4 w 0.97 777 1343 4 r 0.04 1333 777 5 b 0.4 293 5 c 0.67 694 293 5 w 0.25 76 694 6 r 0.01 114 </code></pre>
0debug
In need of an IDE to make an app with a powerful Ui : <p>I'm starting to study mobile development and i want to know what is the best language/IDE to develop an app with a powerful UI. I prefer a android native app over a web one, but it can be an hybrid. I've already tried with C# in visual studio and xamarin, but it looks confusing. I want to build those crazy smooth modern and flat UI apps, so what's the best IDE?</p>
0debug
How to create an array constructor for my class? : <p>I would like to create a constructor, which is similar to the <code>int</code> array constructor: <code>int foo[3] = { 4, 5, 6 };</code></p> <p>But I would like to use it like this:</p> <pre><code>MyClass&lt;3&gt; foo = { 4, 5, 6 }; </code></pre> <p>There is a private <code>n</code> size array in my class:</p> <pre><code>template&lt;const int n=2&gt; class MyClass { public: // code... private: int numbers[n]; // code... }; </code></pre>
0debug
Show entire bottom sheet with EditText above Keyboard : <p>I'm implementing a UI where a bottom sheet will appear above the keyboard with an EditText for the user to enter a value. The problem is the View is being partially overlapped by the keyboard, covering up the bottom of the bottom sheet.</p> <p>Here is the Bottom Sheet and no keyboard.</p> <p><a href="https://i.stack.imgur.com/Yz3x1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Yz3x1.png" alt="Bottom Sheet"></a></p> <p>Here is the Bottom Sheet with the keyboard showing.</p> <p><a href="https://i.stack.imgur.com/9THkr.png" rel="noreferrer"><img src="https://i.stack.imgur.com/9THkr.png" alt="enter image description here"></a></p> <p>What's the best method to ensure the entire Bottom Sheet is shown?</p> <p>Thanks.</p>
0debug