problem
stringlengths
26
131k
labels
class label
2 classes
Mail script needs ran every hour, Cron not working. Help Plz, Open to Ideas? : Thank you for your time and help. Below is the fully functioning code. It works when I call it via the browser. However, I can't get my Cron job to run it. I greatly appreciate any help you have as I have tried coming up with any solution and am open to any ideas that will make this script fire off once every hour 24/7 365 so to speak. Info: *Hostgator *PHP 5.4 *Link for Hostgator Cron commands - http://support.hostgator.com/articles/cpanel/what-do-i-put-for-the-cron-job-command?utm_source=cPanel&utm_medium=message&utm_campaign=Cron%20Jobs I have tried the following: **when doing any of these I have yet to have it add a sale to the database or send a single email** */opt/php54/bin/php /home1/user/public_html/Sales/scripts/sales-notif_em.php - Could not open input file: /home1/user/public_html/scripts/sales-notif_em.php *php /home1/user/public_html/Sales/scripts/sales-notif_em.php - blank email with nothing but this showing: Content-type: text/html *php -q /home1/lotscav1/public_html/Sales/scripts/sales_notif_me.php - I don't get any emails from the system of course */usr/bin/curl home1/user/public_html/scripts/sales-notif_em.php - curl: (3) <url> malformed *any command (like php or /usr/bin/curl) that has the second half with http://website.c0m/Sales/scripts/sales_notif_em.php - causes a JSON Error when trying to add the Cron job I have checked the following things: *File permissions are 655 *Timestamp is less than an hour old under the customers table <?php //find out current time and 1 hour ago date_default_timezone_set('America/New_York'); $current_time = strtotime("now"); $hour_ago = strtotime('-1 hour'); ////////////////////////////////////////////////////////////////// /////////////////l// Connect to Sales Database /////////////////// ////////////////////////////////////////////////////////////////// $mysqli_s = new mysqli("localhost", "user", "password", "server_sales_data"); if ($mysqli_s->connect_errno) { echo "Failed to connect to MySQL: (" . $mysqli_s->connect_errno . ") " . $mysqli_s->connect_error; } ////////////////////////////////////////////////////////////////// ///////////////////// Connect to EM Database //////////////////// ////////////////////////////////////////////////////////////////// $mysqli_em = new mysqli("localhost", "user", "password", "server_dlgEM"); if ($mysqli_em->connect_errno) { echo "Failed to connect to MySQL_EM: (" . $mysqli_em->connect_errno . ") " . $mysqli_em->connect_error; } //Grab store name $dlg_store = "EM"; $em_request = "SELECT * FROM customers WHERE date BETWEEN '$hour_ago' AND '$current_time'"; $em_result = mysqli_query($mysqli_em, $em_request) or die("Error No Sales EM"); while ($em_row = mysqli_fetch_array($em_result)) { $em_prod_num = $em_row["prod_num"]; $em_receipt = $em_row["receipt"]; ////////////////////////////////////////////////////////////////// ///////////////////// Grab info for EM Sales //////////////////// ////////////////////////////////////////////////////////////////// $request_s = "SELECT * FROM all_products WHERE dlgprod_num='$em_prod_num' AND dlg_store='$dlg_store'"; $result_s = mysqli_query($mysqli_s, $request_s) or die("Error dlg prod num EM"); while ($row_s = mysqli_fetch_array($result_s)) { $sku_s = $row_s["sku"]; $dlgprod_num_s = $row_s["dlgprod_num"]; $book_title_s = addslashes($row_s["book_title"]); $dlgprod_price_s = $row_s["dlgprod_price"]; $author_name_s = addslashes($row_s["author_name"]); $author_email_s = $row_s["author_email"]; $publisher_s = $row_s["publisher"]; $dlg_store_s = $row_s["dlg_store"]; $add_sql_s = "INSERT INTO all_author_sales SET `sku`='$sku_s', `dlgprod_num`='$dlgprod_num_s', `dlgprod_nam`='$book_title_s', `dlgprod_price`='$dlgprod_price_s', `author_name`='$author_name_s', `author_email`='$author_email_s', `publisher`='$publisher_s', `dlg_store`='$dlg_store_s', `dlgcustomer_receipt`='$em_receipt' "; //create signature $sig = "The Admin Team at www.website.com"; //to $admin_email = "admin@website.com"; $to = array($author_email_s, $admin_email); //setup email headers $headers='From: ' . $admin_email . "\r\n" . 'Reply-To: ' . $admin_email . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $headers .= $emailbody."\n\n"; //email subject and body $subject = "Your book stats"; $message = " Hi $author_name_s,<br /> I just wanted to send you a message and let you know that the book or books below have just been purchased.<br /><br /> Store: $dlg_store_s<br /> Receipt: $em_receipt<br /> Sku Number: $sku_s<br /><br /> Book Title: $book_title_s<br /> Publisher: $publisher_s<br /> Product Number: $dlgprod_num_s<br /> Price: $dlgprod_price_s<br /><br /> Sincerely,<br /> $sig<br /><br /> To remove yourself from this notification, please send an email to $admin_email with Unsubscribe in the subject line. "; if ($mysqli_s->multi_query($add_sql_s) === TRUE) { mail (implode(',', $to), $subject, $message, $headers); } else { echo "Error: " . $add_sql_s . "<br>" . $mysqli_s- >error . "<br>" . $string; } } } ?>
0debug
How To Remove Options From Dropdown : I have 2 dropdown's. 1 is for user to pick 'time from', The 2nd is to pick 'time until'. In order to assure the user does not pick a time on the second dropdown that is b4 the 1st time. I want to remove from the second dropdown all times that are earlier then the time picked in the 1st dropdown {via javascript). How can I do this? <select class="fromWhen form-control" name="From" id=""> <option value=""></option> <option value="12:00:00">12:00 PM</option> <option value="12:30:00">12:30 PM</option> <option value="13:00:00">1:00 PM</option> <option value="13:30:00">1:30 PM</option> <option value="14:00:00">2:00 PM</option> </select> <select class="untilWhen form-control " name="Until" id=""> <option value=""></option> <option value="12:00:00">12:00 PM</option> <option value="12:30:00">12:30 PM</option> <option value="13:00:00">1:00 PM</option> <option value="13:30:00">1:30 PM</option> <option value="14:00:00">2:00 PM</option> </select>
0debug
Linux sh Script for files older than : I have a backup of mysql databases and backup file is with time and date in name, like this daily_amavisd_2016-10-01_05h28m_Saturday.sql.gz daily_amavisd_2016-10-02_05h28m_Sunday.sql.gz daily_amavisd_2016-10-03_05h28m_Monday.sql.gz So I need a script to check if the oldest file in folder /backup/amavisd/daily is not older than one week. If it is older than one week it gives me status "backup failed" if it is not older than 1 week than gives me status "backup OK" Can someone help me with sh script for that?
0debug
My android app stop responding after the Splash Screen : i'm programming a new app which contain a splash screen i finished it and it was all good but after i opened android studio again to work on the navigation bar i tried to run the app to see the result but the application stop and crash after the display of the splash screen this is Main class package com.example.computer.bsinfoshop; public class Main extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } } and this is the class od splash screen package com.example.computer.bsinfoshop; import android.graphics.Typeface; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.content.Intent; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; public class Screen extends AppCompatActivity { TextView tv; ImageView img; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_screen); tv = (TextView)findViewById(R.id.textView); img = (ImageView)findViewById(R.id.imageView); Typeface font = Typeface.createFromAsset(getAssets(),"fonts/Satisfy-Regular.ttf"); tv.setTypeface(font); img.setImageResource(R.drawable.rsz_2rsz_img); Thread timerThread = new Thread(){ public void run(){ try { sleep(3700); } catch(InterruptedException e) { e.printStackTrace(); } finally { Intent intent = new Intent(Screen.this , Main.class); startActivity(intent); } } }; timerThread.start(); } @Override protected void onPause() { super.onPause(); finish(); } } and here where i think is the problem the manifest file <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.computer.bsinfoshop"> <application android:allowBackup="true" android:icon="@drawable/logo" android:label="@string/app_name"> <activity android:name=".Screen" android:theme="@style/App"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name=".Information" android:label="Information" android:theme="@style/AppTheme"> </activity> <activity android:name="com.example.computer.bsinfoshop.Main" android:theme="@style/AppTheme"> </activity> </application> </manifest> so i just want to know what is the problem in my code to fix it and thank you ^^
0debug
add xml child in first index of an array using php : im stuck for hours to solve this problem. i have multiple array contains mathml(xml) element. for example my arraylist <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> Array ( [0] => <mi>x</mi><mo>=</mo><mfrac><mrow><mo>-</mo><mi>b</mi> <mo>±</mo><msqrt><msup><mi>b</mi><mn>2</mn></msup><mo>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac> [1] => <mi>x</mi><mo>+</mo><mn>2</mn><mo>=</mo><mn>3</mn> [2] => <mfrac><mrow><mn>2</mn><mi>x</mi><mo>+</mo><mn>2</mn></mrow><mn>3</mn></mfrac><mo>-</mo><mn>3</mn><mo>=</mo><mn>2</mn> [3] => <mo>-</mo><mn>3</mn><mo>+</mo><mn>2</mn><mo>=</mo><mi>x</mi> ) <!-- end snippet --> i want all array start with <mo>, if its start with <mo> and then it fine like array [3]. for example the array i want <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> Array ( [0] =><mo>+</mo><mi>x</mi><mo>=</mo><mfrac><mrow><mo>-</mo><mi>b</mi><mo>±</mo><msqrt><msup><mi>b</mi><mn>2</mn></msup><mo>-</mo><mn>4</mn><mi>a</mi><mi>c</mi></msqrt></mrow><mrow><mn>2</mn><mi>a</mi></mrow></mfrac> [1] =><mo>+</mo><mi>x</mi><mo>+</mo><mn>2</mn><mo>=</mo><mn>3</mn> [2] =><mo>+</mo><mfrac><mrow><mn>2</mn><mi>x</mi><mo>+</mo><mn>2</mn></mrow><mn>3</mn></mfrac><mo>-</mo><mn>3</mn><mo>=</mo><mn>2</mn> [3] =><mo>-</mo><mn>3</mn><mo>+</mo><mn>2</mn><mo>=</mo><mi>x</mi> ) <!-- end snippet --> as you can see all array start with <mo>, below is my current coding to add it <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> $ress = array(); $arr_result=[]; for ($i=0; $i <= $length ; $i++) { $ress=$result[$i]; if ($pos = (substr($ress,0,3)!="<mo>")) { $arr_result[]=array_unshift($ress, "<mo>+</mo>"); } else{ $arr_result[]=$ress; } } print_r($arr_result); <!-- end snippet --> $result store the array. thanks in advance
0debug
Endless For Loop : <p>This might be a silly question, but i can't actually understand why this FOR loop is running infinitely. The code is given below:</p> <pre><code>for(int k=0;k&lt;size-1;k++){ for(int i=k+1;i&lt;size;i++){ for(int j=k+1;j&lt;size;j++){ if(k=0){ a[i][j]=((a[i][j]*a[k][k]) - (a[i][k]*a[k][j])); }else{ a[i][j]=((a[i][j]*a[k][k]) - (a[i][k]*a[k][j]))/a[k-1][k-1]; } } } } </code></pre> <p>In my case the value of size is 3, can anyone tell me why this is going to an infinite loop?</p>
0debug
University of south africa : Good day I am trying to write a that will prompt me to enter five integer numbers and store them in an array. The program should then add 5 to those elements divisible by 5. Then I want to display the modified array. A sample run: Enter an integer number: 10 Enter an integer number: 8 Enter an integer number: 15 Enter an integer number: 9 Enter an integer number: 44 The modified array is: 15 8 20 9 44
0debug
static void disas_arm_insn(CPUARMState * env, DisasContext *s) { unsigned int cond, insn, val, op1, i, shift, rm, rs, rn, rd, sh; TCGv_i32 tmp; TCGv_i32 tmp2; TCGv_i32 tmp3; TCGv_i32 addr; TCGv_i64 tmp64; insn = arm_ldl_code(env, s->pc, s->bswap_code); s->pc += 4; if (IS_M(env)) goto illegal_op; cond = insn >> 28; if (cond == 0xf){ ARCH(5); if (((insn >> 25) & 7) == 1) { if (!arm_feature(env, ARM_FEATURE_NEON)) goto illegal_op; if (disas_neon_data_insn(env, s, insn)) goto illegal_op; return; } if ((insn & 0x0f100000) == 0x04000000) { if (!arm_feature(env, ARM_FEATURE_NEON)) goto illegal_op; if (disas_neon_ls_insn(env, s, insn)) goto illegal_op; return; } if ((insn & 0x0f000e10) == 0x0e000a00) { if (disas_vfp_insn(env, s, insn)) { goto illegal_op; } return; } if (((insn & 0x0f30f000) == 0x0510f000) || ((insn & 0x0f30f010) == 0x0710f000)) { if ((insn & (1 << 22)) == 0) { if (!arm_feature(env, ARM_FEATURE_V7MP)) { goto illegal_op; } } ARCH(5TE); return; } if (((insn & 0x0f70f000) == 0x0450f000) || ((insn & 0x0f70f010) == 0x0650f000)) { ARCH(7); return; } if (((insn & 0x0f700000) == 0x04100000) || ((insn & 0x0f700010) == 0x06100000)) { if (!arm_feature(env, ARM_FEATURE_V7MP)) { goto illegal_op; } return; } if ((insn & 0x0ffffdff) == 0x01010000) { ARCH(6); if (((insn >> 9) & 1) != s->bswap_code) { qemu_log_mask(LOG_UNIMP, "arm: unimplemented setend\n"); goto illegal_op; } return; } else if ((insn & 0x0fffff00) == 0x057ff000) { switch ((insn >> 4) & 0xf) { case 1: ARCH(6K); gen_clrex(s); return; case 4: case 5: case 6: ARCH(7); return; default: goto illegal_op; } } else if ((insn & 0x0e5fffe0) == 0x084d0500) { if (IS_USER(s)) { goto illegal_op; } ARCH(6); gen_srs(s, (insn & 0x1f), (insn >> 23) & 3, insn & (1 << 21)); return; } else if ((insn & 0x0e50ffe0) == 0x08100a00) { int32_t offset; if (IS_USER(s)) goto illegal_op; ARCH(6); rn = (insn >> 16) & 0xf; addr = load_reg(s, rn); i = (insn >> 23) & 3; switch (i) { case 0: offset = -4; break; case 1: offset = 0; break; case 2: offset = -8; break; case 3: offset = 4; break; default: abort(); } if (offset) tcg_gen_addi_i32(addr, addr, offset); tmp = tcg_temp_new_i32(); gen_aa32_ld32u(tmp, addr, 0); tcg_gen_addi_i32(addr, addr, 4); tmp2 = tcg_temp_new_i32(); gen_aa32_ld32u(tmp2, addr, 0); if (insn & (1 << 21)) { switch (i) { case 0: offset = -8; break; case 1: offset = 4; break; case 2: offset = -4; break; case 3: offset = 0; break; default: abort(); } if (offset) tcg_gen_addi_i32(addr, addr, offset); store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } gen_rfe(s, tmp, tmp2); return; } else if ((insn & 0x0e000000) == 0x0a000000) { int32_t offset; val = (uint32_t)s->pc; tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, val); store_reg(s, 14, tmp); offset = (((int32_t)insn) << 8) >> 8; val += (offset << 2) | ((insn >> 23) & 2) | 1; val += 4; gen_bx_im(s, val); return; } else if ((insn & 0x0e000f00) == 0x0c000100) { if (arm_feature(env, ARM_FEATURE_IWMMXT)) { if (env->cp15.c15_cpar & (1 << 1)) if (!disas_iwmmxt_insn(env, s, insn)) return; } } else if ((insn & 0x0fe00000) == 0x0c400000) { ARCH(5TE); } else if ((insn & 0x0f000010) == 0x0e000010) { } else if ((insn & 0x0ff10020) == 0x01000000) { uint32_t mask; uint32_t val; if (IS_USER(s)) return; mask = val = 0; if (insn & (1 << 19)) { if (insn & (1 << 8)) mask |= CPSR_A; if (insn & (1 << 7)) mask |= CPSR_I; if (insn & (1 << 6)) mask |= CPSR_F; if (insn & (1 << 18)) val |= mask; } if (insn & (1 << 17)) { mask |= CPSR_M; val |= (insn & 0x1f); } if (mask) { gen_set_psr_im(s, mask, 0, val); } return; } goto illegal_op; } if (cond != 0xe) { s->condlabel = gen_new_label(); arm_gen_test_cc(cond ^ 1, s->condlabel); s->condjmp = 1; } if ((insn & 0x0f900000) == 0x03000000) { if ((insn & (1 << 21)) == 0) { ARCH(6T2); rd = (insn >> 12) & 0xf; val = ((insn >> 4) & 0xf000) | (insn & 0xfff); if ((insn & (1 << 22)) == 0) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, val); } else { tmp = load_reg(s, rd); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_ori_i32(tmp, tmp, val << 16); } store_reg(s, rd, tmp); } else { if (((insn >> 12) & 0xf) != 0xf) goto illegal_op; if (((insn >> 16) & 0xf) == 0) { gen_nop_hint(s, insn & 0xff); } else { val = insn & 0xff; shift = ((insn >> 8) & 0xf) * 2; if (shift) val = (val >> shift) | (val << (32 - shift)); i = ((insn & (1 << 22)) != 0); if (gen_set_psr_im(s, msr_mask(env, s, (insn >> 16) & 0xf, i), i, val)) goto illegal_op; } } } else if ((insn & 0x0f900000) == 0x01000000 && (insn & 0x00000090) != 0x00000090) { op1 = (insn >> 21) & 3; sh = (insn >> 4) & 0xf; rm = insn & 0xf; switch (sh) { case 0x0: if (op1 & 1) { tmp = load_reg(s, rm); i = ((op1 & 2) != 0); if (gen_set_psr(s, msr_mask(env, s, (insn >> 16) & 0xf, i), i, tmp)) goto illegal_op; } else { rd = (insn >> 12) & 0xf; if (op1 & 2) { if (IS_USER(s)) goto illegal_op; tmp = load_cpu_field(spsr); } else { tmp = tcg_temp_new_i32(); gen_helper_cpsr_read(tmp, cpu_env); } store_reg(s, rd, tmp); } break; case 0x1: if (op1 == 1) { ARCH(4T); tmp = load_reg(s, rm); gen_bx(s, tmp); } else if (op1 == 3) { ARCH(5); rd = (insn >> 12) & 0xf; tmp = load_reg(s, rm); gen_helper_clz(tmp, tmp); store_reg(s, rd, tmp); } else { goto illegal_op; } break; case 0x2: if (op1 == 1) { ARCH(5J); tmp = load_reg(s, rm); gen_bx(s, tmp); } else { goto illegal_op; } break; case 0x3: if (op1 != 1) goto illegal_op; ARCH(5); tmp = load_reg(s, rm); tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, s->pc); store_reg(s, 14, tmp2); gen_bx(s, tmp); break; case 0x4: { uint32_t c = extract32(insn, 8, 4); if (!arm_feature(env, ARM_FEATURE_CRC) || op1 == 0x3 || (c & 0xd) != 0) { goto illegal_op; } rn = extract32(insn, 16, 4); rd = extract32(insn, 12, 4); tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); tmp3 = tcg_const_i32(1 << op1); if (c & 0x2) { gen_helper_crc32c(tmp, tmp, tmp2, tmp3); } else { gen_helper_crc32(tmp, tmp, tmp2, tmp3); } tcg_temp_free_i32(tmp2); tcg_temp_free_i32(tmp3); store_reg(s, rd, tmp); break; } case 0x5: ARCH(5TE); rd = (insn >> 12) & 0xf; rn = (insn >> 16) & 0xf; tmp = load_reg(s, rm); tmp2 = load_reg(s, rn); if (op1 & 2) gen_helper_double_saturate(tmp2, cpu_env, tmp2); if (op1 & 1) gen_helper_sub_saturate(tmp, cpu_env, tmp, tmp2); else gen_helper_add_saturate(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); break; case 7: { int imm16 = extract32(insn, 0, 4) | (extract32(insn, 8, 12) << 4); if (op1 != 1) { goto illegal_op; } ARCH(5); gen_exception_insn(s, 4, EXCP_BKPT, syn_aa32_bkpt(imm16, false)); break; } case 0x8: case 0xa: case 0xc: case 0xe: ARCH(5TE); rs = (insn >> 8) & 0xf; rn = (insn >> 12) & 0xf; rd = (insn >> 16) & 0xf; if (op1 == 1) { tmp = load_reg(s, rm); tmp2 = load_reg(s, rs); if (sh & 4) tcg_gen_sari_i32(tmp2, tmp2, 16); else gen_sxth(tmp2); tmp64 = gen_muls_i64_i32(tmp, tmp2); tcg_gen_shri_i64(tmp64, tmp64, 16); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); if ((sh & 2) == 0) { tmp2 = load_reg(s, rn); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } store_reg(s, rd, tmp); } else { tmp = load_reg(s, rm); tmp2 = load_reg(s, rs); gen_mulxy(tmp, tmp2, sh & 2, sh & 4); tcg_temp_free_i32(tmp2); if (op1 == 2) { tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); tcg_temp_free_i32(tmp); gen_addq(s, tmp64, rn, rd); gen_storeq_reg(s, rn, rd, tmp64); tcg_temp_free_i64(tmp64); } else { if (op1 == 0) { tmp2 = load_reg(s, rn); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } store_reg(s, rd, tmp); } } break; default: goto illegal_op; } } else if (((insn & 0x0e000000) == 0 && (insn & 0x00000090) != 0x90) || ((insn & 0x0e000000) == (1 << 25))) { int set_cc, logic_cc, shiftop; op1 = (insn >> 21) & 0xf; set_cc = (insn >> 20) & 1; logic_cc = table_logic_cc[op1] & set_cc; if (insn & (1 << 25)) { val = insn & 0xff; shift = ((insn >> 8) & 0xf) * 2; if (shift) { val = (val >> shift) | (val << (32 - shift)); } tmp2 = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp2, val); if (logic_cc && shift) { gen_set_CF_bit31(tmp2); } } else { rm = (insn) & 0xf; tmp2 = load_reg(s, rm); shiftop = (insn >> 5) & 3; if (!(insn & (1 << 4))) { shift = (insn >> 7) & 0x1f; gen_arm_shift_im(tmp2, shiftop, shift, logic_cc); } else { rs = (insn >> 8) & 0xf; tmp = load_reg(s, rs); gen_arm_shift_reg(tmp2, shiftop, tmp, logic_cc); } } if (op1 != 0x0f && op1 != 0x0d) { rn = (insn >> 16) & 0xf; tmp = load_reg(s, rn); } else { TCGV_UNUSED_I32(tmp); } rd = (insn >> 12) & 0xf; switch(op1) { case 0x00: tcg_gen_and_i32(tmp, tmp, tmp2); if (logic_cc) { gen_logic_CC(tmp); } store_reg_bx(env, s, rd, tmp); break; case 0x01: tcg_gen_xor_i32(tmp, tmp, tmp2); if (logic_cc) { gen_logic_CC(tmp); } store_reg_bx(env, s, rd, tmp); break; case 0x02: if (set_cc && rd == 15) { if (IS_USER(s)) { goto illegal_op; } gen_sub_CC(tmp, tmp, tmp2); gen_exception_return(s, tmp); } else { if (set_cc) { gen_sub_CC(tmp, tmp, tmp2); } else { tcg_gen_sub_i32(tmp, tmp, tmp2); } store_reg_bx(env, s, rd, tmp); } break; case 0x03: if (set_cc) { gen_sub_CC(tmp, tmp2, tmp); } else { tcg_gen_sub_i32(tmp, tmp2, tmp); } store_reg_bx(env, s, rd, tmp); break; case 0x04: if (set_cc) { gen_add_CC(tmp, tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); } store_reg_bx(env, s, rd, tmp); break; case 0x05: if (set_cc) { gen_adc_CC(tmp, tmp, tmp2); } else { gen_add_carry(tmp, tmp, tmp2); } store_reg_bx(env, s, rd, tmp); break; case 0x06: if (set_cc) { gen_sbc_CC(tmp, tmp, tmp2); } else { gen_sub_carry(tmp, tmp, tmp2); } store_reg_bx(env, s, rd, tmp); break; case 0x07: if (set_cc) { gen_sbc_CC(tmp, tmp2, tmp); } else { gen_sub_carry(tmp, tmp2, tmp); } store_reg_bx(env, s, rd, tmp); break; case 0x08: if (set_cc) { tcg_gen_and_i32(tmp, tmp, tmp2); gen_logic_CC(tmp); } tcg_temp_free_i32(tmp); break; case 0x09: if (set_cc) { tcg_gen_xor_i32(tmp, tmp, tmp2); gen_logic_CC(tmp); } tcg_temp_free_i32(tmp); break; case 0x0a: if (set_cc) { gen_sub_CC(tmp, tmp, tmp2); } tcg_temp_free_i32(tmp); break; case 0x0b: if (set_cc) { gen_add_CC(tmp, tmp, tmp2); } tcg_temp_free_i32(tmp); break; case 0x0c: tcg_gen_or_i32(tmp, tmp, tmp2); if (logic_cc) { gen_logic_CC(tmp); } store_reg_bx(env, s, rd, tmp); break; case 0x0d: if (logic_cc && rd == 15) { if (IS_USER(s)) { goto illegal_op; } gen_exception_return(s, tmp2); } else { if (logic_cc) { gen_logic_CC(tmp2); } store_reg_bx(env, s, rd, tmp2); } break; case 0x0e: tcg_gen_andc_i32(tmp, tmp, tmp2); if (logic_cc) { gen_logic_CC(tmp); } store_reg_bx(env, s, rd, tmp); break; default: case 0x0f: tcg_gen_not_i32(tmp2, tmp2); if (logic_cc) { gen_logic_CC(tmp2); } store_reg_bx(env, s, rd, tmp2); break; } if (op1 != 0x0f && op1 != 0x0d) { tcg_temp_free_i32(tmp2); } } else { op1 = (insn >> 24) & 0xf; switch(op1) { case 0x0: case 0x1: sh = (insn >> 5) & 3; if (sh == 0) { if (op1 == 0x0) { rd = (insn >> 16) & 0xf; rn = (insn >> 12) & 0xf; rs = (insn >> 8) & 0xf; rm = (insn) & 0xf; op1 = (insn >> 20) & 0xf; switch (op1) { case 0: case 1: case 2: case 3: case 6: tmp = load_reg(s, rs); tmp2 = load_reg(s, rm); tcg_gen_mul_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); if (insn & (1 << 22)) { ARCH(6T2); tmp2 = load_reg(s, rn); tcg_gen_sub_i32(tmp, tmp2, tmp); tcg_temp_free_i32(tmp2); } else if (insn & (1 << 21)) { tmp2 = load_reg(s, rn); tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } if (insn & (1 << 20)) gen_logic_CC(tmp); store_reg(s, rd, tmp); break; case 4: ARCH(6); tmp = load_reg(s, rs); tmp2 = load_reg(s, rm); tmp64 = gen_mulu_i64_i32(tmp, tmp2); gen_addq_lo(s, tmp64, rn); gen_addq_lo(s, tmp64, rd); gen_storeq_reg(s, rn, rd, tmp64); tcg_temp_free_i64(tmp64); break; case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: tmp = load_reg(s, rs); tmp2 = load_reg(s, rm); if (insn & (1 << 22)) { tcg_gen_muls2_i32(tmp, tmp2, tmp, tmp2); } else { tcg_gen_mulu2_i32(tmp, tmp2, tmp, tmp2); } if (insn & (1 << 21)) { TCGv_i32 al = load_reg(s, rn); TCGv_i32 ah = load_reg(s, rd); tcg_gen_add2_i32(tmp, tmp2, tmp, tmp2, al, ah); tcg_temp_free_i32(al); tcg_temp_free_i32(ah); } if (insn & (1 << 20)) { gen_logicq_cc(tmp, tmp2); } store_reg(s, rn, tmp); store_reg(s, rd, tmp2); break; default: goto illegal_op; } } else { rn = (insn >> 16) & 0xf; rd = (insn >> 12) & 0xf; if (insn & (1 << 23)) { int op2 = (insn >> 8) & 3; op1 = (insn >> 21) & 0x3; switch (op2) { case 0: if (op1 == 1) { goto illegal_op; } ARCH(8); break; case 1: goto illegal_op; case 2: ARCH(8); break; case 3: if (op1) { ARCH(6K); } else { ARCH(6); } break; } addr = tcg_temp_local_new_i32(); load_reg_var(s, addr, rn); if (op2 == 0) { if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); switch (op1) { case 0: gen_aa32_ld32u(tmp, addr, IS_USER(s)); break; case 2: gen_aa32_ld8u(tmp, addr, IS_USER(s)); break; case 3: gen_aa32_ld16u(tmp, addr, IS_USER(s)); break; default: abort(); } store_reg(s, rd, tmp); } else { rm = insn & 0xf; tmp = load_reg(s, rm); switch (op1) { case 0: gen_aa32_st32(tmp, addr, IS_USER(s)); break; case 2: gen_aa32_st8(tmp, addr, IS_USER(s)); break; case 3: gen_aa32_st16(tmp, addr, IS_USER(s)); break; default: abort(); } tcg_temp_free_i32(tmp); } } else if (insn & (1 << 20)) { switch (op1) { case 0: gen_load_exclusive(s, rd, 15, addr, 2); break; case 1: gen_load_exclusive(s, rd, rd + 1, addr, 3); break; case 2: gen_load_exclusive(s, rd, 15, addr, 0); break; case 3: gen_load_exclusive(s, rd, 15, addr, 1); break; default: abort(); } } else { rm = insn & 0xf; switch (op1) { case 0: gen_store_exclusive(s, rd, rm, 15, addr, 2); break; case 1: gen_store_exclusive(s, rd, rm, rm + 1, addr, 3); break; case 2: gen_store_exclusive(s, rd, rm, 15, addr, 0); break; case 3: gen_store_exclusive(s, rd, rm, 15, addr, 1); break; default: abort(); } } tcg_temp_free_i32(addr); } else { rm = (insn) & 0xf; addr = load_reg(s, rn); tmp = load_reg(s, rm); tmp2 = tcg_temp_new_i32(); if (insn & (1 << 22)) { gen_aa32_ld8u(tmp2, addr, IS_USER(s)); gen_aa32_st8(tmp, addr, IS_USER(s)); } else { gen_aa32_ld32u(tmp2, addr, IS_USER(s)); gen_aa32_st32(tmp, addr, IS_USER(s)); } tcg_temp_free_i32(tmp); tcg_temp_free_i32(addr); store_reg(s, rd, tmp2); } } } else { int address_offset; int load; rn = (insn >> 16) & 0xf; rd = (insn >> 12) & 0xf; addr = load_reg(s, rn); if (insn & (1 << 24)) gen_add_datah_offset(s, insn, 0, addr); address_offset = 0; if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); switch(sh) { case 1: gen_aa32_ld16u(tmp, addr, IS_USER(s)); break; case 2: gen_aa32_ld8s(tmp, addr, IS_USER(s)); break; default: case 3: gen_aa32_ld16s(tmp, addr, IS_USER(s)); break; } load = 1; } else if (sh & 2) { ARCH(5TE); if (sh & 1) { tmp = load_reg(s, rd); gen_aa32_st32(tmp, addr, IS_USER(s)); tcg_temp_free_i32(tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = load_reg(s, rd + 1); gen_aa32_st32(tmp, addr, IS_USER(s)); tcg_temp_free_i32(tmp); load = 0; } else { tmp = tcg_temp_new_i32(); gen_aa32_ld32u(tmp, addr, IS_USER(s)); store_reg(s, rd, tmp); tcg_gen_addi_i32(addr, addr, 4); tmp = tcg_temp_new_i32(); gen_aa32_ld32u(tmp, addr, IS_USER(s)); rd++; load = 1; } address_offset = -4; } else { tmp = load_reg(s, rd); gen_aa32_st16(tmp, addr, IS_USER(s)); tcg_temp_free_i32(tmp); load = 0; } if (!(insn & (1 << 24))) { gen_add_datah_offset(s, insn, address_offset, addr); store_reg(s, rn, addr); } else if (insn & (1 << 21)) { if (address_offset) tcg_gen_addi_i32(addr, addr, address_offset); store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } if (load) { store_reg(s, rd, tmp); } } break; case 0x4: case 0x5: goto do_ldst; case 0x6: case 0x7: if (insn & (1 << 4)) { ARCH(6); rm = insn & 0xf; rn = (insn >> 16) & 0xf; rd = (insn >> 12) & 0xf; rs = (insn >> 8) & 0xf; switch ((insn >> 23) & 3) { case 0: op1 = (insn >> 20) & 7; tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); sh = (insn >> 5) & 7; if ((op1 & 3) == 0 || sh == 5 || sh == 6) goto illegal_op; gen_arm_parallel_addsub(op1, sh, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); break; case 1: if ((insn & 0x00700020) == 0) { tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); shift = (insn >> 7) & 0x1f; if (insn & (1 << 6)) { if (shift == 0) shift = 31; tcg_gen_sari_i32(tmp2, tmp2, shift); tcg_gen_andi_i32(tmp, tmp, 0xffff0000); tcg_gen_ext16u_i32(tmp2, tmp2); } else { if (shift) tcg_gen_shli_i32(tmp2, tmp2, shift); tcg_gen_ext16u_i32(tmp, tmp); tcg_gen_andi_i32(tmp2, tmp2, 0xffff0000); } tcg_gen_or_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((insn & 0x00200020) == 0x00200000) { tmp = load_reg(s, rm); shift = (insn >> 7) & 0x1f; if (insn & (1 << 6)) { if (shift == 0) shift = 31; tcg_gen_sari_i32(tmp, tmp, shift); } else { tcg_gen_shli_i32(tmp, tmp, shift); } sh = (insn >> 16) & 0x1f; tmp2 = tcg_const_i32(sh); if (insn & (1 << 22)) gen_helper_usat(tmp, cpu_env, tmp, tmp2); else gen_helper_ssat(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((insn & 0x00300fe0) == 0x00200f20) { tmp = load_reg(s, rm); sh = (insn >> 16) & 0x1f; tmp2 = tcg_const_i32(sh); if (insn & (1 << 22)) gen_helper_usat16(tmp, cpu_env, tmp, tmp2); else gen_helper_ssat16(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((insn & 0x00700fe0) == 0x00000fa0) { tmp = load_reg(s, rn); tmp2 = load_reg(s, rm); tmp3 = tcg_temp_new_i32(); tcg_gen_ld_i32(tmp3, cpu_env, offsetof(CPUARMState, GE)); gen_helper_sel_flags(tmp, tmp3, tmp, tmp2); tcg_temp_free_i32(tmp3); tcg_temp_free_i32(tmp2); store_reg(s, rd, tmp); } else if ((insn & 0x000003e0) == 0x00000060) { tmp = load_reg(s, rm); shift = (insn >> 10) & 3; if (shift != 0) tcg_gen_rotri_i32(tmp, tmp, shift * 8); op1 = (insn >> 20) & 7; switch (op1) { case 0: gen_sxtb16(tmp); break; case 2: gen_sxtb(tmp); break; case 3: gen_sxth(tmp); break; case 4: gen_uxtb16(tmp); break; case 6: gen_uxtb(tmp); break; case 7: gen_uxth(tmp); break; default: goto illegal_op; } if (rn != 15) { tmp2 = load_reg(s, rn); if ((op1 & 3) == 0) { gen_add16(tmp, tmp2); } else { tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } } store_reg(s, rd, tmp); } else if ((insn & 0x003f0f60) == 0x003f0f20) { tmp = load_reg(s, rm); if (insn & (1 << 22)) { if (insn & (1 << 7)) { gen_revsh(tmp); } else { ARCH(6T2); gen_helper_rbit(tmp, tmp); } } else { if (insn & (1 << 7)) gen_rev16(tmp); else tcg_gen_bswap32_i32(tmp, tmp); } store_reg(s, rd, tmp); } else { goto illegal_op; } break; case 2: switch ((insn >> 20) & 0x7) { case 5: if (((insn >> 6) ^ (insn >> 7)) & 1) { goto illegal_op; } tmp = load_reg(s, rm); tmp2 = load_reg(s, rs); tmp64 = gen_muls_i64_i32(tmp, tmp2); if (rd != 15) { tmp = load_reg(s, rd); if (insn & (1 << 6)) { tmp64 = gen_subq_msw(tmp64, tmp); } else { tmp64 = gen_addq_msw(tmp64, tmp); } } if (insn & (1 << 5)) { tcg_gen_addi_i64(tmp64, tmp64, 0x80000000u); } tcg_gen_shri_i64(tmp64, tmp64, 32); tmp = tcg_temp_new_i32(); tcg_gen_trunc_i64_i32(tmp, tmp64); tcg_temp_free_i64(tmp64); store_reg(s, rn, tmp); break; case 0: case 4: if (insn & (1 << 7)) { goto illegal_op; } tmp = load_reg(s, rm); tmp2 = load_reg(s, rs); if (insn & (1 << 5)) gen_swap_half(tmp2); gen_smul_dual(tmp, tmp2); if (insn & (1 << 6)) { tcg_gen_sub_i32(tmp, tmp, tmp2); } else { gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); } tcg_temp_free_i32(tmp2); if (insn & (1 << 22)) { tmp64 = tcg_temp_new_i64(); tcg_gen_ext_i32_i64(tmp64, tmp); tcg_temp_free_i32(tmp); gen_addq(s, tmp64, rd, rn); gen_storeq_reg(s, rd, rn, tmp64); tcg_temp_free_i64(tmp64); } else { if (rd != 15) { tmp2 = load_reg(s, rd); gen_helper_add_setq(tmp, cpu_env, tmp, tmp2); tcg_temp_free_i32(tmp2); } store_reg(s, rn, tmp); } break; case 1: case 3: if (!arm_feature(env, ARM_FEATURE_ARM_DIV)) { goto illegal_op; } if (((insn >> 5) & 7) || (rd != 15)) { goto illegal_op; } tmp = load_reg(s, rm); tmp2 = load_reg(s, rs); if (insn & (1 << 21)) { gen_helper_udiv(tmp, tmp, tmp2); } else { gen_helper_sdiv(tmp, tmp, tmp2); } tcg_temp_free_i32(tmp2); store_reg(s, rn, tmp); break; default: goto illegal_op; } break; case 3: op1 = ((insn >> 17) & 0x38) | ((insn >> 5) & 7); switch (op1) { case 0: ARCH(6); tmp = load_reg(s, rm); tmp2 = load_reg(s, rs); gen_helper_usad8(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); if (rd != 15) { tmp2 = load_reg(s, rd); tcg_gen_add_i32(tmp, tmp, tmp2); tcg_temp_free_i32(tmp2); } store_reg(s, rn, tmp); break; case 0x20: case 0x24: case 0x28: case 0x2c: ARCH(6T2); shift = (insn >> 7) & 0x1f; i = (insn >> 16) & 0x1f; i = i + 1 - shift; if (rm == 15) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, 0); } else { tmp = load_reg(s, rm); } if (i != 32) { tmp2 = load_reg(s, rd); tcg_gen_deposit_i32(tmp, tmp2, tmp, shift, i); tcg_temp_free_i32(tmp2); } store_reg(s, rd, tmp); break; case 0x12: case 0x16: case 0x1a: case 0x1e: case 0x32: case 0x36: case 0x3a: case 0x3e: ARCH(6T2); tmp = load_reg(s, rm); shift = (insn >> 7) & 0x1f; i = ((insn >> 16) & 0x1f) + 1; if (shift + i > 32) goto illegal_op; if (i < 32) { if (op1 & 0x20) { gen_ubfx(tmp, shift, (1u << i) - 1); } else { gen_sbfx(tmp, shift, i); } } store_reg(s, rd, tmp); break; default: goto illegal_op; } break; } break; } do_ldst: sh = (0xf << 20) | (0xf << 4); if (op1 == 0x7 && ((insn & sh) == sh)) { goto illegal_op; } rn = (insn >> 16) & 0xf; rd = (insn >> 12) & 0xf; tmp2 = load_reg(s, rn); i = (IS_USER(s) || (insn & 0x01200000) == 0x00200000); if (insn & (1 << 24)) gen_add_data_offset(s, insn, tmp2); if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); if (insn & (1 << 22)) { gen_aa32_ld8u(tmp, tmp2, i); } else { gen_aa32_ld32u(tmp, tmp2, i); } } else { tmp = load_reg(s, rd); if (insn & (1 << 22)) { gen_aa32_st8(tmp, tmp2, i); } else { gen_aa32_st32(tmp, tmp2, i); } tcg_temp_free_i32(tmp); } if (!(insn & (1 << 24))) { gen_add_data_offset(s, insn, tmp2); store_reg(s, rn, tmp2); } else if (insn & (1 << 21)) { store_reg(s, rn, tmp2); } else { tcg_temp_free_i32(tmp2); } if (insn & (1 << 20)) { store_reg_from_load(env, s, rd, tmp); } break; case 0x08: case 0x09: { int j, n, user, loaded_base; TCGv_i32 loaded_var; user = 0; if (insn & (1 << 22)) { if (IS_USER(s)) goto illegal_op; if ((insn & (1 << 15)) == 0) user = 1; } rn = (insn >> 16) & 0xf; addr = load_reg(s, rn); loaded_base = 0; TCGV_UNUSED_I32(loaded_var); n = 0; for(i=0;i<16;i++) { if (insn & (1 << i)) n++; } if (insn & (1 << 23)) { if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, 4); } else { } } else { if (insn & (1 << 24)) { tcg_gen_addi_i32(addr, addr, -(n * 4)); } else { if (n != 1) tcg_gen_addi_i32(addr, addr, -((n - 1) * 4)); } } j = 0; for(i=0;i<16;i++) { if (insn & (1 << i)) { if (insn & (1 << 20)) { tmp = tcg_temp_new_i32(); gen_aa32_ld32u(tmp, addr, IS_USER(s)); if (user) { tmp2 = tcg_const_i32(i); gen_helper_set_user_reg(cpu_env, tmp2, tmp); tcg_temp_free_i32(tmp2); tcg_temp_free_i32(tmp); } else if (i == rn) { loaded_var = tmp; loaded_base = 1; } else { store_reg_from_load(env, s, i, tmp); } } else { if (i == 15) { val = (long)s->pc + 4; tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, val); } else if (user) { tmp = tcg_temp_new_i32(); tmp2 = tcg_const_i32(i); gen_helper_get_user_reg(tmp, cpu_env, tmp2); tcg_temp_free_i32(tmp2); } else { tmp = load_reg(s, i); } gen_aa32_st32(tmp, addr, IS_USER(s)); tcg_temp_free_i32(tmp); } j++; if (j != n) tcg_gen_addi_i32(addr, addr, 4); } } if (insn & (1 << 21)) { if (insn & (1 << 23)) { if (insn & (1 << 24)) { } else { tcg_gen_addi_i32(addr, addr, 4); } } else { if (insn & (1 << 24)) { if (n != 1) tcg_gen_addi_i32(addr, addr, -((n - 1) * 4)); } else { tcg_gen_addi_i32(addr, addr, -(n * 4)); } } store_reg(s, rn, addr); } else { tcg_temp_free_i32(addr); } if (loaded_base) { store_reg(s, rn, loaded_var); } if ((insn & (1 << 22)) && !user) { tmp = load_cpu_field(spsr); gen_set_cpsr(tmp, 0xffffffff); tcg_temp_free_i32(tmp); s->is_jmp = DISAS_UPDATE; } } break; case 0xa: case 0xb: { int32_t offset; val = (int32_t)s->pc; if (insn & (1 << 24)) { tmp = tcg_temp_new_i32(); tcg_gen_movi_i32(tmp, val); store_reg(s, 14, tmp); } offset = sextract32(insn << 2, 0, 26); val += offset + 4; gen_jmp(s, val); } break; case 0xc: case 0xd: case 0xe: if (((insn >> 8) & 0xe) == 10) { if (disas_vfp_insn(env, s, insn)) { goto illegal_op; } } else if (disas_coproc_insn(env, s, insn)) { goto illegal_op; } break; case 0xf: gen_set_pc_im(s, s->pc); s->svc_imm = extract32(insn, 0, 24); s->is_jmp = DISAS_SWI; break; default: illegal_op: gen_exception_insn(s, 4, EXCP_UDEF, syn_uncategorized()); break; } } }
1threat
Text based game : <pre><code>"#TextBasedGame import random import time attackers=random.randint(0,100) val1=random.randint(0,1) health=100 bear=100 name=input("What is your name hero? ") print("Okay ",name," i need to teach you the basics of combat") time.sleep (1) print ("Bear spawns") if val1==0: print ("Bear attacks -25 HP") health=health -25 print ("Health = 75") attack=int(input("Press 1 to attack ")) if attack==1: print ("Bears HP -25") bear = bear -25 else: print ("Why didn't you attack?!?!?") if bear==100: print ("Bear =100") else: print ("Bear =75")" </code></pre> <p>If anyone could help me not do each health part and make it print it after every battle / attack that'd help. Please don't make it too complex this is my homework for school and i only started a few weeks ago.</p>
0debug
static void dec_sr(DisasContext *dc) { if (dc->format == OP_FMT_RI) { LOG_DIS("sri r%d, r%d, %d\n", dc->r1, dc->r0, dc->imm5); } else { LOG_DIS("sr r%d, r%d, r%d\n", dc->r2, dc->r0, dc->r1); } if (!(dc->env->features & LM32_FEATURE_SHIFT)) { if (dc->format == OP_FMT_RI) { } else { if (dc->imm5 != 1) { cpu_abort(dc->env, "hardware shifter is not available\n"); } } } if (dc->format == OP_FMT_RI) { tcg_gen_sari_tl(cpu_R[dc->r1], cpu_R[dc->r0], dc->imm5); } else { TCGv t0 = tcg_temp_new(); tcg_gen_andi_tl(t0, cpu_R[dc->r1], 0x1f); tcg_gen_sar_tl(cpu_R[dc->r2], cpu_R[dc->r0], t0); tcg_temp_free(t0); } }
1threat
Modify functions in R using body, formals and environment methods : <p><strong>function definition</strong></p> <pre><code>f &lt;- function(x) { x + x*x } </code></pre> <p>3 methods i.e. <code>body</code>, <code>formals</code> and <code>environment</code> can be used for modification</p> <p><strong>body</strong></p> <pre><code>&gt; body(f) { x + x * x } </code></pre> <p>If we want to change the body using <code>body</code></p> <pre><code>&gt; body(f) &lt;- expression({x*x*x}) &gt; f function (x) { x * x * x } </code></pre> <p>see its changed.</p> <p><strong>formals</strong></p> <p>If want to change the arguments using <code>formals</code> to <code>(x = 3, y = 6)</code></p> <pre><code>&gt; formals(f) &lt;- list(x = 3, y = 4) &gt; f function (x = 3, y = 4) { x * x * x } </code></pre> <p>see its changed.</p> <p>But if want to change the arguments to <code>(x, y)</code> instead. Obviously <code>formals(f) &lt;- list(x, y)</code> will not work.</p> <p>Any help will be appreciated.</p>
0debug
Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given : <p>I got this really weird problem that </p> <pre><code>Warning: mysql_fetch_row() expects parameter 1 to be resource, null given ... </code></pre> <p>however, I checked mysql_num_rows($result), and it is not 0.</p> <pre><code> echo '&lt;h3&gt;Comments&lt;/h3&gt;'; $comment_query = "select * from comments where post_id='$post_id' order by comment_timestamp desc"; $comment_result = mysql_query($comment_query) or die(mysql_error()); if (mysql_num_rows($comment_result) != 0) { while ($crow = mysql_fetch_assoc($commment_result)) { $comment_username = $crow['username']; $comment_text = $crow['comment_text']; $comment_time = $crow['comment_timestamp']; echo "&lt;b&gt;$comment_username &lt;/b&gt;&lt;b&gt;$comment_timestamp: &lt;/b&gt; &lt;br /&gt;".$comment_text."&lt;hr /&gt;&lt;br&gt;"; } } else { echo "No comments yet!"; } </code></pre> <p>Any ideas on that? I have been stuck with it for a while, really thanks for your help!</p>
0debug
How to move line up and down in VS2015 : <p>I don't know if something has changed recently in Visual Studio 2015 but before I was able to press <code>ALT + UP ARROW KEY</code> or <code>ALT + DOWN ARROW KEY</code> to move lines in code up or down and now it does not do anything.</p> <p>I went into <code>Tools &gt; Options &gt; Environment &gt; Keyboard</code> and I cannot find anything like in the past called <code>ProjectandSolutionContextMenus.Item.MoveUp</code> or <code>ProjectandSolutionContextMenus.Item.MoveDown</code></p> <p>Also here in the list of VS2015 I don't see that option: <a href="http://visualstudioshortcuts.com/2015/" rel="noreferrer">http://visualstudioshortcuts.com/2015/</a></p> <p>How to achieve this?</p>
0debug
get value of a checkbox in another fragment : I would like to get the value of my checkbox that is in my confiFragment and get that value in MainActivity . the configFragment is related to the confiActivity. I tried this method but i get a null ; can someone help me please? this is my fragment: public class configFragment extends android.support.v4.app.Fragment { CheckBox check; configActivity cmt; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.config_layout, container, false); check = (CheckBox) rootView.findViewById(R.id.checkbox1); TextView text1=(TextView) rootView.findViewById(R.id.text1); text1.setText("hello "); cmt=(configActivity) getActivity(); check.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if(check.isChecked()){ Log.d("status","checked"); //check.setChecked(true); cmt.checking=true; }else{ Log.d("status","not checked"); //check.setChecked(false); cmt.checking=false; } } }); //cmt.checking=load(); // check(); return rootView; } @Override public void onPause() { super.onPause(); save(check.isChecked()); } @Override public void onResume() { super.onResume(); check.setChecked(load()); } private void save(final boolean isChecked) { SharedPreferences sharedPreferences = getActivity().getPreferences(Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putBoolean("check", isChecked); editor.commit(); } public boolean load() { SharedPreferences sharedPreferences = getActivity().getPreferences(Context.MODE_PRIVATE); return sharedPreferences.getBoolean("check", check.isChecked()); } } and this is the activity of this fragment: public class configActivity extends SingleFragmentActivity { public Boolean checking; @Override protected Fragment createFragment() { return new configFragment(); } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); configFragment cf=new configFragment(); SharedPreferences sharedPreferences = this.getPreferences(Context.MODE_PRIVATE); checking=sharedPreferences.getBoolean("check", cf.check.isChecked()); } } and this is my main activity : public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView hello=(TextView) findViewById(R.id.hello); Button but1=(Button) findViewById(R.id.button1); but1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i=new Intent(MainActivity.this,configActivity.class); startActivity(i); } }); hello.setText("Hello world"); configActivity config=new configActivity(); Log.d("status of checking",config.checking.toString()); if(config.checking=true){ Log.d("checked","true"); }else{ Log.d("not checked","false"); } }
0debug
How to clear history in browser by using selenium webDriver? : <p>Actually I am using code as shown bellow but, I am getting error like.History.clear is not a function. Build info: version: '2.53.0', revision: '35ae25b', Can anyone help me out. What is the problem in this code?</p> <pre><code>JavascriptExecutor js=(JavascriptExecutor) driver; js.executeScript("History.clear();"); </code></pre> <p>Thanks, Nagaraj Ediger.</p>
0debug
uint64_t float64_to_uint64 (float64 a STATUS_PARAM) { int64_t v; v = int64_to_float64(INT64_MIN STATUS_VAR); v = float64_to_int64((a + v) STATUS_VAR); return v - INT64_MIN; }
1threat
How can I insert date in my SQL Server 2012? : <p>The date that is receive is in the format 'Wed Jan 01 02:00:00 IST 2020'.</p> <p>If I use hibernate, it automatically converts this format into '2020-01-01 02:00:00' but for this case I have to use native query.</p> <p>Is it possible in SQL SERVER 2012 to save the date 'Wed Jan 01 02:00:00 IST 2020' as the format '2020-01-01 02:00:00'?</p>
0debug
take input until input positive number : <p>Take two integers p &amp; q ... Sum should be printed of p to next q numbers including p .. if q &lt;= 0 , then it will take the value of q again ...</p> <p>Input :::: 3 2 Output :::: 7 (p=3 &amp; q = 2 ..... So from 3 to next 2 numbers are 3 &amp; 4 as it will be included in the sum ... Now we will have to print the sum of 3+4 and that's 7 )</p> <p>Input ::: 4 -1 1 Output :::. 4 ( as the next number is 4 )</p> <p>That means we have to start counting from the taken integer ....</p> <p>Solve it and drop the solution here ......</p> <pre><code>import java.util.Scanner; public class Ahmed { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int p=sc.nextInt(); int q=sc.nextInt(); int sum=0; if(q&gt;=0){ for(int i=1; i&lt;=q ;i++) { sum=p+sum; p++; } } else{ q=sc.nextInt(); for(int i=1; i&lt;=q ;i++) { sum=p+sum; p++; } } System.out.println(sum); } } </code></pre> <p>if I take input 4 -1 -1 there is a error. Loop will continue until I take q input a positive number or 0;</p> <p>Correct input 4 -1 -1 2 output 9. </p>
0debug
static HTTPContext *find_rtp_session_with_url(const char *url, const char *session_id) { HTTPContext *rtp_c; char path1[1024]; const char *path; char buf[1024]; int s; rtp_c = find_rtp_session(session_id); if (!rtp_c) return NULL; url_split(NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url); path = path1; if (*path == '/') path++; if(!strcmp(path, rtp_c->stream->filename)) return rtp_c; for(s=0; s<rtp_c->stream->nb_streams; ++s) { snprintf(buf, sizeof(buf), "%s/streamid=%d", rtp_c->stream->filename, s); if(!strncmp(path, buf, sizeof(buf))) { return rtp_c; } } return NULL; }
1threat
static int vhdx_create_new_region_table(BlockDriverState *bs, uint64_t image_size, uint32_t block_size, uint32_t sector_size, uint32_t log_size, bool use_zero_blocks, VHDXImageType type, uint64_t *metadata_offset) { int ret = 0; uint32_t offset = 0; void *buffer = NULL; uint64_t bat_file_offset; uint32_t bat_length; BDRVVHDXState *s = NULL; VHDXRegionTableHeader *region_table; VHDXRegionTableEntry *rt_bat; VHDXRegionTableEntry *rt_metadata; assert(metadata_offset != NULL); s = g_malloc0(sizeof(BDRVVHDXState)); s->chunk_ratio = (VHDX_MAX_SECTORS_PER_BLOCK) * (uint64_t) sector_size / (uint64_t) block_size; s->sectors_per_block = block_size / sector_size; s->virtual_disk_size = image_size; s->block_size = block_size; s->logical_sector_size = sector_size; vhdx_set_shift_bits(s); vhdx_calc_bat_entries(s); buffer = g_malloc0(VHDX_HEADER_BLOCK_SIZE); region_table = buffer; offset += sizeof(VHDXRegionTableHeader); rt_bat = buffer + offset; offset += sizeof(VHDXRegionTableEntry); rt_metadata = buffer + offset; region_table->signature = VHDX_REGION_SIGNATURE; region_table->entry_count = 2; rt_bat->guid = bat_guid; rt_bat->length = ROUND_UP(s->bat_entries * sizeof(VHDXBatEntry), MiB); rt_bat->file_offset = ROUND_UP(VHDX_HEADER_SECTION_END + log_size, MiB); s->bat_offset = rt_bat->file_offset; rt_metadata->guid = metadata_guid; rt_metadata->file_offset = ROUND_UP(rt_bat->file_offset + rt_bat->length, MiB); rt_metadata->length = 1 * MiB; *metadata_offset = rt_metadata->file_offset; bat_file_offset = rt_bat->file_offset; bat_length = rt_bat->length; vhdx_region_header_le_export(region_table); vhdx_region_entry_le_export(rt_bat); vhdx_region_entry_le_export(rt_metadata); vhdx_update_checksum(buffer, VHDX_HEADER_BLOCK_SIZE, offsetof(VHDXRegionTableHeader, checksum)); ret = vhdx_create_bat(bs, s, image_size, type, use_zero_blocks, bat_file_offset, bat_length); if (ret < 0) { goto exit; } ret = bdrv_pwrite(bs, VHDX_REGION_TABLE_OFFSET, buffer, VHDX_HEADER_BLOCK_SIZE); if (ret < 0) { goto exit; } ret = bdrv_pwrite(bs, VHDX_REGION_TABLE2_OFFSET, buffer, VHDX_HEADER_BLOCK_SIZE); if (ret < 0) { goto exit; } exit: g_free(s); g_free(buffer); return ret; }
1threat
Parse error: syntax error, unexpected 'function_construct' (T_STRING), expecting variable (T_VARIABLE) on line 4 : <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 error_reporting(E_ALL); ini_set('display_errors', '1'); require_once('..\includes\class-db.php'); $db = new DB; ?&gt;</code></pre> </div> </div> </p> <p>I am getting an error in line 4 I don't know why Thats my Error<br> Parse error: syntax error, unexpected 'function_construct' (T_STRING), expecting variable (T_VARIABLE) in C:\xampp\htdocs\cmc\includes\class-db.php on line 4</p> <p>Please help me out here "Thanks in advance"</p>
0debug
how can we embed google maps in our website and add our own locations? : <p>I not only wish to add map to my site but also add local locations on my own to tke map like the site one <a href="http://1ropani.com/Map.aspx" rel="nofollow noreferrer">here</a>.</p>
0debug
Angular Material and Jasmine : " No provider for InjectionToken MdDialogData! " : <p>I have a component which is meant to be used in an Angular Material MdDialog :</p> <pre><code>@Component({ ... }) export class MyComponent { constructor(@Inject(MD_DIALOG_DATA) public data: any, public dialogRef: MdDialogRef&lt;MyComponent&gt;) { ... } } </code></pre> <p>I am trying to Unit Test it with Jasmine :</p> <pre><code>describe('MyComponent', () =&gt; { let component: MyComponent; let fixture: ComponentFixture&lt;MyComponent&gt;; beforeEach(async(() =&gt; { TestBed.configureTestingModule({ imports: [ SharedTestingModule, ], declarations: [ MyComponent, ], }) .compileComponents(); })); ... }); </code></pre> <p>Unfortunately, I am getting the following error :</p> <blockquote> <p>Error: No provider for InjectionToken MdDialogData!</p> </blockquote> <p>SharedTestingModule imports and exports my custom Angular Material module, which itself imports and exports MdDialogModule.</p> <p>How can I get rid of this error?</p> <p>Thank you very much!</p> <pre><code>Angular 4.2.4 Angular Material 2.0.0-beta.7 Jasmine 2.5.3 </code></pre>
0debug
how to write method for sequential search through array? : <p>I am writing a java method which runs through an array and if a value is present, then it returns the index of the value. It is not compiling, but I don't know what part of my code isn't comprehensive.</p> <pre><code>import java.util.*; import static java.lang.System.out; public class Lab26 { public static void main(String[] args) { } public static int simpleSearch(int[] nums, int value) { int nul = 0; for (int i = 0; i &lt; nums.length; i++) { if (nums[i] == value) { return i; } } } } </code></pre>
0debug
static void init_block_index(VC1Context *v) { MpegEncContext *s = &v->s; ff_init_block_index(s); if (v->field_mode && !(v->second_field ^ v->tff)) { s->dest[0] += s->current_picture_ptr->f.linesize[0]; s->dest[1] += s->current_picture_ptr->f.linesize[1]; s->dest[2] += s->current_picture_ptr->f.linesize[2]; } }
1threat
FullCalendar JS modify day Names in mobile : <p>In desktop I want to have ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] days. And in mobile will change to ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].</p>
0debug
Item is shifted way too much to the left, no clue how to change the position? : Thank you for helping me, so for some odd reason all my column 1 items are moved to the left of my screen, and so I cannot see it unless I add a String with a bunch of spaces, eg. "----- This works" whereas '4' this would not work. In the table below I added an example if I add a bunch of spaces with a string and then with a normal number 1) I have tried googling for a solution but for some reason, I cannot find any likewise situations 2) I have tried to mess around with the layout but it only makes everything scrambled. I added a Picture of the code https://i.imgur.com/sRbgClT.png
0debug
Showing/hiding unlimited number of divs based on time : I have this simple JavaScript yet: $("body").children("div").each( function( ) { $(this).hide(); }); The goal is: - hide every direct children divs (completed :) - show first direct children div - hide that first div, show second - hide that second div, show third etc. - no matter how many divs there is it - time for how long div stays displayed bassed on variable How can I do that?
0debug
static attribute_align_arg void *frame_worker_thread(void *arg) { PerThreadContext *p = arg; FrameThreadContext *fctx = p->parent; AVCodecContext *avctx = p->avctx; const AVCodec *codec = avctx->codec; pthread_mutex_lock(&p->mutex); while (1) { while (p->state == STATE_INPUT_READY && !fctx->die) pthread_cond_wait(&p->input_cond, &p->mutex); if (fctx->die) break; if (!codec->update_thread_context && (avctx->thread_safe_callbacks || ( #if FF_API_GET_BUFFER !avctx->get_buffer && #endif avctx->get_buffer2 == avcodec_default_get_buffer2))) ff_thread_finish_setup(avctx); avcodec_get_frame_defaults(&p->frame); p->got_frame = 0; p->result = codec->decode(avctx, &p->frame, &p->got_frame, &p->avpkt); p->frame.extended_data = p->frame.data; if (p->state == STATE_SETTING_UP) ff_thread_finish_setup(avctx); pthread_mutex_lock(&p->progress_mutex); #if 0 for (i = 0; i < MAX_BUFFERS; i++) if (p->progress_used[i] && (p->got_frame || p->result<0 || avctx->codec_id != AV_CODEC_ID_H264)) { p->progress[i][0] = INT_MAX; p->progress[i][1] = INT_MAX; } #endif p->state = STATE_INPUT_READY; pthread_cond_broadcast(&p->progress_cond); pthread_cond_signal(&p->output_cond); pthread_mutex_unlock(&p->progress_mutex); } pthread_mutex_unlock(&p->mutex); return NULL; }
1threat
static void gem_cleanup(NetClientState *nc) { GemState *s = qemu_get_nic_opaque(nc); DB_PRINT("\n"); s->nic = NULL; }
1threat
script bash to update web pages and to check if there's something different : <p>I need a bash script to refresh web pages and to check if it has changed since last update. How can I do? Using temporary files? Can someone post the code?</p>
0debug
how i use transaction in this code : i was trying to use this code without transaction but it gave me error so i want to use it with transaction, so how i can use ? my code is SqlConnection con= new SqlConnection("Data Source=.;Initial Catalog=Sample;Integrated Security=true;"); SqlCommand cmd; SqlDataAdapter adapt; private void btn_Update_Click(object sender, EventArgs e) { string query="insert into users(Name,Password)values('ubaid','ali')"; cmd = new SqlCommand(query, con); con.Open(); cmd.ExecuteNonQuery(); MessageBox.Show("Record Updated Successfully"); con.Close(); }
0debug
static int l2tpv3_can_send(void *opaque) { NetL2TPV3State *s = opaque; return qemu_can_send_packet(&s->nc); }
1threat
Laravel Eloquent Lazy Eager Load Count : <p>I'm ideally looking for a function like</p> <pre><code>load('relationship') </code></pre> <p>but which loads a count in the same way</p> <pre><code>withCount('relationship') </code></pre> <p>works for eager loading.</p> <p>I'm thinking it is going to be called <code>loadCount('relationship')</code> </p>
0debug
C# Read a string with a particular format : I have some strings like string text = "these all are strings, 000_00_0 and more strings are there I have here 649_17_8, and more with this format 975_63_7." So here I wanted to read only 000_00_0, 649_17_8, 975_64_7.... All the string with this format Please help me with the situation Thanks in advance
0debug
change the currently being displayed string from an array : <p>I would like to change the current string displayed on the screen by pressing buttons. for example:</p> <p>I have an array of strings here:</p> <pre><code>std::string test[] = { "hey", "how", "are", "you" }; </code></pre> <p>then i have some code here to change the current displayed string from the array:</p> <pre><code>if (GetAsyncKeyState(VK_LEFT)) //display one string left from the array else if (GetAsyncKeyState(VK_RIGHT)) //display string next to the current one in array std::cout &lt;&lt; test; </code></pre> <p>so what kind of code should i put to the commented parts???</p>
0debug
Blueprism- Extract data from a web page into a collection; : i am new to blue prism. I have a scenario where I am giving input (passengers details for travelling) to a travel portal and based on the input its generating a booking reference number,total cost etc. Now I want to read all the outputs into a collection but the problem is data is not tabular (cant use Get Table in read component). Its just the details of travel which are populating into textboxes.Please find attached the screen shot to have more clarity on this. [enter image description here][1] How to achieve this? Any leads will be appreciated. Thanks- [1]: https://i.stack.imgur.com/m7RpB.jpg
0debug
MAX = 3000 def smartNumber(n): primes = [0] * MAX result = [] for i in range(2, MAX): if (primes[i] == 0): primes[i] = 1 j = i * 2 while (j < MAX): primes[j] -= 1 if ( (primes[j] + 3) == 0): result.append(j) j = j + i result.sort() return result[n - 1]
0debug
static void gen_hrfid(DisasContext *ctx) { #if defined(CONFIG_USER_ONLY) gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); #else if (unlikely(ctx->pr || !ctx->hv)) { gen_inval_exception(ctx, POWERPC_EXCP_PRIV_OPC); return; } gen_helper_hrfid(cpu_env); gen_sync_exception(ctx); #endif }
1threat
javaScript my array code runs with for loops, but nothing displays? : I don't understand why this runs but does not print anything. (I am new to coding altogether, so any advice is great.) import java.util.Scanner; import java.util.Random; public class ArrayDoubleValues{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); // Length input System.out.println("Length: "); int length = scan.nextInt(); int[] list = new int[length]; for (int i = 0; i == list.length; i++){ list[i] =(int)(Math.random()+ 1) * 100; System.out.print(list.length);} for(int i = 0; i == list.length; i++){ System.out.println(list[i]); } } }
0debug
static void virtio_net_set_status(struct VirtIODevice *vdev, uint8_t status) { VirtIONet *n = VIRTIO_NET(vdev); VirtIONetQueue *q; int i; uint8_t queue_status; virtio_net_vnet_endian_status(n, status); virtio_net_vhost_status(n, status); for (i = 0; i < n->max_queues; i++) { NetClientState *ncs = qemu_get_subqueue(n->nic, i); bool queue_started; q = &n->vqs[i]; if ((!n->multiqueue && i != 0) || i >= n->curr_queues) { queue_status = 0; } else { queue_status = status; } queue_started = virtio_net_started(n, queue_status) && !n->vhost_started; if (queue_started) { qemu_flush_queued_packets(ncs); } if (!q->tx_waiting) { continue; } if (queue_started) { if (q->tx_timer) { timer_mod(q->tx_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + n->tx_timeout); } else { qemu_bh_schedule(q->tx_bh); } } else { if (q->tx_timer) { timer_del(q->tx_timer); } else { qemu_bh_cancel(q->tx_bh); } if ((n->status & VIRTIO_NET_S_LINK_UP) == 0 && (queue_status & VIRTIO_CONFIG_S_DRIVER_OK)) { q->tx_waiting = 0; virtio_queue_set_notification(q->tx_vq, 1); virtio_net_drop_tx_queue_data(vdev, q->tx_vq); } } } }
1threat
static uint32_t nvdimm_rw_label_data_check(NVDIMMDevice *nvdimm, uint32_t offset, uint32_t length) { uint32_t ret = 3 ; if (offset + length < offset) { nvdimm_debug("offset %#x + length %#x is overflow.\n", offset, length); return ret; } if (nvdimm->label_size < offset + length) { nvdimm_debug("position %#x is beyond label data (len = %" PRIx64 ").\n", offset + length, nvdimm->label_size); return ret; } if (length > nvdimm_get_max_xfer_label_size()) { nvdimm_debug("length (%#x) is larger than max_xfer (%#x).\n", length, nvdimm_get_max_xfer_label_size()); return ret; } return 0 ; }
1threat
How to remove Controller and method URL in codeignitor : This is my current URL http://www.example.com/agent/index/$id, and i want to change this http://www.example.com/demo_name(by agent name) Please suggest your answer.
0debug
static av_cold int flac_decode_init(AVCodecContext *avctx) { FLACContext *s = avctx->priv_data; s->avctx = avctx; avctx->sample_fmt = SAMPLE_FMT_S16; if (avctx->extradata_size > 4) { if (avctx->extradata_size == FLAC_STREAMINFO_SIZE) { ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, avctx->extradata); allocate_buffers(s); } else { init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8); metadata_parse(s); } } return 0; }
1threat
How to multiply multiple column dataframe to another single column df in Python? : I'm trying to multiply two dataframes:(3868 rows x 758 columns) and (3868 rows x 1 column) Below codes give me error:operands could not be broadcast together with shapes (14961424,) (3868,) free_float = pd.DataFrame(free_float) weights = pd.DataFrame(weights ) columns = weights.columns weights[columns] *= free_float['A']
0debug
How to set reply action in below nougat version like whatsapp in android : Am trying to set reply action in push notification like whatsapp. How to show popup window like whatsapp for replying in push notification [I have to open a dialog like below image when click of reply ][1] [1]: https://i.stack.imgur.com/W8CSi.png
0debug
What is the point in setting a slice's capacity? : <p>In Golang, we can use the builtin <code>make()</code> function to create a slice with a given initial length and capacity.</p> <p>Consider the following lines, the slice's length is set to 1, and its capacity 3:</p> <pre><code>func main() { var slice = make([]int, 1, 3) slice[0] = 1 slice = append(slice, 6, 0, 2, 4, 3, 1) fmt.Println(slice) } </code></pre> <p>I was surprised to see that this program prints:</p> <blockquote> <p>[1 6 0 2 4 3 1]</p> </blockquote> <p>This got me wondering- what is the point of initially defining a slice's capacity if <code>append()</code> can simply blow past it? Are there performance gains for setting a sufficiently large capacity?</p>
0debug
Using Vue.js in Golang's HTML templates : <p>I want to use Vue.js with the Golang's HTML template engine but as both use <code>{{ ... }}</code> for syntax, they conflict with each other...</p> <p>Does anyone has already did it somehow or have any suggestions on how to overlap this problem?</p> <p>Thanks in advance.</p>
0debug
static int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info, const char *name) { QEMUSnapshotInfo *sn_tab, *sn; int nb_sns, i, ret; ret = -ENOENT; nb_sns = bdrv_snapshot_list(bs, &sn_tab); if (nb_sns < 0) return ret; for(i = 0; i < nb_sns; i++) { sn = &sn_tab[i]; if (!strcmp(sn->id_str, name) || !strcmp(sn->name, name)) { *sn_info = *sn; ret = 0; break; } } g_free(sn_tab); return ret; }
1threat
MSSQL Stored procedure custom paging stored procedure : I have a stored procedure like following: USE [db_Test] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO ALTER PROCEDURE [dbo].[zsp_GetUsersAdministratorPanel] ( @StartRowIndex int, @MaxRows int, @OrderByField nvarchar(200), @Asc bit, @SearchValue nvarchar(200) )AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; DECLARE @UsersTable TABLE(UserId uniqueidentifier, FirstName nvarchar(400), LastName nvarchar(400), Email nvarchar(200)) DECLARE @WhereQuery nvarchar(max) SET @WhereQuery = ' WHERE ' IF LEN(@SearchValue) > 0 BEGIN SET @WhereQuery = @WhereQuery + 'FirstName like ''%' + @SearchValue + '%'' or ' + ' LastName like ''%' + @SearchValue + '%'' or ' + ' Email like ''%' + @SearchValue + '%''' END DECLARE @OrderQuery nvarchar(max) IF LEN(@OrderByField) > 0 BEGIN IF @OrderByField = 'Email' SET @OrderQuery = ' ORDER BY Email ' + CASE @Asc WHEN 1 THEN ' ASC ' ELSE ' DESC ' END ELSE IF @OrderByField = 'FirstName' SET @OrderQuery = ' ORDER BY FirstName ' + CASE @Asc WHEN 1 THEN ' ASC ' ELSE ' DESC ' END ELSE IF @OrderByField = 'LastName' SET @OrderQuery = ' ORDER BY LastName ' + CASE @Asc WHEN 1 THEN ' ASC ' ELSE ' DESC ' END END DECLARE @Query NVARCHAR(MAX) SET @Query = 'select UserId, FirstName, LastName, Email from ( SELECT ROW_NUMBER() OVER ('+ @OrderQuery +') AS [ROW_NUMBER], [t0].[UserId], [t0].[FirstName], [t0].[LastName], [t0].[Email] FROM [dbo].[Users] AS [t0]' + @WhereQuery + ') AS [t1]' + + ' WHERE [ROW_NUMBER] BETWEEN @StartRowIndex AND @MaxRows' + @OrderQuery PRINT @Query INSERT INTO @UsersTable EXEC sp_Executesql @Query, N'@OrderQuery nvarchar(max), @StartRowIndex int,@MaxRows int', @OrderQuery=@OrderQuery, @StartRowIndex = @StartRowIndex, @MaxRows = @MaxRows SELECT * FROM @UsersTable SET NOCOUNT OFF; END When I pass the following parameters: StartRowIndex - 1 MaxRows(page size) - 50 OrderByField - FirstName Asc - 1 SearchValue - Test I'm getting a following error: select UserId, FirstName, LastName, Email from ( SELECT ROW_NUMBER() OVER ( ORDER BY FirstName ASC ) AS [ROW_NUMBER], [t0].[UserId], [t0].[FirstName], [t0].[LastName], [t0].[Email] FROM [dbo].[Users] AS [t0] WHERE FirstName like '%test%' or LastName like '%test%' or Email like '%test%') AS [t1] WHERE [ROW_NUMBER] BETWEEN @StartRowIndex AND @MaxRows ORDER BY FirstName ASC Msg 206, Level 16, State 2, Line 4 Operand type clash: int is incompatible with uniqueidentifier (1 row(s) affected) I'm not quite sure what is causing the error here... I'm trying to create a stored procedure which would go through my Users test table which will have a large amount of data (500000 users later on), so I'm trying to ensure smooth user experience. Why am I getting this error? Can someone help me out?
0debug
How do I format all files in a Visual Studio Code project? : <p>Is there a way to format all files in a project without formatting each one individually?</p>
0debug
static void search_for_ms(AACEncContext *s, ChannelElement *cpe) { int start = 0, i, w, w2, g, sid_sf_boost; float M[128], S[128]; float *L34 = s->scoefs, *R34 = s->scoefs + 128, *M34 = s->scoefs + 128*2, *S34 = s->scoefs + 128*3; const float lambda = s->lambda; const float mslambda = FFMIN(1.0f, lambda / 120.f); SingleChannelElement *sce0 = &cpe->ch[0]; SingleChannelElement *sce1 = &cpe->ch[1]; if (!cpe->common_window) return; for (w = 0; w < sce0->ics.num_windows; w += sce0->ics.group_len[w]) { int min_sf_idx_mid = SCALE_MAX_POS; int min_sf_idx_side = SCALE_MAX_POS; for (g = 0; g < sce0->ics.num_swb; g++) { if (!sce0->zeroes[w*16+g] && sce0->band_type[w*16+g] < RESERVED_BT) min_sf_idx_mid = FFMIN(min_sf_idx_mid, sce0->sf_idx[w*16+g]); if (!sce1->zeroes[w*16+g] && sce1->band_type[w*16+g] < RESERVED_BT) min_sf_idx_side = FFMIN(min_sf_idx_side, sce1->sf_idx[w*16+g]); } start = 0; for (g = 0; g < sce0->ics.num_swb; g++) { float bmax = bval2bmax(g * 17.0f / sce0->ics.num_swb) / 0.0045f; cpe->ms_mask[w*16+g] = 0; if (!cpe->ch[0].zeroes[w*16+g] && !cpe->ch[1].zeroes[w*16+g]) { float Mmax = 0.0f, Smax = 0.0f; for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) { for (i = 0; i < sce0->ics.swb_sizes[g]; i++) { M[i] = (sce0->coeffs[start+(w+w2)*128+i] + sce1->coeffs[start+(w+w2)*128+i]) * 0.5; S[i] = M[i] - sce1->coeffs[start+(w+w2)*128+i]; } abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]); abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]); for (i = 0; i < sce0->ics.swb_sizes[g]; i++ ) { Mmax = FFMAX(Mmax, M34[i]); Smax = FFMAX(Smax, S34[i]); } } for (sid_sf_boost = 0; sid_sf_boost < 4; sid_sf_boost++) { float dist1 = 0.0f, dist2 = 0.0f; int B0 = 0, B1 = 0; int minidx; int mididx, sididx; int midcb, sidcb; minidx = FFMIN(sce0->sf_idx[w*16+g], sce1->sf_idx[w*16+g]); mididx = av_clip(minidx, min_sf_idx_mid, min_sf_idx_mid + SCALE_MAX_DIFF); sididx = av_clip(minidx - sid_sf_boost * 3, min_sf_idx_side, min_sf_idx_side + SCALE_MAX_DIFF); midcb = find_min_book(Mmax, mididx); sidcb = find_min_book(Smax, sididx); if ((mididx > minidx) || (sididx > minidx)) { continue; } midcb = FFMAX(1,midcb); sidcb = FFMAX(1,sidcb); for (w2 = 0; w2 < sce0->ics.group_len[w]; w2++) { FFPsyBand *band0 = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g]; FFPsyBand *band1 = &s->psy.ch[s->cur_channel+1].psy_bands[(w+w2)*16+g]; float minthr = FFMIN(band0->threshold, band1->threshold); int b1,b2,b3,b4; for (i = 0; i < sce0->ics.swb_sizes[g]; i++) { M[i] = (sce0->coeffs[start+(w+w2)*128+i] + sce1->coeffs[start+(w+w2)*128+i]) * 0.5; S[i] = M[i] - sce1->coeffs[start+(w+w2)*128+i]; } abs_pow34_v(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]); abs_pow34_v(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]); abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]); abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]); dist1 += quantize_band_cost(s, &sce0->coeffs[start + (w+w2)*128], L34, sce0->ics.swb_sizes[g], sce0->sf_idx[(w+w2)*16+g], sce0->band_type[(w+w2)*16+g], lambda / band0->threshold, INFINITY, &b1, NULL, 0); dist1 += quantize_band_cost(s, &sce1->coeffs[start + (w+w2)*128], R34, sce1->ics.swb_sizes[g], sce1->sf_idx[(w+w2)*16+g], sce1->band_type[(w+w2)*16+g], lambda / band1->threshold, INFINITY, &b2, NULL, 0); dist2 += quantize_band_cost(s, M, M34, sce0->ics.swb_sizes[g], sce0->sf_idx[(w+w2)*16+g], sce0->band_type[(w+w2)*16+g], lambda / minthr, INFINITY, &b3, NULL, 0); dist2 += quantize_band_cost(s, S, S34, sce1->ics.swb_sizes[g], sce1->sf_idx[(w+w2)*16+g], sce1->band_type[(w+w2)*16+g], mslambda / (minthr * bmax), INFINITY, &b4, NULL, 0); B0 += b1+b2; B1 += b3+b4; dist1 -= B0; dist2 -= B1; } cpe->ms_mask[w*16+g] = dist2 <= dist1 && B1 < B0; if (cpe->ms_mask[w*16+g]) { if (!cpe->is_mask[w*16+g] && sce0->band_type[w*16+g] != NOISE_BT && sce1->band_type[w*16+g] != NOISE_BT) { sce0->sf_idx[w*16+g] = mididx; sce1->sf_idx[w*16+g] = sididx; sce0->band_type[w*16+g] = midcb; sce1->band_type[w*16+g] = sidcb; } break; } else if (B1 > B0) { break; } } } start += sce0->ics.swb_sizes[g]; } } }
1threat
convert List of Dicts into a 2 deep Nested Dict : <p>Ive been banging my head against a wall for some time with this now, so hoping somebody will be able to point me in the right direction</p> <p>I am writing a flask app and my query returns the following list of dictionaries (via cur.fetchall) ..</p> <pre><code>MyQueryResult = [{'gameID': 'game_1', 'prediction': 41, 'bonus': 'no', 'userName': 'Paul'}, {'gameID': 'game_2', 'prediction': 77, 'bonus': 'no', 'userName': 'Paul'}, {'gameID': 'game_1', 'prediction': 62, 'bonus': 'no', 'userName': 'Steve'}, {'gameID': 'game_2', 'prediction': 77, 'bonus': 'yes', 'userName': 'Steve'} ] </code></pre> <p>I need to convert this into a nested dictionary so that i can use it to build an html table with jinja2 templating ...the table will have 'gameID' as Y axis, 'userName' as X axis, with prediction as the value in the table.. there could be any number of games or users in any particular week</p> <p>Ideally, for me to iterate over it in jinja2, i need to convert the above 'flat' list of dictionaries to a nested dictionary keyed on 'userName' and then 'gameID' ..so that it looks like this</p> <pre><code>MyDict = { 'Paul': { 'game_1': { 'prediction': 'home_win', 'bonus': 'no' }, 'game_2': { 'prediction': 'away_win', 'bonus': 'no' }}, 'Steve': { 'game_1': { 'prediction': 'home_win', 'bonus': 'no' }, 'game_2': { 'prediction': 'away_win', 'bonus': 'yes' } } } </code></pre> <p>This format will enable me to iterate over on a per user /per game basis in Jinja2 and thus enable me to build a table</p> <p>Does anyone have any idea on how i can perform the above conversion ...ive been trying for ages now and really struggling to figure it out :(</p> <p>Any help would be greatly appreciated</p>
0debug
static int decode_extended_mips16_opc (CPUMIPSState *env, DisasContext *ctx, int *is_branch) { int extend = cpu_lduw_code(env, ctx->pc + 2); int op, rx, ry, funct, sa; int16_t imm, offset; ctx->opcode = (ctx->opcode << 16) | extend; op = (ctx->opcode >> 11) & 0x1f; sa = (ctx->opcode >> 22) & 0x1f; funct = (ctx->opcode >> 8) & 0x7; rx = xlat((ctx->opcode >> 8) & 0x7); ry = xlat((ctx->opcode >> 5) & 0x7); offset = imm = (int16_t) (((ctx->opcode >> 16) & 0x1f) << 11 | ((ctx->opcode >> 21) & 0x3f) << 5 | (ctx->opcode & 0x1f)); switch (op) { case M16_OPC_ADDIUSP: gen_arith_imm(ctx, OPC_ADDIU, rx, 29, imm); break; case M16_OPC_ADDIUPC: gen_addiupc(ctx, rx, imm, 0, 1); break; case M16_OPC_B: gen_compute_branch(ctx, OPC_BEQ, 4, 0, 0, offset << 1); break; case M16_OPC_BEQZ: gen_compute_branch(ctx, OPC_BEQ, 4, rx, 0, offset << 1); break; case M16_OPC_BNEQZ: gen_compute_branch(ctx, OPC_BNE, 4, rx, 0, offset << 1); break; case M16_OPC_SHIFT: switch (ctx->opcode & 0x3) { case 0x0: gen_shift_imm(ctx, OPC_SLL, rx, ry, sa); break; case 0x1: #if defined(TARGET_MIPS64) check_mips_64(ctx); gen_shift_imm(ctx, OPC_DSLL, rx, ry, sa); #else generate_exception(ctx, EXCP_RI); #endif break; case 0x2: gen_shift_imm(ctx, OPC_SRL, rx, ry, sa); break; case 0x3: gen_shift_imm(ctx, OPC_SRA, rx, ry, sa); break; } break; #if defined(TARGET_MIPS64) case M16_OPC_LD: check_mips_64(ctx); gen_ld(ctx, OPC_LD, ry, rx, offset); break; #endif case M16_OPC_RRIA: imm = ctx->opcode & 0xf; imm = imm | ((ctx->opcode >> 20) & 0x7f) << 4; imm = imm | ((ctx->opcode >> 16) & 0xf) << 11; imm = (int16_t) (imm << 1) >> 1; if ((ctx->opcode >> 4) & 0x1) { #if defined(TARGET_MIPS64) check_mips_64(ctx); gen_arith_imm(ctx, OPC_DADDIU, ry, rx, imm); #else generate_exception(ctx, EXCP_RI); #endif } else { gen_arith_imm(ctx, OPC_ADDIU, ry, rx, imm); } break; case M16_OPC_ADDIU8: gen_arith_imm(ctx, OPC_ADDIU, rx, rx, imm); break; case M16_OPC_SLTI: gen_slt_imm(ctx, OPC_SLTI, 24, rx, imm); break; case M16_OPC_SLTIU: gen_slt_imm(ctx, OPC_SLTIU, 24, rx, imm); break; case M16_OPC_I8: switch (funct) { case I8_BTEQZ: gen_compute_branch(ctx, OPC_BEQ, 4, 24, 0, offset << 1); break; case I8_BTNEZ: gen_compute_branch(ctx, OPC_BNE, 4, 24, 0, offset << 1); break; case I8_SWRASP: gen_st(ctx, OPC_SW, 31, 29, imm); break; case I8_ADJSP: gen_arith_imm(ctx, OPC_ADDIU, 29, 29, imm); break; case I8_SVRS: { int xsregs = (ctx->opcode >> 24) & 0x7; int aregs = (ctx->opcode >> 16) & 0xf; int do_ra = (ctx->opcode >> 6) & 0x1; int do_s0 = (ctx->opcode >> 5) & 0x1; int do_s1 = (ctx->opcode >> 4) & 0x1; int framesize = (((ctx->opcode >> 20) & 0xf) << 4 | (ctx->opcode & 0xf)) << 3; if (ctx->opcode & (1 << 7)) { gen_mips16_save(ctx, xsregs, aregs, do_ra, do_s0, do_s1, framesize); } else { gen_mips16_restore(ctx, xsregs, aregs, do_ra, do_s0, do_s1, framesize); } } break; default: generate_exception(ctx, EXCP_RI); break; } break; case M16_OPC_LI: tcg_gen_movi_tl(cpu_gpr[rx], (uint16_t) imm); break; case M16_OPC_CMPI: tcg_gen_xori_tl(cpu_gpr[24], cpu_gpr[rx], (uint16_t) imm); break; #if defined(TARGET_MIPS64) case M16_OPC_SD: gen_st(ctx, OPC_SD, ry, rx, offset); break; #endif case M16_OPC_LB: gen_ld(ctx, OPC_LB, ry, rx, offset); break; case M16_OPC_LH: gen_ld(ctx, OPC_LH, ry, rx, offset); break; case M16_OPC_LWSP: gen_ld(ctx, OPC_LW, rx, 29, offset); break; case M16_OPC_LW: gen_ld(ctx, OPC_LW, ry, rx, offset); break; case M16_OPC_LBU: gen_ld(ctx, OPC_LBU, ry, rx, offset); break; case M16_OPC_LHU: gen_ld(ctx, OPC_LHU, ry, rx, offset); break; case M16_OPC_LWPC: gen_ld(ctx, OPC_LWPC, rx, 0, offset); break; #if defined(TARGET_MIPS64) case M16_OPC_LWU: gen_ld(ctx, OPC_LWU, ry, rx, offset); break; #endif case M16_OPC_SB: gen_st(ctx, OPC_SB, ry, rx, offset); break; case M16_OPC_SH: gen_st(ctx, OPC_SH, ry, rx, offset); break; case M16_OPC_SWSP: gen_st(ctx, OPC_SW, rx, 29, offset); break; case M16_OPC_SW: gen_st(ctx, OPC_SW, ry, rx, offset); break; #if defined(TARGET_MIPS64) case M16_OPC_I64: decode_i64_mips16(ctx, ry, funct, offset, 1); break; #endif default: generate_exception(ctx, EXCP_RI); break; } return 4; }
1threat
static void virt_acpi_build_update(void *build_opaque) { AcpiBuildState *build_state = build_opaque; AcpiBuildTables tables; if (!build_state || build_state->patched) { return; } build_state->patched = true; acpi_build_tables_init(&tables); virt_acpi_build(build_state->guest_info, &tables); acpi_ram_update(build_state->table_mr, tables.table_data); acpi_ram_update(build_state->rsdp_mr, tables.rsdp); acpi_ram_update(build_state->linker_mr, tables.linker); acpi_build_tables_cleanup(&tables, true); }
1threat
sql server integration services importing 2 tsv : <p>I have two .tsv files and I need to import them to sql server: one has the data (data.tsv) and the other is column_headers.tsv</p> <p>I need to import it to a table, the table must be created with column_headers.tsv columns and the data.tsv should be inserted to that table.</p> <p>I will need to do this a few times, so I would like to automate it… Can I achieve this with SSIS?</p> <p>is there a standard process on how to import data to sql server using 2 tsv files: data.tsv and column_headers.tsv ? is there a standard process on how to create tables based on column names provided from a .tsv?</p> <p>I know nothing about the data itself… Extra information I have for the data:</p> <p>Datafeed-Manifest-Version: 1.0</p> <p>Lookup-Files: 1</p> <p>Data-Files: 1</p> <p>Total-Records: 18,584</p> <p>Lookup-File: c-it_2016-09-30-lookup_data.tar.gz</p> <p>MD5-Digest: 7efa8c4e901bb666</p> <p>File-Size: 3663715</p> <p>Data-File: c-it_2016-09-30.tsv.gz</p> <p>MD5-Digest: 6ece62faaaaa084f8a3d73b55</p> <p>File-Size: 1066972</p> <p>Record-Count: 18,584</p>
0debug
Why would you combine two 32 bit integers into a 64 bit integer? : <p>Recently I saw how a compiler combined two 32 bit integers which were values of properties of a class and stored them as a 64 bit integer. My question now is, why is this done? What advantages are there when combining integers?</p> <p>for example if we had the following properties of a class</p> <pre><code>class FooBar { int x = 1; int y = 100; } </code></pre> <p>so instead of</p> <pre><code>i32 = 00000001 i32 = 01100100 </code></pre> <p>We get:</p> <pre><code>i64 = 0000000101100100 </code></pre> <p>Why would you combine them?</p>
0debug
Concatenate Column A depending on Value of Column B - SQL Server : <pre><code>I have a table that looks like the following COLUMN_A|| COLUMN_B || ====================== NAME1 || 1 || NAME2 || 1 || NAME3 || 1 || NAME4 || 2 || NAME5 || 2 || NAME6 || 3 || NAME7 || 3 || </code></pre> <p>I want to concatenate COLUMN_A depending on COLUMN_B. If values of COLUMN_B are same, then COLUMN_A should be concatenated seperated by a comma.</p> <p>Expected result</p> <pre><code>NAME1, NAME2, NAME3 NAME4, NAME5 NAME6, NAME7 </code></pre>
0debug
static int flashsv_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { int buf_size = avpkt->size; FlashSVContext *s = avctx->priv_data; int h_blocks, v_blocks, h_part, v_part, i, j; GetBitContext gb; if (buf_size == 0) return 0; if (buf_size < 4) return -1; init_get_bits(&gb, avpkt->data, buf_size * 8); s->block_width = 16 * (get_bits(&gb, 4) + 1); s->image_width = get_bits(&gb, 12); s->block_height = 16 * (get_bits(&gb, 4) + 1); s->image_height = get_bits(&gb, 12); if (s->ver == 2) { skip_bits(&gb, 6); if (get_bits1(&gb)) { av_log_missing_feature(avctx, "iframe", 1); return AVERROR_PATCHWELCOME; if (get_bits1(&gb)) { av_log_missing_feature(avctx, "Custom palette", 1); return AVERROR_PATCHWELCOME; h_blocks = s->image_width / s->block_width; h_part = s->image_width % s->block_width; v_blocks = s->image_height / s->block_height; v_part = s->image_height % s->block_height; if (s->block_size < s->block_width * s->block_height) { int tmpblock_size = 3 * s->block_width * s->block_height; s->tmpblock = av_realloc(s->tmpblock, tmpblock_size); if (!s->tmpblock) { av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n"); return AVERROR(ENOMEM); if (s->ver == 2) { s->deflate_block_size = calc_deflate_block_size(tmpblock_size); if (s->deflate_block_size <= 0) { av_log(avctx, AV_LOG_ERROR, "Can't determine deflate buffer size.\n"); return -1; s->deflate_block = av_realloc(s->deflate_block, s->deflate_block_size); if (!s->deflate_block) { av_log(avctx, AV_LOG_ERROR, "Can't allocate deflate buffer.\n"); return AVERROR(ENOMEM); s->block_size = s->block_width * s->block_height; if (avctx->width == 0 && avctx->height == 0) { avctx->width = s->image_width; avctx->height = s->image_height; if (avctx->width != s->image_width || avctx->height != s->image_height) { "Frame width or height differs from first frame!\n"); av_log(avctx, AV_LOG_ERROR, "fh = %d, fv %d vs ch = %d, cv = %d\n", avctx->height, avctx->width, s->image_height, s->image_width); s->is_keyframe = (avpkt->flags & AV_PKT_FLAG_KEY) && (s->ver == 2); if (s->is_keyframe) { s->keyframedata = av_realloc(s->keyframedata, avpkt->size); memcpy(s->keyframedata, avpkt->data, avpkt->size); s->blocks = av_realloc(s->blocks, (v_blocks + !!v_part) * (h_blocks + !!h_part) * sizeof(s->blocks[0])); av_dlog(avctx, "image: %dx%d block: %dx%d num: %dx%d part: %dx%d\n", s->image_width, s->image_height, s->block_width, s->block_height, h_blocks, v_blocks, h_part, v_part); s->frame.reference = 3; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if (avctx->reget_buffer(avctx, &s->frame) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return -1; for (j = 0; j < v_blocks + (v_part ? 1 : 0); j++) { int y_pos = j * s->block_height; int cur_blk_height = (j < v_blocks) ? s->block_height : v_part; for (i = 0; i < h_blocks + (h_part ? 1 : 0); i++) { int x_pos = i * s->block_width; int cur_blk_width = (i < h_blocks) ? s->block_width : h_part; int has_diff = 0; int size = get_bits(&gb, 16); s->color_depth = 0; s->zlibprime_curr = 0; s->zlibprime_prev = 0; s->diff_start = 0; s->diff_height = cur_blk_height; if (8 * size > get_bits_left(&gb)) { avctx->release_buffer(avctx, &s->frame); s->frame.data[0] = NULL; if (s->ver == 2 && size) { skip_bits(&gb, 3); s->color_depth = get_bits(&gb, 2); has_diff = get_bits1(&gb); s->zlibprime_curr = get_bits1(&gb); s->zlibprime_prev = get_bits1(&gb); if (s->color_depth != 0 && s->color_depth != 2) { "%dx%d invalid color depth %d\n", i, j, s->color_depth); if (has_diff) { s->diff_start = get_bits(&gb, 8); s->diff_height = get_bits(&gb, 8); av_log(avctx, AV_LOG_DEBUG, "%dx%d diff start %d height %d\n", i, j, s->diff_start, s->diff_height); size -= 2; if (s->zlibprime_prev) av_log(avctx, AV_LOG_DEBUG, "%dx%d zlibprime_prev\n", i, j); if (s->zlibprime_curr) { int col = get_bits(&gb, 8); int row = get_bits(&gb, 8); av_log(avctx, AV_LOG_DEBUG, "%dx%d zlibprime_curr %dx%d\n", i, j, col, row); size -= 2; av_log_missing_feature(avctx, "zlibprime_curr", 1); return AVERROR_PATCHWELCOME; size--; if (has_diff) { int k; int off = (s->image_height - y_pos - 1) * s->frame.linesize[0]; for (k = 0; k < cur_blk_height; k++) memcpy(s->frame.data[0] + off - k*s->frame.linesize[0] + x_pos*3, s->keyframe + off - k*s->frame.linesize[0] + x_pos*3, cur_blk_width * 3); if (size) { if (flashsv_decode_block(avctx, avpkt, &gb, size, cur_blk_width, cur_blk_height, x_pos, y_pos, i + j * (h_blocks + !!h_part))) "error in decompression of block %dx%d\n", i, j); if (s->is_keyframe && s->ver == 2) { s->keyframe = av_malloc(s->frame.linesize[0] * avctx->height); av_log(avctx, AV_LOG_ERROR, "Cannot allocate image data\n"); return AVERROR(ENOMEM); memcpy(s->keyframe, s->frame.data[0], s->frame.linesize[0] * avctx->height); *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; if ((get_bits_count(&gb) / 8) != buf_size) av_log(avctx, AV_LOG_ERROR, "buffer not fully consumed (%d != %d)\n", buf_size, (get_bits_count(&gb) / 8)); return buf_size;
1threat
Find the n amount of highest values in an unsorted double array : Homework How would i code a program that will search a double array for the n amount of highest values. The n is determined by the user. For example a user inputs the number 3, the program is required to display the 3 highest values from the array. From what i understand i need a for loop to search the array for the highest number, store that number in a new double array and repeat the search depending on the number inputted by the user. If this is the case how would i go about coding these steps. I understand how to ask for user input and such, just not how to code the calculations in searching the array, storing the values inside an aray based on the user.
0debug
Parse XML from Axios response, pushing to Vue data array : <p>In my Vue app, I get a XML file with Axios and use parseString to parse XML as JSON. I then need to pass the <code>result</code> to Vue data (this.events). My console log shows the parsed XML as Json, but I cannot push to Vue data inside this function.</p> <pre><code>var parseString = require('xml2js').parseString; axios.get(`http://url.to/events.xml`) .then(response =&gt; { parseString(response.data, function (err, result) { console.log(result); // returns a json array this.events = result // nothing happens }); }) } </code></pre> <p>How to store my JSON array to this.data in Vue?</p>
0debug
How do I create a list like the one below in Python 3.x? : I have a series on URL's that I need to replicate as follows. https://wipp.edmundsassoc.com/Wipp/?wippid=*1205* The 1205 is variable the final outputs need to look like "https://wipp.edmundsassoc.com/Wipp/?wippid=1205#taxpage1" ................................................#taxpage2" ................................................#taxpage3 ................................................#taxpage4 and so on. I have a list of URL's with out the "#taxpage" portion and list of how many tax pages each should have. I want to generate list of all the possible pages for each URL. Thank you for any help....completely new to coding and any help is greatly appreciated.
0debug
How to search this kind of pattern in regex : <p><strong>This is the sample text I want to get the regex of the Match specified string that regex will qualify the Not match conditions</strong></p> <blockquote> <p>1abc.def.ghi (Match)</p> <p>abc.111.ghi (Match)</p> <p>123.123.123.132.123.123 (Match)</p> <p>123.123.123.132.123.123.123.123.123.132.123.123.123.123.123.132.123.123(Match)</p> <p>123.123.123.132.123.<em>12335</em> (Not Match)</p> <p><em>7645</em>.123.111.887 (Not Match)</p> </blockquote>
0debug
Unit testing a python function that depends on database : I am running tests on some functions. I have a function that uses database queries. So, I have gone through the blogs and docs that say we have to make an in memory or test database to use such functions. Below is my function, def already_exists(story_data,c): # TODO(salmanhaseeb): Implement de-dupe functionality by checking if it already exists in the DB. c.execute("""SELECT COUNT(*) from posts where post_id = ?""", (story_data.post_id,)) (number_of_rows,)=c.fetchone() if number_of_rows > 0: return True return False This function hits the production database. My question is that, when in testing, I create an in memory database and populate my values there, I will be quering that database(test DB). But I want to test my "already_exists" function, after calling my already_exists function from test, my production db will be hit. How do I make my test DB hit while testing this function.
0debug
void ff_dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx) { const int high_bit_depth = avctx->bits_per_raw_sample > 8; c->prefetch = prefetch_ppc; if (!high_bit_depth) { switch (check_dcbzl_effect()) { case 32: c->clear_blocks = clear_blocks_dcbz32_ppc; break; case 128: c->clear_blocks = clear_blocks_dcbz128_ppc; break; default: break; } } #if HAVE_ALTIVEC if(CONFIG_H264_DECODER) ff_dsputil_h264_init_ppc(c, avctx); if (av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC) { ff_dsputil_init_altivec(c, avctx); ff_float_init_altivec(c, avctx); ff_int_init_altivec(c, avctx); c->gmc1 = ff_gmc1_altivec; #if CONFIG_ENCODERS if (avctx->bits_per_raw_sample <= 8 && (avctx->dct_algo == FF_DCT_AUTO || avctx->dct_algo == FF_DCT_ALTIVEC)) { c->fdct = ff_fdct_altivec; } #endif if (avctx->bits_per_raw_sample <= 8) { if ((avctx->idct_algo == FF_IDCT_AUTO) || (avctx->idct_algo == FF_IDCT_ALTIVEC)) { c->idct_put = ff_idct_put_altivec; c->idct_add = ff_idct_add_altivec; c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM; }else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER) && avctx->idct_algo==FF_IDCT_VP3){ c->idct_put = ff_vp3_idct_put_altivec; c->idct_add = ff_vp3_idct_add_altivec; c->idct = ff_vp3_idct_altivec; c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM; } } } #endif }
1threat
Help to using Switch case in c++? : How do I use switch case in this code ?? I have tried several times , But I really do not know how to make it without error . I don't know anywhere i put it ?? #include<iostream.h> int x,y; int sum(int a,int b) { int c; c = a+b; return (c); } int sub (int a ,int b) { int c; c = a-b ; return (c); } int multi ( int a, int b ) { int c ; c = a*b; return (c); } float div ( int a , int b) { float c; c = a/b ; return (c); } main() { cout<<"enter the value of x = "; cin>>x; cout<<"enter the value of y = "; cin>>y; cout<<"x + y = "<< sum(x,y); cout<<"\n x - y = "<< sub(x,y); cout<<"\n x * y = "<< multi(x,y); cout<<"\n x /y = "<< div (x,y); cin>>"\n"; }
0debug
Why can't I store an oauth refresh token in the browser? : <p>I want to store an oauth refresh token in the browser. The reason I want to store it there is so that the app can refresh the access token and let the user continue their session uninterrupted. I also want to eliminate the need for any kind of cache on the server to store the tokens, thus making it stateful.</p> <p>I'm told that storing the refresh token in the browser is wrong because it's insecure.</p> <p>I think it's OK because:</p> <ul> <li>The tokens would be stored in httpOnly, secure session cookies so they shouldn't be vulnerable to XSS or man in the middle attacks and they will be discarded when the user closes their session.</li> <li>All communication to the server is done via HTTPS</li> <li>The refresh token can be invalidated if suspicious activity is detected</li> <li>Most importantly you can't use the refresh token unless you know the client secret which would be known only by the server.</li> </ul> <p>Am I wrong to think it should be OK? Please explain why!</p>
0debug
Global extension function in kotlin : <p>Hey I want to make a class in kotlin that will hold all extension functions that I will use in a few places for example:</p> <pre><code>class DateUtils { //in this case I use jodatime fun Long.toDateTime() : DateTime = DateTime(this) fun String.toDateTime() : DateTime = DateTime.parse(this) } class SomeClassWithNoConnectionToDateUtils { fun handleDataFromServer(startDate: String) { someOtherFunction() //startDate knows about toDateTime function in DateUtils startDate.toDateTime().plusDays(4) } } </code></pre> <p>Is there a way to perform such operation </p>
0debug
static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { char *buf; int ret; BDRVVmdkState *s = bs->opaque; uint32_t magic; buf = vmdk_read_desc(bs->file, 0, errp); if (!buf) { return -EINVAL; } magic = ldl_be_p(buf); switch (magic) { case VMDK3_MAGIC: case VMDK4_MAGIC: ret = vmdk_open_sparse(bs, bs->file, flags, buf, errp); s->desc_offset = 0x200; break; default: ret = vmdk_open_desc_file(bs, flags, buf, errp); break; } if (ret) { goto fail; } ret = vmdk_parent_open(bs); if (ret) { goto fail; } s->cid = vmdk_read_cid(bs, 0); s->parent_cid = vmdk_read_cid(bs, 1); qemu_co_mutex_init(&s->lock); error_setg(&s->migration_blocker, "The vmdk format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(bs)); migrate_add_blocker(s->migration_blocker); g_free(buf); return 0; fail: g_free(buf); g_free(s->create_type); s->create_type = NULL; vmdk_free_extents(bs); return ret; }
1threat
ngModel with a bind function not working in ng2 : <p>If I do in a template of a component something like:</p> <pre><code>&lt;input [(ngModel)]="myProperty"&gt;&lt;/input&gt; </code></pre> <p>then it works, but if I do it with a function in my component it does not:</p> <pre><code>&lt;input [(ngModel)]="getMyProperty()"&gt;&lt;/input&gt; </code></pre> <p><a href="https://plnkr.co/edit/j0FZIIqSH94QEoOJrmsv?p=preview" rel="noreferrer">Here</a> is the plunkr. Tested on RC6. Why?</p>
0debug
static void cpu_handle_guest_debug(CPUState *env) { gdb_set_stop_cpu(env); qemu_system_debug_request(); #ifdef CONFIG_IOTHREAD env->stopped = 1; #endif }
1threat
static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap) { ASFContext *asf = s->priv_data; ff_asf_guid g; ByteIOContext *pb = s->pb; AVStream *st; ASFStream *asf_st; int size, i; int64_t gsize; AVRational dar[128]; uint32_t bitrate[128]; memset(dar, 0, sizeof(dar)); memset(bitrate, 0, sizeof(bitrate)); get_guid(pb, &g); if (guidcmp(&g, &ff_asf_header)) return -1; get_le64(pb); get_le32(pb); get_byte(pb); get_byte(pb); memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid)); for(;;) { uint64_t gpos= url_ftell(pb); get_guid(pb, &g); gsize = get_le64(pb); dprintf(s, "%08"PRIx64": ", gpos); print_guid(&g); dprintf(s, " size=0x%"PRIx64"\n", gsize); if (!guidcmp(&g, &ff_asf_data_header)) { asf->data_object_offset = url_ftell(pb); if (!(asf->hdr.flags & 0x01) && gsize >= 100) { asf->data_object_size = gsize - 24; } else { asf->data_object_size = (uint64_t)-1; } break; } if (gsize < 24) return -1; if (!guidcmp(&g, &ff_asf_file_header)) { get_guid(pb, &asf->hdr.guid); asf->hdr.file_size = get_le64(pb); asf->hdr.create_time = get_le64(pb); asf->nb_packets = get_le64(pb); asf->hdr.play_time = get_le64(pb); asf->hdr.send_time = get_le64(pb); asf->hdr.preroll = get_le32(pb); asf->hdr.ignore = get_le32(pb); asf->hdr.flags = get_le32(pb); asf->hdr.min_pktsize = get_le32(pb); asf->hdr.max_pktsize = get_le32(pb); asf->hdr.max_bitrate = get_le32(pb); s->packet_size = asf->hdr.max_pktsize; } else if (!guidcmp(&g, &ff_asf_stream_header)) { enum AVMediaType type; int type_specific_size, sizeX; uint64_t total_size; unsigned int tag1; int64_t pos1, pos2, start_time; int test_for_ext_stream_audio, is_dvr_ms_audio=0; if (s->nb_streams == ASF_MAX_STREAMS) { av_log(s, AV_LOG_ERROR, "too many streams\n"); return AVERROR(EINVAL); } pos1 = url_ftell(pb); st = av_new_stream(s, 0); if (!st) return AVERROR(ENOMEM); av_set_pts_info(st, 32, 1, 1000); asf_st = av_mallocz(sizeof(ASFStream)); if (!asf_st) return AVERROR(ENOMEM); st->priv_data = asf_st; start_time = asf->hdr.preroll; asf_st->stream_language_index = 128; if(!(asf->hdr.flags & 0x01)) { st->duration = asf->hdr.play_time / (10000000 / 1000) - start_time; } get_guid(pb, &g); test_for_ext_stream_audio = 0; if (!guidcmp(&g, &ff_asf_audio_stream)) { type = AVMEDIA_TYPE_AUDIO; } else if (!guidcmp(&g, &ff_asf_video_stream)) { type = AVMEDIA_TYPE_VIDEO; } else if (!guidcmp(&g, &ff_asf_command_stream)) { type = AVMEDIA_TYPE_DATA; } else if (!guidcmp(&g, &ff_asf_ext_stream_embed_stream_header)) { test_for_ext_stream_audio = 1; type = AVMEDIA_TYPE_UNKNOWN; } else { return -1; } get_guid(pb, &g); total_size = get_le64(pb); type_specific_size = get_le32(pb); get_le32(pb); st->id = get_le16(pb) & 0x7f; asf->asfid2avid[st->id] = s->nb_streams - 1; get_le32(pb); if (test_for_ext_stream_audio) { get_guid(pb, &g); if (!guidcmp(&g, &ff_asf_ext_stream_audio_stream)) { type = AVMEDIA_TYPE_AUDIO; is_dvr_ms_audio=1; get_guid(pb, &g); get_le32(pb); get_le32(pb); get_le32(pb); get_guid(pb, &g); get_le32(pb); } } st->codec->codec_type = type; if (type == AVMEDIA_TYPE_AUDIO) { ff_get_wav_header(pb, st->codec, type_specific_size); if (is_dvr_ms_audio) { st->codec->codec_id = CODEC_ID_PROBE; st->codec->codec_tag = 0; } if (st->codec->codec_id == CODEC_ID_AAC) { st->need_parsing = AVSTREAM_PARSE_NONE; } else { st->need_parsing = AVSTREAM_PARSE_FULL; } pos2 = url_ftell(pb); if (gsize >= (pos2 + 8 - pos1 + 24)) { asf_st->ds_span = get_byte(pb); asf_st->ds_packet_size = get_le16(pb); asf_st->ds_chunk_size = get_le16(pb); get_le16(pb); get_byte(pb); } if (asf_st->ds_span > 1) { if (!asf_st->ds_chunk_size || (asf_st->ds_packet_size/asf_st->ds_chunk_size <= 1) || asf_st->ds_packet_size % asf_st->ds_chunk_size) asf_st->ds_span = 0; } switch (st->codec->codec_id) { case CODEC_ID_MP3: st->codec->frame_size = MPA_FRAME_SIZE; break; case CODEC_ID_PCM_S16LE: case CODEC_ID_PCM_S16BE: case CODEC_ID_PCM_U16LE: case CODEC_ID_PCM_U16BE: case CODEC_ID_PCM_S8: case CODEC_ID_PCM_U8: case CODEC_ID_PCM_ALAW: case CODEC_ID_PCM_MULAW: st->codec->frame_size = 1; break; default: st->codec->frame_size = 1; break; } } else if (type == AVMEDIA_TYPE_VIDEO) { get_le32(pb); get_le32(pb); get_byte(pb); size = get_le16(pb); sizeX= get_le32(pb); st->codec->width = get_le32(pb); st->codec->height = get_le32(pb); get_le16(pb); st->codec->bits_per_coded_sample = get_le16(pb); tag1 = get_le32(pb); url_fskip(pb, 20); size= sizeX; if (size > 40) { st->codec->extradata_size = size - 40; st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); get_buffer(pb, st->codec->extradata, st->codec->extradata_size); } if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) { st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl)); #if HAVE_BIGENDIAN for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++) st->codec->palctrl->palette[i] = bswap_32(((uint32_t*)st->codec->extradata)[i]); #else memcpy(st->codec->palctrl->palette, st->codec->extradata, FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)); #endif st->codec->palctrl->palette_changed = 1; } st->codec->codec_tag = tag1; st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag1); if(tag1 == MKTAG('D', 'V', 'R', ' ')) st->need_parsing = AVSTREAM_PARSE_FULL; if(st->codec->codec_id == CODEC_ID_H264) st->need_parsing = AVSTREAM_PARSE_FULL_ONCE; } pos2 = url_ftell(pb); url_fskip(pb, gsize - (pos2 - pos1 + 24)); } else if (!guidcmp(&g, &ff_asf_comment_header)) { int len1, len2, len3, len4, len5; len1 = get_le16(pb); len2 = get_le16(pb); len3 = get_le16(pb); len4 = get_le16(pb); len5 = get_le16(pb); get_tag(s, "title" , 0, len1); get_tag(s, "author" , 0, len2); get_tag(s, "copyright", 0, len3); get_tag(s, "comment" , 0, len4); url_fskip(pb, len5); } else if (!guidcmp(&g, &stream_bitrate_guid)) { int stream_count = get_le16(pb); int j; for(j = 0; j < stream_count; j++) { int flags, bitrate, stream_id; flags= get_le16(pb); bitrate= get_le32(pb); stream_id= (flags & 0x7f); asf->stream_bitrates[stream_id]= bitrate; } } else if (!guidcmp(&g, &ff_asf_language_guid)) { int j; int stream_count = get_le16(pb); for(j = 0; j < stream_count; j++) { char lang[6]; unsigned int lang_len = get_byte(pb); get_str16_nolen(pb, lang_len, lang, sizeof(lang)); if (j < 128) av_strlcpy(asf->stream_languages[j], lang, sizeof(*asf->stream_languages)); } } else if (!guidcmp(&g, &ff_asf_extended_content_header)) { int desc_count, i; desc_count = get_le16(pb); for(i=0;i<desc_count;i++) { int name_len,value_type,value_len; char name[1024]; name_len = get_le16(pb); if (name_len%2) name_len += 1; get_str16_nolen(pb, name_len, name, sizeof(name)); value_type = get_le16(pb); value_len = get_le16(pb); if (!value_type && value_len%2) value_len += 1; get_tag(s, name, value_type, value_len); } } else if (!guidcmp(&g, &ff_asf_metadata_header)) { int n, stream_num, name_len, value_len, value_type, value_num; n = get_le16(pb); for(i=0;i<n;i++) { char name[1024]; get_le16(pb); stream_num= get_le16(pb); name_len= get_le16(pb); value_type= get_le16(pb); value_len= get_le32(pb); get_str16_nolen(pb, name_len, name, sizeof(name)); value_num= get_le16(pb); url_fskip(pb, value_len - 2); if(stream_num<128){ if (!strcmp(name, "AspectRatioX")) dar[stream_num].num= value_num; else if(!strcmp(name, "AspectRatioY")) dar[stream_num].den= value_num; } } } else if (!guidcmp(&g, &ff_asf_ext_stream_header)) { int ext_len, payload_ext_ct, stream_ct; uint32_t ext_d, leak_rate, stream_num; unsigned int stream_languageid_index; get_le64(pb); get_le64(pb); leak_rate = get_le32(pb); get_le32(pb); get_le32(pb); get_le32(pb); get_le32(pb); get_le32(pb); get_le32(pb); get_le32(pb); stream_num = get_le16(pb); stream_languageid_index = get_le16(pb); if (stream_num < 128) asf->streams[stream_num].stream_language_index = stream_languageid_index; get_le64(pb); stream_ct = get_le16(pb); payload_ext_ct = get_le16(pb); if (stream_num < 128) bitrate[stream_num] = leak_rate; for (i=0; i<stream_ct; i++){ get_le16(pb); ext_len = get_le16(pb); url_fseek(pb, ext_len, SEEK_CUR); } for (i=0; i<payload_ext_ct; i++){ get_guid(pb, &g); ext_d=get_le16(pb); ext_len=get_le32(pb); url_fseek(pb, ext_len, SEEK_CUR); } continue; } else if (!guidcmp(&g, &ff_asf_head1_guid)) { int v1, v2; get_guid(pb, &g); v1 = get_le32(pb); v2 = get_le16(pb); continue; } else if (!guidcmp(&g, &ff_asf_marker_header)) { int i, count, name_len; char name[1024]; get_le64(pb); get_le64(pb); count = get_le32(pb); get_le16(pb); name_len = get_le16(pb); for(i=0;i<name_len;i++){ get_byte(pb); } for(i=0;i<count;i++){ int64_t pres_time; int name_len; get_le64(pb); pres_time = get_le64(pb); get_le16(pb); get_le32(pb); get_le32(pb); name_len = get_le32(pb); get_str16_nolen(pb, name_len * 2, name, sizeof(name)); ff_new_chapter(s, i, (AVRational){1, 10000000}, pres_time, AV_NOPTS_VALUE, name ); } #if 0 } else if (!guidcmp(&g, &ff_asf_codec_comment_header)) { int len, v1, n, num; char str[256], *q; char tag[16]; get_guid(pb, &g); print_guid(&g); n = get_le32(pb); for(i=0;i<n;i++) { num = get_le16(pb); get_str16(pb, str, sizeof(str)); get_str16(pb, str, sizeof(str)); len = get_le16(pb); q = tag; while (len > 0) { v1 = get_byte(pb); if ((q - tag) < sizeof(tag) - 1) *q++ = v1; len--; } *q = '\0'; } #endif } else if (url_feof(pb)) { return -1; } else { if (!s->keylen) { if (!guidcmp(&g, &ff_asf_content_encryption)) { av_log(s, AV_LOG_WARNING, "DRM protected stream detected, decoding will likely fail!\n"); } else if (!guidcmp(&g, &ff_asf_ext_content_encryption)) { av_log(s, AV_LOG_WARNING, "Ext DRM protected stream detected, decoding will likely fail!\n"); } else if (!guidcmp(&g, &ff_asf_digital_signature)) { av_log(s, AV_LOG_WARNING, "Digital signature detected, decoding will likely fail!\n"); } } } if(url_ftell(pb) != gpos + gsize) av_log(s, AV_LOG_DEBUG, "gpos mismatch our pos=%"PRIu64", end=%"PRIu64"\n", url_ftell(pb)-gpos, gsize); url_fseek(pb, gpos + gsize, SEEK_SET); } get_guid(pb, &g); get_le64(pb); get_byte(pb); get_byte(pb); if (url_feof(pb)) return -1; asf->data_offset = url_ftell(pb); asf->packet_size_left = 0; for(i=0; i<128; i++){ int stream_num= asf->asfid2avid[i]; if(stream_num>=0){ AVStream *st = s->streams[stream_num]; if (!st->codec->bit_rate) st->codec->bit_rate = bitrate[i]; if (dar[i].num > 0 && dar[i].den > 0) av_reduce(&st->sample_aspect_ratio.num, &st->sample_aspect_ratio.den, dar[i].num, dar[i].den, INT_MAX); if (asf->streams[i].stream_language_index < 128) { const char *rfc1766 = asf->stream_languages[asf->streams[i].stream_language_index]; if (rfc1766 && strlen(rfc1766) > 1) { const char primary_tag[3] = { rfc1766[0], rfc1766[1], '\0' }; const char *iso6392 = av_convert_lang_to(primary_tag, AV_LANG_ISO639_2_BIBL); if (iso6392) av_metadata_set2(&st->metadata, "language", iso6392, 0); } } } } return 0; }
1threat
How to @import .css file as a .scss file in sass? : <p>I am using gulp as a task runner which merge and minifying <code>scss</code> files for me. In this case if I try to import a regular <code>CSS</code> file, it will compile to a css <code>import</code> statement as below:</p> <pre class="lang-css prettyprint-override"><code>/* style.scss */ @import "../../bower_components/animate.css/animate.css"; /* style.css */ @import url(../../bower_components/animate.css/animate.css); </code></pre> <p>So how to import that regular css file, to have a <strong>compiled</strong> version of that in the <code>style.css</code> instead of just <code>css @import</code> statement?</p>
0debug
MPAndroidChart - First and last bars not rendering correctly : <ol> <li><p>In the bar chart I am creating the first and last rows are consistently being cut in half (even if I add additional bars). This also causes the values above the bars to be out of place. I am inflating this within a fragment.</p></li> <li><p>The axis are also only increasing by 0.9 instead of 1. To fix this do I need to implement the AxisValueFormatter interface?</p></li> </ol> <p>Image:</p> <p><a href="https://i.stack.imgur.com/ryrxj.png"><img src="https://i.stack.imgur.com/ryrxj.png" alt="enter image description here"></a></p> <p>Code: .java</p> <pre><code>chart = (BarChart) view.findViewById(R.id.chart1); // Chart settings chart.setDrawGridBackground(false); chart.setHighlightFullBarEnabled(true); chart.setDrawBarShadow(false); chart.setDrawValueAboveBar(true); chart.setDescription(""); // Settings for X-Axis XAxis xAxis = chart.getXAxis(); xAxis.setDrawGridLines(false); xAxis.setEnabled(true); xAxis.setDrawLabels(true); xAxis.setPosition(XAxisPosition.BOTTOM); // Settings for Y-Axis YAxis leftAxis = chart.getAxisLeft(); YAxis rightAxis = chart.getAxisRight(); leftAxis.setAxisMinValue(0f); rightAxis.setAxisMinValue(0f); BARENTRY = new ArrayList&lt;&gt;(); BarEntryLabels = new ArrayList&lt;String&gt;(); BARENTRY.add(new BarEntry(2f, 1)); BARENTRY.add(new BarEntry(3f, 2)); BARENTRY.add(new BarEntry(4f, 3)); BARENTRY.add(new BarEntry(5f, 4)); BARENTRY.add(new BarEntry(6f, 5)); Bardataset = new BarDataSet(BARENTRY, "Projects"); Bardataset.setColors(ColorTemplate.COLORFUL_COLORS); BARDATA = new BarData(Bardataset); chart.setData(BARDATA); chart.invalidate(); // refresh chart.animateY(1500); return view; </code></pre>
0debug
"You are binding v-model directly to a v-for iteration alias" : <p>Just run into this error I hadn't encountered before: "You are binding v-model directly to a v-for iteration alias. This will not be able to modify the v-for source array because writing to the alias is like modifying a function local variable. Consider using an array of objects and use v-model on an object property instead." I am a little puzzled, as I don't appear to be doing anythong wrong. The only difference from other v-for loops I've used before is that this one is a little simpler, in that it's simply looping through an array of strings, rather than objects:</p> <pre><code> &lt;tr v-for="(run, index) in this.settings.runs"&gt; &lt;td&gt; &lt;text-field :name="'run'+index" v-model="run"/&gt; &lt;/td&gt; &lt;td&gt; &lt;button @click.prevent="removeRun(index)"&gt;X&lt;/button&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>The error message would seem to suggest that I need to actually make things a little more complicated, and use objects instead of simple strings, which somehow doesn't seem right to me. Am I missing something?</p>
0debug
Gradle console - get more log output : <p>I am using Android studio. In the gradle console getting the below error message</p> <blockquote> <p>Compilation error. See log for more details</p> <ul> <li>Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.</li> </ul> <p>BUILD FAILED</p> </blockquote> <p>But where to run <strong>--info option</strong> to see the more log ?</p>
0debug
Why "this" is undefined inside a fat arrow function definition? : <p>First I tried this -</p> <pre><code>const profile = { name: 'Alex', getName: function(){ return this.name; } }; </code></pre> <p>Which works fine. Now I tried the same thing with fat arrow. In that case "this" is coming undefined.</p> <pre><code>const profile = { name: 'Alex', getName: () =&gt; { return this.name; } }; </code></pre> <p>This gives me an error </p> <blockquote> <p>TypeError: Cannot read property 'name' of undefined</p> </blockquote> <p>What I learned was, fat arrow syntaxes are way better handling implicit "this". Please explain why is this happening.</p>
0debug
Android Studio Help Java Error : Hi guys I have the following code and I have a Java error. Could someone please help me out? Thanks My activity_main.xml is: <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout 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:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.andriod.justjava.MainActivity"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="QUANTITY" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/quantity_text_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="16dp" android:text="0" android:textColor="@android:color/black" android:textSize="16sp" /> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:onClick="submitOrder" android:text="Order" /> </LinearLayout> </android.support.constraint.ConstraintLayout> The red that is marking is the .MainActicity in tools:context="com.example.andriod.justjava.MainActivity"> and I can't it is telling me ''Validates inside refernces inside Android XML file''. While my MainActivity.java: /** * IMPORTANT: Make sure you are using the correct package name. * This example uses the package name: * package com.example.android.justjava * If you get an error when copying this code into Android studio, update it to match teh package name found * in the project's AndroidManifest.xml file. **/ package com.example.android.justjava; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; import com.example.andriod.justjava.R; /** * This app displays an order form to order coffee. */ public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } /** * This method is called when the order button is clicked. */ public void submitOrder(View view) { display(1); } /** * This method displays the given quantity value on the screen. */ private void display(int number) { TextView quantityTextView = (TextView) findViewById(R.id.quantity_text_view); quantityTextView.setText("" + number); } } tells me that MainActivity from public class MainActivity extends AppCompatActivity { ''is not registed in the manifest Androidmainfest.xml file'' Culd someone please help me out since I'm assuming it's something pretty stupid and I'm a noob. Thanks
0debug
gcloud app deploy, flag to automate prompting? : <p>Is it possible to do silent deployment when using <code>gcloud app deploy</code></p> <p>When I run the command <code>gcloud app deploy ./deployment/app.yaml --version v1</code> its always prompting for </p> <p><code>Do you want to continue (Y/n)? Y</code></p> <p>how to automate this? is there any flag that we can pass in to mute this? </p>
0debug
Can someone help me find why there's no output I'm new to c? : #include <stdio.h> #include <string.h> #include <ctype.h> int main(void) { char str[50]; int count[26] = {0}; int x; int len; int max; printf("Enter your input: "); scanf("%s", str); while( ! feof(stdin)) { len = strlen(str); for(x = 0; x < len; ++x) { char ch = str[x]; int sub = ch - 97; count[sub] = count[sub] + 1; } scanf("%s", str); } max = count[0]; for(x = 0; x < len; ++x) { if(count[x] > max){ max = count[x]; } } printf("Missing letters: "); for(x = 0; x < 26; ++x) { if(count[x] == 0) { x = x + 97; printf("%c", x); } } printf("\n"); return 0; } I've been trying to fix this for a few hours now and I'm just not understanding. I think the issue is with the while loop, but I've just started coding I have no idea. Does anything jump out at anyone? This is supposed to read a sentence and output the letters that were not seen. Thank you.
0debug
AVVDPAUContext *av_vdpau_alloc_context(void) { return av_mallocz(sizeof(AVVDPAUContext)); }
1threat
Optional JSX Props In a TSX/JSX Project : <p>I have a React project that I'm converting from JS to TS. An issue I'm running into is that TSX React is assuming that all properties defined in a functional component are required props.</p> <pre><code>// ComponentA.tsx class ComponentA extends React.Component&lt;any, any&gt; { render() { /* Type '{ equalWidth: true; children: Element[]; }' is not assignable to type '{ children: any; className: any; equalWidth: any; }'. * Property 'className' is missing in type '{ equalWidth: true; children: Element[]; }'.' */ return &lt;ComponentB equalWidth /&gt; } } </code></pre> <p>and</p> <pre><code>// ComponentB.js const ComponentB = ({ children, className, equalWidth }) =&gt; { return (...) } </code></pre> <p>is there a way to signal to TS that JSX component props are all optional?</p>
0debug
Warning assignment from incompatible pointer type while assiging to another parameter : In my code i'm getting this warning while compiling. I tried to fix this my i'm unable to solve this issue. static uint8_t tx_data; int *recvdata2,*recvdata; recvdata= str2int(tx_data); //warning assignment from incompatible pointer type recvdata2=(uint8_t*)&recvdata str2int is a function to convert the string to integer. int str2int(char *str) { int res=0; int i; for ( i = 0; str[i] != '\0'; ++i) res=(res)*10+str[i]-'0'; return res; } I'm a noobie to this. Please help me to fix this issue. Any help will be appreciated.
0debug
Odata service model for SAPUI5 App : I'm trying to build a Odata model. My last successful time was following the guide to import the transparent table and create an EntitySet and implement CRUD function into the generated classes via ABAP workbench. This time I wanna create model by importing the view (of some Master Data Tables) and do not create EntitySet. I just need to select the data to read. There is no need for inserts, modify or delete records. Anyone please can show me if there are any guides that I can follow. Thank you and Best regards,
0debug
React Router DOM not working correctly on Amplify Console AWS : <p>I have deployed react app on Amplify Console following their documentation. The site is deployed and running fine, I am able to navigate using links but when I try to land to any url directly I get redirected to my configured 404 page.</p> <p>Below is the code I am using</p> <pre><code>ReactDOM.render( &lt;Router&gt; &lt;Route path="/" component={App} /&gt; &lt;/Router&gt;, document.getElementById("root"), ); </code></pre> <p>And here is how my route looks like -</p> <pre><code>&lt;Switch&gt; &lt;Route exact path="/" render={(): JSX.Element =&gt; &lt;Home auth={this.auth} /&gt;} /&gt; &lt;Route path="/features" render={(): JSX.Element =&gt; &lt;Features /&gt;} /&gt; &lt;Route path="/pagenotfound" render={(): JSX.Element =&gt; &lt;PageNotFound /&gt;} /&gt; &lt;Redirect from="/**" to="/pagenotfound" /&gt; &lt;/Switch&gt; </code></pre> <p>Here is the link to the app - <a href="https://master.dkf0zemoh330o.amplifyapp.com/features" rel="noreferrer">https://master.dkf0zemoh330o.amplifyapp.com/features</a></p>
0debug
static int net_vde_init(VLANState *vlan, const char *model, const char *name, const char *sock, int port, const char *group, int mode) { VDEState *s; char *init_group = strlen(group) ? (char *)group : NULL; char *init_sock = strlen(sock) ? (char *)sock : NULL; struct vde_open_args args = { .port = port, .group = init_group, .mode = mode, }; s = qemu_mallocz(sizeof(VDEState)); s->vde = vde_open(init_sock, "QEMU", &args); if (!s->vde){ free(s); return -1; } s->vc = qemu_new_vlan_client(vlan, model, name, vde_from_qemu, NULL, s); qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s); snprintf(s->vc->info_str, sizeof(s->vc->info_str), "sock=%s,fd=%d", sock, vde_datafd(s->vde)); return 0; }
1threat
Why does this implementation of move corresponding work? vb.net : Since three is read only and depends on a non property (four). Three should be undefined. How does props, which does not set four, set three to the correct value? -------------------------------------------------- public sub main Dim x1 = New one, x2 = New two x1.one = 3 MoveCorresponding(x1, x2) end sub Public Sub MoveCorresponding(a As Object, b As Object, Optional ignoreList As List(Of String) = Nothing) Dim oType As Type = b.GetType Dim iType = a.GetType Dim props = iType.GetProperties() For Each pInf As PropertyInfo In props Dim parName = pInf.Name If pInf.CanWrite Then Try Dim val = pInf.GetValue(a, Nothing) pInf.SetValue(b, val) Catch ex As Exception MsgBox(ex.Message) End Try End If Next End Sub End Class Class one Public Property one As String = "1" Dim four As Integer = 1 Public ReadOnly Property three As Integer Get Return four * 10 End Get End Property End Class
0debug
any one help me.. how to convert in codeigniter : SELECT sum(`quantity`) as 'Total Product Sales',product.i_name as 'Product Name' FROM `order_details` inner join orders on orders.order_id = order_details.order_id and orders.status like 'C' inner join product on product.p_id = order_details.product_id group by order_details.product_id
0debug
int ff_qsv_enc_close(AVCodecContext *avctx, QSVEncContext *q) { QSVFrame *cur; MFXVideoENCODE_Close(q->session); if (q->internal_session) MFXClose(q->internal_session); q->session = NULL; q->internal_session = NULL; cur = q->work_frames; while (cur) { q->work_frames = cur->next; av_frame_free(&cur->frame); av_freep(&cur); cur = q->work_frames; } while (q->async_fifo && av_fifo_size(q->async_fifo)) { AVPacket pkt; mfxSyncPoint sync; mfxBitstream *bs; av_fifo_generic_read(q->async_fifo, &pkt, sizeof(pkt), NULL); av_fifo_generic_read(q->async_fifo, &sync, sizeof(sync), NULL); av_fifo_generic_read(q->async_fifo, &bs, sizeof(bs), NULL); av_freep(&bs); av_packet_unref(&pkt); } av_fifo_free(q->async_fifo); q->async_fifo = NULL; av_frame_free(&avctx->coded_frame); return 0; }
1threat
void kvm_s390_interrupt_internal(S390CPU *cpu, int type, uint32_t parm, uint64_t parm64, int vm) { CPUState *cs = CPU(cpu); struct kvm_s390_interrupt kvmint; int r; if (!cs->kvm_state) { return; } kvmint.type = type; kvmint.parm = parm; kvmint.parm64 = parm64; if (vm) { r = kvm_vm_ioctl(cs->kvm_state, KVM_S390_INTERRUPT, &kvmint); } else { r = kvm_vcpu_ioctl(cs, KVM_S390_INTERRUPT, &kvmint); } if (r < 0) { fprintf(stderr, "KVM failed to inject interrupt\n"); exit(1); } }
1threat
apache cordova game development, is it valid? : <p>I've been developing a game using libgdx (Java), it's basically a super mario game, a few moving objects, some sound effects, could something like that be done with html5 and javascript?</p> <p>I tried searching the world wide web for some info, but didn't find a lot, I guess it's not common, or even possible?</p> <p>I'm asking because I want to create non-game apps as well, and will be using apache cordova for those, would be nice to use the same language. </p>
0debug
Reactjs: How to open a multiple message box with reactjs : How to open a multiple message box with reactjs Am building a multiple chatbox like facebook. At the moment, User can call up a chatbox, can close it, minimize it etc. **Here is the issue.** when I click on different users for example three users, am supposed to have three chatbox pop up that corresponds to those three different users but its showing just one chatbox. Any help will be appreciated. **Here is the full code** import React, { Component, Fragment } from "react"; import { render } from "react-dom"; import axios from 'axios'; import './style.css'; class MessageBox extends Component { constructor() { super(); this.state = { showBox: false, shownToggle: true, data: [ { id: "1", name: "Tony" }, { id: "2", name: "Mark"}, { id: "3", name: "Joy"} ], currentRec: undefined, }; this.showBox = this.showBox.bind(this); this.closeBox = this.closeBox.bind(this); this.toggle = this.toggle.bind(this); } showBox = (i, pid, name) => { // showBox(pid, name) { this.setState({ currentRec: i }); console.log(`Selected record index: ${i}`); alert(pid); alert(name); //event.preventDefault(); this.setState({ showBox: true }, () => { document.addEventListener('click', this.closeBox); }); } closeBox(event) { if (this.dropdownBox.contains(event.target)) { this.setState({ showBox: false }, () => { document.removeEventListener('click', this.closeBox); }); } } toggle() { this.setState({ shownToggle: !this.state.shownToggle }); } /* handleChat(id, name) { alert(id); alert(name); } */ render() { var hidden = { display: this.state.shownToggle ? "block" : "none" } return ( <div> <ul style={{float: "right"}}> {this.state.data.map((person, i) => ( <div className="chat-sidebar" key={i}> <button onClick={ () => this.showBox(i, person.id, person.name)}> Chat with {person.name}</button> {this.state.showBox ? ( <div className="msg_box" style={{right: '270px'}}> <div onClick={this.toggle.bind(this)} class="msg_head"> (<b style={{color: 'orange'}}> {this.state.currentRec !== undefined && <div className="modal-body"> {this.state.data[this.state.currentRec].name} ({this.state.data[this.state.currentRec].id}) </div>} </b>) Minimize <div className="close" ref={(element) => {this.dropdownBox = element;}} style={{color: 'white'}}>Close</div> </div> <div style={ hidden } className="msg_wrap"> <div className="msg_body">Message will appear here</div> </div> </div> ): ( null )} </div> ))} </ul> </div> ); } } **Here is the css** /**** Chat Popup Layout******/ body{ background:#e5e5e5; font-family: sans-serif; } .msg_box{ position:fixed; bottom:-5px; width:250px; background:white; border-radius:5px 5px 0px 0px; } .msg_head{ background:black; color:white; padding:8px; font-weight:bold; cursor:pointer; border-radius:5px 5px 0px 0px; } .msg_body{ background:white; height:200px; font-size:12px; padding:15px; overflow:auto; overflow-x: hidden; } .close{ float:right; cursor:pointer; } .minimize{ float:right; cursor:pointer; padding-right:5px; } /**** Slider Layout Popup *********/ .chat-sidebar { width: 250px; //position: fixed; height: 100%; right: 0px; top: 0px; padding-top: 10px; padding-bottom: 10px; border: 1px solid #b2b2b2; }
0debug
Why doesn`t operator<< work successfuly? : While compiling these code blocks, i am getting error like this below. What is my mistake in here? What should i do to fix? And while giving initial value to parameter like this "Os(std::cout)" what does it mean ? error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and 'std::ostream {aka std::basic_ostream<char>}') Os << "Os: " << Os << std::endl; //Expression.h class Expression{ ... protected: std::ostream Os; }; //Expression.c Expression::Expression(): Os(std::cout) { ... } Expression::Expression(std::ostream&os):Os(os) { ... } Expression::Dump() { Os << "=============================================================" << std::endl; Os << "Os: " << Os << std::endl; }
0debug
Can developer lock other apps in iOS 10? : <p>Does Apple allow third party developer lock other app or setup passcode for other apps in iOS10?</p> <p>If so, what is the best library to do it?</p>
0debug
use of undeclared type UIViewController : <p>I have not changed anything major in this swift file, yet for some reason when I went to run my app I got a new error stating "Use of undeclared type UIViewController" in the first line of my swift file. I have tried cleaning and checking the targets, but am unable to figure out the issue.</p> <p>I am getting an errors on every line below, excluding the import statements</p> <pre><code>import Foundation import FirebaseAuth import FirebaseDatabase public class User: UIViewController { @IBOutlet weak var _Fname: UITextField! @IBOutlet weak var _Lname: UITextField! @IBOutlet weak var _Email: UITextField! @IBOutlet weak var _Password1: UITextField! @IBOutlet weak var _Password2: UITextField! </code></pre> <p>Please let me know if you have any thoughts on why this may be occurring. Thanks in advance!</p>
0debug
Preg_replace for a specific iframe : <p>Writing a quick plugin to strip Amazon associate links out of emails and feed to not brake the terms ofservice. Worked it all out apart from the iframe.</p> <p>A typical iframe associate link looks like this</p> <pre><code> &lt;iframe style="width:120px;height:240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="//ws-eu.amazon-adsystem.com/widgets/q?ServiceVersion=20070822&amp;OneJS=1&amp;Operation=GetAdHtml&amp;MarketPlace=GB&amp;source=ac&amp;ref=qf_sp_asin_til&amp;ad_type=product_link&amp;tracking_id=keepchickens-21&amp;marketplace=amazon&amp;region=GB&amp;placement=1473689309&amp;asins=1473689309&amp;linkId=2ee7072c3050c40cded9c2ecdb317332&amp;show_border=true&amp;link_opens_in_new_window=true&amp;price_color=333333&amp;title_color=0066c0&amp;bg_color=ffffff"&gt; &lt;/iframe&gt; </code></pre> <p>This regexp </p> <pre><code>/(&lt;iframe )(.*)(amazon.adsystem.com).*/ </code></pre> <p>picks up everything except the closing iframe tag I have tried variations of </p> <pre><code>/(&lt;iframe )(.*)(amazon.adsystem.com).*(&lt;/iframe&gt;)/ </code></pre> <p>But can't get it to work. Any ideas?</p>
0debug
Flutter Layout Container Margin : <p>I have a problem with my Flutter Layout.</p> <p>I have a simple container with a Margin right and left of 20.0 Inside this container i have another container.</p> <p>But this container does not fit to the parent container only on the left side. I dont know why this happens.</p> <p>Here is my Code:</p> <pre><code> @override Widget build(BuildContext context) { return new Scaffold( backgroundColor: Colors.white, body: new Container( margin: new EdgeInsets.symmetric(horizontal: 20.0), child: new Container( ) ), ); } </code></pre> <p><a href="https://i.stack.imgur.com/KtN8B.png" rel="noreferrer">Screenshot of the Problem</a></p>
0debug
Negative number modulo in swift : <p>How does modulo of negative numbers work in swift ? When i did (-1 % 3) it is giving -1 but the remainder is 2. What is the catch in it?</p>
0debug
Single user login at ont time in angular web application : <p>I have an application where UI is build in angular and communicates with back end asp.net core web api. To manage Authentication web api generate a JWT token with an expire date. I have a requirement to not allow any new user login where there is already and active user logged into the website.</p> <p>I have read some suggestion where active session in angular application need to call web api, to update status after some small time interval. I need some suggestion about possible approaches.</p>
0debug
Flutter internationalization - Dynamic strings : <p>I'm translating my app to spanish using the intl package. </p> <p>locales.dart</p> <pre><code>class AppLocale { ... String get folder =&gt; Intl.message("Folder", name: 'folder'); ... } </code></pre> <p>messages_es.dart</p> <pre><code>class MessageLookup extends MessageLookupByLibrary { get localeName =&gt; 'es'; final messages = _notInlinedMessages(_notInlinedMessages); static _notInlinedMessages(_) =&gt; &lt;String, Function&gt; { "folder": MessageLookupByLibrary.simpleMessage("Carpeta"), }; } </code></pre> <p>I call it using the following code:</p> <pre><code>AppLocale.of(context).folder </code></pre> <p>It is working fine. </p> <p>However, I need to create "dynamic" strings. For example:</p> <p>"Hi, {$name}"</p> <p>Then I would call this string, passing this "name" as parameter, or something like this. It would be translate as "Hola, {$name}" in spanish.</p> <p>It is possible using this intl package?</p>
0debug