problem
stringlengths
26
131k
labels
class label
2 classes
Very confused regarding professor's instructions on classes and class parameters - Intro to C++ course : <p>We just started learning classes in this intro c++ CS class. I'm including much of the prompt for this project just in case it is helpful to answering my question, but I bolded the lines that I have specific questions on.</p> <blockquote> <p>Declare and define a class called Odometer. This class will have two private variables, one for the miles driven and the other for the gallons of gas pumped into the car. We are going to assume that the car starts with a full tank, but these values begin at zero in the default constructor. The member functions should include: </p> <p>• A constructor that takes initial values for both of the private variables. </p> <p>• A default constructor that sets both values to zero.</p> <p>• A get_miles function </p> <p>• A get_gallons function </p> <p>• <strong>An add_in_trip_miles function which increases the miles by the amount sent in its parameter</strong></p> <p>• <strong>An add_gas function that records how much gasoline was pumped into the tank.</strong> </p> <p>• A mpg function that returns the number of miles per gallon for the miles driven and the total amount of gas added to the tank.</p> <p>• A reset function which resets the miles and the gallons to zero.</p> <p>Write the class declaration at the top of your program and the function definitions at the bottom. In the middle write a main which declares an odometer object and then offers the user a menu n a loop to allow them to chose to</p> <ol> <li>See total miles</li> <li>See total gallons</li> <li>Record more miles driven</li> <li>Record gallons pumped into the tank</li> <li>See the average mpg that the car has gotten – this is a cumulative number based on the total number of miles driven and gallons pumped into the tank since the odometer was lat reset, or the object created</li> <li>Reset the odometer</li> <li>Quit the program</li> </ol> </blockquote> <p>So the two functions bolded essentially do the same thing, one increases how many miles have been driven and the other increases how many gallons of gas into the tank, both by user-inputed values. My question towards my professor, then, was why does the miles function require data sent into the parameter, while the gallons function does not? They are essentially the same, so I'm confused as to why they shouldn't either both pass a parameter, or neither pass one. Here are the those two functions in my code:</p> <pre><code>void Odometer::add_in_trip_miles(){ double milesToAdd; cout &lt;&lt; "How many miles would you like to add to the total?" &lt;&lt; endl; cin &gt;&gt; milesToAdd; milesDriven += milesToAdd; } void Odometer::add_gas(){ double gallonsToAdd; cout &lt;&lt; "How many gallons would you like to add to the total?" &lt;&lt; endl; cin &gt;&gt; gallonsToAdd; gallonsGas += gallonsToAdd; } </code></pre> <p>Currently the first one doesn't meet the project prompt, since it doesn't pass the value in the parameter, it just uses cout/cin in the function itself to get the value to add to the total. I figured i could meet the prompt by just putting the cout/cin in the int main(), and passing that value into the <code>add_in_trip_miles</code> function. </p> <p>I emailed him about the confusion, and got the following response, which left me even more confused:</p> <blockquote> <p>There's a difference between input/output functions, which get information from the keyboard/input-file or output information to the screen/output file, and the set functions. I programmer can use the set functions if they would like to do their own user interaction, or if they are getting the information to be put into the object from somewhere else - perhaps a calculated value.I was hoping that you would implement both, which is what we usually do when we write a class so as to give the application programmer the options.</p> </blockquote> <p>Is he just asking for more functions that are input/output functions only, that then pass those input functions into <code>add_in_trip_miles</code> and <code>add_gas</code>? This email left me even more confused, since he mentioned (in the project prompt, above) each member function that was needed, and none of them are input functions. </p> <p>Any guidance here would be great, my code currently does exactly what he wants it do to, but I don't want to be penalized because I didn't use functions in a certain way, etc. Let me know what you guys think and thanks for any help!</p>
0debug
static void tcp_chr_tls_init(CharDriverState *chr) { TCPCharDriver *s = chr->opaque; QIOChannelTLS *tioc; Error *err = NULL; if (s->is_listen) { tioc = qio_channel_tls_new_server( s->ioc, s->tls_creds, NULL, &err); } else { tioc = qio_channel_tls_new_client( s->ioc, s->tls_creds, s->addr->u.inet->host, &err); } if (tioc == NULL) { error_free(err); tcp_chr_disconnect(chr); } object_unref(OBJECT(s->ioc)); s->ioc = QIO_CHANNEL(tioc); qio_channel_tls_handshake(tioc, tcp_chr_tls_handshake, chr, NULL); }
1threat
How to attach VS Code Debugger to Internet Explorer 11 for JavaScript/HTML : <p>I am trying to add a debug configuration that will allow me debug a normal JavaScript application. There is no server-side code or server, just a .html file with vanilla JavaScript.</p> <p>I would like to be able to use the VS Code debugger, breakpoints, etc. and preview in Internet Explorer 11 by simply pressing F5. </p> <p>I was able to get my launch.json configuration to run Chrome, but it doesn't seem attach to the process the same way that normal Visual Studio does. I would like to know how to do this with iexplore.exe:</p> <pre><code> { "version": "0.2.0", "configurations": [ { "type": "chrome", "request": "launch", "name": "Launch Chrome against localhost", "url": "${file}", "webRoot": "${workspaceRoot}" } ] } </code></pre> <p>I cannot find any documentation for how to set these values. Everything I've found talks about nodejs. I don't use Node. I'm also not interested in downloading extensions because this is basic stuff and should be configurable being these are both Microsoft products. I'm sure someone has solved this already.</p>
0debug
Duplicate zip entry [classes.jar:android/support/design/widget/CoordinatorLayout$Behavior.class] : <p>I have following dependency and getting <code>CoordinatorLayout$Behavior</code> duplicate entry. I have searched so more but did not find any solution. </p> <p>I am getting </p> <pre><code>Caused by: java.io.IOException: Duplicate zip entry [classes.jar:android/support/design/widget/CoordinatorLayout$Behavior.class] at proguard.io.JarWriter.getOutputStream(JarWriter.java:138) at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106) at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:106) at proguard.io.FilteredDataEntryWriter.getOutputStream(FilteredDataEntryWriter.java:92) at proguard.io.ClassRewriter.read(ClassRewriter.java:68) at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87) at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87) at proguard.io.FilteredDataEntryReader.read(FilteredDataEntryReader.java:87) at proguard.io.JarReader.read(JarReader.java:65) at proguard.io.DirectoryPump.readFiles(DirectoryPump.java:65) at proguard.io.DirectoryPump.pumpDataEntries(DirectoryPump.java:53) at proguard.InputReader.readInput(InputReader.java:184) ... 50 more </code></pre> <p>where core UI comes in? I think this makes issues. Can anyone know where i need to exclude one of this lib?</p> <p>I have explore my all lib and having following scene. </p> <p><a href="https://i.stack.imgur.com/8snPs.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8snPs.png" alt="enter image description here"></a></p> <pre><code>dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') // compile('com.mikepenz:materialdrawer:5.8.0@aar') { // transitive = true // } compile 'com.android.support:multidex:1.0.2' compile group: 'com.google.code.gson', name: 'gson', version: '2.8.2' compile 'com.android.support:appcompat-v7:27.0.0' compile 'com.android.support:support-v4:27.0.0' compile 'com.android.support:recyclerview-v7:27.0.0' compile 'com.android.support:design:27.0.0' compile 'com.android.support:cardview-v7:27.0.0' compile 'com.google.android.gms:play-services-gcm:11.8.0' compile 'com.google.android.gms:play-services-location:11.8.0' compile 'com.google.android.gms:play-services-auth:11.8.0' compile 'com.pnikosis:materialish-progress:1.7' compile 'de.hdodenhof:circleimageview:2.2.0' compile 'com.github.rey5137:material:1.2.4' compile 'org.apache.commons:commons-lang3:3.6' compile 'com.afollestad.material-dialogs:core:0.9.5.0' compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' compile 'com.loopj.android:android-async-http:1.4.9' compile 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar' compile 'com.bignerdranch.android:expandablerecyclerview:3.0.0-RC1' compile 'com.github.travijuu:numberpicker:1.0.7' compile 'com.github.carlosmuvi:SegmentedProgressBar:0.6.0' compile 'com.nex3z:notification-badge:0.3.0' compile 'com.bogdwellers:pinchtozoom:0.1' compile 'com.theartofdev.edmodo:android-image-cropper:2.6.0' compile 'com.aurelhubert:ahbottomnavigation:2.1.0' testCompile 'junit:junit:4.12' compile 'com.jakewharton:butterknife:8.8.1' annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' compile files('libs/PGSDK_V2.1.jar') compile 'com.facebook.android:facebook-android-sdk:[4,5)' compile 'com.race604.waveloading:library:1.1.1' compile 'com.karumi:dexter:4.2.0' compile 'com.msg91.sendotp.library:library:3.1' } </code></pre>
0debug
Update Failed! : while install word press Thems : I am trying to install thems in word press. When i clicked install button of them it says update failed! . What should I do? [1]: https://i.stack.imgur.com/jSgMy.png
0debug
Simplest way to get data from AWS mysql RDS to AWS Elasticsearch? : <p>I have data in an AWS RDS, and I would like to pipe it over to an AWS ES instance, preferably updating once an hour, or similar.</p> <p>On my local machine, with a local mysql database and Elasticsearch database, it was easy to set this up using Logstash.</p> <p>Is there a "native" AWS way to do the same thing? Or do I need to set up an EC2 server and install Logstash on it myself?</p>
0debug
I have to search for largest word match in a vocabulary from a given string : I have a string "the big cat in the zoo", and my vocabulary has ["in the zoo, the zoo"] i cant do a direct search , have to search the combinations: 1) zoo 2) the zoo 3) in the zoo how to do this reverse search and match in python
0debug
static void decode_opc_special3(CPUMIPSState *env, DisasContext *ctx) { int rs, rt, rd, sa; uint32_t op1, op2; rs = (ctx->opcode >> 21) & 0x1f; rt = (ctx->opcode >> 16) & 0x1f; rd = (ctx->opcode >> 11) & 0x1f; sa = (ctx->opcode >> 6) & 0x1f; op1 = MASK_SPECIAL3(ctx->opcode); switch (op1) { case OPC_EXT: case OPC_INS: check_insn(ctx, ISA_MIPS32R2); gen_bitops(ctx, op1, rt, rs, sa, rd); break; case OPC_BSHFL: op2 = MASK_BSHFL(ctx->opcode); switch (op2) { case OPC_ALIGN ... OPC_ALIGN_END: case OPC_BITSWAP: check_insn(ctx, ISA_MIPS32R6); decode_opc_special3_r6(env, ctx); break; default: check_insn(ctx, ISA_MIPS32R2); gen_bshfl(ctx, op2, rt, rd); break; } break; #if defined(TARGET_MIPS64) case OPC_DEXTM ... OPC_DEXT: case OPC_DINSM ... OPC_DINS: check_insn(ctx, ISA_MIPS64R2); check_mips_64(ctx); gen_bitops(ctx, op1, rt, rs, sa, rd); break; case OPC_DBSHFL: op2 = MASK_DBSHFL(ctx->opcode); switch (op2) { case OPC_DALIGN ... OPC_DALIGN_END: case OPC_DBITSWAP: check_insn(ctx, ISA_MIPS32R6); decode_opc_special3_r6(env, ctx); break; default: check_insn(ctx, ISA_MIPS64R2); check_mips_64(ctx); op2 = MASK_DBSHFL(ctx->opcode); gen_bshfl(ctx, op2, rt, rd); break; } break; #endif case OPC_RDHWR: gen_rdhwr(ctx, rt, rd); break; case OPC_FORK: check_insn(ctx, ASE_MT); { TCGv t0 = tcg_temp_new(); TCGv t1 = tcg_temp_new(); gen_load_gpr(t0, rt); gen_load_gpr(t1, rs); gen_helper_fork(t0, t1); tcg_temp_free(t0); tcg_temp_free(t1); } break; case OPC_YIELD: check_insn(ctx, ASE_MT); { TCGv t0 = tcg_temp_new(); gen_load_gpr(t0, rs); gen_helper_yield(t0, cpu_env, t0); gen_store_gpr(t0, rd); tcg_temp_free(t0); } break; default: if (ctx->insn_flags & ISA_MIPS32R6) { decode_opc_special3_r6(env, ctx); } else { decode_opc_special3_legacy(env, ctx); } } }
1threat
static void arm_gicv3_icc_reset(CPUARMState *env, const ARMCPRegInfo *ri) { ARMCPU *cpu; GICv3State *s; GICv3CPUState *c; c = (GICv3CPUState *)env->gicv3state; s = c->gic; cpu = ARM_CPU(c->cpu); kvm_device_access(s->dev_fd, KVM_DEV_ARM_VGIC_GRP_CPU_SYSREGS, KVM_VGIC_ATTR(ICC_CTLR_EL1, cpu->mp_affinity), &c->icc_ctlr_el1[GICV3_NS], false); c->icc_ctlr_el1[GICV3_S] = c->icc_ctlr_el1[GICV3_NS]; c->icc_pmr_el1 = 0; c->icc_bpr[GICV3_G0] = GIC_MIN_BPR; c->icc_bpr[GICV3_G1] = GIC_MIN_BPR; c->icc_bpr[GICV3_G1NS] = GIC_MIN_BPR; c->icc_sre_el1 = 0x7; memset(c->icc_apr, 0, sizeof(c->icc_apr)); memset(c->icc_igrpen, 0, sizeof(c->icc_igrpen)); }
1threat
Child element on top of parent element on a small screen : I have 2 divs, one nested inside of the other. According to the page design, the nested div needs to appear normally inside its parent on a large screen, [as in this image.][1] But on a small screen, the nested div needs to appear to be"on top of" the parent div, [as in this image.][2] I don't want to position the child element absolutely, because it's a very poor and inflexible choice, especially for a responsive page. HTML for divs: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <div class="container-div"> <div class="child-div"> ... </div> </div> <!-- end snippet --> [1]: http://i.stack.imgur.com/Z1Vs9.jpg [2]: http://i.stack.imgur.com/mvhcL.jpg
0debug
Django BooleanField as a dropdown : <p>Is there a way to make a Django BooleanField a drop down in a form?</p> <p>Right now it renders as a radio button. Is it possible to have a dropdown with options: 'Yes', 'No' ?</p> <p>Currently my form definition for this field is:</p> <pre><code>attending = forms.BooleanField(required=True) </code></pre>
0debug
alert('Hello ' + user_input);
1threat
static void m5208_sys_write(void *opaque, target_phys_addr_t addr, uint64_t value, unsigned size) { hw_error("m5208_sys_write: Bad offset 0x%x\n", (int)addr); }
1threat
int virtio_blk_handle_scsi_req(VirtIOBlock *blk, VirtQueueElement *elem) { int status = VIRTIO_BLK_S_OK; struct virtio_scsi_inhdr *scsi = NULL; VirtIODevice *vdev = VIRTIO_DEVICE(blk); #ifdef __linux__ int i; struct sg_io_hdr hdr; #endif if (elem->out_num < 2 || elem->in_num < 3) { status = VIRTIO_BLK_S_IOERR; goto fail; } scsi = (void *)elem->in_sg[elem->in_num - 2].iov_base; if (!blk->conf.scsi) { status = VIRTIO_BLK_S_UNSUPP; goto fail; } if (elem->out_num > 2 && elem->in_num > 3) { status = VIRTIO_BLK_S_UNSUPP; goto fail; } #ifdef __linux__ memset(&hdr, 0, sizeof(struct sg_io_hdr)); hdr.interface_id = 'S'; hdr.cmd_len = elem->out_sg[1].iov_len; hdr.cmdp = elem->out_sg[1].iov_base; hdr.dxfer_len = 0; if (elem->out_num > 2) { hdr.dxfer_direction = SG_DXFER_TO_DEV; hdr.iovec_count = elem->out_num - 2; for (i = 0; i < hdr.iovec_count; i++) hdr.dxfer_len += elem->out_sg[i + 2].iov_len; hdr.dxferp = elem->out_sg + 2; } else if (elem->in_num > 3) { hdr.dxfer_direction = SG_DXFER_FROM_DEV; hdr.iovec_count = elem->in_num - 3; for (i = 0; i < hdr.iovec_count; i++) hdr.dxfer_len += elem->in_sg[i].iov_len; hdr.dxferp = elem->in_sg; } else { hdr.dxfer_direction = SG_DXFER_NONE; } hdr.sbp = elem->in_sg[elem->in_num - 3].iov_base; hdr.mx_sb_len = elem->in_sg[elem->in_num - 3].iov_len; status = bdrv_ioctl(blk->bs, SG_IO, &hdr); if (status) { status = VIRTIO_BLK_S_UNSUPP; goto fail; } if (hdr.status == 0 && hdr.sb_len_wr > 0) { hdr.status = CHECK_CONDITION; } virtio_stl_p(vdev, &scsi->errors, hdr.status | (hdr.msg_status << 8) | (hdr.host_status << 16) | (hdr.driver_status << 24)); virtio_stl_p(vdev, &scsi->residual, hdr.resid); virtio_stl_p(vdev, &scsi->sense_len, hdr.sb_len_wr); virtio_stl_p(vdev, &scsi->data_len, hdr.dxfer_len); return status; #else abort(); #endif fail: if (scsi) { virtio_stl_p(vdev, &scsi->errors, 255); } return status; }
1threat
replace empty list with NaN in pandas dataframe : <p>I'm trying to replace some empty list in my data with a NaN values. But how to represent an empty list in the expression?</p> <pre><code>import numpy as np import pandas as pd d = pd.DataFrame({'x' : [[1,2,3], [1,2], ["text"], []], 'y' : [1,2,3,4]}) d x y 0 [1, 2, 3] 1 1 [1, 2] 2 2 [text] 3 3 [] 4 d.loc[d['x'] == [],['x']] = d.loc[d['x'] == [],'x'].apply(lambda x: np.nan) d ValueError: Arrays were different lengths: 4 vs 0 </code></pre> <p>And, I want to select <code>[text]</code> by using <code>d[d['x'] == ["text"]]</code> with a <code>ValueError: Arrays were different lengths: 4 vs 1</code> error, but select <code>3</code> by using <code>d[d['y'] == 3]</code> is correct. Why?</p>
0debug
Android Studio: Where are Manifest Merger Logs? : <p>I am very new to Android Studio, and trying to import a fairly old project from Eclipse into Android Studio. I am getting the dreaded error:</p> <blockquote> <p>Error:Execution failed for task ':app:processDebugManifest'.</p> <blockquote> <p>Manifest merger failed with multiple errors, see logs</p> </blockquote> </blockquote> <p>I have tried a number of the highly rated solutions already with no luck. But my actual question is: <strong>Where are these damned log files?!</strong></p> <p>I can't troubleshoot more deeply <strong>or</strong> ask a more detailed question until I find and inspect the log files, which Android Studio seems to have hidden completely out of view. </p>
0debug
Adding multiple component inside AppComponent in agular : <p>I am wondering is it possible to add multiple components like Component1 , Cmponent2 inside AppComponent like below code but it seems not working am i missing anything ?(ignore this so complaining )ajxbajcbjascjajcabcajbcbajbcajbcjbascbjajbcjacbacjajcacbacbjabcajbcbjabcjajbcabjcjbacbjajbcbajcbjajbcabjcajbcbacbjajbcbjacbjabjcbjacbjajbcajbcbjacbjajbcbjabjcbjacbja</p> <pre><code>import { Component,Directive,ElementRef, APP_BOOTSTRAP_LISTENER } from '@angular/core'; @Component({ selector: 'app-root', template: ` &lt;second-component&gt; test second &lt;/second-component&gt; &lt;third-component&gt; test third &lt;/third-component&gt; `, styles: [` `] }) export class AppComponent { } @Component({ selector: 'second-componet', template: ` &lt;h1&gt; test &lt;/h1&gt; `, styles: [` `] }) export class SecondCompoent{ } @Component({ selector: 'third-componet', template: ` &lt;h1&gt; test &lt;/h1&gt; `, styles: [` `] }) export class ThirdCompoent{ } </code></pre>
0debug
Why does this java casting fail : <p>I have three classes.</p> <p><code>Person &lt;-- Student &lt;-- GradStudent</code>, where <code>&lt;--</code> means extends (ie, GradStudent extends Student, Student extends Person)</p> <p><code>Person person = new Student(); // this is perfectly legal</code></p> <pre><code>GradStudent gradStudent = (GradStudent) person; System.out.println(gradStudent); // java.lang.ClassCastException here </code></pre> <p>Why? Our <strong>person</strong> variable is a Student, and we could do <strong>Student s = new GradStudent()</strong>, and so why is this not working?</p> <p>Similarly if I do</p> <pre><code>Student student = new Student(); GradStudent aGradStudent = (GradStudent) student; System.out.println(aGradStudent); // same error here </code></pre> <p>Why can we do <strong>Student s = new GradStudent()</strong>, but we cannot do <strong>Student student = new Student()</strong>, and THEN <strong>GradStudent aGradeStudent = (GradStudent) student</strong></p>
0debug
def get_maxgold(gold, m, n): goldTable = [[0 for i in range(n)] for j in range(m)] for col in range(n-1, -1, -1): for row in range(m): if (col == n-1): right = 0 else: right = goldTable[row][col+1] if (row == 0 or col == n-1): right_up = 0 else: right_up = goldTable[row-1][col+1] if (row == m-1 or col == n-1): right_down = 0 else: right_down = goldTable[row+1][col+1] goldTable[row][col] = gold[row][col] + max(right, right_up, right_down) res = goldTable[0][0] for i in range(1, m): res = max(res, goldTable[i][0]) return res
0debug
Sourcetree not refreshing view : <p>The view within sourcetree has to be manually updated by hitting F5 as of version 3.3.6.3829. I attempted to raise this as a bug on <a href="https://jira.atlassian.com/" rel="noreferrer">https://jira.atlassian.com/</a>, but the form doesn't give me a correct option for version with 3.2 being the most up to date version available. If someone can point me to the correct place to raise this bug, it would be much appreciated. </p>
0debug
Lombok.hashCode issue with "java.lang.StackOverflowError: null" : <p>I have two tables has one to one relationship as below:</p> <pre><code>@Entity @Data @NoArgsConstructor @AllArgsConstructor public class Book { @Id @GeneratedValue(strategy = GenerationType.TABLE) private int id; private String name; @OneToOne(cascade = CascadeType.ALL) @JoinColumn(name = "book_dtail_id") private BookDetail bookDetail; } @Entity @Table(name = "book_detail") @Data @NoArgsConstructor @AllArgsConstructor public class BookDetail { @Id @GeneratedValue(strategy = GenerationType.TABLE) private Integer id; @Column(name = "number_of_pages") private Integer numberOfPages; @OneToOne(mappedBy = "bookDetail") private Book book; } </code></pre> <p>I used a Form to input data as below</p> <pre><code>@Data @NoArgsConstructor @AllArgsConstructor public class BookForm { Book book; BookDetail bookDetail; } </code></pre> <p>The controller looks like this:</p> <pre><code>String handleNewBook(Model model){ Book book = new Book(); BookDetail bookDetail = new BookDetail(); BookForm bookForm = new BookForm(book, bookDetail); model.addAttribute("bookForm", bookForm); return "index"; } String handleSaveBookCreate(BookForm bookForm, Model model){ bookForm.getBook().setBookDetail(bookForm.getBookDetail()); bookForm.getBookDetail().setBook(bookForm.getBook()); bookService.save(bookForm.getBook())); return "index"; } </code></pre> <p>Last is my form as below:</p> <pre><code>&lt;form role="form" action="#" th:object="${bookForm}" th:action="@{/book}" method="POST"&gt; &lt;input type="text" th:field="*{book.name}"/&gt; &lt;input type="text" th:filed="*{bookDetail} == null ? '' : *{bookDetail.numberOfPages}" placeholder="Enter Book Page Numbers"/&gt; &lt;button type="submit"&gt;Submit&lt;/button&gt; &lt;/form&gt; </code></pre> <p>everything seems no problems, but when I "bookService.save(bookForm.getBook()));" is executed, I got error as below</p> <pre><code>java.lang.StackOverflowError: null, at com.zangland.study.jpa.entity.BookDetail.hashCode(BookDetail.java:17) ~[classes/:na] at com.zangland.study.jpa.entity.Book.hashCode(Book.java:16) ~[classes/:na] at com.zangland.study.jpa.entity.BookDetail.hashCode(BookDetail.java:17) ~[classes/:na] at com.zangland.study.jpa.entity.Book.hashCode(Book.java:16) ~[classes/:na] </code></pre> <p>repeat the same as above about 100 lines.... do this mean that I can't use Lombok.hashCode? </p> <p>Saved Book: '32768','Spring JPA','32768' Saved BookDetail: '32768','1157'</p>
0debug
Fetching all collections in Firestore : <p>I am using Firestore in my project, so i want to show all collection names in my project.</p> <p>Is it posible to get all collection names from Firebase project.</p> <p>Thanks..</p>
0debug
static void mirror_iteration_done(MirrorOp *op, int ret) { MirrorBlockJob *s = op->s; struct iovec *iov; int64_t chunk_num; int i, nb_chunks, sectors_per_chunk; trace_mirror_iteration_done(s, op->sector_num, op->nb_sectors, ret); s->in_flight--; s->sectors_in_flight -= op->nb_sectors; iov = op->qiov.iov; for (i = 0; i < op->qiov.niov; i++) { MirrorBuffer *buf = (MirrorBuffer *) iov[i].iov_base; QSIMPLEQ_INSERT_TAIL(&s->buf_free, buf, next); s->buf_free_count++; } sectors_per_chunk = s->granularity >> BDRV_SECTOR_BITS; chunk_num = op->sector_num / sectors_per_chunk; nb_chunks = DIV_ROUND_UP(op->nb_sectors, sectors_per_chunk); bitmap_clear(s->in_flight_bitmap, chunk_num, nb_chunks); if (ret >= 0) { if (s->cow_bitmap) { bitmap_set(s->cow_bitmap, chunk_num, nb_chunks); } s->common.offset += (uint64_t)op->nb_sectors * BDRV_SECTOR_SIZE; } qemu_iovec_destroy(&op->qiov); g_free(op); if (s->waiting_for_io) { qemu_coroutine_enter(s->common.co, NULL); } }
1threat
Django migrations error KeyError: ('list', u'user') : <p>I am trying to run</p> <pre><code>python manage.py migrate </code></pre> <p>or</p> <pre><code>python manage.py makemigrations </code></pre> <p>I got this error:</p> <pre><code>Running migrations: No migrations to apply. Traceback (most recent call last): File "manage.py", line 10, in &lt;module&gt; execute_from_command_line(sys.argv) File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute output = self.handle(*args, **options) File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 183, in handle executor.loader.project_state(), File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/db/migrations/loader.py", line 338, in project_state return self.graph.make_state(nodes=nodes, at_end=at_end, real_apps=list(self.unmigrated_apps)) File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/db/migrations/graph.py", line 280, in make_state project_state = self.nodes[node].mutate_state(project_state, preserve=False) File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/db/migrations/migration.py", line 88, in mutate_state operation.state_forwards(self.app_label, new_state) File "/Users/rostunov/temp/venv/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 547, in state_forwards model_state = state.models[app_label, self.name_lower] KeyError: ('list', u'user') </code></pre> <p>It happen after I pulled another version of my app from the git.</p> <p>I don't have this error with the same code on the another machine. I've tried to use <code>--fake</code> with <code>zero</code> or to <code>squashmigrations</code> to previous but this also doesn't help.</p> <p>Cannot get how to solve it.</p>
0debug
How to take a build of python project to deploy it as a website for public : i am very much interested to learn python nd do more projects in it. As a starting a did a small django app. it runs an my local machine successfully. I need to know how o take a build of my project to deploy it as a web site forpublic I used python .6.6, django, pycharm did my project in Windows 10
0debug
Passing an array as an argument in a function : <p>I have initialised an array of integers which i later call in a function. I noticed that the values have changed. What can i do to stop that from happening?</p> <pre><code>void check(int arr[5][6]){ printf("%s", arr[0][0]); } int main(){ int arr[5][6]; arr[0][0] = 5; check(arr); } </code></pre>
0debug
void ppc_tb_set_jmp_target(uintptr_t jmp_addr, uintptr_t addr) { tcg_insn_unit i1, i2; uint64_t pair; intptr_t diff = addr - jmp_addr; if (in_range_b(diff)) { i1 = B | (diff & 0x3fffffc); i2 = NOP; } else if (USE_REG_RA) { intptr_t lo, hi; diff = addr - (uintptr_t)tb_ret_addr; lo = (int16_t)diff; hi = (int32_t)(diff - lo); assert(diff == hi + lo); i1 = ADDIS | TAI(TCG_REG_TMP1, TCG_REG_RA, hi >> 16); i2 = ADDI | TAI(TCG_REG_TMP1, TCG_REG_TMP1, lo); } else { assert(TCG_TARGET_REG_BITS == 32 || addr == (int32_t)addr); i1 = ADDIS | TAI(TCG_REG_TMP1, 0, addr >> 16); i2 = ORI | SAI(TCG_REG_TMP1, TCG_REG_TMP1, addr); } #ifdef HOST_WORDS_BIGENDIAN pair = (uint64_t)i1 << 32 | i2; #else pair = (uint64_t)i2 << 32 | i1; #endif *(uint64_t *)jmp_addr = pair; flush_icache_range(jmp_addr, jmp_addr + 8); }
1threat
void visit_type_enum(Visitor *v, const char *name, int *obj, const char *const strings[], Error **errp) { assert(obj && strings); if (v->type == VISITOR_INPUT) { input_type_enum(v, name, obj, strings, errp); } else if (v->type == VISITOR_OUTPUT) { output_type_enum(v, name, obj, strings, errp); } }
1threat
static void xenfv_machine_options(MachineClass *m) { pc_common_machine_options(m); m->desc = "Xen Fully-virtualized PC"; m->max_cpus = HVM_MAX_VCPUS; m->default_machine_opts = "accel=xen"; m->hot_add_cpu = pc_hot_add_cpu; }
1threat
C# // How to close console in a middle of else if statement // beginner : <pre><code> Write("Hello, what is you name? "); customer = ReadLine(); WriteLine($"Nice to meet you, {customer}. What kind of pizza would you like?"); pizza = ReadLine(); if (pizza == "Sausage") { WriteLine("Nice, that will be 20.00"); } else if (pizza != "Sausage") { WriteLine("Make up your mind"); } </code></pre> <p>//////////////////////How do I close in this instance? For answer is not sausage</p>
0debug
How can i connect mongodb with reactjs? : connect mongoDb with react.my need is that i have to store my sass variable in mongoDb and than fetch them in my sass via mongoDb
0debug
static void yop_paint_block(YopDecContext *s, int tag) { s->dstptr[0] = s->srcptr[0]; s->dstptr[1] = s->srcptr[paint_lut[tag][0]]; s->dstptr[s->frame.linesize[0]] = s->srcptr[paint_lut[tag][1]]; s->dstptr[s->frame.linesize[0] + 1] = s->srcptr[paint_lut[tag][2]]; s->srcptr += paint_lut[tag][3]; }
1threat
why javaScript behave like synchronous without web api call : I know javaScript is asynchronous by nature. So that when I call a function with web API It performs asynchronous. setTimeout(function(){ console.log('1'); }, 2000); console.log('2'); it will print '2' then '1' but when I run a loop like for loop and increase the iteration It executes synchrounous var first = function(){ for(var i=0;i<=100000000;i++){ if(i==100000000){ console.log('first') }; }; }; var second = function() { console.log('second') }; var a = function() { first(); second(); } a(); It will print the first second respectively. > So, is javaScript perform synchronously with native code
0debug
static int mov_write_stts_tag(AVIOContext *pb, MOVTrack *track) { MOVStts *stts_entries; uint32_t entries = -1; uint32_t atom_size; int i; if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO && !track->audio_vbr) { stts_entries = av_malloc(sizeof(*stts_entries)); if (!stts_entries) return AVERROR(ENOMEM); stts_entries[0].count = track->sample_count; stts_entries[0].duration = 1; entries = 1; } else { stts_entries = track->entry ? av_malloc_array(track->entry, sizeof(*stts_entries)) : NULL; if (!stts_entries) return AVERROR(ENOMEM); for (i = 0; i < track->entry; i++) { int duration = get_cluster_duration(track, i); if (i && duration == stts_entries[entries].duration) { stts_entries[entries].count++; } else { entries++; stts_entries[entries].duration = duration; stts_entries[entries].count = 1; } } entries++; } atom_size = 16 + (entries * 8); avio_wb32(pb, atom_size); ffio_wfourcc(pb, "stts"); avio_wb32(pb, 0); avio_wb32(pb, entries); for (i = 0; i < entries; i++) { avio_wb32(pb, stts_entries[i].count); avio_wb32(pb, stts_entries[i].duration); } av_free(stts_entries); return atom_size; }
1threat
uint64_t helper_subqv (uint64_t op1, uint64_t op2) { uint64_t res; res = op1 - op2; if (unlikely((op1 ^ op2) & (res ^ op1) & (1ULL << 63))) { arith_excp(env, GETPC(), EXC_M_IOV, 0); } return res; }
1threat
Using SparkContext in Executors : How can I use SparkContext (to create Spark Session or Cassandra Sessions) in executors? If I pass it as parameter to the foreach or foreachpartition, then it will have a null value. Shall I create a new SparkContext in each executor?
0debug
random string generator in laravel : <p>I have 1 file: testController.php</p> <pre><code>use Illuminate\Support\Str; $Quantity = 5; $Promo_code = Str::random($length = 10); for($i = 0; $i &lt; $Quantity; $i++){ \Debugbar::info($Promo_code); } </code></pre> <p>result:</p> <pre><code>a366PPbdB6 a366PPbdB6 a366PPbdB6 a366PPbdB6 a366PPbdB6 a366PPbdB6 </code></pre> <p>I want the result to be random code For example:</p> <pre><code>rxXELTrs9z BOja7WVDHl 6NWL91Den1 GxAdiVHuIV Lyaf9GPwn9 </code></pre> <p>thanks you for help me!</p>
0debug
How to set URL direct donwloadable. : I have a short video sharing website. User can download video from there. Im facing some problem now. I want user download video directly but when use visit my link browser auto playing the video. I only want when user click on link Video download will start auto. **Now im sharing video link like this Example: www.example.com/examle.mp4** Please give me suggestion
0debug
Identity resolution with RegEx : <p>I have a list of authors of papers that benefits from identity resolution! As an example, it should match these names:</p> <pre><code>Peter J. Smith Peter Smith P.J. Smith P. J. Smith (works with space or without it) p.j. smith </code></pre> <p>I'm new to RegEx. I'd like to write a RegEx in R/Python that match the initial of the first name and the whole last name and ignore the middle name. (Although, this method will have some issues, for example there are occurrences of names such as Peter L. Smith but I think considering the middle name will complicate things.) Thanks for your help. </p>
0debug
static CharDriverState *qemu_chr_open_tty_fd(int fd) { CharDriverState *chr; tty_serial_init(fd, 115200, 'N', 8, 1); chr = qemu_chr_open_fd(fd, fd); chr->chr_ioctl = tty_serial_ioctl; chr->chr_close = qemu_chr_close_tty; return chr; }
1threat
Concatenating and splitting json files in a 1 level deep folder structure : <p>I'm working on a translation project the content of which is in a one level deep folder structure in JSON files. Essentialy it looks like this</p> <pre><code>\folder1 file1.json file2.json ... \folder2 file3.json file4.json ... </code></pre> <p>I need some automated way to:</p> <ul> <li>Merge these into a single file, preferebly one that contains the original file name and folder as the first line of each file's content e.g.:</li> </ul> <pre><code> \folder1\file1.json &lt;file1 content&gt; \folder1\file2.json &lt;file2 content&gt; \folder2\file3.json &lt;file3 content&gt; \folder2\file4.json &lt;file4 content&gt; </code></pre> <ul> <li>Split the merged file and re-create the original folder structure. </li> </ul> <p>I'm using Windows10.</p>
0debug
Here i have the code which works on click. I need this to work onBlur mode iin javascript. Please give your opinions... Here is my code : if(!m.isSystemButtonClicked) { console.debug("Inside onHide. m.isSystemButtonClicked=",m.isSystemButtonClicked); if(m.unloadListener) { window.onbeforeunload = m.unloadListener; } }
0debug
static int qemu_rdma_registration_handle(QEMUFile *f, void *opaque, uint64_t flags) { RDMAControlHeader reg_resp = { .len = sizeof(RDMARegisterResult), .type = RDMA_CONTROL_REGISTER_RESULT, .repeat = 0, }; RDMAControlHeader unreg_resp = { .len = 0, .type = RDMA_CONTROL_UNREGISTER_FINISHED, .repeat = 0, }; RDMAControlHeader blocks = { .type = RDMA_CONTROL_RAM_BLOCKS_RESULT, .repeat = 1 }; QEMUFileRDMA *rfile = opaque; RDMAContext *rdma = rfile->rdma; RDMALocalBlocks *local = &rdma->local_ram_blocks; RDMAControlHeader head; RDMARegister *reg, *registers; RDMACompress *comp; RDMARegisterResult *reg_result; static RDMARegisterResult results[RDMA_CONTROL_MAX_COMMANDS_PER_MESSAGE]; RDMALocalBlock *block; void *host_addr; int ret = 0; int idx = 0; int count = 0; int i = 0; CHECK_ERROR_STATE(); do { DDDPRINTF("Waiting for next request %" PRIu64 "...\n", flags); ret = qemu_rdma_exchange_recv(rdma, &head, RDMA_CONTROL_NONE); if (ret < 0) { break; } if (head.repeat > RDMA_CONTROL_MAX_COMMANDS_PER_MESSAGE) { fprintf(stderr, "rdma: Too many requests in this message (%d)." "Bailing.\n", head.repeat); ret = -EIO; break; } switch (head.type) { case RDMA_CONTROL_COMPRESS: comp = (RDMACompress *) rdma->wr_data[idx].control_curr; network_to_compress(comp); DDPRINTF("Zapping zero chunk: %" PRId64 " bytes, index %d, offset %" PRId64 "\n", comp->length, comp->block_idx, comp->offset); block = &(rdma->local_ram_blocks.block[comp->block_idx]); host_addr = block->local_host_addr + (comp->offset - block->offset); ram_handle_compressed(host_addr, comp->value, comp->length); break; case RDMA_CONTROL_REGISTER_FINISHED: DDDPRINTF("Current registrations complete.\n"); goto out; case RDMA_CONTROL_RAM_BLOCKS_REQUEST: DPRINTF("Initial setup info requested.\n"); if (rdma->pin_all) { ret = qemu_rdma_reg_whole_ram_blocks(rdma); if (ret) { fprintf(stderr, "rdma migration: error dest " "registering ram blocks!\n"); goto out; } } for (i = 0; i < local->nb_blocks; i++) { rdma->block[i].remote_host_addr = (uint64_t)(local->block[i].local_host_addr); if (rdma->pin_all) { rdma->block[i].remote_rkey = local->block[i].mr->rkey; } rdma->block[i].offset = local->block[i].offset; rdma->block[i].length = local->block[i].length; remote_block_to_network(&rdma->block[i]); } blocks.len = rdma->local_ram_blocks.nb_blocks * sizeof(RDMARemoteBlock); ret = qemu_rdma_post_send_control(rdma, (uint8_t *) rdma->block, &blocks); if (ret < 0) { fprintf(stderr, "rdma migration: error sending remote info!\n"); goto out; } break; case RDMA_CONTROL_REGISTER_REQUEST: DDPRINTF("There are %d registration requests\n", head.repeat); reg_resp.repeat = head.repeat; registers = (RDMARegister *) rdma->wr_data[idx].control_curr; for (count = 0; count < head.repeat; count++) { uint64_t chunk; uint8_t *chunk_start, *chunk_end; reg = &registers[count]; network_to_register(reg); reg_result = &results[count]; DDPRINTF("Registration request (%d): index %d, current_addr %" PRIu64 " chunks: %" PRIu64 "\n", count, reg->current_index, reg->key.current_addr, reg->chunks); block = &(rdma->local_ram_blocks.block[reg->current_index]); if (block->is_ram_block) { host_addr = (block->local_host_addr + (reg->key.current_addr - block->offset)); chunk = ram_chunk_index(block->local_host_addr, (uint8_t *) host_addr); } else { chunk = reg->key.chunk; host_addr = block->local_host_addr + (reg->key.chunk * (1UL << RDMA_REG_CHUNK_SHIFT)); } chunk_start = ram_chunk_start(block, chunk); chunk_end = ram_chunk_end(block, chunk + reg->chunks); if (qemu_rdma_register_and_get_keys(rdma, block, (uint8_t *)host_addr, NULL, &reg_result->rkey, chunk, chunk_start, chunk_end)) { fprintf(stderr, "cannot get rkey!\n"); ret = -EINVAL; goto out; } reg_result->host_addr = (uint64_t) block->local_host_addr; DDPRINTF("Registered rkey for this request: %x\n", reg_result->rkey); result_to_network(reg_result); } ret = qemu_rdma_post_send_control(rdma, (uint8_t *) results, &reg_resp); if (ret < 0) { fprintf(stderr, "Failed to send control buffer!\n"); goto out; } break; case RDMA_CONTROL_UNREGISTER_REQUEST: DDPRINTF("There are %d unregistration requests\n", head.repeat); unreg_resp.repeat = head.repeat; registers = (RDMARegister *) rdma->wr_data[idx].control_curr; for (count = 0; count < head.repeat; count++) { reg = &registers[count]; network_to_register(reg); DDPRINTF("Unregistration request (%d): " " index %d, chunk %" PRIu64 "\n", count, reg->current_index, reg->key.chunk); block = &(rdma->local_ram_blocks.block[reg->current_index]); ret = ibv_dereg_mr(block->pmr[reg->key.chunk]); block->pmr[reg->key.chunk] = NULL; if (ret != 0) { perror("rdma unregistration chunk failed"); ret = -ret; goto out; } rdma->total_registrations--; DDPRINTF("Unregistered chunk %" PRIu64 " successfully.\n", reg->key.chunk); } ret = qemu_rdma_post_send_control(rdma, NULL, &unreg_resp); if (ret < 0) { fprintf(stderr, "Failed to send control buffer!\n"); goto out; } break; case RDMA_CONTROL_REGISTER_RESULT: fprintf(stderr, "Invalid RESULT message at dest.\n"); ret = -EIO; goto out; default: fprintf(stderr, "Unknown control message %s\n", control_desc[head.type]); ret = -EIO; goto out; } } while (1); out: if (ret < 0) { rdma->error_state = ret; } return ret; }
1threat
static void hid_keyboard_event(DeviceState *dev, QemuConsole *src, InputEvent *evt) { HIDState *hs = (HIDState *)dev; int scancodes[3], i, count; int slot; count = qemu_input_key_value_to_scancode(evt->key->key, evt->key->down, scancodes); if (hs->n + count > QUEUE_LENGTH) { fprintf(stderr, "usb-kbd: warning: key event queue full\n"); return; } for (i = 0; i < count; i++) { slot = (hs->head + hs->n) & QUEUE_MASK; hs->n++; hs->kbd.keycodes[slot] = scancodes[i]; } hs->event(hs); }
1threat
static int decode_phys_chunk(AVCodecContext *avctx, PNGDecContext *s) { if (s->state & PNG_IDAT) { av_log(avctx, AV_LOG_ERROR, "pHYs after IDAT\n"); return AVERROR_INVALIDDATA; } avctx->sample_aspect_ratio.num = bytestream2_get_be32(&s->gb); avctx->sample_aspect_ratio.den = bytestream2_get_be32(&s->gb); if (avctx->sample_aspect_ratio.num < 0 || avctx->sample_aspect_ratio.den < 0) avctx->sample_aspect_ratio = (AVRational){ 0, 1 }; bytestream2_skip(&s->gb, 1); bytestream2_skip(&s->gb, 4); return 0; }
1threat
static void build_chunks(MOVTrack *trk) { int i; MOVIentry *chunk= &trk->cluster[0]; uint64_t chunkSize = chunk->size; chunk->chunkNum= 1; trk->chunkCount= 1; for(i=1; i<trk->entry; i++){ if(chunk->pos + chunkSize == trk->cluster[i].pos){ chunkSize += trk->cluster[i].size; chunk->samplesInChunk += trk->cluster[i].entries; }else{ trk->cluster[i].chunkNum = chunk->chunkNum+1; chunk=&trk->cluster[i]; chunkSize = chunk->size; trk->chunkCount++; } } }
1threat
Pandas: Knowing when an operation affects the original dataframe : <p>I love pandas and have been using it for years and feel pretty confident I have a good handle on how to subset dataframes and deal with views vs copies appropriately (though I use a lot of assertions to be sure). I also know that there have been tons of questions about SettingWithCopyWarning, e.g. <a href="https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas">How to deal with SettingWithCopyWarning in Pandas?</a> and some great recent guides on wrapping your head around when it happens, e.g. <a href="https://www.dataquest.io/blog/settingwithcopywarning/" rel="noreferrer">Understanding SettingWithCopyWarning in pandas</a>. </p> <p>But I also know specific things like the quote from <a href="https://stackoverflow.com/a/17961468/8022335">this answer</a> are no longer in the most recent docs (<code>0.22.0</code>) and that many things have been deprecated over the years (leading to some inappropriate old SO answers), and that things are <a href="https://stackoverflow.com/a/34908742/8022335">continuing to change</a>. </p> <p>Recently after teaching pandas to complete newcomers with very basic general Python knowledge about things like avoiding chained-indexing (and using <code>.iloc</code>/<code>.loc</code>), I've still struggled to provide <em>general rules of thumb</em> to know when it's important to pay attention to the <code>SettingWithCopyWarning</code> (e.g. when it's safe to ignore it). </p> <p>I've personally found that the specific pattern of subsetting a dataframe according so some rule (e.g. slicing or boolean operation) and then modifying that subset, <em>independent of the original dataframe</em>, is a much more common operation than the docs suggest. In this situation we want to <em>modify the copy not the original</em> and the warning is confusing/scary to newcomers.</p> <p>I know it's not trivial to know ahead of time when a view vs a copy is returned, e.g.<br> <a href="https://stackoverflow.com/questions/23296282/what-rules-does-pandas-use-to-generate-a-view-vs-a-copy">What rules does Pandas use to generate a view vs a copy?</a><br> <a href="https://stackoverflow.com/questions/26879073/checking-whether-data-frame-is-copy-or-view-in-pandas">Checking whether data frame is copy or view in Pandas</a></p> <p>So instead I'm looking for the answer to a more general (beginner friendly) question: <strong>when does performing an operation on a subsetted dataframe affect the original dataframe from which it was created, and when are they independent?</strong>. </p> <p>I've created some cases below that I think seem reasonable, but I'm not sure if there's a "gotcha" I'm missing or if there's any easier way to think/check this. I was hoping someone could confirm that my intuitions about the following use cases are correct as the pertain to my question above.</p> <pre><code>import pandas as pd df1 = pd.DataFrame({'A':[2,4,6,8,10],'B':[1,3,5,7,9],'C':[10,20,30,40,50]}) </code></pre> <p>1) Warning: No<br> Original changed: No </p> <pre><code># df1 will be unaffected because we use .copy() method explicitly df2 = df1.copy() # # Reference: docs df2.iloc[0,1] = 100 </code></pre> <p>2) Warning: Yes (I don't really understood why)<br> Original changed: No </p> <pre><code># df1 will be unaffected because .query() always returns a copy # # Reference: # https://stackoverflow.com/a/23296545/8022335 df2 = df1.query('A &lt; 10') df2.iloc[0,1] = 100 </code></pre> <p>3) Warning: Yes<br> Original changed: No</p> <pre><code># df1 will be unaffected because boolean indexing with .loc # always returns a copy # # Reference: # https://stackoverflow.com/a/17961468/8022335 df2 = df1.loc[df1['A'] &lt; 10,:] df2.iloc[0,1] = 100 </code></pre> <p>4) Warning: No<br> Original changed: No</p> <pre><code># df1 will be unaffected because list indexing with .loc (or .iloc) # always returns a copy # # Reference: # Same as 4) df2 = df1.loc[[0,3,4],:] df2.iloc[0,1] = 100 </code></pre> <p>5) Warning: No<br> Original changed: Yes (confusing to newcomers but makes sense) </p> <pre><code># df1 will be affected because scalar/slice indexing with .iloc/.loc # always references the original dataframe, but may sometimes # provide a view and sometimes provide a copy # # Reference: docs df2 = df1.loc[:10,:] df2.iloc[0,1] = 100 </code></pre> <p><strong>tl;dr</strong> When creating a new dataframe from the original, changing the new dataframe:<br> Will change the original when <strong>scalar/slice indexing with .loc/.iloc is used to create the new dataframe</strong>.<br> Will <em>not</em> change the original when <strong>boolean indexing with .loc, <code>.query()</code>, or <code>.copy()</code> is used to create the new dataframe</strong></p>
0debug
NodeJS How to pad the end of numbers with . and zeros? : <p>Let's say we have the number 300 and I wanted it to be padded to end as 300.000</p> <p>Or the number 23,5 would be something like 23.500</p>
0debug
Access SQL Issue : <p>I am curious if there are any experts in Access' version of SQL that could help me decode the below? I am not great in Access and try use SSMS but I am taking over an already built report. </p> <p>Thanks! </p> <pre><code>LT CRD: IIf(Day(Date()+[IAM_MAN_LEAD_TIME]) Between 1 And 15,DateSerial(Year(Date()+[IAM_MAN_LEAD_TIME]),Month(Date()+[IAM_MAN_LEAD_TIME]),15),DateSerial(Year(Date()+[IAM_MAN_LEAD_TIME]),Month(Date()+[IAM_MAN_LEAD_TIME])+1,0)) </code></pre>
0debug
how to find the address of a function in a c++ program : <p>i need to find the address of func in the stack so that if i provided a 32 long "A" string and then the function address in the stack i would get the Access granted </p> <p>i remember i did it using <code>objdump</code> but i can't seem to figure it out </p> <pre><code>#include &lt;iostream&gt; using namespace std; void func() { cout &lt;&lt; "Access Granted \n"; } int main() { char buff[20]; cin &gt;&gt; buff; cout &lt;&lt; buff; return 0; } </code></pre> <p>i tried immunity debugger but i was not successful </p>
0debug
Facing some errors in c++ : <p>I am writing a program in c++11 and I have faced some problems. I am new to c++11 programming, while I used to develop in c earlier, but I want to be familiar with the new facilities of c++. </p> <p>I will present you below the contentious part of code explaining where are the errors and what kind of them I get.</p> <pre><code>#include &lt;iostream&gt; #include &lt;ctime&gt; #include &lt;cstdio&gt; #include &lt;cstring&gt; #include &lt;cstdlib&gt; #include &lt;vector&gt; #include &lt;map&gt; #include &lt;algorithm&gt; using namespace std; // A struct describing a product. typedef struct Products { string category; string name; float price; } Product; inline void scenario1(int num_cashiers) { extern vector&lt;Product&gt; products; // It is a vector(a pseudo-second dimension) of products which will be used for each customer extern vector&lt;vector&lt;Product&gt; products&gt; customers; // A vector containing all customers vector&lt;vector&lt;vector&lt;Product&gt; products&gt; customers&gt; cashiers(num_cashiers); // A vector describing the supermarket cashiers declaring a queue of customers for each cashier ... } </code></pre> <p>Error 1: At the second line of the function scenario1(int num_cashiers): template argument 1 is invalid</p> <p>Error 2: At the second line of the function scenario1(int num_cashiers): template argument 2 is invalid</p> <p>Error 3: At the second line of the function scenario1(int num_cashiers): invalid type in declaration before ';' token</p> <p>Error 4: At the third line of the function scenario1(int num_cashiers): template argument 1 is invalid</p> <p>Error 5: At the third line of the function scenario1(int num_cashiers): template argument 2 is invalid</p> <p>Error 6: At the third line of the function scenario1(int num_cashiers): template argument 1 is invalid //Same error again</p> <p>Error 7: At the third line of the function scenario1(int num_cashiers): template argument 2 is invalid //Same error again</p> <p>Error 8: At the third line of the function scenario1(int num_cashiers): invalid type in declaration before '(' token</p> <p>So, where am I wrong and what do I have to do to fix the errors?</p> <p>I would appreciate any help!</p>
0debug
Python 'print' function 'sep' parameter is not working as expected : <p>I am using Python version 3.7.4 on Windows 10 Enterprise.</p> <p>I am facing a weird issue with Python's <code>print</code> function and especially <code>sep</code> parameter. </p> <p>In Python REPL, when I use code <code>print(1, 2, 3, 4, 5, sep='\t')</code>, I get proper output as <code>1 2 3 4 5</code></p> <p>However when code tries to iterate over a collection as shown below, instead of showing number separated by a tab, it always displays individual value on a new line.</p> <pre><code>numbers = {1, 2, 3, 4, 5} for n in numbers: print(n, sep='\t') </code></pre> <p>Can someone please help me to understand why its displaying number value on a separate line? </p> <p>I have attached screenshot for the reference.</p> <p><a href="https://i.stack.imgur.com/2R1C5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2R1C5.png" alt="Python print function sep parameter"></a></p> <p>Thanks.</p>
0debug
How can Cassandra be considered a good database for storing unstructured data? : <p>In many online articles, I see Cassandra being talked as a a wide-column store for unstructured data. I don’t see how that is as schema has to be defined for a table in Cassandra.</p> <p>Is my understanding correct? If not, could you elaborate on how Cassandra can store unstructured data efficiently like in wide column databases? </p>
0debug
How can I change python version in Visual Studio Code? : <p>There is a problem I can't solve. I already set up :</p> <p>1.user setting</p> <pre><code>{ "atomKeymap.promptV3Features": true, "editor.multiCursorModifier": "ctrlCmd", "editor.formatOnPaste": true, "python.pythonPath": "python3", "command": "python3", </code></pre> <p>}</p> <p>2.Workspace Settings</p> <pre><code>{ "python.pythonPath": "${workspaceFolder}/env/bin/python3.6", "git.ignoreLimitWarning": true </code></pre> <p>}</p> <p>3.tasks.jason file</p> <pre><code>{ // See https://go.microsoft.com/fwlink/?LinkId=733558 // for the documentation about the tasks.json format "version": "0.1.0", "command": "python3", "isShellCommand": true, "args": ["${file}"], "showOutput": "always" </code></pre> <p>}</p> <p>If I use debug console and the version and path is right, <a href="https://i.stack.imgur.com/SEu0t.png" rel="noreferrer">debug</a></p> <p>But my output always default "python2.7" no matter what I do. How can I improve it? <a href="https://i.stack.imgur.com/cWadS.jpg" rel="noreferrer">output</a></p>
0debug
What is the difference between Expo CLI and React Native CLI? : <blockquote> <p>React Native provides two way to create Project.</p> </blockquote> <p><strong>First:</strong> </p> <pre><code>npm install -g expo-cli </code></pre> <p><strong>Second:</strong></p> <pre><code>npm install -g react-native-cli </code></pre> <p>so what is different between them and what should be used if we create react native app?</p>
0debug
cocoapods configuration AFnetworking ios : [I am about to install cocoapods and AFNetworking I have got this error I always try everything of my PODFILE ( workspace ' path / to / AFService.xcworkspace ' source ' https://github.com/CocoaPods/Specs.git ' platform: ios, ' 8.0 ' target ' AFService ' do pod ' AFNetworking ' ' ~ > 3.0' end)][1] [1]: http://i.stack.imgur.com/s6P6f.png
0debug
static int crystalhd_receive_frame(AVCodecContext *avctx, AVFrame *frame) { BC_STATUS bc_ret; BC_DTS_STATUS decoder_status = { 0, }; CopyRet rec_ret; CHDContext *priv = avctx->priv_data; HANDLE dev = priv->dev; int got_frame = 0; av_log(avctx, AV_LOG_VERBOSE, "CrystalHD: receive_frame\n"); bc_ret = DtsGetDriverStatus(dev, &decoder_status); if (bc_ret != BC_STS_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "CrystalHD: GetDriverStatus failed\n"); return -1; } if (decoder_status.ReadyListCount == 0) { av_log(avctx, AV_LOG_INFO, "CrystalHD: Insufficient frames ready. Returning\n"); return AVERROR(EAGAIN); } rec_ret = receive_frame(avctx, frame, &got_frame); if (rec_ret == RET_ERROR) { return -1; } else if (got_frame == 0) { return AVERROR(EAGAIN); } else { return 0; } }
1threat
Convert character column to date column in lubridate : <p>I have a dataframe looking like: </p> <pre><code># A tibble: 10 x 4 id incoming_date expiry_date end_date &lt;dbl&gt; &lt;chr&gt; &lt;chr&gt; &lt;chr&gt; 1 1 11.17.18 10.1.19 03.1.19 2 11 03.4.19 NA 03.20.19 3 2 03.17.19 02.1.20 05.7.19 4 2 05.7.19 NA 06.15.19 5 4 06.11.19 05.1.21 06.22.19 6 1 06.12.19 04.1.21 NA 7 2 06.12.19 04.1.21 NA 8 13 11.16.18 06.1.19 02.20.19 9 7 02.19.19 12.1.21 3.23.19 10 1 03.19.19 01.1.21 09.10.19 </code></pre> <p>reproducible:</p> <pre><code>library(tidyverse) library(lubridate) df &lt;- as.tibble(structure(list(id = c(1, 11, 2, 2, 4, 1, 2, 13, 7, 1), incoming_date = c("11.17.18", "03.4.19", "03.17.19", "05.7.19", "06.11.19", "06.12.19", "06.12.19", "11.16.18", "02.19.19", "03.19.19"), expiry_date = c("10.1.19", NA, "02.1.20", NA, "05.1.21", "04.1.21", "04.1.21", "06.1.19", "12.1.21", "01.1.21"), end_date = c("03.1.19", "03.20.19", "05.7.19", "06.15.19", "06.22.19", NA, NA, "02.20.19", "3.23.19", "09.10.19" )), row.names = c(NA, -10L), class = c("tbl_df", "tbl", "data.frame" ))) </code></pre> <p>I want to convert the columns from character to date format, as follows: </p> <pre><code> id incoming_date expiry_date end_date &lt;dbl&gt; &lt;date&gt; &lt;date&gt; &lt;date&gt; 1 1 2018-11-17 2019-10-01 2019-03-01 2 11 2019-03-04 NA 2019-03-20 3 2 2019-03-17 2020-02-01 2019-05-07 4 2 2019-05-07 NA 2019-06-15 5 4 2019-06-11 2021-05-01 2019-06-22 6 1 2019-06-12 2021-04-01 NA 7 2 2019-06-12 2021-04-01 NA 8 13 2018-11-16 2019-06-01 2019-02-20 9 7 2019-02-19 2021-12-01 2019-03-23 10 1 2019-03-19 2021-01-01 2019-09-10 </code></pre> <p>What I tried to do - starting from the <code>incoming_date</code> column - is: </p> <pre><code>df %&gt;% mutate(incoming_date_parsed = strptime(as.POSIXct(incoming_date), "%m.%d.%Y")) </code></pre> <p>throwing the error:</p> <pre><code>Error in as.POSIXlt.character(x, tz, ...) : character string is not in a standard unambiguous format </code></pre> <p>In logical order, what I would do is: </p> <ol> <li>Convert the column from character to datetime </li> <li>Parse the date following in the format YYYY-MM-dd</li> </ol>
0debug
How To Share Code W/ Other Devs? (And naming) : <p>tl;dr I have code I think others would find useful but don't know how to package it up for others to include in their projects and easily modify.</p> <p>I'm new to C++ and created an algorithm to solve paths efficiently (enough) for a bot. The algorithm creates the longest path possible within a set of points ("Nodes") with the two limitations being that the Nodes are single-visit only and that the next Node hopped to must be within X distance of the current Node.</p> <p>After having "finished" the bot (learning exercise) I decided that it would make sense to remove the pathfinding algorithm from the bot and package it up as a more generic and understandable snippet to host on GitHub for others to use.</p> <p>I'm having an oddly difficult time finding information on how to best construct my "library" - probably because it's really obvious if I were more familiar with C++. I don't want it to be like OpenCV where it's a DLL and my only other example is a .hpp JSON library + the information in the Google Style Guide.</p> <p>I'm not certain as to whether distributing my code as a Header (with overview + usage documentation) and CPP (with more specific comments) file will result in what I want - which is the JSON .hpp workflow - I simply had to download the file, #include JSON.hpp, and then I was able to call its methods. </p> <hr> <p>&lt;-&lt; PS. How does one name such an algorithm? I'm using a namespace as per the Google recommendations but at the moment that would result in a REALLY long name for devs that aren't #using my namespace. </p> <p>Google's Styleguide is for a large project - not a single distributed file - so perhaps I should name the GitHub / "official name" something descriptive but give the namespace / project "SVNL" ?</p> <p>Single Visit Node Linker</p> <p>Single Visit Node Pathing for Maximum Nodes Traveled Within Distance Between Individual Nodes</p> <p>Visit Maximizing Node Linker Within Distance Between Individual Nodes</p>
0debug
Take next several items from arraylist : <p>I wish to take first 10 items from array list, then after some action take 10 more (for inserting it in android view list). Is it possible in kotlin/java?</p>
0debug
static void ich9_smb_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); k->vendor_id = PCI_VENDOR_ID_INTEL; k->device_id = PCI_DEVICE_ID_INTEL_ICH9_6; k->revision = ICH9_A2_SMB_REVISION; k->class_id = PCI_CLASS_SERIAL_SMBUS; dc->no_user = 1; dc->vmsd = &vmstate_ich9_smbus; dc->desc = "ICH9 SMBUS Bridge"; k->init = ich9_smbus_initfn; k->config_write = ich9_smbus_write_config; }
1threat
int cpu_ppc_handle_mmu_fault (CPUState *env, target_ulong address, int rw, int mmu_idx, int is_softmmu) { mmu_ctx_t ctx; int access_type; int ret = 0; if (rw == 2) { rw = 0; access_type = ACCESS_CODE; } else { access_type = ACCESS_INT; } ret = get_physical_address(env, &ctx, address, rw, access_type, 1); if (ret == 0) { ret = tlb_set_page_exec(env, address & TARGET_PAGE_MASK, ctx.raddr & TARGET_PAGE_MASK, ctx.prot, mmu_idx, is_softmmu); } else if (ret < 0) { #if defined (DEBUG_MMU) if (loglevel != 0) cpu_dump_state(env, logfile, fprintf, 0); #endif if (access_type == ACCESS_CODE) { switch (ret) { case -1: switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: env->exception_index = POWERPC_EXCP_IFTLB; env->error_code = 1 << 18; env->spr[SPR_IMISS] = address; env->spr[SPR_ICMP] = 0x80000000 | ctx.ptem; goto tlb_miss; case POWERPC_MMU_SOFT_74xx: env->exception_index = POWERPC_EXCP_IFTLB; goto tlb_miss_74xx; case POWERPC_MMU_SOFT_4xx: case POWERPC_MMU_SOFT_4xx_Z: env->exception_index = POWERPC_EXCP_ITLB; env->error_code = 0; env->spr[SPR_40x_DEAR] = address; env->spr[SPR_40x_ESR] = 0x00000000; break; case POWERPC_MMU_32B: #if defined(TARGET_PPC64) case POWERPC_MMU_64B: #endif env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x40000000; break; case POWERPC_MMU_BOOKE: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE_FSL: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_REAL_4xx: cpu_abort(env, "PowerPC 401 should never raise any MMU " "exceptions\n"); return -1; default: cpu_abort(env, "Unknown or invalid MMU model\n"); return -1; } break; case -2: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x08000000; break; case -3: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x10000000; break; case -4: env->exception_index = POWERPC_EXCP_ISI; env->error_code = 0x10000000; break; #if defined(TARGET_PPC64) case -5: env->exception_index = POWERPC_EXCP_ISEG; env->error_code = 0; break; #endif } } else { switch (ret) { case -1: switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: if (rw == 1) { env->exception_index = POWERPC_EXCP_DSTLB; env->error_code = 1 << 16; } else { env->exception_index = POWERPC_EXCP_DLTLB; env->error_code = 0; } env->spr[SPR_DMISS] = address; env->spr[SPR_DCMP] = 0x80000000 | ctx.ptem; tlb_miss: env->error_code |= ctx.key << 19; env->spr[SPR_HASH1] = ctx.pg_addr[0]; env->spr[SPR_HASH2] = ctx.pg_addr[1]; break; case POWERPC_MMU_SOFT_74xx: if (rw == 1) { env->exception_index = POWERPC_EXCP_DSTLB; } else { env->exception_index = POWERPC_EXCP_DLTLB; } tlb_miss_74xx: env->error_code = ctx.key << 19; env->spr[SPR_TLBMISS] = (address & ~((target_ulong)0x3)) | ((env->last_way + 1) & (env->nb_ways - 1)); env->spr[SPR_PTEHI] = 0x80000000 | ctx.ptem; break; case POWERPC_MMU_SOFT_4xx: case POWERPC_MMU_SOFT_4xx_Z: env->exception_index = POWERPC_EXCP_DTLB; env->error_code = 0; env->spr[SPR_40x_DEAR] = address; if (rw) env->spr[SPR_40x_ESR] = 0x00800000; else env->spr[SPR_40x_ESR] = 0x00000000; break; case POWERPC_MMU_32B: #if defined(TARGET_PPC64) case POWERPC_MMU_64B: #endif env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x42000000; else env->spr[SPR_DSISR] = 0x40000000; break; case POWERPC_MMU_BOOKE: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_BOOKE_FSL: cpu_abort(env, "MMU model not implemented\n"); return -1; case POWERPC_MMU_REAL_4xx: cpu_abort(env, "PowerPC 401 should never raise any MMU " "exceptions\n"); return -1; default: cpu_abort(env, "Unknown or invalid MMU model\n"); return -1; } break; case -2: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x0A000000; else env->spr[SPR_DSISR] = 0x08000000; break; case -4: switch (access_type) { case ACCESS_FLOAT: env->exception_index = POWERPC_EXCP_ALIGN; env->error_code = POWERPC_EXCP_ALIGN_FP; env->spr[SPR_DAR] = address; break; case ACCESS_RES: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x06000000; else env->spr[SPR_DSISR] = 0x04000000; break; case ACCESS_EXT: env->exception_index = POWERPC_EXCP_DSI; env->error_code = 0; env->spr[SPR_DAR] = address; if (rw == 1) env->spr[SPR_DSISR] = 0x06100000; else env->spr[SPR_DSISR] = 0x04100000; break; default: printf("DSI: invalid exception (%d)\n", ret); env->exception_index = POWERPC_EXCP_PROGRAM; env->error_code = POWERPC_EXCP_INVAL | POWERPC_EXCP_INVAL_INVAL; env->spr[SPR_DAR] = address; break; } break; #if defined(TARGET_PPC64) case -5: env->exception_index = POWERPC_EXCP_DSEG; env->error_code = 0; env->spr[SPR_DAR] = address; break; #endif } } #if 0 printf("%s: set exception to %d %02x\n", __func__, env->exception, env->error_code); #endif ret = 1; } return ret; }
1threat
Display table from MySQL on the web : <p>I have just installed MySQL and set up a server and a database. I have also created a table and insert data into it. Now I want to display this table on the web. I am planning to use this code <a href="https://www.w3schools.com/php/php_mysql_connect.asp" rel="nofollow noreferrer">https://www.w3schools.com/php/php_mysql_connect.asp</a> to connect it to the web, but I don't know where to place this file for it to work. Can anybody help me? I'm really new to PHP and I have googled but everyone is using PHPMyAdmin.</p>
0debug
can Anyone help me in asking run time permission for WRITE_External_STORAGE when i m downloading a file from my application.? : can Anyone help me in asking run time permission for WRITE_External_STORAGE when i m downloading a file from my application.? Using my webview in android which display my website that i have pdf files in that so i require runtime permission to allow storage access in my app.. Here is my sample code: public class MainActivity extends AppCompatActivity { private WebView myWebView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); myWebView = (WebView)findViewById(R.id.webView); WebSettings webSettings = myWebView.getSettings(); WebSettings.setJavaScriptEnabled(true); myWebView.loadUrl("https://learntatatrusts.org/"); myWebView.setWebViewClient(new WebViewClient()); myWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); CookieManager cookieManager = CookieManager.getInstance(); String cookie = cookieManager.getCookie("https://learntatatrusts.org/"); request.addRequestHeader("Cookie", cookie); request.allowScanningByMediaScanner(); Environment.getExternalStorageDirectory(); getApplicationContext().getFilesDir().getPath(); //which returns the internal app files directory path request.setNotificationVisibility(DownloadManager.Request. VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setDestinationInExternalPublicDir(Environment. DIRECTORY_DOWNLOADS, "download"); DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); dm.enqueue(request); } }); } @Override public void onBackPressed() { if(myWebView.canGoBack()) { myWebView.goBack(); } else { super.onBackPressed(); } } }
0debug
How to get the value of a key in object inside an array : <p>I have an array of objects. With some logic I am returning the <strong>id</strong> of some selected objects. What I need is to get the value of <strong>name</strong> property of that selected objects. I have only one thing to process which is the <strong>id</strong> of that selected objects.</p>
0debug
How to change active bootstrap tab with javascript : <p>I have tried to change the active tab and failed to use the javascript onclick element correctly. Here's the code:</p> <pre><code>&lt;ul class="nav nav-tabs" style="text-align: left;"&gt; &lt;li class="active"&gt;&lt;a href="#first" data-toggle="tab"&gt;First&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#second" data-toggle="tab"&gt;Second&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#third" data-toggle="tab"&gt;Third&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;div class=“tab-content"&gt; &lt;div id="first" class="tab-pane fade in active”&gt; Text &lt;a href="#second" class="btn btn-primary btn-lg" onclick=“CHANGE ACTIVE TAB TO SECOND” data-toggle="tab"&gt;Second&lt;/a&gt; &lt;a href="#third" class="btn btn-primary btn-lg" onclick=“CHANGE ACTIVE TAB TO THIRD” data-toggle=“tab"&gt;Third&lt;/a&gt; &lt;/div&gt; &lt;div id="second" class="tab-pane fade in”&gt; Text &lt;/div&gt; &lt;div id="third" class="tab-pane fade in”&gt; Text &lt;/div&gt; &lt;/div&gt; </code></pre> <p>How could I be able to use the buttons to change the active tab to their associated id? Please advise.</p> <p>Have a great day!</p>
0debug
AngularJS. Adding $watch to the partiular model : I am new to angularJS and i dont know how to add `$watch` to the particular model. When going through the angularjs tutorial i facing some issue. i mentioned my doubt in comments part. please go through this. (function(angular) { angular.module('controllerAsExample', []) .controller('SettingsController1', SettingsController1); function SettingsController1() { this.name = "John Smith"; this.contacts = [ {type: 'phone', value: '408 555 1212'}, {type: 'email', value: 'john.smith@example.org'} ]; } //how to add $watch to ng-model 'settings.name' /*$scope.$watch("settings.name", function(oldval, newval){ console.log(oldval + " + " + newval); });*/ SettingsController1.prototype.greet = function() { console.log(this.name); }; })(window.angular); HTML code.. <body ng-app="controllerAsExample"> <div id="ctrl-as-exmpl" ng-controller="SettingsController1 as settings"> <label>Name: <input type="text" ng-model="settings.name"/></label> <button ng-click="settings.greet()">greet</button><br/> </div> </body> Here check my [link][1] [1]: http://plnkr.co/edit/3YJCsuOcLpoFAgipmus8?p=preview
0debug
What is the difference between an abstract class and an interface? i want to know why use the abstract class : <p>Under what circumstances is the abstract class used?</p> <p>I do not think you need to use an abstract class.</p> <p>interface is more useful than abstract class</p> <p>but Why use the abstract class even though the interface is more convenient</p>
0debug
How to update controls of FormArray : <p>My form group code is as</p> <pre><code>this.myForm = this._fb.group({ branch_name: ['', [Validators.required]], branch_timing: this._fb.array([ this.initBranchTiming(), ]) }); initBranchTiming() { return this._fb.group({ day: ['', []], open_from: ['00:00:00', []], open_till: ['00:00:00', []] }); } </code></pre> <p>branch_name is updated by this code </p> <pre><code>(&lt;FormControl&gt;this.myForm.controls['branch_name']).updateValue(this.branch_detail.branch_name); </code></pre> <p>Now i have to update the 'day' field of form array. what to do to update the 'day' field of form array branch_timing ?</p>
0debug
static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int calculate_checksum) { int64_t start, size; start= url_ftell(bc) - 8; init_checksum(bc, calculate_checksum ? update_adler32 : NULL, 0); size= get_v(bc); nut->packet_start[2] = start; nut->written_packet_size= size; return size; }
1threat
String must contain a specific character once : <p>When writing a regex I only know how to specify what is ALLOWED to be in a string, but I don't know how to specify what MUST be in it.</p> <p>Let's say I need a regex that validates e.g. a sentence that contains exactly one <code>$</code> character anywhere.</p> <pre><code>"This $ should validate." "This shouldn't validate." "This $ should not $ validate either." </code></pre> <p>How to do that?</p>
0debug
Is it possible to change the colour of the line below / Border of a TextBox (Entry) : <p>I am creating a <code>Xamarin.Forms</code> application on <code>Android</code> and I am trying to change the colour of the line below my <code>Xamarin.Forms</code> <code>Entry</code> control.</p> <p>I have an <code>Entry</code> control like so:</p> <pre><code>&lt;Entry Text="new cool street"/&gt; </code></pre> <p><a href="https://i.stack.imgur.com/xfn3V.png" rel="noreferrer"><img src="https://i.stack.imgur.com/xfn3V.png" alt="enter image description here"></a></p> <p>I would like to change the colour of the line below this <code>Entry</code> from the default white to more of a purple to match my theme.</p> <p>Idealy it would be better to do using Android Styles as it would apply to all controls inheriting from <code>Entry</code> if possible</p> <p>Is this possible to do?</p>
0debug
Flutter, render widget after async call : <p>I would like to render a widget that needs an HTTP call to gather some data.</p> <p>Got the following code (simplified)</p> <pre><code>import 'package:flutter/material.dart'; import 'dart:async'; import 'dart:convert'; void main() { runApp(new MyApp()); } class MyApp extends StatelessWidget { // This widget is the root of your application. @override Widget build(BuildContext context) { return new MaterialApp( title: 'Flutter demo', theme: new ThemeData( primarySwatch: Colors.blue, ), home: new MyHomePage(title: 'async demo'), ); } } class MyHomePage extends StatefulWidget { MyHomePage({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() =&gt; new _MyHomePageState(); } class _MyHomePageState extends State&lt;MyHomePage&gt; { var asyncWidget; @override initState() { super.initState(); loadData().then((result) { print(result); setState(() { asyncWidget = result; }); }); } loadData() async { var widget = new AsyncWidget(); return widget.build(); } @override Widget build(BuildContext context) { if(asyncWidget == null) { return new Scaffold( appBar: new AppBar( title: new Text("Loading..."), ), ); } else { return new Scaffold( appBar: new AppBar( title: new Text(widget.title), ), body: new Center( child: this.asyncWidget, ), ); } } } class MyRenderer { MyRenderer(); Widget render (List data) { List&lt;Widget&gt; renderedWidgets = new List&lt;Widget&gt;(); data.forEach((element) { renderedWidgets.add(new ListTile( title: new Text("one element"), subtitle: new Text(element.toString()), )); }); var lv = new ListView( children: renderedWidgets, ); return lv; } } class MyCollector { Future gather() async { var response = await // do the http request here; return response.body; } } class AsyncWidget { MyCollector collector; MyRenderer renderer; AsyncWidget() { this.collector = new MyCollector(); this.renderer = new MyRenderer(); } Widget build() { var data = this.collector.gather(); data.then((response) { var responseObject = JSON.decode(response); print(response); return this.renderer.render(responseObject); }); data.catchError((error) { return new Text("Oups"); }); } } </code></pre> <p>My code works like this : the widget using async data takes a collector (which make the http call) and a renderer which will render the widgets with the http data. I create an instance of this widget on the initState() and then I make my async call.</p> <p>I found some documentation saying that we should use the setState() method to update the widget with the new data but this doesn't work for me.</p> <p>However when I put some logs, i see the HTTP call is done and the setState() method is called, but the widget does not update.</p>
0debug
what is the use of equal sign two times in statement : In c language, what is the use of equal sign twice in statement. for example in following code statement - *arr += *(arr + n - 1) += 10; has twice equal sign #include <stdio.h> #define SIZE(arr) sizeof(arr) / sizeof(*arr); void fun(int* arr, int n) { int i; *arr += *(arr + n - 1) += 10; } void printArr(int* arr, int n) { int i; for(i = 0; i < n; ++i) printf("%d ", arr[i]); } int main() { int arr[] = {10, 20, 30}; int size = SIZE(arr); fun(arr, size); printArr(arr, size); return 0; }
0debug
Remove trailing zeros from string java : <p>Although I have seen a question similar to this one asked quite a few times, I actually mean remove all trailing zeroes.</p> <p>I would like to convert something like</p> <pre><code>"1903895810000" </code></pre> <p>to</p> <pre><code>"190389581" </code></pre> <p>I am looking for a String.replace() solution</p>
0debug
Date matching in Swift not working code there : <p>iam trying to send some string dates to one method and if its matching the date format then return true,</p> <p>my input paramters look like "4325/353/53" this is fail case and success case "09/25/2020"</p> <p>my methode, but this is returning fail for everything. pls help</p> <pre><code>func isValidDate(dateString: String) -&gt; Bool { let dateFormatterGet = DateFormatter() dateFormatterGet.dateFormat = "dd/MM/yyyy" if let _ = dateFormatterGet.date(from: dateString) { //date parsing succeeded, if you need to do additional logic, replace _ with some variable name i.e date return true } else { // Invalid date return false } } </code></pre>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
Change icon when click button ionic 2 : <p>i'm trying to change the icon when click the button its show hidden content i need to change up and down arrow icon </p> <pre><code>&lt;button clear text-center (click)="toggle()"&gt; &lt;ion-icon name="arrow-dropdown-circle"&gt;&lt;/ion-icon&gt; &lt;/button&gt; &lt;ion-col [hidden]="!visible" class="accountBalance animated slideInUp"&gt; &lt;ion-list&gt; &lt;ion-item&gt; &lt;h3&gt;limit&lt;/h3&gt; &lt;ion-note item-right&gt; &lt;h2&gt;&amp;#x20B9; 55000.00&lt;/h2&gt; &lt;/ion-note&gt; &lt;/ion-item&gt; &lt;ion-list&gt;&lt;/ion-col&gt; </code></pre> <p>file.ts</p> <pre><code>visible = false; toggle() { this.visible = !this.visible; } </code></pre>
0debug
document.location = 'http://evil.com?username=' + user_input;
1threat
How to get input field values based on classes : <p>i have a form where i am showing input fields using loop. all fields have classes. Basically there are 3 fields. 1 - quantity 2 - price 3 - total</p> <p>as the input fields are in loop. so here is the problem that i want to show total from the quantity*price == total but i want to calculate total on click.</p> <p>please help</p>
0debug
static av_noinline void FUNC(hl_decode_mb_444)(const H264Context *h, H264SliceContext *sl) { const int mb_x = sl->mb_x; const int mb_y = sl->mb_y; const int mb_xy = sl->mb_xy; const int mb_type = h->cur_pic.mb_type[mb_xy]; uint8_t *dest[3]; int linesize; int i, j, p; const int *block_offset = &h->block_offset[0]; const int transform_bypass = !SIMPLE && (sl->qscale == 0 && h->sps.transform_bypass); const int plane_count = (SIMPLE || !CONFIG_GRAY || !(h->flags & AV_CODEC_FLAG_GRAY)) ? 3 : 1; for (p = 0; p < plane_count; p++) { dest[p] = h->cur_pic.f->data[p] + ((mb_x << PIXEL_SHIFT) + mb_y * sl->linesize) * 16; h->vdsp.prefetch(dest[p] + (sl->mb_x & 3) * 4 * sl->linesize + (64 << PIXEL_SHIFT), sl->linesize, 4); } h->list_counts[mb_xy] = sl->list_count; if (!SIMPLE && MB_FIELD(sl)) { linesize = sl->mb_linesize = sl->mb_uvlinesize = sl->linesize * 2; block_offset = &h->block_offset[48]; if (mb_y & 1) for (p = 0; p < 3; p++) dest[p] -= sl->linesize * 15; if (FRAME_MBAFF(h)) { int list; for (list = 0; list < sl->list_count; list++) { if (!USES_LIST(mb_type, list)) continue; if (IS_16X16(mb_type)) { int8_t *ref = &sl->ref_cache[list][scan8[0]]; fill_rectangle(ref, 4, 4, 8, (16 + *ref) ^ (sl->mb_y & 1), 1); } else { for (i = 0; i < 16; i += 4) { int ref = sl->ref_cache[list][scan8[i]]; if (ref >= 0) fill_rectangle(&sl->ref_cache[list][scan8[i]], 2, 2, 8, (16 + ref) ^ (sl->mb_y & 1), 1); } } } } } else { linesize = sl->mb_linesize = sl->mb_uvlinesize = sl->linesize; } if (!SIMPLE && IS_INTRA_PCM(mb_type)) { if (PIXEL_SHIFT) { const int bit_depth = h->sps.bit_depth_luma; GetBitContext gb; init_get_bits(&gb, sl->intra_pcm_ptr, 768 * bit_depth); for (p = 0; p < plane_count; p++) for (i = 0; i < 16; i++) { uint16_t *tmp = (uint16_t *)(dest[p] + i * linesize); for (j = 0; j < 16; j++) tmp[j] = get_bits(&gb, bit_depth); } } else { for (p = 0; p < plane_count; p++) for (i = 0; i < 16; i++) memcpy(dest[p] + i * linesize, sl->intra_pcm_ptr + p * 256 + i * 16, 16); } } else { if (IS_INTRA(mb_type)) { if (sl->deblocking_filter) xchg_mb_border(h, sl, dest[0], dest[1], dest[2], linesize, linesize, 1, 1, SIMPLE, PIXEL_SHIFT); for (p = 0; p < plane_count; p++) hl_decode_mb_predict_luma(h, sl, mb_type, SIMPLE, transform_bypass, PIXEL_SHIFT, block_offset, linesize, dest[p], p); if (sl->deblocking_filter) xchg_mb_border(h, sl, dest[0], dest[1], dest[2], linesize, linesize, 0, 1, SIMPLE, PIXEL_SHIFT); } else { FUNC(hl_motion_444)(h, sl, dest[0], dest[1], dest[2], h->qpel_put, h->h264chroma.put_h264_chroma_pixels_tab, h->qpel_avg, h->h264chroma.avg_h264_chroma_pixels_tab, h->h264dsp.weight_h264_pixels_tab, h->h264dsp.biweight_h264_pixels_tab); } for (p = 0; p < plane_count; p++) hl_decode_mb_idct_luma(h, sl, mb_type, SIMPLE, transform_bypass, PIXEL_SHIFT, block_offset, linesize, dest[p], p); } }
1threat
static void gen_spr_power8_book4(CPUPPCState *env) { #if !defined(CONFIG_USER_ONLY) spr_register_kvm(env, SPR_ACOP, "ACOP", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, KVM_REG_PPC_ACOP, 0); spr_register_kvm(env, SPR_BOOKS_PID, "PID", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, KVM_REG_PPC_PID, 0); spr_register_kvm(env, SPR_WORT, "WORT", SPR_NOACCESS, SPR_NOACCESS, &spr_read_generic, &spr_write_generic, KVM_REG_PPC_WORT, 0); #endif }
1threat
static SocketAddressLegacy *nbd_build_socket_address(const char *sockpath, const char *bindto, const char *port) { SocketAddressLegacy *saddr; saddr = g_new0(SocketAddressLegacy, 1); if (sockpath) { saddr->type = SOCKET_ADDRESS_LEGACY_KIND_UNIX; saddr->u.q_unix.data = g_new0(UnixSocketAddress, 1); saddr->u.q_unix.data->path = g_strdup(sockpath); } else { InetSocketAddress *inet; saddr->type = SOCKET_ADDRESS_LEGACY_KIND_INET; inet = saddr->u.inet.data = g_new0(InetSocketAddress, 1); inet->host = g_strdup(bindto); if (port) { inet->port = g_strdup(port); } else { inet->port = g_strdup_printf("%d", NBD_DEFAULT_PORT); } } return saddr; }
1threat
How to split an large string to two different arrays : I'm working on a app where the user creates a large string containing consisting a and b.Now I want to split the character a to one array or string and b to another array or string.And convert them to its original form when needed. What I'm trying to achieve is String:abbabbaabbab. array1:{a,a,a,a,a}, array2:{b,b,b,b,b,b}.
0debug
Ruby find and return objects in an array based on an attribute : <p>How can you iterate through an array of objects and return the entire object if a certain attribute is correct? </p> <p>I have the following in my rails app</p> <pre><code>array_of_objects.each { |favor| favor.completed == false } array_of_objects.each { |favor| favor.completed } </code></pre> <p>but for some reason these two return the same result! I have tried to replace <code>each</code> with <code>collect</code>, <code>map</code>, <code>keep_if</code> as well as <code>!favor.completed</code> instead of <code>favor.completed == false</code> and none of them worked! </p> <p>Any help is highly appreciated!</p>
0debug
What does "__consuming" do in Swift? : <p>There are functions prepended with <code>__consuming</code> in <a href="https://github.com/apple/swift/blob/master/stdlib/public/core/Sequence.swift" rel="noreferrer">Sequence.swift</a> (most likely other places too, but I haven't really looked around). I know it's some type of declaration modifier but I'm not sure what it does.</p>
0debug
I've deployed JButton using multiple layout managers, but it doesn't display properly : <p>I wanted to place several buttons to check the differences between the different layout managers. But the code I wrote shows only the buttons displayed by one layout manager, and the buttons of the other layout manager are not displayed at all. What should I do?</p> <p>This is my code:</p> <pre><code>import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.GridLayout; import javax.swing.*; public class No2{ public No2() { JFrame frame=new JFrame("MyFrame"); JPanel MainPanel=new JPanel(); JPanel panel1=new JPanel(); JPanel panel2=new JPanel(); JPanel panel3=new JPanel(); JButton[] btn=new JButton[5]; for (int i = 0; i &lt; btn.length; i++) { btn[i]=new JButton("Button"+(i+1)); } frame.add(MainPanel); MainPanel.setLayout(new GridLayout(3,1)); MainPanel.add(panel1); MainPanel.add(panel2); MainPanel.add(panel3); panel1.setLayout(new FlowLayout()); for (int i = 0; i &lt; btn.length; i++) { panel1.add(btn[i]); } panel1.setLayout(new BorderLayout()); for (int i = 0; i &lt; btn.length; i++) { panel2.add(btn[i]); } panel1.setLayout(new GridLayout()); for (int i = 0; i &lt; btn.length; i++) { panel3.add(btn[i]); } frame.pack(); frame.setVisible(true); frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE); } public static void main(String[] args) { new No2(); } } </code></pre>
0debug
static AVFrame *get_video_buffer(AVFilterLink *inlink, int w, int h) { PadContext *s = inlink->dst->priv; AVFrame *frame = ff_get_video_buffer(inlink->dst->outputs[0], w + (s->w - s->in_w), h + (s->h - s->in_h)); int plane; if (!frame) return NULL; frame->width = w; frame->height = h; for (plane = 0; plane < 4 && frame->data[plane]; plane++) { int hsub = s->draw.hsub[plane]; int vsub = s->draw.vsub[plane]; frame->data[plane] += (s->x >> hsub) * s->draw.pixelstep[plane] + (s->y >> vsub) * frame->linesize[plane]; } return frame; }
1threat
Why do i need QML when i have C++ in Qt? : <p>I have been working in Qt for nearly 4 - 5 month and now i found QML. First i thought that QML is front-end of your project while c++ is back-end. And if it is really so why the hack i learned QWidgets, QTreeView, QTableWidget...etc if i don`t use them in my project as QML comes here!!! I feel very "annoyance". What i mean that why Qt created QML as it has above widgets and C++ (the best language for me:)? In some QML books i found that it is completaly a language which has everything in c++, i mean network, class, function so on... and which one should i use when working in Qt c++ or QML?</p>
0debug
Install Tkinter On Amazon Linux : <p>I am working on an Amazon Linux ec2 machine. When I try to run a Python script inside a virtualenv, I get the following message:</p> <pre><code>File "/home/sp/Envs/crispor/local/lib/python2.7/dist-packages/matplotlib/externals/six.py", line 80, in _import_module __import__(name) ImportError: No module named Tkinter </code></pre> <p>As I understand Tkinter should have been a part of the Python installation. But somehow it is not. These do not work - </p> <pre><code>sudo yum install python-tk sudo yum install tkinter </code></pre> <p>How do I install Tkinter? Or should I be doing that at all give it should have been a part of the Python installation?</p>
0debug
avoiding data redundency : ey guys, so im working on a code for my music site, this is part of the registration phase, i want the code to check the database for any existing email address, if found, print " email ("email address") already exists, but if not found, then insert the information into the database... the code seems to run if an email address similar to the one submitted from the html form is found, but if there is no code found, the system stops and does nothing after that. can someone help me figure out where i went wrong. if ($_POST['submit2']){ $fname = $_POST['Fname']; $sname = $_POST['Sname']; $email = $_POST['Emailaddress']; $pass = $_POST['newpassword']; $sql= "select * from cust_information where email = '$email';"; $results = mysqli_query($conn, $sql) or die(mysqli_error($conn)); $row = mysqli_fetch_array($results) or die(mysqli_error($conn)); if (count($row) < 0) { $sql2 = "insert into cust_information (firstName, lastName, email, password) values(`$fname`, `$sname`, `$email`, `$pass`)"; $results2 = mysqli_query($conn, $sql) or die(mysqli_error($conn)); if (!$results2){ echo "successfully uploaded cust"; } }else{ echo "email <strong>".$row["email"]. " </strong> already Exist"; } }
0debug
How to convert w/ or w/o decimal numbers to words // Python : <p>What I am going to add/improve to this code? Can it be done without importing num2words or inflect module? I've tried to mix some code with this code but none of them are working.</p> <p>This is my improved code from <a href="https://codereview.stackexchange.com/questions/173971/converting-number-to-words">this original code.</a> Thank you in advance!</p> <pre><code>one = ['', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine'] tenp = ['Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'] tenp2 = ['', '', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'] def once(num): word = one[int(num)] word = word.strip() return word def ten(num): if num[0] == '1': word = tenp[int(num[1])] else: text = once(num[1]) word = tenp2[int(num[0])] word = word + " " + text word = word.strip() return word def hundred(num): word = '' text = ten(num[1:]) word = one[int(num[0])] if num[0] != '0': word = word + " Hundred " word = word + text word = word.strip() return word def thousand(num): word = '' pref = '' text = '' length = len(num) if length == 6: text = hundred(num[3:]) pref = hundred(num[:3]) if length == 5: text = hundred(num[2:]) pref = ten(num[:2]) if length == 4: text = hundred(num[1:]) word = one[int(num[0])] if num[0] != '0' or num[1] != '0' or num[2] != '0': word = word + " Thousand " word = word + text if length == 6 or length == 5: word = pref + word word = word.strip() return word test = int(input("Enter number(0-999,999):")) a = str(test) leng = len(a) if leng == 1: if a == '0': num = 'Zero' else: num = once(a) if leng == 2: num = ten(a) if leng == 3: num = hundred(a) if leng &gt; 3 and leng &lt; 7: num = thousand(a) print(num) </code></pre> <p>This is the output of this code</p> <pre><code>Enter number(0-999,999):123456 One Hundred Twenty Three Thousand Four Hundred Fifty Six </code></pre> <p>And I want it to be like this</p> <pre><code>Enter number(0-999,999):123456.25 One Hundred Twenty Three Thousand Four Hundred Fifty Six and 25/100 </code></pre>
0debug
Vectors vs Dynamic arrays : <p>I find it possible to initialise arrays dynamically in C++. By this i mean :</p> <pre><code>int n; int ar[n]; </code></pre> <p>works fine.</p> <p>So what is the difference between this and <strong>vectors</strong> ?</p>
0debug
void vncws_handshake_read(void *opaque) { VncState *vs = opaque; uint8_t *handshake_end; long ret; buffer_reserve(&vs->ws_input, 4096); ret = vnc_client_read_buf(vs, buffer_end(&vs->ws_input), 4096); if (!ret) { if (vs->csock == -1) { vnc_disconnect_finish(vs); } return; } vs->ws_input.offset += ret; handshake_end = (uint8_t *)g_strstr_len((char *)vs->ws_input.buffer, vs->ws_input.offset, WS_HANDSHAKE_END); if (handshake_end) { qemu_set_fd_handler2(vs->csock, NULL, vnc_client_read, NULL, vs); vncws_process_handshake(vs, vs->ws_input.buffer, vs->ws_input.offset); buffer_advance(&vs->ws_input, handshake_end - vs->ws_input.buffer + strlen(WS_HANDSHAKE_END)); } }
1threat
How do I read and print the first 5 integers from a .txt file in C? : <p>I'm trying to read and print the first five integers from a .txt file in C. I have a few files with lists of varying integers that I need to be able to read, using command line arguments.</p> <p>For example, if I type</p> <pre><code>./firstFive 50to100.txt </code></pre> <p>[File 50to100.txt contains integers 50-100 separated by a new line]</p> <p>So the program should print - </p> <pre><code>50 51 52 53 54 </code></pre> <p>As there are a few different files to read (all containing integers), I'm using "fp" as a catch all to open a file specified from argv[1].</p> <p>Here is what I have so far - </p> <pre><code>#include &lt;stdio.h&gt; int main(int argc, char *argv[]) { FILE *fp; int num; int i; if (argc &lt; 2) { fprintf(stderr, "Usage: %s &lt;filename&gt;\n", argv[0]); return 1; } fp = fopen(argv[1], "r"); if (fp == NULL) { fprintf(stderr, "%s: unable to open file %s,\n", argv[0], argv[1]); return 1; } while (fscanf(fp, "%d", &amp;num) == 1) { for(i=0; i&lt;5; i++) { printf("%c/n", num[i]); } } fclose(fp); return 0; } </code></pre> <p>At the moment it won't even compile. Any idea on what's going wrong?</p>
0debug
Does Eigen have solution for repair non-positive defined covariance matrix : <p>Does Eigen contains an algorithm for solving nearest correlation matrix problems?</p>
0debug
static void allocate_buffers(FLACContext *s){ int i; assert(s->max_blocksize); if(s->max_framesize == 0 && s->max_blocksize){ s->max_framesize= (s->channels * s->bps * s->max_blocksize + 7)/ 8; } for (i = 0; i < s->channels; i++) { s->decoded[i] = av_realloc(s->decoded[i], sizeof(int32_t)*s->max_blocksize); } s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize); }
1threat
C++ Operator Overload [ ] : <p>let's say i have the following classes:</p> <pre><code>class temp1 { private: int A; double B; }; class temp2 { private: int A[20]; double B; }; void main() { temp1 a[100]; temp2 b; } </code></pre> <p>now the question is why do i need to overload the operator [ ] only for temp2 and not for temp 1 aswell ? i know that inorder to get to the 10 index in veriable A in class temp 2 i will need to overload indeed the operator [ ] but in the main i have array of classes (temp1 a[100]) so how the compiler knows what will i mean when i will use [ ] operator without overloading one.</p>
0debug
hadamard_func(mmx2) hadamard_func(sse2) hadamard_func(ssse3) void ff_dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx) { int mm_flags = av_get_cpu_flags(); #if HAVE_INLINE_ASM int bit_depth = avctx->bits_per_raw_sample; if (mm_flags & AV_CPU_FLAG_MMX) { const int dct_algo = avctx->dct_algo; if (avctx->bits_per_raw_sample <= 8 && (dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX)) { if(mm_flags & AV_CPU_FLAG_SSE2){ c->fdct = ff_fdct_sse2; } else if (mm_flags & AV_CPU_FLAG_MMXEXT) { c->fdct = ff_fdct_mmx2; }else{ c->fdct = ff_fdct_mmx; } } if (bit_depth <= 8) c->get_pixels = get_pixels_mmx; c->diff_pixels = diff_pixels_mmx; c->pix_sum = pix_sum16_mmx; c->diff_bytes= diff_bytes_mmx; c->sum_abs_dctelem= sum_abs_dctelem_mmx; c->pix_norm1 = pix_norm1_mmx; c->sse[0] = sse16_mmx; c->sse[1] = sse8_mmx; c->vsad[4]= vsad_intra16_mmx; c->nsse[0] = nsse16_mmx; c->nsse[1] = nsse8_mmx; if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->vsad[0] = vsad16_mmx; } if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_mmx; } c->add_8x8basis= add_8x8basis_mmx; c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx; if (mm_flags & AV_CPU_FLAG_MMXEXT) { c->sum_abs_dctelem= sum_abs_dctelem_mmx2; c->vsad[4]= vsad_intra16_mmx2; if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->vsad[0] = vsad16_mmx2; } c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_mmx2; } if(mm_flags & AV_CPU_FLAG_SSE2){ if (bit_depth <= 8) c->get_pixels = get_pixels_sse2; c->sum_abs_dctelem= sum_abs_dctelem_sse2; } #if HAVE_SSSE3_INLINE if(mm_flags & AV_CPU_FLAG_SSSE3){ if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_ssse3; } c->add_8x8basis= add_8x8basis_ssse3; c->sum_abs_dctelem= sum_abs_dctelem_ssse3; } #endif if(mm_flags & AV_CPU_FLAG_3DNOW){ if(!(avctx->flags & CODEC_FLAG_BITEXACT)){ c->try_8x8basis= try_8x8basis_3dnow; } c->add_8x8basis= add_8x8basis_3dnow; } } #endif #if HAVE_YASM if (mm_flags & AV_CPU_FLAG_MMX) { c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx; c->hadamard8_diff[1] = ff_hadamard8_diff_mmx; if (mm_flags & AV_CPU_FLAG_MMXEXT) { c->hadamard8_diff[0] = ff_hadamard8_diff16_mmx2; c->hadamard8_diff[1] = ff_hadamard8_diff_mmx2; } if (mm_flags & AV_CPU_FLAG_SSE2){ c->sse[0] = ff_sse16_sse2; #if HAVE_ALIGNED_STACK c->hadamard8_diff[0] = ff_hadamard8_diff16_sse2; c->hadamard8_diff[1] = ff_hadamard8_diff_sse2; #endif } #if HAVE_SSSE3 && HAVE_ALIGNED_STACK if (mm_flags & AV_CPU_FLAG_SSSE3) { c->hadamard8_diff[0] = ff_hadamard8_diff16_ssse3; c->hadamard8_diff[1] = ff_hadamard8_diff_ssse3; } #endif } #endif ff_dsputil_init_pix_mmx(c, avctx); }
1threat
int kvmppc_remove_spapr_tce(void *table, int fd, uint32_t window_size) { long len; if (fd < 0) { return -1; } len = (window_size / SPAPR_VIO_TCE_PAGE_SIZE)*sizeof(VIOsPAPR_RTCE); if ((munmap(table, len) < 0) || (close(fd) < 0)) { fprintf(stderr, "KVM: Unexpected error removing KVM SPAPR TCE " "table: %s", strerror(errno)); } return 0; }
1threat