problem
stringlengths
26
131k
labels
class label
2 classes
Is this a valid way of checking if a variadic macro argument list is empty? : <p>I've been looking for a way to check if a variadic macro argument list is empty. All solutions I find seem to be either quite complex or using non-standard extensions. </p> <p>I think I've found an easy solution that is both compact and standard:</p> <pre><code>#define is_empty(...) ( sizeof( (char[]){#__VA_ARGS__} ) == 1 ) </code></pre> <p>Q: Are there any circumstances where my solution will fail or invoke poorly-defined behavior?</p> <p>Based on C17 6.10.3.2/2 (the # operator): <em>"The character string literal corresponding to an empty argument is <code>""</code>"</em>, I believe that <code>#__VA_ARGS__</code> is always well-defined. </p> <p>Explanation of the macro:</p> <ul> <li>This creates a compound literal char array and initializes it by using a string literal.</li> <li>No matter what is passed to the macro, all arguments will be translated to one long string literal. </li> <li>In case the macro list is empty, the string literal will become <code>""</code>, which consists only of a null terminator and therefore has size 1. </li> <li>In all other cases, it will have a size greater than 1.</li> </ul>
0debug
Difference between generators and functions returning generators : <p>I was debugging some code with generators and came to this question. Assume I have a generator function</p> <pre><code>def f(x): yield x </code></pre> <p>and a function returning a generator:</p> <pre><code>def g(x): return f(x) </code></pre> <p>They surely return the same thing. Can there be any differences when using them interchangeably in Python code? Is there any way to distinguish the two (without <code>inspect</code>)?</p>
0debug
Angular 2 - communication of typescript functions with external js libraries : <p>Using <a href="https://philogb.github.io/jit/" rel="noreferrer">Javascript Infovis Toolkit</a> as an external library for drawing graph and trees. I need to manipulate the onClick method of nodes in order to asynchronously sending an HTTP GET request to the server and assign the data that comes from server to the properties and variables of an Angular service class. By Using webpack for packing all the compiled typescripts to a single js file, the output file is confusing and unreadable. so calling a function which is in the compiled js file from an external js library, is not the best solution clearly.</p> <p>I try the following solution inside my Angular service so I can access to the properties of this service without any trouble:</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>document.addEventListener('DOMContentLoaded', function () { var nodes = document.querySelectorAll(".nodes"); // nodes = [] for (var i = 0; i &lt; nodes.length; i++) { // nodes.length = 0 nodes[i].addEventListener("click", function () { // asynchronously sending GET request to the server // and assing receiving data to the properties of this Angular service }); } });</code></pre> </div> </div> </p> <p>However, this solution doesn't work because in Javascript Infovis Toolkit the nodes are drawn after finishing rendering of DOM and also after <code>window.onload</code> event. This library has some lifecycle methods such as onAfterCompute() which is called after drawing tree is completed. How can I trigger a global event to inform the Angular service that the drawing of tree is completed and it can query all of the nodes?</p>
0debug
get the value of a point by interpolation in R : <p>I need to get the value of temperature in a point (latitude, longitude) using the value of temperature of others points (latitude, longitude) by interpolation... I have the temperature of some stations (for exemple, 10, 40.01, 03.00 ....) in a csv file. I want to use only the values inside a radio from my point. How can I do that in R?</p>
0debug
C++ Problems modifying string with numbers : <p>I have made a simple encryption function,which encrypts everything except 0-9 numbers (ignoring the special characters).</p> <p>Here is the code.</p> <pre><code>#include &lt;iostream&gt; using namespace std; void encrypt(char s[]) { char *ptr; ptr=s; while(*ptr) { switch (*ptr) { case 'a': *ptr='b'; break; case 'b': *ptr='a'; break; case 'c': *ptr='z'; break; case 'd': *ptr='y'; break; case 'e': *ptr='c'; break; case 'f': *ptr='d'; break; case 'g': *ptr='x'; break; case 'h': *ptr='g'; break; case 'i': *ptr='i'; break; case 'j': *ptr='h'; break; case 'k': *ptr='f'; break; case 'l': *ptr='j'; break; case 'm': *ptr='q'; break; case 'n': *ptr='o'; break; case 'o': *ptr='p'; break; case 'p': *ptr='m'; break; case 'q': *ptr='n'; break; case 'r': *ptr='l'; break; case 's': *ptr='k'; break; case 't': *ptr='x'; break; case 'u': *ptr='w'; break; case 'v': *ptr='u'; break; case 'w': *ptr='v'; break; case 'x': *ptr='t'; break; case 'y': *ptr='s'; break; case 'z': *ptr='r'; break; case 1: *ptr=5; break; case 2: *ptr=6; break; case 3: *ptr=0; break; case 4: *ptr=1; break; case 5: *ptr=2; break; case 6: *ptr=7; break; case 7: *ptr=4; break; case 8: *ptr=3; break; case 9: *ptr=8; break; case 0: *ptr=9; break; default: *ptr=*ptr; break; } *ptr++; } *ptr='\0'; } int main() { char password[10]; cout&lt;&lt;"Enter the password\n"; cin&gt;&gt;password; encrypt(password); cout&lt;&lt;password&lt;&lt;endl; return 0; } </code></pre> <p>Here is a sample output sh-4.3$ main<br> Enter the password<br> thisisanex!!1234567<br> xgikikboct!!1234567 </p>
0debug
Why does closing a channel in defer statement panics? : In the following example, a go routine is pumping values into unbuffered channel and the main function is iterating over it. ```go package main import ( "fmt" "strconv" ) var chanStr chan string func main() { go pump() fmt.Println("iterating ...") for val := range chanStr { fmt.Printf("fetched val: %s from channel\n", val) } } func pump() { defer close(chanStr) chanStr = make(chan string) for i := 1; i <= 5; i++ { fmt.Printf("pumping seq %d into channel\n", i) chanStr <- "val" + strconv.Itoa(i) } //close(chanStr) } ``` The function panics with the following output: ``` iterating ... pumping seq 1 into channel pumping seq 2 into channel fetched val: val1 from channel ...... fetched val: val4 from channel pumping seq 5 into channel panic: close of nil channel goroutine 5 [running]: main.pump() C:/personal/gospace/go-rules/test.go:26 +0x1a6 created by main.main C:/personal/gospace/go-rules/test.go:11 +0x4e ``` However if I comment the defer statement and close right after the for loop in the goroutine `pump` , the receiver doesn't panic. *What's the difference in both the cases?* Looks like defer closes the channel before the value is received but the regular close waits. Also when I built using the race detector on, even in the regular close it flags a potential race condition (I'm not able recreate the race every time). Does it imply that both of those ways are not right in gracefully closing the channel?
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
HTML horizonal aligment : I have a div in which theres an image and an text. <div class="logo"> <img src="images/car_logo.png" alt="logo" width="100px" height="100px"> <h1>Some text</h1> </div> Right now, the logo is above the text. I want that the logo would be on left and text on right but close to each other, so I can add something else on the far side of left page. Thank you in advance
0debug
android studio 2: Capture latitude and longitude : i know this question is repeated question, but i didn't find a clear overview. I am using Studio 2.1 and I need below information. I am developing a app, which capture the latitude and logitude from one mobile and send those details to Master/Server Mobile, So that server mobile will show the tracking maps on server mobile. Here i need an over all process. 1. I developed a background code in client mobile After 1st step, i am confused how to move further. Do i need to create any website and capture the latitude and longitude. OR Do i need to follow any other steps. Please guide me only on higher level steps. Regards Kathi
0debug
Write a C++ program that prompts the user for the radius of a circle then calls inline function circleArea() to calculate the area of that circle : #include<stdio.h> #include<iostream> #include<math.h> using namespace std; class Circle { private: float radius; public: inline void circleArea(float) void input() { cout<<"\nEnter the radius of circle"; cin>>radius; } Circle() { float radius=0.0; } }; void circleArea() { float a,r; a=(3.14*r*r); } int main() { Circle c; c.input(); c.circleArea(); } Here i dont undestand how to put inline function,and i am not getting any output,my output shows blank space after putting the value of radius please help..
0debug
static void virtio_serial_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); dc->exit = virtio_serial_device_exit; dc->props = virtio_serial_properties; set_bit(DEVICE_CATEGORY_INPUT, dc->categories); vdc->init = virtio_serial_device_init; vdc->get_features = get_features; vdc->get_config = get_config; vdc->set_config = set_config; vdc->set_status = set_status; vdc->reset = vser_reset; }
1threat
Best way to check for null values using *ngFor in Angular 2 : <p>I'm showing some records coming from an <code>api</code> and some of the results are null and I would like to show a different value in case the response values are null. How would be the best way to do it?</p> <p>Below is my code: </p> <p>Component: </p> <pre><code>import {Component, OnInit} from '@angular/core'; import {PerformancesService} from '../../services/performances.service'; import {Performance} from '../../common/performance'; @Component({ selector: 'performances', templateUrl: './app/components/performances/performances.component.html' }) export class PerformancesComponent implements OnInit{ performances: Performance[]; constructor(private _service : PerformancesService){ } getFunds(){ this._service.getData().then( performances =&gt; this.performances = performances ) } ngOnInit(){ this.getFunds(); } } </code></pre> <p>template: </p> <pre><code>&lt;h2&gt;Performance&lt;/h2&gt; &lt;table class="table table-hover"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Fund Id&lt;/th&gt; &lt;th&gt;Country Id&lt;/th&gt; &lt;th&gt;1Mth&lt;/th&gt; &lt;th&gt;3Mth&lt;/th&gt; &lt;th&gt;YTD&lt;/th&gt; &lt;th&gt;1Yr&lt;/th&gt; &lt;th&gt;3Yrs&lt;/th&gt; &lt;th&gt;5Yrs&lt;/th&gt; &lt;th&gt;10Yrs&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr *ngFor="let performance of performances"&gt; &lt;td&gt;{{performance.id}}&lt;/td&gt; &lt;td&gt;{{performance.country_id}}&lt;/td&gt; &lt;td&gt;{{performance.OneMonthBack}}&lt;/td&gt; &lt;td&gt;{{performance.ThreeMonthsBack}}&lt;/td&gt; &lt;td&gt;{{performance.YearToDate}}&lt;/td&gt; &lt;td&gt;{{performance.OneYearBack}}&lt;/td&gt; &lt;td&gt;{{performance.ThreeYearsBack}}&lt;/td&gt; &lt;td&gt;{{performance.FiveYearsBack}}&lt;/td&gt; &lt;td&gt;{{performance.TenYearsBack}}&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>I don't know if I could do it in the template or I should check each value in my component. Any idea? Thanks!</p>
0debug
rdt_parse_packet (AVFormatContext *ctx, PayloadContext *rdt, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t rtp_seq, int flags) { int seq = 1, res; AVIOContext pb; if (!rdt->rmctx) return AVERROR(EINVAL); if (rdt->audio_pkt_cnt == 0) { int pos; ffio_init_context(&pb, buf, len, 0, NULL, NULL, NULL, NULL); flags = (flags & RTP_FLAG_KEY) ? 2 : 0; res = ff_rm_parse_packet (rdt->rmctx, &pb, st, rdt->rmst[st->index], len, pkt, &seq, flags, *timestamp); pos = avio_tell(&pb); if (res < 0) return res; if (res > 0) { if (st->codec->codec_id == AV_CODEC_ID_AAC) { memcpy (rdt->buffer, buf + pos, len - pos); rdt->rmctx->pb = avio_alloc_context (rdt->buffer, len - pos, 0, NULL, NULL, NULL, NULL); } goto get_cache; } } else { get_cache: rdt->audio_pkt_cnt = ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb, st, rdt->rmst[st->index], pkt); if (rdt->audio_pkt_cnt == 0 && st->codec->codec_id == AV_CODEC_ID_AAC) av_freep(&rdt->rmctx->pb); } pkt->stream_index = st->index; pkt->pts = *timestamp; return rdt->audio_pkt_cnt > 0; }
1threat
AWS SSL on EC2 instance without Load Balancer - NodeJS : <p>Is it possible to have an EC2 instance running, listening on <code>port 443</code>, without a <code>load balancer</code>? I'm trying right now in my <code>Node.JS</code> app but it doesn't work when I call the page using <code>https://</code>. However, if I set it to <code>port 80</code> everything works fine with <code>http://</code>. </p> <p>I had it working earlier with a <code>load balancer</code> and <code>route53</code>, but I don't want to pay $18/mo for an ELB anymore, especially when I only have one server running.</p> <p>Thanks for the help</p>
0debug
const char *qemu_opt_get(QemuOpts *opts, const char *name) { QemuOpt *opt = qemu_opt_find(opts, name); if (!opt) { const QemuOptDesc *desc = find_desc_by_name(opts->list->desc, name); if (desc && desc->def_value_str) { return desc->def_value_str; } } return opt ? opt->str : NULL; }
1threat
how do i make a txt file editble from batch : So right now, I am trying to figure out how to make a .txt file editable by the user of the batch program. I already have the batch file creating the file, but now I need to make it so the .txt file has what the user answered for the question. Here is what I have now: `@echo off echo Welcome to the Space Mapping Discord Report Maker pause echo Made by N3ther, version 0.1 ALPHA pause @echo off break>"%userdomain%\%username%\Desktop\report.txt" echo Question 1: What is your username on Discord?` (It's for a report maker I am moderator on)
0debug
Fatal error: Call to a member function execute() on boolean on line 33 : <p>I've been getting one warning and one fatal error when trying to run the execute() command. I can't seem to find the error at my stm->execute();</p> <p>Here are my errors:</p> <blockquote> <p>Warning: mysqli_stmt::bind_param(): Invalid type or no types specified in C:\xampp\htdocs\library\admin-reg.php on line 20</p> <p>Fatal error: Call to a member function execute() on boolean in C:\xampp\htdocs\library\admin-reg.php on line 33</p> </blockquote> <p>Then this is a snippet of my code.</p> <pre><code> &lt;?php #CONNECTION require 'dbcon.php'; #INPUT CONTAINERS $ACTIVATION_CODE=$USERNAME=$PASSWORD=$EMAIL=$FIRST_NAME=$MIDDLE_NAME=$LAST_NAME=$CONTACT_NO=$ADDRESS=$PROFILE=''; #ERROR CONTAINERS $USERNAME=$PASSWORD=$EMAIL=$FIRST_NAME=$MIDDLE_NAME=$LAST_NAME=$CONTACT_NO=$ADDRESS=$PROFILE=$USER_TYPE=''; #CONNECTION/QUERY# $connection = mysqli_connect('localhost','root','','library_system') or die(mysqli_error()); $stm = $mysli_link-&gt;prepare("INSERT INTO users (username,password,first_name,middle_name,last_name,address,contact_no,email,activation_code) values(?,?,?,?,?,?,?,?,?)"); $stm = $stm-&gt;bind_param($USERNAME,$PASSWORD,$FIRST_NAME,$MIDDLE_NAME,$LAST_NAME,$ADDRESS,$CONTACT_NO,$EMAIL,$ACTIVATION_CODE); #VERIFICATION SCRIPT IF(isset($_POST['register'])){ $USERNAME = trim(mysqli_real_escape_string($connection,$_POST['username'])); $PASSWORD = trim(mysqli_real_escape_string($connection,password_hash($_POST['password'],PASSWORD_DEFAULT))); $EMAIL = trim(mysqli_real_escape_string($connection,$_POST['email'])); $FIRST_NAME = mysqli_real_escape_string($connection,$_POST['first_name']); $MIDDLE_NAME = mysqli_real_escape_string($connection,$_POST['middle_name']); $LAST_NAME = mysqli_real_escape_string($connection,$_POST['last_name']); $CONTACT_NO = trim(mysqli_real_escape_string($connection,$_POST['contact_no'])); $ADDRESS = mysqli_real_escape_string($connection,$_POST['address']); $ACTIVATION_CODE = md5($USERNAME.(rand(0,1000))); $USER_TYPE = "ADMIN"; $stm-&gt;execute(); } ?&gt; </code></pre> <p>Hope you can help me.</p>
0debug
uint64_t helper_ld_asi(target_ulong addr, int asi, int size, int sign) { uint64_t ret = 0; #if defined(DEBUG_ASI) target_ulong last_addr = addr; #endif asi &= 0xff; if ((asi < 0x80 && (env->pstate & PS_PRIV) == 0) || ((env->def->features & CPU_FEATURE_HYPV) && asi >= 0x30 && asi < 0x80 && !(env->hpstate & HS_PRIV))) raise_exception(TT_PRIV_ACT); helper_check_align(addr, size - 1); switch (asi) { case 0x82: case 0x8a: LE case 0x83: case 0x8b: LE { int access_mmu_idx = ( asi & 1 ) ? MMU_KERNEL_IDX : MMU_KERNEL_SECONDARY_IDX; if (cpu_get_phys_page_nofault(env, addr, access_mmu_idx) == -1ULL) { #ifdef DEBUG_ASI dump_asi("read ", last_addr, asi, size, ret); #endif return 0; } } case 0x10: case 0x11: case 0x18: LE case 0x19: LE case 0x80: case 0x81: case 0x88: LE case 0x89: LE case 0xe2: case 0xe3: if ((asi & 0x80) && (env->pstate & PS_PRIV)) { if ((env->def->features & CPU_FEATURE_HYPV) && env->hpstate & HS_PRIV) { switch(size) { case 1: ret = ldub_hypv(addr); break; case 2: ret = lduw_hypv(addr); break; case 4: ret = ldl_hypv(addr); break; default: case 8: ret = ldq_hypv(addr); break; } } else { if (asi & 1) { switch(size) { case 1: ret = ldub_kernel_secondary(addr); break; case 2: ret = lduw_kernel_secondary(addr); break; case 4: ret = ldl_kernel_secondary(addr); break; default: case 8: ret = ldq_kernel_secondary(addr); break; } } else { switch(size) { case 1: ret = ldub_kernel(addr); break; case 2: ret = lduw_kernel(addr); break; case 4: ret = ldl_kernel(addr); break; default: case 8: ret = ldq_kernel(addr); break; } } } } else { if (asi & 1) { switch(size) { case 1: ret = ldub_user_secondary(addr); break; case 2: ret = lduw_user_secondary(addr); break; case 4: ret = ldl_user_secondary(addr); break; default: case 8: ret = ldq_user_secondary(addr); break; } } else { switch(size) { case 1: ret = ldub_user(addr); break; case 2: ret = lduw_user(addr); break; case 4: ret = ldl_user(addr); break; default: case 8: ret = ldq_user(addr); break; } } } break; case 0x14: case 0x15: , non-cacheable case 0x1c: LE case 0x1d: , non-cacheable LE { switch(size) { case 1: ret = ldub_phys(addr); break; case 2: ret = lduw_phys(addr); break; case 4: ret = ldl_phys(addr); break; default: case 8: ret = ldq_phys(addr); break; } break; } case 0x24: case 0x2c: LE raise_exception(TT_ILL_INSN); return 0; case 0x04: case 0x0c: Little Endian (LE) { switch(size) { case 1: ret = ldub_nucleus(addr); break; case 2: ret = lduw_nucleus(addr); break; case 4: ret = ldl_nucleus(addr); break; default: case 8: ret = ldq_nucleus(addr); break; } break; } case 0x4a: break; case 0x45: ret = env->lsu; break; case 0x50: { int reg = (addr >> 3) & 0xf; if (reg == 0) { ret = ultrasparc_tag_target(env->immu.tag_access); } else { ret = env->immuregs[reg]; } break; } case 0x51: { ret = ultrasparc_tsb_pointer(env->immu.tsb, env->immu.tag_access, 8*1024); break; } case 0x52: { ret = ultrasparc_tsb_pointer(env->immu.tsb, env->immu.tag_access, 64*1024); break; } case 0x55: { int reg = (addr >> 3) & 0x3f; ret = env->itlb[reg].tte; break; } case 0x56: { int reg = (addr >> 3) & 0x3f; ret = env->itlb[reg].tag; break; } case 0x58: { int reg = (addr >> 3) & 0xf; if (reg == 0) { ret = ultrasparc_tag_target(env->dmmu.tag_access); } else { ret = env->dmmuregs[reg]; } break; } case 0x59: { ret = ultrasparc_tsb_pointer(env->dmmu.tsb, env->dmmu.tag_access, 8*1024); break; } case 0x5a: { ret = ultrasparc_tsb_pointer(env->dmmu.tsb, env->dmmu.tag_access, 64*1024); break; } case 0x5d: { int reg = (addr >> 3) & 0x3f; ret = env->dtlb[reg].tte; break; } case 0x5e: { int reg = (addr >> 3) & 0x3f; ret = env->dtlb[reg].tag; break; } case 0x46: case 0x47: case 0x4b: case 0x4c: case 0x4d: case 0x4e: case 0x66: case 0x67: case 0x6e: case 0x6f: case 0x76: case 0x7e: break; case 0x5b: case 0x48: case 0x49: case 0x7f: break; case 0x54: case 0x57: case 0x5c: case 0x5f: case 0x77: default: do_unassigned_access(addr, 0, 0, 1, size); ret = 0; break; } switch (asi) { case 0x0c: Little Endian (LE) case 0x18: LE case 0x19: LE case 0x1c: LE case 0x1d: , non-cacheable LE case 0x88: LE case 0x89: LE case 0x8a: LE case 0x8b: LE switch(size) { case 2: ret = bswap16(ret); break; case 4: ret = bswap32(ret); break; case 8: ret = bswap64(ret); break; default: break; } default: break; } if (sign) { switch(size) { case 1: ret = (int8_t) ret; break; case 2: ret = (int16_t) ret; break; case 4: ret = (int32_t) ret; break; default: break; } } #ifdef DEBUG_ASI dump_asi("read ", last_addr, asi, size, ret); #endif return ret; }
1threat
Add RelativeLayout with buttons below RecyclerView : <p>I need to add a RelativeLayout below my RecyclerView and was able to do so, except that the button under TOTAL(R.id.total_amount_tv) does not show:</p> <p><a href="https://i.stack.imgur.com/0I5kT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0I5kT.png" alt="enter image description here"></a> </p> <p>I can easily scroll through the items and it doesn't affect my RelativeLayout. I just need the button to be visible.</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/white" android:weightSum="1"&gt; &lt;android.support.v7.widget.RecyclerView android:id="@+id/order_recycler" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="40dp" tools:context=".ShoppingCartActivity" /&gt; &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginRight="10dp"&gt; &lt;TextView android:id="@+id/total_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:text="@string/total" android:textSize="20sp" android:textStyle="bold|italic" /&gt; &lt;TextView android:id="@+id/total_amount_tv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" android:layout_alignTop="@+id/total_tv" android:textSize="20sp" android:textStyle="bold|italic" /&gt; &lt;Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_below="@+id/total_amount_tv" android:layout_marginTop="51dp" android:background="@color/accent" android:onClick="onClickSendOrder" android:text="@string/order_btn" android:textColor="@android:color/white" android:textSize="20sp" /&gt; &lt;/RelativeLayout&gt; &lt;/RelativeLayout&gt; </code></pre>
0debug
Difference between sprite and texture? : <p>Can you please explain the difference between texture and sprite? When we zoom in a sprite, it appears blurry because it's basically an image. Is it the same for a texture?</p> <p>I read this comment on the image below online: </p> <blockquote> <p>The background layers are textures and not sprites.</p> </blockquote> <p><a href="https://i.stack.imgur.com/Rfr5B.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Rfr5B.png" alt="enter image description here"></a></p> <p>Can someone explain?</p>
0debug
static void pci_nop(void) { qvirtio_scsi_start(NULL); qvirtio_scsi_stop(); }
1threat
void timer_mod_anticipate(QEMUTimer *ts, int64_t expire_time) { timer_mod_anticipate_ns(ts, expire_time * ts->scale); }
1threat
calling specific index to add a function for that index : I have a liquidfloatingactionbutton and the way you add an action is a didselectitematindex function but how can I call certain indexes to add different function to each different index. This is what I have so far but the error I get is "cannot assign to value: 'index' is a 'let' constant". func liquidFloatingActionButton(_ liquidFloatingActionButton: LiquidFloatingActionButton, didSelectItemAtIndex index: Int) { print("did Tapped! \(index)") if index = "0"{ print("Buy") }else if index = "1"{ print("Trade") }else if index = "2"{ print("Save") }else if index = "3"{ print("Message") }else if index = "4"{ print("Directions") } liquidFloatingActionButton.close() }
0debug
Specifying multiple simultaneous output formats in knitr (new) : <p>Can I write a YAML header to produce multiple output formats for an R Markdown file using knitr? I could not reproduce the functionality described in the answer for <a href="https://stackoverflow.com/questions/25078572/specifying-multiple-simultaneous-output-formats-in-knitr">the original question with this title</a>.</p> <p>This markdown file:</p> <pre><code>--- title: "Multiple output formats" output: pdf_document: default html_document: keep_md: yes --- # This document should be rendered as an html file and as a pdf file </code></pre> <p>produces a pdf file but no HTML file.</p> <p>And this file:</p> <pre><code>--- title: "Multiple output formats" output: html_document: keep_md: yes pdf_document: default --- # This document should be rendered as an html file and as a pdf file </code></pre> <p>produces an HTML file (and an md file) but no pdf file. </p> <p>This latter example was the solution given to the <a href="https://stackoverflow.com/questions/25078572/specifying-multiple-simultaneous-output-formats-in-knitr">original question</a>. I have tried knitting with Shift-Ctrl-K and with the Knit button in RStudio, as well as calling <code>rmarkdown::render</code>, but only a single output format is created, regardless of the method I use to generate the output file.</p> <p>Possibly related, but I could not identify solutions:</p> <ul> <li><a href="https://stackoverflow.com/questions/31214524/how-do-i-produce-r-package-vignettes-in-multiple-formats">How do I produce R package vignettes in multiple formats?</a></li> <li><a href="https://github.com/yihui/knitr/issues/1051" rel="noreferrer">Render all vignette formats #1051</a></li> <li><a href="https://github.com/yihui/knitr/issues/769" rel="noreferrer">knitr::pandoc can't create pdf and tex files with a single config #769</a></li> <li><a href="https://github.com/yihui/knitr/issues/547" rel="noreferrer">Multiple formats for pandoc #547</a></li> <li>An allusion to multiple output format support in a <a href="https://blog.rstudio.org/2014/06/18/r-markdown-v2/#comment-10813" rel="noreferrer">three year old RStudio blog post</a></li> </ul> <p>Using R version 3.3.1 (2016-06-21), knitr 1.14, Rmarkdown 1.3</p>
0debug
Delegate runner 'androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner' for AndroidJUnit4 could not be loaded : <p>I try to run Kotlin instrumentation tests for android.</p> <p>In my app/build.gradle:</p> <pre><code> android { dataBinding { enabled = true } compileSdkVersion 28 defaultConfig { applicationId "com.myproject" minSdkVersion 18 targetSdkVersion 28 versionCode 6 versionName "0.0.7" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } sourceSets { main.java.srcDirs += 'src/main/kotlin' androidTest.java.srcDirs += 'src/androidTest/kotlin' } androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0-alpha02' androidTestImplementation 'androidx.test.ext:junit:1.1.0' androidTestImplementation 'androidx.test:rules:1.1.2-alpha02' androidTestImplementation 'androidx.test:runner:1.1.2-alpha02' </code></pre> <p>In folder <code>/app/src/androidTest/kotlin/com/myproject/</code> I has Kotlin test:</p> <pre><code>import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import org.junit.Rule import org.junit.runner.RunWith import androidx.test.rule.ActivityTestRule import com.myproject.ui.activity.TradersActivity import org.junit.Before @RunWith(AndroidJUnit4::class) @SmallTest class TradersActivityTest { private lateinit var stringToBetyped: String @get:Rule var activityRule: ActivityTestRule&lt;TradersActivity&gt; = ActivityTestRule(TradersActivity::class.java) @Before fun initValidString() { // Specify a valid string. stringToBetyped = "Espresso" } } </code></pre> <p>but when I run test I get error:</p> <pre><code>$ adb shell am instrument -w -r -e debug false -e class 'com.myproject.TradersActivityTest' com.myproject.debug.test/androidx.test.runner.AndroidJUnitRunner Client not ready yet.. Started running tests java.lang.RuntimeException: Delegate runner 'androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner' for AndroidJUnit4 could not be loaded. at androidx.test.ext.junit.runners.AndroidJUnit4.throwInitializationError(AndroidJUnit4.java:92) at androidx.test.ext.junit.runners.AndroidJUnit4.loadRunner(AndroidJUnit4.java:82) at androidx.test.ext.junit.runners.AndroidJUnit4.loadRunner(AndroidJUnit4.java:51) at androidx.test.ext.junit.runners.AndroidJUnit4.&lt;init&gt;(AndroidJUnit4.java:46) at java.lang.reflect.Constructor.newInstance(Native Method) at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:104) at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:86) at androidx.test.internal.runner.junit4.AndroidAnnotatedBuilder.runnerForClass(AndroidAnnotatedBuilder.java:63) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26) at androidx.test.internal.runner.AndroidRunnerBuilder.runnerForClass(AndroidRunnerBuilder.java:153) at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59) at androidx.test.internal.runner.TestLoader.doCreateRunner(TestLoader.java:73) at androidx.test.internal.runner.TestLoader.getRunnersFor(TestLoader.java:104) at androidx.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:789) at androidx.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:544) at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:387) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1879) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance(Native Method) at androidx.test.ext.junit.runners.AndroidJUnit4.loadRunner(AndroidJUnit4.java:72) ... 16 more Caused by: org.junit.runners.model.InitializationError at org.junit.runners.ParentRunner.validate(ParentRunner.java:418) at org.junit.runners.ParentRunner.&lt;init&gt;(ParentRunner.java:84) at org.junit.runners.BlockJUnit4ClassRunner.&lt;init&gt;(BlockJUnit4ClassRunner.java:65) at androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner.&lt;init&gt;(AndroidJUnit4ClassRunner.java:43) at androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner.&lt;init&gt;(AndroidJUnit4ClassRunner.java:48) ... 18 more Tests ran to completion. </code></pre>
0debug
void timer_mod(QEMUTimer *ts, int64_t expire_time) { timer_mod_ns(ts, expire_time * ts->scale); }
1threat
vb6 Anding two numbers into a boolean? : Can somebody explain to me how ANDing two numbers results in a boolean here? Why does j=3 return true but j=2 return false? dim jak as Boolean dim i as Integer dim j as Integer i = 1 j = 3 jak = j And i Console.WriteLine("Hello, world!" & jak)
0debug
iscsi_aio_read16_cb(struct iscsi_context *iscsi, int status, void *command_data, void *opaque) { IscsiAIOCB *acb = opaque; trace_iscsi_aio_read16_cb(iscsi, status, acb, acb->canceled); if (acb->canceled) { qemu_aio_release(acb); return; } acb->status = 0; if (status != 0) { error_report("Failed to read16 data from iSCSI lun. %s", iscsi_get_error(iscsi)); acb->status = -EIO; } iscsi_schedule_bh(iscsi_readv_writev_bh_cb, acb); }
1threat
For If Else Statement : <p>Working on this problem and I'm stuck. I know this should be a simple fix, but I'm not sure. I believe it's stuck in a for loop so the could keep on repeating but I'm not sure how to fix it. I tried adding a printf and scanf function, That didn't work. Adding a do while. that didn't work. I'm obviously making this thing harder than it needs to be. </p> <pre><code> int i; for (int i = 0; i &lt;= 10; i++) { if (i = 5) { printf("\nFive is my favorite number\n"); } else { printf("\n%di is \n", i); } } </code></pre>
0debug
Is it really necessary to call delete on this pointer : <p>I have a pointer to a very large static array of objects that don't have any destructors nor they inherit from any class. This array is allocated at the beginning of the program and never allocated/relocated again (by design). This array needs to be destroyed only at the very end of the program. Do I really need to call delete for the array, or is it OK to let the OS (Windows) clean up? Deleting delays exiting of program by 5-10sec. Without calling delete, OS will do that for us and program exits immediately.</p>
0debug
uint32_t HELPER(get_cp15)(CPUARMState *env, uint32_t insn) { int op1; int op2; int crm; op1 = (insn >> 21) & 7; op2 = (insn >> 5) & 7; crm = insn & 0xf; switch ((insn >> 16) & 0xf) { case 0: switch (op1) { case 0: switch (crm) { case 0: switch (op2) { case 0: return env->cp15.c0_cpuid; case 1: return env->cp15.c0_cachetype; case 2: return 0; case 3: return 0; case 5: if (arm_feature(env, ARM_FEATURE_V7) || ARM_CPUID(env) == ARM_CPUID_ARM11MPCORE) { int mpidr = env->cpu_index; if (arm_feature(env, ARM_FEATURE_V7MP)) { mpidr |= (1 << 31); } return mpidr; } default: goto bad_reg; } case 3: case 4: case 5: case 6: case 7: return 0; default: goto bad_reg; } default: goto bad_reg; } case 4: goto bad_reg; case 11: case 12: goto bad_reg; } bad_reg: cpu_abort(env, "Unimplemented cp15 register read (c%d, c%d, {%d, %d})\n", (insn >> 16) & 0xf, crm, op1, op2); return 0; }
1threat
ionic app getting compailed and on building getting error : hi i am new to ionic and i had build an app using ionic it had running while i am compling on my pc and when i am trying to run the app using ionic cordova run android it was showing error and i found that all the variables i am using as the errors and i am unable to build the app too. so plz anyone help me with this issue thank q in advance This is the error i am getting [12:00:54] typescript: src/pages/find-genie4/find-genie4.ts, line: 31 Argument of type '{ headers: { 'Authorization': string; }; }' is not assignable to parameter of type 'RequestOptionsArgs'. Types of property 'headers' are incompatible. Type '{ 'Authorization': string; }' is not assignable to type 'Headers'. Object literal may only specify known properties, and ''Authorization'' does not exist in type 'Headers'. L30: const token = JSON.parse(localStorage.getItem("userData")); L31: this.http.get('https://api.findgenie.org/v1/my-requests/',{headers: {'Authorization': 'Token '+token.token}} L32: this.posts = data.json().data.user_requests; [12:00:54] typescript: src/pages/find-genie4/find-genie4.ts, line: 32 Property 'posts' does not exist on type 'FindGenie4Page'. L31: this.http.get('https://api.findgenie.org/v1/my-requests/',{headers: {'Authorization': 'Token '+token.token}}).subscribe(data => { L32: this.posts = data.json().data.user_requests; L33: this.rating = data.json().data.user_details.rating; [12:00:54] typescript: src/pages/find-genie4/find-genie4.ts, line: 33 Property 'rating' does not exist on type 'FindGenie4Page'. L32: this.posts = data.json().data.user_requests; L33: this.rating = data.json().data.user_details.rating; L34: console.log("this.posts",this.posts) [12:00:54] typescript: src/pages/find-genie4/find-genie4.ts, line: 34 Property 'posts' does not exist on type 'FindGenie4Page'. L33: this.rating = data.json().data.user_details.rating; L34: console.log("this.posts",this.posts) L35: });
0debug
Using Awk to find Unique cars bought by a customer : I have log files like this : Customer Car Bought François Nissan Pajero 28/05/2016 Matthew Mercedes S 10/01/2019 Andrew Peugeot 508 05/0/2000 Matthew Toyota Hilux 02/10/2012 I need to make an awk script which display for each customer what car he has bought like this : Matthew, car bought: Mercedes S,Toyota Hilux, number of cars: 2 Francois, car bought: Nissan Pjero, number of cars: 1 I tried various things but wasnt able to do it.
0debug
static int vmdk_open_vmdk4(BlockDriverState *bs, BlockDriverState *file, int flags, Error **errp) { int ret; uint32_t magic; uint32_t l1_size, l1_entry_sectors; VMDK4Header header; VmdkExtent *extent; BDRVVmdkState *s = bs->opaque; int64_t l1_backup_offset = 0; ret = bdrv_pread(file, sizeof(magic), &header, sizeof(header)); if (ret < 0) { error_setg_errno(errp, -ret, "Could not read header from file '%s'", file->filename); return -EINVAL; } if (header.capacity == 0) { uint64_t desc_offset = le64_to_cpu(header.desc_offset); if (desc_offset) { char *buf = vmdk_read_desc(file, desc_offset << 9, errp); if (!buf) { return -EINVAL; } ret = vmdk_open_desc_file(bs, flags, buf, errp); g_free(buf); return ret; } } if (!s->create_type) { s->create_type = g_strdup("monolithicSparse"); } if (le64_to_cpu(header.gd_offset) == VMDK4_GD_AT_END) { struct { struct { uint64_t val; uint32_t size; uint32_t type; uint8_t pad[512 - 16]; } QEMU_PACKED footer_marker; uint32_t magic; VMDK4Header header; uint8_t pad[512 - 4 - sizeof(VMDK4Header)]; struct { uint64_t val; uint32_t size; uint32_t type; uint8_t pad[512 - 16]; } QEMU_PACKED eos_marker; } QEMU_PACKED footer; ret = bdrv_pread(file, bs->file->total_sectors * 512 - 1536, &footer, sizeof(footer)); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read footer"); return ret; } if (be32_to_cpu(footer.magic) != VMDK4_MAGIC || le32_to_cpu(footer.footer_marker.size) != 0 || le32_to_cpu(footer.footer_marker.type) != MARKER_FOOTER || le64_to_cpu(footer.eos_marker.val) != 0 || le32_to_cpu(footer.eos_marker.size) != 0 || le32_to_cpu(footer.eos_marker.type) != MARKER_END_OF_STREAM) { error_setg(errp, "Invalid footer"); return -EINVAL; } header = footer.header; } if (le32_to_cpu(header.version) > 3) { char buf[64]; snprintf(buf, sizeof(buf), "VMDK version %" PRId32, le32_to_cpu(header.version)); error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, bdrv_get_device_or_node_name(bs), "vmdk", buf); return -ENOTSUP; } else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR)) { error_setg(errp, "VMDK version 3 must be read only"); return -EINVAL; } if (le32_to_cpu(header.num_gtes_per_gt) > 512) { error_setg(errp, "L2 table size too big"); return -EINVAL; } l1_entry_sectors = le32_to_cpu(header.num_gtes_per_gt) * le64_to_cpu(header.granularity); if (l1_entry_sectors == 0) { error_setg(errp, "L1 entry size is invalid"); return -EINVAL; } l1_size = (le64_to_cpu(header.capacity) + l1_entry_sectors - 1) / l1_entry_sectors; if (le32_to_cpu(header.flags) & VMDK4_FLAG_RGD) { l1_backup_offset = le64_to_cpu(header.rgd_offset) << 9; } if (bdrv_nb_sectors(file) < le64_to_cpu(header.grain_offset)) { error_setg(errp, "File truncated, expecting at least %" PRId64 " bytes", (int64_t)(le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE)); return -EINVAL; } ret = vmdk_add_extent(bs, file, false, le64_to_cpu(header.capacity), le64_to_cpu(header.gd_offset) << 9, l1_backup_offset, l1_size, le32_to_cpu(header.num_gtes_per_gt), le64_to_cpu(header.granularity), &extent, errp); if (ret < 0) { return ret; } extent->compressed = le16_to_cpu(header.compressAlgorithm) == VMDK4_COMPRESSION_DEFLATE; if (extent->compressed) { g_free(s->create_type); s->create_type = g_strdup("streamOptimized"); } extent->has_marker = le32_to_cpu(header.flags) & VMDK4_FLAG_MARKER; extent->version = le32_to_cpu(header.version); extent->has_zero_grain = le32_to_cpu(header.flags) & VMDK4_FLAG_ZERO_GRAIN; ret = vmdk_init_tables(bs, extent, errp); if (ret) { vmdk_free_last_extent(bs); } return ret; }
1threat
Try and Catch Int range limit : <p>I want to catch the error if the value exceeds the maximum int range in c++.</p> <pre><code>try { int num = 123123123123123123123312; cout &lt;&lt; num; } catch(.....) { } </code></pre>
0debug
from math import radians, sin, cos, acos def distance_lat_long(slat,slon,elat,elon): dist = 6371.01 * acos(sin(slat)*sin(elat) + cos(slat)*cos(elat)*cos(slon - elon)) return dist
0debug
What does this type declaration do? : <p>Reading through the source for <a href="https://github.com/bet365/jingo" rel="nofollow noreferrer">jingo</a>, and stubble upon this code:</p> <pre><code>var _ io.Writer = &amp;Buffer{} // commit to compatibility with io.Writer </code></pre> <p>The comment is not really helping me; what does this code enforce? Assume I am familiar with interface in go.</p> <p><a href="https://github.com/bet365/jingo/blob/master/buffer.go#L20" rel="nofollow noreferrer">source code</a></p>
0debug
Python: I need help writing a function that uses a pair and returns sets of carnality of 2 : I need help writing some python code that input is a list A that represents a set and whose output is a list of the subsets of A that have cardinality of 2. For instance, if A = [a, b, c], then listPairs(A) = [[a, b], [a, c], [b, c]].
0debug
Invalid types 'int[int]' for array subscript - multi-dimensional array : <p>I'm getting an " Invalid types 'int[int]' for array subscript error ". I searched for the same, but the previously asked Q's involved objects. This is a simple snippet.</p> <blockquote> <p>Code</p> </blockquote> <pre><code> #include&lt;iostream&gt; #include&lt;cmath&gt; using namespace std; int main() { int *a; a = new int a[10][10]; //Line 8 for(int z=0;z&lt;10;z++) { for(int y=0;y&lt;10;y++) { a[z][y]=y; // Line 13 cout &lt;&lt;"\t"&lt;&lt;a[z][y]&lt;&lt;endl; // Line 14 } } return 0; } </code></pre> <blockquote> <p>Error</p> </blockquote> <ol> <li><p>Line 8 error: expected ';' before 'a'</p></li> <li><p>Line 13 error: invalid types 'int[int]' for array subscript</p></li> <li>Line 14 error: invalid types 'int[int]' for array subscript</li> </ol>
0debug
Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed. (Django 1.8 and OSX ElCapitan) : <p>I'm trying to internationalize a Django app by following the wonderful Django documentation. The problem is when I try to run command to create language files: </p> <pre><code>python manage.py makemessages -l fr </code></pre> <p>It outputs an error :</p> <pre><code>CommandError: Can't find msguniq. Make sure you have GNU gettext tools 0.15 or newer installed. </code></pre> <p>My configuration : </p> <ul> <li>OS : <strong>OSX El Capitan v10.11.3</strong> </li> <li>Python : <strong>v3.5</strong> </li> <li>Django : <strong>v1.8</strong></li> </ul>
0debug
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; VmncContext * const c = avctx->priv_data; GetByteContext *gb = &c->gb; uint8_t *outptr; int dx, dy, w, h, depth, enc, chunks, res, size_left, ret; if ((ret = ff_reget_buffer(avctx, c->pic)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } bytestream2_init(gb, buf, buf_size); c->pic->key_frame = 0; c->pic->pict_type = AV_PICTURE_TYPE_P; if (c->screendta) { int i; w = c->cur_w; if (c->width < c->cur_x + w) w = c->width - c->cur_x; h = c->cur_h; if (c->height < c->cur_y + h) h = c->height - c->cur_y; dx = c->cur_x; if (dx < 0) { w += dx; dx = 0; } dy = c->cur_y; if (dy < 0) { h += dy; dy = 0; } if ((w > 0) && (h > 0)) { outptr = c->pic->data[0] + dx * c->bpp2 + dy * c->pic->linesize[0]; for (i = 0; i < h; i++) { memcpy(outptr, c->screendta + i * c->cur_w * c->bpp2, w * c->bpp2); outptr += c->pic->linesize[0]; } } } bytestream2_skip(gb, 2); chunks = bytestream2_get_be16(gb); while (chunks--) { dx = bytestream2_get_be16(gb); dy = bytestream2_get_be16(gb); w = bytestream2_get_be16(gb); h = bytestream2_get_be16(gb); enc = bytestream2_get_be32(gb); outptr = c->pic->data[0] + dx * c->bpp2 + dy * c->pic->linesize[0]; size_left = bytestream2_get_bytes_left(gb); switch (enc) { case MAGIC_WMVd: if (size_left < 2 + w * h * c->bpp2 * 2) { av_log(avctx, AV_LOG_ERROR, "Premature end of data! (need %i got %i)\n", 2 + w * h * c->bpp2 * 2, size_left); return AVERROR_INVALIDDATA; } bytestream2_skip(gb, 2); c->cur_w = w; c->cur_h = h; c->cur_hx = dx; c->cur_hy = dy; if ((c->cur_hx > c->cur_w) || (c->cur_hy > c->cur_h)) { av_log(avctx, AV_LOG_ERROR, "Cursor hot spot is not in image: " "%ix%i of %ix%i cursor size\n", c->cur_hx, c->cur_hy, c->cur_w, c->cur_h); c->cur_hx = c->cur_hy = 0; } if (c->cur_w * c->cur_h >= INT_MAX / c->bpp2) { reset_buffers(c); return AVERROR(EINVAL); } else { int screen_size = c->cur_w * c->cur_h * c->bpp2; if ((ret = av_reallocp(&c->curbits, screen_size)) < 0 || (ret = av_reallocp(&c->curmask, screen_size)) < 0 || (ret = av_reallocp(&c->screendta, screen_size)) < 0) { reset_buffers(c); return ret; } } load_cursor(c); break; case MAGIC_WMVe: bytestream2_skip(gb, 2); break; case MAGIC_WMVf: c->cur_x = dx - c->cur_hx; c->cur_y = dy - c->cur_hy; break; case MAGIC_WMVg: bytestream2_skip(gb, 10); break; case MAGIC_WMVh: bytestream2_skip(gb, 4); break; case MAGIC_WMVi: c->pic->key_frame = 1; c->pic->pict_type = AV_PICTURE_TYPE_I; depth = bytestream2_get_byte(gb); if (depth != c->bpp) { av_log(avctx, AV_LOG_INFO, "Depth mismatch. Container %i bpp, " "Frame data: %i bpp\n", c->bpp, depth); } bytestream2_skip(gb, 1); c->bigendian = bytestream2_get_byte(gb); if (c->bigendian & (~1)) { av_log(avctx, AV_LOG_INFO, "Invalid header: bigendian flag = %i\n", c->bigendian); return AVERROR_INVALIDDATA; } bytestream2_skip(gb, 13); break; case MAGIC_WMVj: bytestream2_skip(gb, 2); break; case 0x00000000: if ((dx + w > c->width) || (dy + h > c->height)) { av_log(avctx, AV_LOG_ERROR, "Incorrect frame size: %ix%i+%ix%i of %ix%i\n", w, h, dx, dy, c->width, c->height); return AVERROR_INVALIDDATA; } if (size_left < w * h * c->bpp2) { av_log(avctx, AV_LOG_ERROR, "Premature end of data! (need %i got %i)\n", w * h * c->bpp2, size_left); return AVERROR_INVALIDDATA; } paint_raw(outptr, w, h, gb, c->bpp2, c->bigendian, c->pic->linesize[0]); break; case 0x00000005: if ((dx + w > c->width) || (dy + h > c->height)) { av_log(avctx, AV_LOG_ERROR, "Incorrect frame size: %ix%i+%ix%i of %ix%i\n", w, h, dx, dy, c->width, c->height); return AVERROR_INVALIDDATA; } res = decode_hextile(c, outptr, gb, w, h, c->pic->linesize[0]); if (res < 0) return res; break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported block type 0x%08X\n", enc); chunks = 0; } } if (c->screendta) { int i; w = c->cur_w; if (c->width < c->cur_x + w) w = c->width - c->cur_x; h = c->cur_h; if (c->height < c->cur_y + h) h = c->height - c->cur_y; dx = c->cur_x; if (dx < 0) { w += dx; dx = 0; } dy = c->cur_y; if (dy < 0) { h += dy; dy = 0; } if ((w > 0) && (h > 0)) { outptr = c->pic->data[0] + dx * c->bpp2 + dy * c->pic->linesize[0]; for (i = 0; i < h; i++) { memcpy(c->screendta + i * c->cur_w * c->bpp2, outptr, w * c->bpp2); outptr += c->pic->linesize[0]; } outptr = c->pic->data[0]; put_cursor(outptr, c->pic->linesize[0], c, c->cur_x, c->cur_y); } } *got_frame = 1; if ((ret = av_frame_ref(data, c->pic)) < 0) return ret; return buf_size; }
1threat
Flutter: How to Make an array with the JSON data : <p>I would like to make an array with JSON, But I duplicate the same post. I am using the REST API JSON plugin for WordPress</p> <p>More information about <strong>WP REST API</strong>: <a href="https://v2.wp-api.org" rel="noreferrer">https://v2.wp-api.org</a></p> <p>This is my <strong>JSON</strong> code</p> <pre><code> [ { "id": 65, "date": "2014-08-24T18:56:26", "date_gmt": "2014-08-24T18:56:26", "guid": { "rendered": "http:\/\/********\/********\/?p=1" }, "modified": "2018-06-05T13:24:58", "modified_gmt": "2018-06-05T13:24:58", "slug": "this-url-wordpress", "status": "publish", "type": "post", "title": { "rendered": "\u2018 This a test title 1 \u2019" }, "content": { "rendered": "&lt;p&gt;This is a content 1&lt;/p&gt;", "protected": false }, "excerpt": { "rendered": "&lt;p&gt;this a excerpt 1...&lt;\/p&gt;\n", "protected": false }, "author": 1, "featured_media": 468, "comment_status": "open", "ping_status": "open", "sticky": false, "template": "", "format": "standard", "meta": [ ], "categories": [ 14 ], "tags": [ 17, 18 ], }, { "id": 650, "date": "2014-08-24T18:56:26", "date_gmt": "2014-08-24T18:56:26", "guid": { "rendered": "http:\/\/********\/********\/?p=1" }, "modified": "2018-06-05T13:24:58", "modified_gmt": "2018-06-05T13:24:58", "slug": "this-url-wordpress", "status": "publish", "type": "post", "title": { "rendered": "\u2018 This a test title 2 \u2019" }, "content": { "rendered": "&lt;p&gt;This is a content 2&lt;/p&gt;", "protected": false }, "excerpt": { "rendered": "&lt;p&gt;this a excerpt 2...&lt;\/p&gt;\n", "protected": false }, "author": 1, "featured_media": 468, "comment_status": "open", "ping_status": "open", "sticky": false, "template": "", "format": "standard", "meta": [ ], "categories": [ 14 ], "tags": [ 17, 18 ], }, { "id": 230, "date": "2014-08-24T18:56:26", "date_gmt": "2014-08-24T18:56:26", "guid": { "rendered": "http:\/\/********\/********\/?p=1" }, "modified": "2018-06-05T13:24:58", "modified_gmt": "2018-06-05T13:24:58", "slug": "this-url-wordpress", "status": "publish", "type": "post", "title": { "rendered": "\u2018 This a test title 3 \u2019" }, "content": { "rendered": "&lt;p&gt;This is a content 3&lt;/p&gt;", "protected": false }, "excerpt": { "rendered": "&lt;p&gt;this a excerpt 3...&lt;\/p&gt;\n", "protected": false }, "author": 1, "featured_media": 468, "comment_status": "open", "ping_status": "open", "sticky": false, "template": "", "format": "standard", "meta": [ ], "categories": [ 14 ], "tags": [ 17, 18 ], }, ] </code></pre> <p><strong>My code</strong>:</p> <pre><code>import 'dart:async'; import 'package:flutter/material.dart'; import 'package:peluqueriafran/WebView.dart'; import 'dart:convert'; import 'package:http/http.dart' as http; Future&lt;Post&gt; fetchPost() async { final response = await http.get('http://**********:88/WordPress/wp-json/wp/v2/posts/'); final responseJson = json.decode(response.body); return new Post.fromJson(responseJson); } class Post { final int id; final String title; final String body; final String urlimagen; final String linkWeb; Post({this.id, this.title, this.body, this.urlimagen, this.linkWeb}); factory Post.fromJson(Map&lt;String, dynamic&gt; json) { return new Post( title: json['title']['rendered'].toString(), ); } } </code></pre> <p><strong>WEB:</strong> <br> <a href="https://i.stack.imgur.com/NUnRa.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/NUnRa.jpg" alt="enter image description here"></a></p> <p><strong>App: - The last generated is selected, I would like to get all the post.</strong> <br> I hope someone can help me out, thanks <br> <a href="https://i.stack.imgur.com/1HMmb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/1HMmb.png" alt="enter image description here"></a></p>
0debug
Why it not return the float value of the divison in c++? : <p>I have this code in c++:</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { float division = 5/2; cout&lt;&lt;division; return 0; } </code></pre> <p>But it return <code>2</code>, instead of <code>2.5</code> , why ?</p>
0debug
static uint64_t openpic_msi_read(void *opaque, hwaddr addr, unsigned size) { OpenPICState *opp = opaque; uint64_t r = 0; int i, srs; DPRINTF("%s: addr " TARGET_FMT_plx "\n", __func__, addr); if (addr & 0xF) { return -1; } srs = addr >> 4; switch (addr) { case 0x00: case 0x10: case 0x20: case 0x30: case 0x40: case 0x50: case 0x60: case 0x70: r = opp->msi[srs].msir; opp->msi[srs].msir = 0; break; case 0x120: for (i = 0; i < MAX_MSI; i++) { r |= (opp->msi[i].msir ? 1 : 0) << i; } break; } return r; }
1threat
How to create web listing system? (like amazon, ebay) : <p>I want to create an online listing system, where people can upload there listings and customers can buy them. It's comparable with the main idea of ebay, amazon,..</p> <p>Basic functionality:</p> <ul> <li>Creating listings (uploading pictures, description,..)</li> <li>Buying-System (People can put items in their chart &amp; and buy them)</li> <li>Log-In System (It should be possible to login as seller or buyer)</li> </ul> <p>My questions: What technique should I use for developing such an online system with a lot of database-queries? Would you recommend ASP.net or Java SPRING for implementing it? </p> <p>Or what do you think about using Wordpress and Joomla? There are some usable templates, but I would have to customize them a lot. (Is it easy to develop own things in these CMS-systems?)</p> <p>Thank you!</p> <p>Marko</p>
0debug
Visual Studio 2015 (ASP.NET 5): show 'Manage Bower Packages...' context menu : <p>In Visual Studio 2015, when I create a brand new solution with a brand new ASP.NET 5 project, I see the <code>Manage Bower Packages...</code> context menu when I right-click on the project:</p> <p><a href="https://i.stack.imgur.com/EzHdw.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/EzHdw.jpg" alt="enter image description here"></a></p> <p>However, when I add an ASP.NET 5 project to an existing solution, the <code>Manage Bower Packages...</code> context menu is nowhere to be seen:</p> <p><a href="https://i.stack.imgur.com/r0prL.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/r0prL.jpg" alt="enter image description here"></a></p> <p>Any idea how to get the <code>Manage Bower Packages...</code> context menu option to appear?</p>
0debug
How to find common sub strings in python? : <p>I am writing a python script where I have to find common substrings in many string sequences. For example:</p> <pre><code>sequence1 = 'mweitngaomjksjasper;36nnG1bmaso3th7a\-' sequence2 = 'asngiqbwebs7-236jasper;u52dsv--4512G1b' sequence3 = 'asvjaspermininwqmamnf-121xvxnesgq232' </code></pre> <p>jasper occurs 3 times - one time each in sequence1,sequence2 and sequence3. G1b occurs 2 times - one time in sequence1 and one time in sequence 2.</p> <p>For each substring occuring two times or more, i need to add them to a dictionary as substring => count. In this case my dictionary will be:</p> <pre><code>dict = { 'jasper': '3', 'G1b': '2'} </code></pre> <p>I will be using thousands of sequences to fill up this dictionary and if one substring occurs two or more times in any of the sequences, it needs to be added to this dictionary. What would be the best way to do it without crashing the system?</p>
0debug
static int convert_iteration_sectors(ImgConvertState *s, int64_t sector_num) { int64_t ret; int n; convert_select_part(s, sector_num); assert(s->total_sectors > sector_num); n = MIN(s->total_sectors - sector_num, BDRV_REQUEST_MAX_SECTORS); if (s->sector_next_status <= sector_num) { BlockDriverState *file; ret = bdrv_get_block_status(blk_bs(s->src[s->src_cur]), sector_num - s->src_cur_offset, n, &n, &file); if (ret < 0) { return ret; } if (ret & BDRV_BLOCK_ZERO) { s->status = BLK_ZERO; } else if (ret & BDRV_BLOCK_DATA) { s->status = BLK_DATA; } else if (!s->target_has_backing) { s->status = BLK_DATA; } else { s->status = BLK_BACKING_FILE; } s->sector_next_status = sector_num + n; } n = MIN(n, s->sector_next_status - sector_num); if (s->status == BLK_DATA) { n = MIN(n, s->buf_sectors); } if (s->compressed) { if (n < s->cluster_sectors) { n = MIN(s->cluster_sectors, s->total_sectors - sector_num); s->status = BLK_DATA; } else { n = QEMU_ALIGN_DOWN(n, s->cluster_sectors); } } return n; }
1threat
static inline void xchg_mb_border(H264Context *h, uint8_t *src_y, uint8_t *src_cb, uint8_t *src_cr, int linesize, int uvlinesize, int xchg){ MpegEncContext * const s = &h->s; int temp8, i; uint64_t temp64; src_y -= linesize + 1; src_cb -= uvlinesize + 1; src_cr -= uvlinesize + 1; #define XCHG(a,b,t,xchg)\ t= a;\ if(xchg)\ a= b;\ b= t; for(i=0; i<17; i++){ XCHG(h->left_border[i ], src_y [i* linesize], temp8, xchg); } XCHG(*(uint64_t*)(h->top_border[s->mb_x]+0), *(uint64_t*)(src_y +1), temp64, xchg); XCHG(*(uint64_t*)(h->top_border[s->mb_x]+8), *(uint64_t*)(src_y +9), temp64, 1); if(!(s->flags&CODEC_FLAG_GRAY)){ for(i=0; i<9; i++){ XCHG(h->left_border[i+17 ], src_cb[i*uvlinesize], temp8, xchg); XCHG(h->left_border[i+17+9], src_cr[i*uvlinesize], temp8, xchg); } XCHG(*(uint64_t*)(h->top_border[s->mb_x]+16), *(uint64_t*)(src_cb+1), temp64, 1); XCHG(*(uint64_t*)(h->top_border[s->mb_x]+24), *(uint64_t*)(src_cr+1), temp64, 1); } }
1threat
static void celt_pvq_search(float *X, int *y, int K, int N) { int i; float res = 0.0f, y_norm = 0.0f, xy_norm = 0.0f; for (i = 0; i < N; i++) res += FFABS(X[i]); res = K/res; for (i = 0; i < N; i++) { y[i] = lrintf(res*X[i]); y_norm += y[i]*y[i]; xy_norm += y[i]*X[i]; K -= FFABS(y[i]); } while (K) { int max_idx = 0, phase = FFSIGN(K); float max_den = 1.0f, max_num = 0.0f; y_norm += 1.0f; for (i = 0; i < N; i++) { const int ca = 1 ^ ((y[i] == 0) & (phase < 0)); float xy_new = xy_norm + 1*phase*FFABS(X[i]); float y_new = y_norm + 2*phase*FFABS(y[i]); xy_new = xy_new * xy_new; if (ca && (max_den*xy_new) > (y_new*max_num)) { max_den = y_new; max_num = xy_new; max_idx = i; } } K -= phase; phase *= FFSIGN(X[max_idx]); xy_norm += 1*phase*X[max_idx]; y_norm += 2*phase*y[max_idx]; y[max_idx] += phase; } }
1threat
Which are the consequences if I defined an class attribute as "public"? : <p>I know there is a lot written about information hidding, but I still don't know why I should not define an class attribute as public. </p> <p>Which is the consequences if I defined an attribute as "public"?</p> <p>Please, give an example.</p>
0debug
How do I level all my content? : This is my first post on the site, I'm still learning some basics. So I found some html/CSS exercises online and tried to copy them and so far so good but I can't level all my content and I'm not sure what to do [This is the original][1] and [this is what I have][2] the menus and last posts are not on the same level as the articles. Why and how to fix it? I tried playing around with clear and padding and margins..etc..nothing [This is my CSS][3] this is the html([1][4]and [2][5]) [1]: https://i.stack.imgur.com/RzcnL.png [2]: https://i.stack.imgur.com/0eKDr.png [3]: https://i.stack.imgur.com/pXEJ8.png [4]: https://i.stack.imgur.com/zOI88.png [5]: https://i.stack.imgur.com/qCDvX.png TIA
0debug
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint Laravel : <p>Im trying to create a foreign keys using <code>artisan</code>, but this error show up.</p> <pre><code>[Illuminate\Database\QueryException] SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `comments` add constraint `comments_comment_lot_id_foreign` foreign key (`comment_lot_id`) references `lots` (`lot_id` ) on delete cascade) </code></pre> <p>This is my migration: </p> <pre><code>&lt;?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateCommentsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('comments', function (Blueprint $table) { $table-&gt;increments('id'); $table-&gt;text('comment'); $table-&gt;integer('comment_lot_id')-&gt;unsigned(); $table-&gt;timestamps(); }); Schema::table('comments', function ($table) { $table-&gt;foreign('comment_lot_id')-&gt;references('lot_id')-&gt;on('lots')-&gt;onDelete('cascade'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropForeign(['comment_lot_id']); Schema::dropIfExists('comments'); } } </code></pre> <p>in the lots table i use <code>lot_id</code> as <code>id</code> it model Lot.php i add:</p> <pre><code>&lt;?php namespace App; use Illuminate\Database\Eloquent\Model; class Lot extends Model { protected $primaryKey = 'lot_id'; } </code></pre> <p>Any idea how can i resolve this error? </p>
0debug
perl script for mounted disk space on Temp in Linux machine : I am new to perl world. I written one perl script for calculating free disk space. But whenever output generates, it gives me different number than what actually shows using df -h command. So my requirement is i want to show specific mounted free disk space. E.g I want to show only /boot "Use%" figure and it should match with df -h command figure. Please find my script for reference.
0debug
Why 2.65 + 2.66 = 5.3100000000000005 : <p>Why 2.65 + 2.66 = 5.3100000000000005 in Javascript?<a href="https://i.stack.imgur.com/pjhDV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pjhDV.png" alt="enter image description here"></a></p>
0debug
int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc) { int bps, blkalign, bytespersec; int hdrsize = 18; int waveformatextensible; uint8_t temp[256]; uint8_t *riff_extradata= temp; uint8_t *riff_extradata_start= temp; if(!enc->codec_tag || enc->codec_tag > 0xffff) return -1; waveformatextensible = (enc->channels > 2 && enc->channel_layout) || enc->sample_rate > 48000 || av_get_bits_per_sample(enc->codec_id) > 16; if (waveformatextensible) { avio_wl16(pb, 0xfffe); } else { avio_wl16(pb, enc->codec_tag); } avio_wl16(pb, enc->channels); avio_wl32(pb, enc->sample_rate); if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3 || enc->codec_id == CODEC_ID_GSM_MS) { bps = 0; } else if (enc->codec_id == CODEC_ID_ADPCM_G726) { bps = 4; } else { if (!(bps = av_get_bits_per_sample(enc->codec_id))) bps = 16; } if(bps != enc->bits_per_coded_sample && enc->bits_per_coded_sample){ av_log(enc, AV_LOG_WARNING, "requested bits_per_coded_sample (%d) and actually stored (%d) differ\n", enc->bits_per_coded_sample, bps); } if (enc->codec_id == CODEC_ID_MP2 || enc->codec_id == CODEC_ID_MP3) { blkalign = enc->frame_size; } else if (enc->codec_id == CODEC_ID_AC3) { blkalign = 3840; } else if (enc->codec_id == CODEC_ID_ADPCM_G726) { blkalign = 1; } else if (enc->block_align != 0) { blkalign = enc->block_align; } else blkalign = enc->channels*bps >> 3; if (enc->codec_id == CODEC_ID_PCM_U8 || enc->codec_id == CODEC_ID_PCM_S24LE || enc->codec_id == CODEC_ID_PCM_S32LE || enc->codec_id == CODEC_ID_PCM_F32LE || enc->codec_id == CODEC_ID_PCM_F64LE || enc->codec_id == CODEC_ID_PCM_S16LE) { bytespersec = enc->sample_rate * blkalign; } else { bytespersec = enc->bit_rate / 8; } avio_wl32(pb, bytespersec); avio_wl16(pb, blkalign); avio_wl16(pb, bps); if (enc->codec_id == CODEC_ID_MP3) { hdrsize += 12; bytestream_put_le16(&riff_extradata, 1); bytestream_put_le32(&riff_extradata, 2); bytestream_put_le16(&riff_extradata, 1152); bytestream_put_le16(&riff_extradata, 1); bytestream_put_le16(&riff_extradata, 1393); } else if (enc->codec_id == CODEC_ID_MP2) { hdrsize += 22; bytestream_put_le16(&riff_extradata, 2); bytestream_put_le32(&riff_extradata, enc->bit_rate); bytestream_put_le16(&riff_extradata, enc->channels == 2 ? 1 : 8); bytestream_put_le16(&riff_extradata, 0); bytestream_put_le16(&riff_extradata, 1); bytestream_put_le16(&riff_extradata, 16); bytestream_put_le32(&riff_extradata, 0); bytestream_put_le32(&riff_extradata, 0); } else if (enc->codec_id == CODEC_ID_GSM_MS || enc->codec_id == CODEC_ID_ADPCM_IMA_WAV) { hdrsize += 2; bytestream_put_le16(&riff_extradata, enc->frame_size); } else if(enc->extradata_size){ riff_extradata_start= enc->extradata; riff_extradata= enc->extradata + enc->extradata_size; hdrsize += enc->extradata_size; } else if (!waveformatextensible){ hdrsize -= 2; } if(waveformatextensible) { hdrsize += 22; avio_wl16(pb, riff_extradata - riff_extradata_start + 22); avio_wl16(pb, enc->bits_per_coded_sample); avio_wl32(pb, enc->channel_layout); avio_wl32(pb, enc->codec_tag); avio_wl32(pb, 0x00100000); avio_wl32(pb, 0xAA000080); avio_wl32(pb, 0x719B3800); } else if(riff_extradata - riff_extradata_start) { avio_wl16(pb, riff_extradata - riff_extradata_start); } avio_write(pb, riff_extradata_start, riff_extradata - riff_extradata_start); if(hdrsize&1){ hdrsize++; avio_w8(pb, 0); } return hdrsize; }
1threat
void dpy_gfx_update_dirty(QemuConsole *con, MemoryRegion *address_space, hwaddr base, bool invalidate) { DisplaySurface *ds = qemu_console_surface(con); int width = surface_stride(ds); int height = surface_height(ds); hwaddr size = width * height; MemoryRegionSection mem_section; MemoryRegion *mem; ram_addr_t addr; int first, last, i; bool dirty; mem_section = memory_region_find(address_space, base, size); mem = mem_section.mr; if (int128_get64(mem_section.size) != size || !memory_region_is_ram(mem_section.mr)) { goto out; } assert(mem); memory_region_sync_dirty_bitmap(mem); addr = mem_section.offset_within_region; first = -1; last = -1; for (i = 0; i < height; i++, addr += width) { dirty = invalidate || memory_region_get_dirty(mem, addr, width, DIRTY_MEMORY_VGA); if (dirty) { if (first == -1) { first = i; } last = i; } if (first != -1 && !dirty) { assert(last != -1 && last >= first); dpy_gfx_update(con, 0, first, surface_width(ds), last - first + 1); first = -1; } } if (first != -1) { assert(last != -1 && last >= first); dpy_gfx_update(con, 0, first, surface_width(ds), last - first + 1); } memory_region_reset_dirty(mem, mem_section.offset_within_region, size, DIRTY_MEMORY_VGA); out: memory_region_unref(mem); }
1threat
int qemu_get_byte(QEMUFile *f) { int result; result = qemu_peek_byte(f, 0); qemu_file_skip(f, 1); return result; }
1threat
Manifest error (Duplication of elements) in android studio while combining two functions : [Need help! how to get rid of this error i have combine 2 functions nearby locations and friend finder as a result it's showing me this manifest error][1] [In this second pic, u will see that manifest is showing duplication error (HOW TO GET RID OF THIS?)][2] [1]: https://i.stack.imgur.com/ggKIF.png [2]: https://i.stack.imgur.com/kemGi.png
0debug
Printing a node from BST : <p>I have a code similar to this one:<br/> <a href="https://www.geeksforgeeks.org/find-closest-element-binary-search-tree/" rel="nofollow noreferrer">https://www.geeksforgeeks.org/find-closest-element-binary-search-tree/</a></p> <p>For this algorithm, it will print out 17. However, I want to print it out as <br/> <code>17 is the node closest to 18</code></p> <p>How is that possible? Do I need to create a toString method? If so, how can it be written? </p>
0debug
How to insert digits between two consecutive digits of a number in java : <p>I want to insert a digit at a specific position in a number. </p> <pre><code>int a=3456; </code></pre> <p>Now I want to make this numbers as</p> <pre><code>a = 32456 </code></pre> <p>So how can i do that in java</p>
0debug
PHP Syntax error, please review my code, I don't need a link to mindlessly view endless code. : I've searched many stackoverflow questions and the provided links like "PHP Parse/Syntax Errors; and How to solve them?" for hours... Can anyone review my section of code and tell me what my error is? I'm pulling my hair-out on this >.< This is a simple school project... I don't care to change the code to use mysqli Error: syntax error , unexpected "", expecting identifier (t_string) or variable (t_variable) or number (t_num_string) Thanks! { $Name = $_POST["Name"]; // ERROR IS IDENTIFIED ON THIS LINE $Address = $_POST["Address"]; $Phone = $_POST["Phone"]; $Email = $_POST["Email"]; $Availability = $_POST['Availability']; $Company = $_POST["Company Name"]; $Job = $_POST['Job Title']; $description = $_POST['Description']; $Skill = $_POST['Skill']; $Period = $_POST['Period']; $Position = $_POST['Position']; $Update=$_POST["Update"]; if(!empty($Name)){ $sql="INSERT INTO employee(Name, Address, Phone, Email, Availability, Company Name, Job Title, Description, Skill, Period, Position) VALUES ('$Name','$Address','$Phone','$Email','$Avaliabilty','$Company','$Job','$Description','$Period','$Skill','$Position')"; if($db->query($sql) == TRUE){ echo ("Record added"); } } if (isset($Update)){ $sql="UPDATE employee SET Address='$Address',Phone='$Phone',Email='$Email',Availability='$Availability',Company='$Company',Job='$Job',Description='$Description',Skill = '$Skill',Period='$Period',Position='$Position' WHERE Name='$Name' "; $db->query($sql); } $db->close(); ?>
0debug
An Array with multiple information per index (an array of arrays???) (OBJ-C) : I am currently making a demo app which is calling a web api (following a tutorial that uses meetup.coms API's). I am passing the information into a tableview to display it and whilst making it I was thinking about this. Can I make an array that has multiple pieces of data per row? Almost like an excel spreadsheet so rather than having NSArray *sampleArray1 = @[@"Name1",@"Name2",@"Name3"]; NSArray *sampleArray2 = @[@"Age1",@"Age2",@"Age3"]; and having to return the `[indexPath row]` of each array into your table view cell, you could instead have: NSArray *superArray = @[@"Name1"|@"Age1", @"Name2"|@"Age2",@"Name3"|@""]; which would return all of your information for the selected index at once. I am familiar with how you could do this in swift. I would normally create a `struct` and give it a few array variables. struct superArray { var names = [String]() var ages = [String]() }` and I could simply do `cell.myLabel = superArray.names.indexPath[row]` (I might be getting some syntax wrong, I've not ran this through xcode. When I setup my tableview I need to return something for the number of rows the table should display. Currently in my Objc project I have just implemented dummy arrays and all the arrays are the same size, I'm returning only one of these. This in my eyes is bad because I could retrieve a dataset with incomplete parameters (maybe an age but not a name) then my table will see the wrong amount of information in my array and not display correctly. I almost want to return the struct's array count and have NO idea how I would do this. And I don't know how to do this in swift.. and I need to do this in objective c (since i've started working on an app that uses objc so I need all the practise I can get). Currently my tableview works and I can populate the table with a dataset pulled from the web. I'm just thinking about defending my implementation from incomplete datasets and trying to 'theorycraft' the best solution to this problem. If anyone has any suggestions I am all ears! I'd prefer answers in objective c, but if you can explain the concept better in swift go for it, I can always try converting it over! Cheers :) As an end note: I have used matlab alot and I know you can basically tell an array to have a certain number of columns. So for example your array could have 4 columns per row all with different pieces of information per indexPath row (if that makes sense). I did alot of audio in matlab so maybe this 4 column array is a BFormat impulse response with 44100 samples (datapoints) and 4 numbers per sample (for WXYZ channels). so as an example sample(row) 1 would return [0.123,-1.230,1.765,0.873] and sample (row) [1.322,-3.478,-0.311,0.421] (all random numbers) You can specify in matlab which row to access AND which column to access, can this principle be extended into objc/swift/ios development?
0debug
How to count Specific words on RichTextbox c# : I have a program where i need to count how many females and Males are in the file that has been read into the richtextbox, but I'm not sure how to do that , in the file has the name, gender,specific job . i have to count between 15 different people for example : " Donna,Female,Human Resources."
0debug
Using wild cards with find and ls : <p>The find command doesn't seem to search recursively when using the * wild card</p> <p>I have a directory with several sub-directories inside it, many of which contain pdf's. There are no actual pdf's in the main directory, just in the sub-directories within it. I want to find all the pdf's without having to open all the directories.</p> <pre><code>find *.pdf </code></pre> <p>Shouldn't my code return all the pdfs in the sub-directories? I get 'No match'. Am I using the wild card correctly? I've also tried it like </p> <p>*pdf</p> <p>*.pdf*</p> <p>*'.pdf'* </p> <p>with no luck. Same results with ls. What am I not understanding?</p>
0debug
PHP : Regex to extract data from web url : <p>I am receiving URL from an application as post data. </p> <p>The URL has a signature : //abc.com/name?q=123456. </p> <p>I want to extract name from the URL using regex ( Regular Expression ) How do I do that?</p>
0debug
How can I detect if device is in Airplane mode? : <p>I want to detect if my device is in Airplane mode in order to cancel active network operations. How can I do that?</p>
0debug
Iterating over a two level structure using nested iterators : <p>I have the following two level <code>XML</code> structure. A list of boxes, each containing a list of drawers.</p> <pre><code>&lt;Boxes&gt; &lt;Box id="0"&gt; &lt;Drawers&gt; &lt;Drawer id="0"/&gt; &lt;Drawer id="1"/&gt; ... &lt;/Drawers&gt; &lt;/Box&gt; &lt;Box id="1"&gt; ... &lt;/Box&gt; &lt;/Boxes&gt; </code></pre> <p>I'm parsing it using <code>StAX</code> and exposed the structure through two <code>Iterators</code>:</p> <ol> <li><code>BoxIterator implements Iterator&lt;Box&gt;, Iterable&lt;Box&gt;</code></li> <li><code>Box implements Iterable&lt;Drawer&gt;</code></li> <li><code>DrawerIterator implements Iterator&lt;Drawer&gt;</code></li> </ol> <p>I can then do the following:</p> <pre><code>BoxIterator boxList; for (Box box : boxList) { for (Drawer drawer : box) { drawer.getId() } } </code></pre> <p>Under the hood of those <code>Iterators</code> I'm using <code>StAX</code> and both of them are accessing the same underlying <code>XMLStreamReader</code>. If I call <code>BoxIterator.next()</code> it will influence the result that will be returned on subsequent calls to <code>DrawerIterator.next()</code> because the cursor will have moved to the next box.</p> <p>Does this break the contract of <code>Iterator</code>? Is there a better way to iterate over a two level structure using <code>StAX</code>?</p>
0debug
When does Angular2 ngAfterViewInit get called? : <p>I need some jQuery code to run after my Angular component view has initialized to transform number values into stars.</p> <p>I put the code in the ngAfterViewInit function, but it is not doing what I need it to. I set a break point in the function and I see that most of the HTML of my component has not even loaded by the time ngAfterViewInit function is called. The parts that have not loaded are generated using *ngFor directive.</p> <p>How can I get my code to run after this directive has generated all of the html on which I need to operate?</p>
0debug
static av_cold int png_dec_init(AVCodecContext *avctx) { PNGDecContext *s = avctx->priv_data; s->avctx = avctx; s->previous_picture.f = av_frame_alloc(); s->last_picture.f = av_frame_alloc(); s->picture.f = av_frame_alloc(); if (!s->previous_picture.f || !s->last_picture.f || !s->picture.f) return AVERROR(ENOMEM); if (!avctx->internal->is_copy) { avctx->internal->allocate_progress = 1; ff_pngdsp_init(&s->dsp); } return 0; }
1threat
static void blockdev_backup_prepare(BlkActionState *common, Error **errp) { BlockdevBackupState *state = DO_UPCAST(BlockdevBackupState, common, common); BlockdevBackup *backup; BlockBackend *blk, *target; Error *local_err = NULL; assert(common->action->type == TRANSACTION_ACTION_KIND_BLOCKDEV_BACKUP); backup = common->action->u.blockdev_backup; blk = blk_by_name(backup->device); if (!blk) { error_setg(errp, "Device '%s' not found", backup->device); return; } if (!blk_is_available(blk)) { error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, backup->device); return; } target = blk_by_name(backup->target); if (!target) { error_setg(errp, "Device '%s' not found", backup->target); return; } state->aio_context = blk_get_aio_context(blk); if (state->aio_context != blk_get_aio_context(target)) { state->aio_context = NULL; error_setg(errp, "Backup between two IO threads is not implemented"); return; } aio_context_acquire(state->aio_context); state->bs = blk_bs(blk); bdrv_drained_begin(state->bs); do_blockdev_backup(backup->device, backup->target, backup->sync, backup->has_speed, backup->speed, backup->has_on_source_error, backup->on_source_error, backup->has_on_target_error, backup->on_target_error, common->block_job_txn, &local_err); if (local_err) { error_propagate(errp, local_err); return; } state->job = state->bs->job; }
1threat
static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q, AVPacket *avpkt) { mfxVideoParam param = { { 0 } }; mfxBitstream bs = { { { 0 } } }; int ret; enum AVPixelFormat pix_fmts[3] = { AV_PIX_FMT_QSV, AV_PIX_FMT_NV12, AV_PIX_FMT_NONE }; ret = ff_get_format(avctx, pix_fmts); if (ret < 0) return ret; avctx->pix_fmt = ret; q->iopattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY; if (avctx->hwaccel_context) { AVQSVContext *qsv = avctx->hwaccel_context; q->session = qsv->session; q->iopattern = qsv->iopattern; q->ext_buffers = qsv->ext_buffers; q->nb_ext_buffers = qsv->nb_ext_buffers; } if (!q->session) { if (!q->internal_qs.session) { ret = ff_qsv_init_internal_session(avctx, &q->internal_qs, q->load_plugins); if (ret < 0) return ret; } q->session = q->internal_qs.session; } if (avpkt->size) { bs.Data = avpkt->data; bs.DataLength = avpkt->size; bs.MaxLength = bs.DataLength; bs.TimeStamp = avpkt->pts; } else return AVERROR_INVALIDDATA; ret = ff_qsv_codec_id_to_mfx(avctx->codec_id); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Unsupported codec_id %08x\n", avctx->codec_id); return ret; } param.mfx.CodecId = ret; ret = MFXVideoDECODE_DecodeHeader(q->session, &bs, &param); if (MFX_ERR_MORE_DATA==ret) { return avpkt->size; } else if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Decode header error %d\n", ret); return ff_qsv_error(ret); } param.IOPattern = q->iopattern; param.AsyncDepth = q->async_depth; param.ExtParam = q->ext_buffers; param.NumExtParam = q->nb_ext_buffers; param.mfx.FrameInfo.BitDepthLuma = 8; param.mfx.FrameInfo.BitDepthChroma = 8; ret = MFXVideoDECODE_Init(q->session, &param); if (ret < 0) { if (MFX_ERR_INVALID_VIDEO_PARAM==ret) { av_log(avctx, AV_LOG_ERROR, "Error initializing the MFX video decoder, unsupported video\n"); } else { av_log(avctx, AV_LOG_ERROR, "Error initializing the MFX video decoder %d\n", ret); } return ff_qsv_error(ret); } avctx->profile = param.mfx.CodecProfile; avctx->level = param.mfx.CodecLevel; avctx->coded_width = param.mfx.FrameInfo.Width; avctx->coded_height = param.mfx.FrameInfo.Height; avctx->width = param.mfx.FrameInfo.CropW - param.mfx.FrameInfo.CropX; avctx->height = param.mfx.FrameInfo.CropH - param.mfx.FrameInfo.CropY; if (!q->async_fifo) { q->async_fifo = av_fifo_alloc((1 + 16) * (sizeof(mfxSyncPoint*) + sizeof(QSVFrame*))); if (!q->async_fifo) return AVERROR(ENOMEM); } if (!q->input_fifo) { q->input_fifo = av_fifo_alloc(1024*16); if (!q->input_fifo) return AVERROR(ENOMEM); } if (!q->pkt_fifo) { q->pkt_fifo = av_fifo_alloc( sizeof(AVPacket) * (1 + 16) ); if (!q->pkt_fifo) return AVERROR(ENOMEM); } q->engine_ready = 1; return 0; }
1threat
Angular 6 Sort Array of object by Date : <p>I try to sort the array object by date for my Angular 6 application. The data has string format. I wonder if there is an existing module to perform sort in Angular or we have to build sort function it in Typescript.</p> <p>Angular Template</p> <pre><code>&lt;app-item *ngFor="let item of someArray"&gt;&lt;/app-item&gt; </code></pre> <p>The Array</p> <pre><code>[ { CREATE_TS: "2018-08-15 17:17:30.0", Key1: "Val1", Key2: "Val2", }, { CREATE_TS: "2018-08-15 17:25:30.0", Key1: "Val1", Key2: "Val2", }, { CREATE_TS: "2018-08-15 17:28:30.0", Key1: "Val1", Key2: "Val2", } ] </code></pre>
0debug
Visual Studio 2017 Unit Test Project vs xUnit Test Project : <p>In .NET Core under Visual Studio 2015 one had to create a unit test project that was based on xunit, though the command line (no dedicated project was available in Visual Studio for .NET Core).</p> <p>In Visual Studio 2017, under .NET Core section there are now 2 types of unit testing projects available:</p> <ol> <li>Unit Test Project (.NET Core)</li> <li>xUnit Test Project (.NET Core)</li> </ol> <p>What is the difference between them? What is the recommended one these days?</p>
0debug
How to create app file with fastlane for simulator : <p>I need to create with fastlane .app file (or .ipa file if it works to) which I could next drag and drop to simulator on another computer. I tried do it with gym or with xcodebuild parameters but I don't know how to do it.</p> <p>For now I do it in this way:</p> <ul> <li><p>In XCode I build application for simulator</p></li> <li><p>Next I am searching app file in DerivedData (~/Library/Developer/XCode/DerivedData/Build/Products/Debug-iphonesimulator/)</p></li> <li><p>I copy this file somewhere else</p></li> </ul> <p>But I need do it with fastlane.</p>
0debug
How i can call a funcktion without click button ? (visual studio c# 2017) : How i can call a funcktion without click button ? when i opened a form, i want to run a function without click any button. How i can run funcktion ? ``` int sayfa = 1; int kapasite = 20; public Form2() { InitializeComponent(); } private void sayfayi_goster(int Sayfa, int Kapasite) { textBox6.Text = Sayfa.ToString() + "/" + Kapasite.ToString(); } sayfayi.goster(sayfa,kapasite); // its not working !!! ```
0debug
def minimum(a,b): if a <= b: return a else: return b
0debug
I want you to help me so that I can concatenate an md5 function with a string variable in php : <p>I want you to help me so that I can concatenate an md5 function with a string variable</p> <pre><code> &lt;?php function Crypter () { $string =""; $string1=md5( $string ); } ?&gt; </code></pre>
0debug
static inline uint64_t bdrv_get_align(BlockDriverState *bs) { return MAX(BDRV_SECTOR_SIZE, bs->request_alignment); }
1threat
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
Clion memory view : <p>I can't find a memory view in Jetbrain's clion IDE. Does anybody know to show it (has clion this feature)?</p> <p>Meant is this: <a href="http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Freference%2Fcdt_u_memoryview.htm" rel="noreferrer">memory view</a> in eclipse </p>
0debug
static void scsi_write_data(SCSIRequest *req) { SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req); SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); SCSIDiskClass *sdc = (SCSIDiskClass *) object_get_class(OBJECT(s)); assert(r->req.aiocb == NULL); scsi_req_ref(&r->req); if (r->req.cmd.mode != SCSI_XFER_TO_DEV) { DPRINTF("Data transfer direction invalid\n"); scsi_write_complete_noio(r, -EINVAL); return; } if (!r->req.sg && !r->qiov.size) { r->started = true; scsi_write_complete_noio(r, 0); return; } if (s->tray_open) { scsi_write_complete_noio(r, -ENOMEDIUM); return; } if (r->req.cmd.buf[0] == VERIFY_10 || r->req.cmd.buf[0] == VERIFY_12 || r->req.cmd.buf[0] == VERIFY_16) { if (r->req.sg) { scsi_dma_complete_noio(r, 0); } else { scsi_write_complete_noio(r, 0); } return; } if (r->req.sg) { dma_acct_start(s->qdev.conf.blk, &r->acct, r->req.sg, BLOCK_ACCT_WRITE); r->req.resid -= r->req.sg->size; r->req.aiocb = dma_blk_io(blk_get_aio_context(s->qdev.conf.blk), r->req.sg, r->sector << BDRV_SECTOR_BITS, sdc->dma_writev, r, scsi_dma_complete, r, DMA_DIRECTION_TO_DEVICE); } else { block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct, r->qiov.size, BLOCK_ACCT_WRITE); r->req.aiocb = sdc->dma_writev(r->sector << BDRV_SECTOR_BITS, &r->qiov, scsi_write_complete, r, r); } }
1threat
Python program to find the sum and divide and check reminder : I want a python or a shell script to find the sum of numbers of a particular range. and divide it by 8. and if the reminder is between 1 to 4 print that number. Example. 5959 5+9+5+9 = 28 Reminder of 28 / 8 is 3 . 3 comes in the range of 1 to 4. so print the number 5959 and go to next number. if reminder is not in the range of 1 to 4 ignore and go to next number. So far i have tried this. but not happening count = 0 lower = 5959 while (count<1000): sum_digit= lower%8 count+=1 lower+=1 if 1<=sum_digit<=4: print lower
0debug
static inline int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block, int n, int coded) { int level, i, last, run, run_diff; int dc_pred_dir; RLTable *rl; RL_VLC_ELEM *rl_vlc; const UINT8 *scan_table; int qmul, qadd; if (s->mb_intra) { qmul=1; qadd=0; set_stat(ST_DC); level = msmpeg4_decode_dc(s, n, &dc_pred_dir); #ifdef PRINT_MB { static int c; if(n==0) c=0; if(n==4) printf("%X", c); c+= c +dc_pred_dir; } #endif if (level < 0){ fprintf(stderr, "dc overflow- block: %d qscale: %d if(s->inter_intra_pred) level=0; else return -1; } if (n < 4) { rl = &rl_table[s->rl_table_index]; if(level > 256*s->y_dc_scale){ fprintf(stderr, "dc overflow+ L qscale: %d if(!s->inter_intra_pred) return -1; } } else { rl = &rl_table[3 + s->rl_chroma_table_index]; if(level > 256*s->c_dc_scale){ fprintf(stderr, "dc overflow+ C qscale: %d if(!s->inter_intra_pred) return -1; } } block[0] = level; run_diff = 0; i = 0; if (!coded) { goto not_coded; } if (s->ac_pred) { if (dc_pred_dir == 0) scan_table = s->intra_v_scantable; else scan_table = s->intra_h_scantable; } else { scan_table = s->intra_scantable; } set_stat(ST_INTRA_AC); rl_vlc= rl->rl_vlc[0]; } else { qmul = s->qscale << 1; qadd = (s->qscale - 1) | 1; i = -1; rl = &rl_table[3 + s->rl_table_index]; if(s->msmpeg4_version==2) run_diff = 0; else run_diff = 1; if (!coded) { s->block_last_index[n] = i; return 0; } scan_table = s->inter_scantable; set_stat(ST_INTER_AC); rl_vlc= rl->rl_vlc[s->qscale]; } { OPEN_READER(re, &s->gb); for(;;) { UPDATE_CACHE(re, &s->gb); GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2); if (level==0) { int cache; cache= GET_CACHE(re, &s->gb); if (s->msmpeg4_version==1 || (cache&0x80000000)==0) { if (s->msmpeg4_version==1 || (cache&0x40000000)==0) { if(s->msmpeg4_version!=1) LAST_SKIP_BITS(re, &s->gb, 2); UPDATE_CACHE(re, &s->gb); if(s->msmpeg4_version<=3){ last= SHOW_UBITS(re, &s->gb, 1); SKIP_CACHE(re, &s->gb, 1); run= SHOW_UBITS(re, &s->gb, 6); SKIP_CACHE(re, &s->gb, 6); level= SHOW_SBITS(re, &s->gb, 8); LAST_SKIP_CACHE(re, &s->gb, 8); SKIP_COUNTER(re, &s->gb, 1+6+8); }else{ int sign; last= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1); if(!s->esc3_level_length){ int ll; if(s->qscale<8){ ll= SHOW_UBITS(re, &s->gb, 3); SKIP_BITS(re, &s->gb, 3); if(ll==0){ if(SHOW_UBITS(re, &s->gb, 1)) printf("cool a new vlc code ,contact the ffmpeg developers and upload the file\n"); SKIP_BITS(re, &s->gb, 1); ll=8; } }else{ ll=2; while(ll<8 && SHOW_UBITS(re, &s->gb, 1)==0){ ll++; SKIP_BITS(re, &s->gb, 1); } if(ll<8) SKIP_BITS(re, &s->gb, 1); } s->esc3_level_length= ll; s->esc3_run_length= SHOW_UBITS(re, &s->gb, 2) + 3; SKIP_BITS(re, &s->gb, 2); UPDATE_CACHE(re, &s->gb); } run= SHOW_UBITS(re, &s->gb, s->esc3_run_length); SKIP_BITS(re, &s->gb, s->esc3_run_length); sign= SHOW_UBITS(re, &s->gb, 1); SKIP_BITS(re, &s->gb, 1); level= SHOW_UBITS(re, &s->gb, s->esc3_level_length); SKIP_BITS(re, &s->gb, s->esc3_level_length); if(sign) level= -level; } #if 0 { const int abs_level= ABS(level); const int run1= run - rl->max_run[last][abs_level] - run_diff; if(abs_level<=MAX_LEVEL && run<=MAX_RUN){ if(abs_level <= rl->max_level[last][run]){ fprintf(stderr, "illegal 3. esc, vlc encoding possible\n"); return DECODING_AC_LOST; } if(abs_level <= rl->max_level[last][run]*2){ fprintf(stderr, "illegal 3. esc, esc 1 encoding possible\n"); return DECODING_AC_LOST; } if(run1>=0 && abs_level <= rl->max_level[last][run1]){ fprintf(stderr, "illegal 3. esc, esc 2 encoding possible\n"); return DECODING_AC_LOST; } } } #endif if (level>0) level= level * qmul + qadd; else level= level * qmul - qadd; #if 0 if(level>2048 || level<-2048){ fprintf(stderr, "|level| overflow in 3. esc\n"); return DECODING_AC_LOST; } #endif i+= run + 1; if(last) i+=192; #ifdef ERROR_DETAILS if(run==66) fprintf(stderr, "illegal vlc code in ESC3 level=%d\n", level); else if((i>62 && i<192) || i>192+63) fprintf(stderr, "run overflow in ESC3 i=%d run=%d level=%d\n", i, run, level); #endif } else { #if MIN_CACHE_BITS < 23 LAST_SKIP_BITS(re, &s->gb, 2); UPDATE_CACHE(re, &s->gb); #else SKIP_BITS(re, &s->gb, 2); #endif GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2); i+= run + rl->max_run[run>>7][level/qmul] + run_diff; level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_BITS(re, &s->gb, 1); #ifdef ERROR_DETAILS if(run==66) fprintf(stderr, "illegal vlc code in ESC2 level=%d\n", level); else if((i>62 && i<192) || i>192+63) fprintf(stderr, "run overflow in ESC2 i=%d run=%d level=%d\n", i, run, level); #endif } } else { #if MIN_CACHE_BITS < 22 LAST_SKIP_BITS(re, &s->gb, 1); UPDATE_CACHE(re, &s->gb); #else SKIP_BITS(re, &s->gb, 1); #endif GET_RL_VLC(level, run, re, &s->gb, rl_vlc, TEX_VLC_BITS, 2); i+= run; level = level + rl->max_level[run>>7][(run-1)&63] * qmul; level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_BITS(re, &s->gb, 1); #ifdef ERROR_DETAILS if(run==66) fprintf(stderr, "illegal vlc code in ESC1 level=%d\n", level); else if((i>62 && i<192) || i>192+63) fprintf(stderr, "run overflow in ESC1 i=%d run=%d level=%d\n", i, run, level); #endif } } else { i+= run; level = (level ^ SHOW_SBITS(re, &s->gb, 1)) - SHOW_SBITS(re, &s->gb, 1); LAST_SKIP_BITS(re, &s->gb, 1); #ifdef ERROR_DETAILS if(run==66) fprintf(stderr, "illegal vlc code level=%d\n", level); else if((i>62 && i<192) || i>192+63) fprintf(stderr, "run overflow i=%d run=%d level=%d\n", i, run, level); #endif } if (i > 62){ i-= 192; if(i&(~63)){ if(s->error_resilience<0){ fprintf(stderr, "ignoring overflow at %d %d\n", s->mb_x, s->mb_y); break; }else{ fprintf(stderr, "ac-tex damaged at %d %d\n", s->mb_x, s->mb_y); return -1; } } block[scan_table[i]] = level; break; } block[scan_table[i]] = level; } CLOSE_READER(re, &s->gb); } not_coded: if (s->mb_intra) { mpeg4_pred_ac(s, block, n, dc_pred_dir); if (s->ac_pred) { i = 63; } } if(s->msmpeg4_version==4 && i>0) i=63; s->block_last_index[n] = i; return 0; }
1threat
Variable usage in C : <p>I'm a novice in C and came across code that seemed peculiar to me,</p> <pre><code>extern int num; int counter; void init_counter() { counter = 0; } int return_position() { int pos = counter; counter = counter * num; return pos; } </code></pre> <p>What is the point of the pos variable? why can't I just do:</p> <pre><code>extern int num; int counter; void init_counter() { counter = 0; } int return_position() { counter = counter * num; return counter; } </code></pre> <p>any help is appreciated</p>
0debug
Android - How to get just the date from date time ? : I have data Json that contains birth date, when i display it it contains the time also. Please help me how can i just display the date without the time...? this is my code to get the birth date ..... <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> userBirthDate.setText(response.body().getData().getBirth_of_date().toString()); <!-- end snippet --> .....
0debug
Qt How to pass data from a GUI to another thread : <p>I have an application that can start pause and cancel the thread. i would like to pass data from the main gui to the thread. in this example i have a spinbox. i wish to reset the counter in the worker thread everytime i change the spin box. </p> <p>for some reason i can't seem to update the counter variable in the worker thread. what am i missing in my program?</p> <p>MAINWINDOW.h</p> <pre><code>#ifndef MAINWINDOW_H #define MAINWINDOW_H #include &lt;QMainWindow&gt; #include &lt;QThread&gt; #include "worker.h" namespace Ui { class MainWindow; } class MainWindow : public QMainWindow { Q_OBJECT signals: void updatecounter(int val); public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); private slots: void on_Time_valueChanged(const QString &amp;arg1); void on_Start_clicked(); void on_Stop_clicked(); void on_Pause_clicked(); private: Ui::MainWindow *ui; QThread *m_Thread; Worker *m_Worker; }; #endif // MAINWINDOW_H </code></pre> <p>WORKER.h</p> <pre><code>#ifndef WORKER_H #define WORKER_H #include &lt;QObject&gt; #include &lt;QMutex&gt; #include &lt;QThread&gt; #include &lt;QDebug&gt; #include &lt;QEventLoop&gt; #include &lt;QAbstractEventDispatcher&gt; class Worker : public QObject { Q_OBJECT public: Worker(); ~Worker(); public slots: void process(); signals: void started(); void finished(); public slots: void updatecounter(int val) { counter = val; } void pause() { auto const dispatcher = QThread::currentThread()-&gt;eventDispatcher(); if (!dispatcher) { qCritical() &lt;&lt; "thread with no dispatcher"; return; } if (state != RUNNING) return; state = PAUSED; qDebug() &lt;&lt; this; qDebug() &lt;&lt; "paused"; do { dispatcher-&gt;processEvents(QEventLoop::WaitForMoreEvents); } while (state == PAUSED); } void resume() { if (state == PAUSED) { state = RUNNING; qDebug() &lt;&lt; this; qDebug() &lt;&lt; "resumed"; updatecounter(0); } } void cancel() { if (state != IDLE) { state = IDLE; qDebug() &lt;&lt; this; qDebug() &lt;&lt; "cancelled"; } } protected: enum State { IDLE, RUNNING, PAUSED }; State state = IDLE; int counter = 0; bool isCancelled() { auto const dispatcher = QThread::currentThread()-&gt;eventDispatcher(); if (!dispatcher) { qCritical() &lt;&lt; "thread with no dispatcher"; return false; } dispatcher-&gt;processEvents(QEventLoop::AllEvents); return state == IDLE; } }; #endif // WORKER_H </code></pre> <p>MAINWINDOW.cpp</p> <pre><code>#include "mainwindow.h" #include "ui_mainwindow.h" #include &lt;QDebug&gt; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui-&gt;setupUi(this); qDebug() &lt;&lt; "main thread"; m_Thread = new QThread(); ui-&gt;Start-&gt;setEnabled(true); ui-&gt;Pause-&gt;setEnabled(false); ui-&gt;Stop-&gt;setEnabled(false); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_Time_valueChanged(const QString &amp;arg1) { emit updatecounter(arg1.toInt()); //auto const m = m_Worker-&gt;metaObject(); //m-&gt;invokeMethod(m_Worker, "updatecounter",Qt::QueuedConnection,Q_ARG(int,arg1.toInt())); } void MainWindow::on_Start_clicked() { if(!m_Thread-&gt;isRunning()) { m_Thread = new QThread(); m_Worker = new Worker(); m_Worker-&gt;moveToThread(m_Thread); connect(m_Thread, &amp;QThread::started, m_Worker, &amp;Worker::process); connect(this,&amp;MainWindow::updatecounter, m_Worker, &amp;Worker::updatecounter, Qt::QueuedConnection); connect(m_Worker, &amp;Worker::finished, m_Thread, &amp;QThread::quit); m_Thread-&gt;start(); } else { auto const m = m_Worker-&gt;metaObject(); m-&gt;invokeMethod(m_Worker, "resume"); } ui-&gt;Start-&gt;setEnabled(false); ui-&gt;Pause-&gt;setEnabled(true); ui-&gt;Stop-&gt;setEnabled(true); } void MainWindow::on_Stop_clicked() { auto const m = m_Worker-&gt;metaObject(); m-&gt;invokeMethod(m_Worker, "cancel"); ui-&gt;Start-&gt;setEnabled(true); ui-&gt;Pause-&gt;setEnabled(false); ui-&gt;Stop-&gt;setEnabled(false); } void MainWindow::on_Pause_clicked() { auto const m = m_Worker-&gt;metaObject(); m-&gt;invokeMethod(m_Worker, "pause"); ui-&gt;Start-&gt;setEnabled(true); ui-&gt;Pause-&gt;setEnabled(false); ui-&gt;Stop-&gt;setEnabled(true); } </code></pre> <p>WORKER.cpp</p> <pre><code>#include "worker.h" #include &lt;QDebug&gt; #include &lt;QThread&gt; #include &lt;QTimer&gt; Worker::Worker() { qDebug() &lt;&lt; this &lt;&lt; " worker thread started"; } Worker::~Worker() { qDebug() &lt;&lt; "worker thread finished"; } void Worker::process() { if (state == PAUSED) // treat as resume state = RUNNING; if (state == RUNNING) return; state = RUNNING; qDebug() &lt;&lt; "started"; emit started(); // This loop simulates the actual work for (auto i = counter; state == RUNNING; ++i) { QThread::msleep(100); if (isCancelled()) { break; } qDebug() &lt;&lt; i; } qDebug() &lt;&lt; this; qDebug() &lt;&lt; "finished"; emit finished(); } </code></pre>
0debug
void register_displaychangelistener(DisplayChangeListener *dcl) { static DisplaySurface *dummy; QemuConsole *con; trace_displaychangelistener_register(dcl, dcl->ops->dpy_name); dcl->ds = get_alloc_displaystate(); QLIST_INSERT_HEAD(&dcl->ds->listeners, dcl, next); gui_setup_refresh(dcl->ds); if (dcl->con) { dcl->con->dcls++; con = dcl->con; } else { con = active_console; } if (dcl->ops->dpy_gfx_switch) { if (con) { dcl->ops->dpy_gfx_switch(dcl, con->surface); } else { if (!dummy) { dummy = qemu_create_dummy_surface(); } dcl->ops->dpy_gfx_switch(dcl, dummy); } } }
1threat
static void usb_mtp_command(MTPState *s, MTPControl *c) { MTPData *data_in = NULL; MTPObject *o; uint32_t nres = 0, res0 = 0; if (c->code >= CMD_CLOSE_SESSION && s->session == 0) { usb_mtp_queue_result(s, RES_SESSION_NOT_OPEN, c->trans, 0, 0, 0); return; } switch (c->code) { case CMD_GET_DEVICE_INFO: data_in = usb_mtp_get_device_info(s, c); break; case CMD_OPEN_SESSION: if (s->session) { usb_mtp_queue_result(s, RES_SESSION_ALREADY_OPEN, c->trans, 1, s->session, 0); return; } if (c->argv[0] == 0) { usb_mtp_queue_result(s, RES_INVALID_PARAMETER, c->trans, 0, 0, 0); return; } trace_usb_mtp_op_open_session(s->dev.addr); s->session = c->argv[0]; usb_mtp_object_alloc(s, s->next_handle++, NULL, s->root); #ifdef __linux__ if (usb_mtp_inotify_init(s)) { fprintf(stderr, "usb-mtp: file monitoring init failed\n"); } #endif break; case CMD_CLOSE_SESSION: trace_usb_mtp_op_close_session(s->dev.addr); s->session = 0; s->next_handle = 0; #ifdef __linux__ usb_mtp_inotify_cleanup(s); #endif usb_mtp_object_free(s, QTAILQ_FIRST(&s->objects)); assert(QTAILQ_EMPTY(&s->objects)); break; case CMD_GET_STORAGE_IDS: data_in = usb_mtp_get_storage_ids(s, c); break; case CMD_GET_STORAGE_INFO: if (c->argv[0] != QEMU_STORAGE_ID && c->argv[0] != 0xffffffff) { usb_mtp_queue_result(s, RES_INVALID_STORAGE_ID, c->trans, 0, 0, 0); return; } data_in = usb_mtp_get_storage_info(s, c); break; case CMD_GET_NUM_OBJECTS: case CMD_GET_OBJECT_HANDLES: if (c->argv[0] != QEMU_STORAGE_ID && c->argv[0] != 0xffffffff) { usb_mtp_queue_result(s, RES_INVALID_STORAGE_ID, c->trans, 0, 0, 0); return; } if (c->argv[1] != 0x00000000) { usb_mtp_queue_result(s, RES_SPEC_BY_FORMAT_UNSUPPORTED, c->trans, 0, 0, 0); return; } if (c->argv[2] == 0x00000000 || c->argv[2] == 0xffffffff) { o = QTAILQ_FIRST(&s->objects); } else { o = usb_mtp_object_lookup(s, c->argv[2]); } if (o == NULL) { usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE, c->trans, 0, 0, 0); return; } if (o->format != FMT_ASSOCIATION) { usb_mtp_queue_result(s, RES_INVALID_PARENT_OBJECT, c->trans, 0, 0, 0); return; } usb_mtp_object_readdir(s, o); if (c->code == CMD_GET_NUM_OBJECTS) { trace_usb_mtp_op_get_num_objects(s->dev.addr, o->handle, o->path); nres = 1; res0 = o->nchildren; } else { data_in = usb_mtp_get_object_handles(s, c, o); } break; case CMD_GET_OBJECT_INFO: o = usb_mtp_object_lookup(s, c->argv[0]); if (o == NULL) { usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE, c->trans, 0, 0, 0); return; } data_in = usb_mtp_get_object_info(s, c, o); break; case CMD_GET_OBJECT: o = usb_mtp_object_lookup(s, c->argv[0]); if (o == NULL) { usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE, c->trans, 0, 0, 0); return; } if (o->format == FMT_ASSOCIATION) { usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE, c->trans, 0, 0, 0); return; } data_in = usb_mtp_get_object(s, c, o); if (data_in == NULL) { usb_mtp_queue_result(s, RES_GENERAL_ERROR, c->trans, 0, 0, 0); return; } break; case CMD_GET_PARTIAL_OBJECT: o = usb_mtp_object_lookup(s, c->argv[0]); if (o == NULL) { usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE, c->trans, 0, 0, 0); return; } if (o->format == FMT_ASSOCIATION) { usb_mtp_queue_result(s, RES_INVALID_OBJECT_HANDLE, c->trans, 0, 0, 0); return; } data_in = usb_mtp_get_partial_object(s, c, o); if (data_in == NULL) { usb_mtp_queue_result(s, RES_GENERAL_ERROR, c->trans, 0, 0, 0); return; } nres = 1; res0 = data_in->length; break; default: trace_usb_mtp_op_unknown(s->dev.addr, c->code); usb_mtp_queue_result(s, RES_OPERATION_NOT_SUPPORTED, c->trans, 0, 0, 0); return; } if (data_in) { assert(s->data_in == NULL); s->data_in = data_in; } usb_mtp_queue_result(s, RES_OK, c->trans, nres, res0, 0); }
1threat
Scroll an element inside a Div up to visible area : How to Scroll an element inside a Div. There are multiple div and each div content an element <span> Like < div class="parent" ><p ><span ></span ></p ></ div > < div class="parent" ><p ><span ></span ></p ></ div > < div class="parent" ><p ><span ></span ></p ></ div > < div class="parent" ><p ><span ></span ></p ></ div > and the are generate dynamically (infinite scroll) where <div class="parent" > is self scrolling div how to put <span ></span > element in visible part of div when page load AND/OR more data load on ajax call
0debug
I'm usingto use google maps and need to get natural feature like ocean, sea etc from location in android : I am trying to get name of oceans from location using this- https://maps.googleapis.com/maps/api/geocode/json?latlng=0,0&result_type=natural_feature&key=AIzaSyBZ1dxaR_eFtP4LYS8Ky9x4hHdVYf6456Y But not found. Please help me to find out this. Thanks in advance
0debug
Search a list for a range of numbers but return index of first example : <blockquote> <p>I have a list that I want to search for values from 500-535 in and I want to return the index for the first value found that is within that range.</p> </blockquote> <pre><code>mylist =[321, 344, 999, 512, 675, 555, 500] rainday=forecastlist.index(range(500,531)) if not rainday: print("Empty") </code></pre> <blockquote> <p>Obviously this isn't working. I want it to return 3. I don't want the location of the other values at this time, just the first one.</p> </blockquote>
0debug
Webstrom 2018.3 Run/Debug start direct error : error message: Error running 'debug': Unknown error and it is ok when i use previous version this is my config [enter image description here][1] [1]: https://i.stack.imgur.com/Nqkar.png
0debug
I need the code for creating the repository class in case of entity framework : What methods I need : 1) performing all CRUD operations . 2) retrieving data from two or more tables which may or may not present in the database . 3) able to perform transactions
0debug
static inline CopyRet copy_frame(AVCodecContext *avctx, BC_DTS_PROC_OUT *output, void *data, int *data_size, uint8_t second_field) { BC_STATUS ret; BC_DTS_STATUS decoder_status; uint8_t is_paff; uint8_t next_frame_same; uint8_t interlaced; CHDContext *priv = avctx->priv_data; int64_t pkt_pts = AV_NOPTS_VALUE; uint8_t pic_type = 0; uint8_t bottom_field = (output->PicInfo.flags & VDEC_FLAG_BOTTOMFIELD) == VDEC_FLAG_BOTTOMFIELD; uint8_t bottom_first = !!(output->PicInfo.flags & VDEC_FLAG_BOTTOM_FIRST); int width = output->PicInfo.width; int height = output->PicInfo.height; int bwidth; uint8_t *src = output->Ybuff; int sStride; uint8_t *dst; int dStride; if (output->PicInfo.timeStamp != 0) { OpaqueList *node = opaque_list_pop(priv, output->PicInfo.timeStamp); if (node) { pkt_pts = node->reordered_opaque; pic_type = node->pic_type; av_free(node); } else { pic_type = PICT_BOTTOM_FIELD; } av_log(avctx, AV_LOG_VERBOSE, "output \"pts\": %"PRIu64"\n", output->PicInfo.timeStamp); av_log(avctx, AV_LOG_VERBOSE, "output picture type %d\n", pic_type); } ret = DtsGetDriverStatus(priv->dev, &decoder_status); if (ret != BC_STS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "CrystalHD: GetDriverStatus failed: %u\n", ret); return RET_ERROR; } is_paff = ASSUME_PAFF_OVER_MBAFF || !(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC); next_frame_same = output->PicInfo.picture_number == (decoder_status.picNumFlags & ~0x40000000); interlaced = ((output->PicInfo.flags & VDEC_FLAG_INTERLACED_SRC) && is_paff) || next_frame_same || bottom_field || second_field; av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: next_frame_same: %u | %u | %u\n", next_frame_same, output->PicInfo.picture_number, decoder_status.picNumFlags & ~0x40000000); if (priv->pic.data[0] && !priv->need_second_field) avctx->release_buffer(avctx, &priv->pic); priv->need_second_field = interlaced && !priv->need_second_field; priv->pic.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; if (!priv->pic.data[0]) { if (avctx->get_buffer(avctx, &priv->pic) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return RET_ERROR; } } bwidth = av_image_get_linesize(avctx->pix_fmt, width, 0); if (priv->is_70012) { int pStride; if (width <= 720) pStride = 720; else if (width <= 1280) pStride = 1280; else if (width <= 1080) pStride = 1080; sStride = av_image_get_linesize(avctx->pix_fmt, pStride, 0); } else { sStride = bwidth; } dStride = priv->pic.linesize[0]; dst = priv->pic.data[0]; av_log(priv->avctx, AV_LOG_VERBOSE, "CrystalHD: Copying out frame\n"); if (interlaced) { int dY = 0; int sY = 0; height /= 2; if (bottom_field) { av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: bottom field\n"); dY = 1; } else { av_log(priv->avctx, AV_LOG_VERBOSE, "Interlaced: top field\n"); dY = 0; } for (sY = 0; sY < height; dY++, sY++) { memcpy(&(dst[dY * dStride]), &(src[sY * sStride]), bwidth); dY++; } } else { av_image_copy_plane(dst, dStride, src, sStride, bwidth, height); } priv->pic.interlaced_frame = interlaced; if (interlaced) priv->pic.top_field_first = !bottom_first; priv->pic.pkt_pts = pkt_pts; if (!priv->need_second_field) { *data_size = sizeof(AVFrame); *(AVFrame *)data = priv->pic; } if (ASSUME_TWO_INPUTS_ONE_OUTPUT && output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) { av_log(priv->avctx, AV_LOG_VERBOSE, "Fieldpair from two packets.\n"); return RET_SKIP_NEXT_COPY; } return priv->need_second_field && !(output->PicInfo.flags & VDEC_FLAG_UNKNOWN_SRC) ? RET_COPY_NEXT_FIELD : RET_OK; }
1threat
static av_cold int dnxhd_init_rc(DNXHDEncContext *ctx) { FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_rc, 8160*ctx->m.avctx->qmax*sizeof(RCEntry), fail); if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD) FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry), fail); ctx->frame_bits = (ctx->cid_table->coding_unit_size - 640 - 4 - ctx->min_padding) * 8; ctx->qscale = 1; ctx->lambda = 2<<LAMBDA_FRAC_BITS; return 0; fail: return -1; }
1threat
static void vnc_display_close(VncDisplay *vd) { size_t i; if (!vd) { return; } vd->is_unix = false; for (i = 0; i < vd->nlsock; i++) { if (vd->lsock_tag[i]) { g_source_remove(vd->lsock_tag[i]); } object_unref(OBJECT(vd->lsock[i])); } g_free(vd->lsock); g_free(vd->lsock_tag); vd->lsock = NULL; vd->lsock_tag = NULL; vd->nlsock = 0; for (i = 0; i < vd->nlwebsock; i++) { if (vd->lwebsock_tag[i]) { g_source_remove(vd->lwebsock_tag[i]); } object_unref(OBJECT(vd->lwebsock[i])); } g_free(vd->lwebsock); g_free(vd->lwebsock_tag); vd->lwebsock = NULL; vd->lwebsock_tag = NULL; vd->nlwebsock = 0; vd->auth = VNC_AUTH_INVALID; vd->subauth = VNC_AUTH_INVALID; if (vd->tlscreds) { object_unparent(OBJECT(vd->tlscreds)); vd->tlscreds = NULL; } g_free(vd->tlsaclname); vd->tlsaclname = NULL; if (vd->lock_key_sync) { qemu_remove_led_event_handler(vd->led); } }
1threat
IntelliJ - Import configuration from old version after first run : <p>I recently installed version 2017.2 of IntelliJ IDEA. I would like to keep my settings from my old 2017.1 version. IntelliJ's <a href="https://www.jetbrains.com/help/idea/install-and-set-up-intellij-idea.html#r_Install_and_set_up__product_.xmld320216e288" rel="noreferrer">support site</a> shows the following dialog box that is supposed to show up when you run the newly installed version for the first time.</p> <p><a href="https://i.stack.imgur.com/gLJa2.png" rel="noreferrer"><img src="https://i.stack.imgur.com/gLJa2.png" alt="Complete Installation Dialog"></a></p> <p>However, neither when I was installing the new version, nor when I ran the new version for the first time, was I ever shown this dialog box. I attempted to import settings from my old version via the <code>File | Import Settings</code> menu option, but it expects a <code>.jar</code> file that would have been exported from an old version by going to <code>File | Export Settings</code>, which I did not do in the old version before installing the new one.</p> <p>I do still have all of the config from my old version in <code>%MY_HOME_DIR%/.IntelliJIdea2017.1</code>. How can I import those settings in the same way that the above dialog box would have done had it shown up when I opened the new version for the first time?</p>
0debug
void qpci_msix_enable(QPCIDevice *dev) { uint8_t addr; uint16_t val; uint32_t table; uint8_t bir_table; uint8_t bir_pba; void *offset; addr = qpci_find_capability(dev, PCI_CAP_ID_MSIX); g_assert_cmphex(addr, !=, 0); val = qpci_config_readw(dev, addr + PCI_MSIX_FLAGS); qpci_config_writew(dev, addr + PCI_MSIX_FLAGS, val | PCI_MSIX_FLAGS_ENABLE); table = qpci_config_readl(dev, addr + PCI_MSIX_TABLE); bir_table = table & PCI_MSIX_FLAGS_BIRMASK; offset = qpci_iomap(dev, bir_table, NULL); dev->msix_table = offset + (table & ~PCI_MSIX_FLAGS_BIRMASK); table = qpci_config_readl(dev, addr + PCI_MSIX_PBA); bir_pba = table & PCI_MSIX_FLAGS_BIRMASK; if (bir_pba != bir_table) { offset = qpci_iomap(dev, bir_pba, NULL); } dev->msix_pba = offset + (table & ~PCI_MSIX_FLAGS_BIRMASK); g_assert(dev->msix_table != NULL); g_assert(dev->msix_pba != NULL); dev->msix_enabled = true; }
1threat
PHP - Anti mitm attack idea : <p>I've got an idea against mitm(man-in-the-middle) attacks that i'd like to implement to my site, so i decided to ask you how secure this is. First i'd get 10 page loading times from the client computer in seconds. Then i'd calculate the standard with all those loading times. Then each time the user loads a new page i check if his/her ip address has changed and if it has i recalculate that standard and compare it to the previous standard. If this standard is 1 or 2 bigger that doesn't really matter, but if it's 4 i can log out the user. Then if the attacker has a slower internet connection he would get logged out. I'm sure i'm not the only one who has thought of this, but i don't know if this is used.</p>
0debug