problem
stringlengths
26
131k
labels
class label
2 classes
Two pointers in ROM hardware implementation : <p>ROM is implemented by case statement to store fixed values in it and read them whenever we need.</p> <p>But how can I read two values at the same clock cycle ??</p>
0debug
Python Falcon - get POST data : <p>I try to use falcon package in my project. Problem is I didn't find a way to get body data from the HTTP post request.</p> <p>I used code from example, but <code>req.stream.read()</code> doesn't return JSON as expected.</p> <p>The code is:</p> <pre><code>raw_json = req.stream.read() result.json(raw_json, encoding='utf-8') resp.body = json.dumps(result_json, encoding='utf-8') </code></pre> <p>How to get the POST data?</p> <p>Thanks for any help</p>
0debug
UICollectionView scroll to item not working with horizontal direction : <p>I have a <code>UICollectionView</code> within a <code>UIViewController</code> with paging enabled. For some strange reason <code>collectionView.scrollToItem</code> works when the direction of the <code>collectionview</code> is <code>vertical</code> but doesn't when direction is <code>horizontal</code>. Is this there something I'm doing wrong or is this supposed to happen?</p> <pre><code> //Test scrollToItem func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let i = IndexPath(item: 3, section: 0) collectionView.reloadData() collectionView.scrollToItem(at: i, at: .top, animated: true) print("Selected") } </code></pre>
0debug
UPDATE SQL SERVER QUERY : Hey guys how are you ? Im trying to update the commission value column but I want that each row get their values but what happens when I execute that query is that all rows are updated and get the same values. Can somenone tell me what im doing wrong ? Do you need more info ? Thanks ! UPDATE Discount set CommissionValue = (SELECT[Discount].VendorCommissions * [Order].OrderTotal / 100 FROM [Order] INNER JOIN[DiscountUsageHistory] ON [Order].Id = [DiscountUsageHistory].OrderId INNER JOIN[Discount] ON [DiscountUsageHistory].Disc
0debug
def check_greater(arr, number): arr.sort() if number > arr[-1]: return ('Yes, the entered number is greater than those in the array') else: return ('No, entered number is less than those in the array')
0debug
How to properly use "keywords" property in package.json? : <p>Is it good to list as many as possible keywords for a package (hundred?) or this is a bad approach?</p> <p>How to list keywords properly?</p>
0debug
static int vpc_create(const char *filename, QemuOpts *opts, Error **errp) { uint8_t buf[1024]; VHDFooter *footer = (VHDFooter *) buf; char *disk_type_param; int fd, i; uint16_t cyls = 0; uint8_t heads = 0; uint8_t secs_per_cyl = 0; int64_t total_sectors; int64_t total_size; int disk_type; int ret = -EIO; bool nocow = false; total_size = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0); disk_type_param = qemu_opt_get_del(opts, BLOCK_OPT_SUBFMT); if (disk_type_param) { if (!strcmp(disk_type_param, "dynamic")) { disk_type = VHD_DYNAMIC; } else if (!strcmp(disk_type_param, "fixed")) { disk_type = VHD_FIXED; } else { ret = -EINVAL; goto out; } } else { disk_type = VHD_DYNAMIC; } nocow = qemu_opt_get_bool_del(opts, BLOCK_OPT_NOCOW, false); fd = qemu_open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) { ret = -EIO; goto out; } if (nocow) { #ifdef __linux__ int attr; if (ioctl(fd, FS_IOC_GETFLAGS, &attr) == 0) { attr |= FS_NOCOW_FL; ioctl(fd, FS_IOC_SETFLAGS, &attr); } #endif } total_sectors = total_size / BDRV_SECTOR_SIZE; for (i = 0; total_sectors > (int64_t)cyls * heads * secs_per_cyl; i++) { if (calculate_geometry(total_sectors + i, &cyls, &heads, &secs_per_cyl)) { ret = -EFBIG; goto fail; } } total_sectors = (int64_t) cyls * heads * secs_per_cyl; memset(buf, 0, 1024); memcpy(footer->creator, "conectix", 8); memcpy(footer->creator_app, "qemu", 4); memcpy(footer->creator_os, "Wi2k", 4); footer->features = be32_to_cpu(0x02); footer->version = be32_to_cpu(0x00010000); if (disk_type == VHD_DYNAMIC) { footer->data_offset = be64_to_cpu(HEADER_SIZE); } else { footer->data_offset = be64_to_cpu(0xFFFFFFFFFFFFFFFFULL); } footer->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE); footer->major = be16_to_cpu(0x0005); footer->minor = be16_to_cpu(0x0003); if (disk_type == VHD_DYNAMIC) { footer->orig_size = be64_to_cpu(total_sectors * 512); footer->size = be64_to_cpu(total_sectors * 512); } else { footer->orig_size = be64_to_cpu(total_size); footer->size = be64_to_cpu(total_size); } footer->cyls = be16_to_cpu(cyls); footer->heads = heads; footer->secs_per_cyl = secs_per_cyl; footer->type = be32_to_cpu(disk_type); #if defined(CONFIG_UUID) uuid_generate(footer->uuid); #endif footer->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE)); if (disk_type == VHD_DYNAMIC) { ret = create_dynamic_disk(fd, buf, total_sectors); } else { ret = create_fixed_disk(fd, buf, total_size); } fail: qemu_close(fd); out: g_free(disk_type_param); return ret; }
1threat
immutable.js get keys from map/hash : <p>I want to retrieve keys() from the following Immutable Map:</p> <pre><code>var map = Immutable.fromJS({"firstKey": null, "secondKey": null }); console.log(JSON.stringify(map.keys())); </code></pre> <p>I would expect the output:</p> <pre><code>["firstKey", "secondKey"] </code></pre> <p>However this outputs:</p> <pre><code>{"_type":0,"_stack":{"node":{"ownerID":{},"entries":[["firstKey",null],["secondKey",null]]},"index":0}} </code></pre> <p>How to do it properly? </p> <p>JSFiddle link: <a href="https://jsfiddle.net/o04btr3j/57/" rel="noreferrer">https://jsfiddle.net/o04btr3j/57/</a></p>
0debug
Optimize and inline calls via function pointer : <p>I wanted to see if the compiler was clever enought to inline calls via a function pointer.</p> <p>If I compile using gcc 4.8 with any -Os or -O2 then the compiler will inline apply1 and apply2 into main, but will additionally for apply2 it removes the indirect call via function pointer and inlines add1 into the code too. In apply1 it does not. In general it seems to be the case that declaring my function static allows this optimization within it, but non static does not.</p> <p>Is there any fundemental difference that explains this?</p> <p>This is now mostly for curiosity but motivated by some high performance code I need to write and so would like to understand what might provoke this difference.</p> <p>Although this code is C I get the same if I compiler as C++ too.</p> <pre><code>#include &lt;stdio.h&gt; int add1(int a) { return a + 1; } void apply1(int lower, int upper, int (* func)(int)) { for (int i = lower; i &lt; upper; i++) { printf("%d = %d\n", i, func(i)); } } static void apply2(int lower, int upper, int (* func)(int)) { for (int i = lower; i &lt; upper; i++) { printf("%d = %d\n", i, func(i)); } } int main() { apply1(0, 10, add1); apply2(0, 10, add1); } </code></pre>
0debug
How to Ignore files when commiting to a git repository rails 4 : <p>I am try to ignore development.rb, database.yml files when commiting to a git repository</p> <p><strong>.gitignore</strong></p> <p>config/environments/development.rb</p> <p>config/database.yml</p>
0debug
For loops in python? : [enter image description here][1] [1]: https://i.stack.imgur.com/YYLgP.png when we have to add in python via for loops then we have to type something like this: list(range(1,10)) OUTPUT-[1, 2, 3, 4, 5, 6, 7, 8, 9] total=0 for element in range(1,10) : total+=element print(total) OUTPUT-45 But i tried doing something else, i did not defined total in the benign and later just defined total as (total=element). and when i print total then every time "4" is coming no matter which number sequence i have. Can any one explain the reason that why every time 4 is coming?
0debug
set the color of the toolbar dynamically : I get color using intent. I need to set this color dynamically in the toolbar. The Internet has found only such a solution, but it does not work. Error `java.lang.IllegalArgumentException: Unknown color` private long randomAndroidColor; randomAndroidColor = getIntent().getLongExtra(EXTRA_COLOR, 0L); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(String.valueOf(randomAndroidColor))));
0debug
static void schedule_refresh(VideoState *is, int delay) { if(!delay) delay=1; SDL_AddTimer(delay, sdl_refresh_timer_cb, is); }
1threat
static inline void init_thread(struct target_pt_regs *_regs, struct image_info *infop) { _regs->gpr[1] = infop->start_stack; #if defined(TARGET_PPC64) && !defined(TARGET_ABI32) if (get_ppc64_abi(infop) < 2) { _regs->gpr[2] = ldq_raw(infop->entry + 8) + infop->load_bias; infop->entry = ldq_raw(infop->entry) + infop->load_bias; } else { _regs->gpr[12] = infop->entry; } #endif _regs->nip = infop->entry; }
1threat
alert('Hello ' + user_input);
1threat
NOT ABLE TO FIGURE OUT WHAT IS HAPPENING WITH THE UNIVERSAL ARRAY : I HAVE CREATED A PROGRAM WHICH TAKES AN EQ. FROM THE USER BY ASKING ABOUT THE DEGREE OF THE EQ. AND THEN TAKING THE CO-EFFICIENTS FROM THE USER AND THEN FORMING THE FUNCTION WHICH RESULTS INTO AN EQ. AND THEN I HAVE USED THE BISECTION METHOD TO SOLVE IT.THE PROGRAM IS:: #include<iostream> #include<math.h> #include<iomanip> using namespace std; int stop=0,d,t[]={1}; float f(float x) { int loop,loopa; float add=0.0,sum=0.0; for(;stop==0;) { int p ; cout << "Enter the degree of the poly. eq. (+ve integer)" << endl; cin >> d ; int *t = new int[d+1]; cout << "The eq. will be in the form of ax^"<<d<<"+bx^"<<(d-1)<<" and so on ." ; p = 97 + d ; for(loop=d;loop>=0;loop--) { cout << "Enter the value of " << char(p-loop) << endl; cin >> t[loop]; cout << "a="<<t[loop]<<endl; } stop=1; //ARRAY IS STILL THERE WHY///// } for(loop=0;loop<=d;loop++) cout<<"out="<<t[loop]<<endl; //ARRAY IS GONE TILL NOW// cout<<"d="<<d<<endl; for(loopa=d;loopa>=0;loopa--) { cout<<"loopa="<<loopa<<"value="<<t[loopa]<<endl; add = t[loopa] * pow(x,loopa); sum=sum+add; } return sum; } int main() { float a , b , c , i , j ; A: cout << " Enter the starting point of interval " <<endl; cin >> a ; cout << " Enter the end point of interval " << endl; cin >> b ; cout << " Enter the number of iterations to be done . ( More the iterations , accurate is the result ) " << endl; cin >> i ; for(j=0;j<i;j++) { if(f(a)*f(b)>0) { cout << " The root of the above polynomial does not lies in the given interval . TRY AGAIN " << endl; goto A; } else { c = a + b ; c = c / 2 ; if (f(a)*f(c)>0) a = c ; else b = c ; cout <<"hello"<< a << "aa \t" << b << "\t" << c << endl; } } cout << "Root = "<< c <<endl; } WHEN THE USER GIVES THE VALUE OF DEGREE IT CREATES AN ARRAY OF SIZE ONE MORE THAN DEGREE IS CREATED THEN THERE IS A FOR LOOP WHICH TAKES THE VALUE OF CO-EFFICIENTS IN THAT ARRAY . THE PROBLEM IS THE VALUE OF THE ARRAY STAYS INTACT TILL THE FIRST FOR LOOP . BUT AS THE CONTROL PROCEEDS TO THE SECOND LOOP ( SEE THE TWO COMMENTS ) THE VALUE OF THE ARRAY IS GONE...I M USING CODELITE ...GUYS HELP ME?????
0debug
Which is the best practices to create a responsive table? : <p>I have this sample:</p> <p><a href="http://codepen.io/anon/pen/ONZBgB" rel="nofollow">link</a></p> <p><strong>CODE HTML:</strong></p> <pre><code>&lt;table class="table table-striped"&gt; &lt;thead&gt; &lt;tr&gt; &lt;td&gt;First Name&lt;/td&gt; &lt;td&gt;Last Name&lt;/td&gt; &lt;td&gt;Email&lt;/td&gt; &lt;td&gt;Phone&lt;/td&gt; &lt;td&gt;Adresss&lt;/td&gt; &lt;td&gt;Message&lt;/td&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;John&lt;/td&gt; &lt;td&gt;Smith&lt;/td&gt; &lt;td&gt;jhs@yahoo.com&lt;/td&gt; &lt;td&gt;0766323123&lt;/td&gt; &lt;td&gt;Test&lt;/td&gt; &lt;td&gt;Test&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Ronny&lt;/td&gt; &lt;td&gt;Stuard&lt;/td&gt; &lt;td&gt;ros@yahoo.com&lt;/td&gt; &lt;td&gt;0877223534&lt;/td&gt; &lt;td&gt;Test2&lt;/td&gt; &lt;td&gt;Test2&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>I found this example and want to do something like</p> <p><a href="https://css-tricks.com/examples/ResponsiveTables/responsive.php" rel="nofollow">sample responsive table</a></p> <p>What I do not understand is how CSS code is written. I need a short sample code CSS to turn my table to be like over there.Also if you know better examples to make a table responsive please put here</p> <p>After all that is the best way to make a table responsive?</p> <p>Thanks in advance!</p>
0debug
How to optimize a table in a perl script : I have an issue with my perl script. It parses a file like this : chr start end strand chr1 11870 11891 + chr1 28537 28558 + chr1 46502 46523 + chr1 39909 39930 - chr1 43896 43917 - chr2 62774 62795 - To `pairs` positions. When the strand is `+` it keeps the start and search all the end of strand `-` to pair. The results is like this : 11870 39930 11870 43917 28537 39930 28537 43917 To do this, I make two tables. I make a table with all the `start` of `+ strand` and another one with all the `end` of `- strand`. After, for each `start` in my table of `start position` I search the `end` (in the table `end position`) which is bigger than my `start`. My issue is that it takes too much time and I try to think about something which do not need to make two tables or with "dynamic table". Do you have an idea to search without these two tables? Thank you for your help.
0debug
Python runs code even though it is in an elif statement : <p>I have a list and an input. I am running code like this:</p> <pre><code>findgtin=input("Enter code to find:") ProductGtin=[] ProductGtin.append(56231878) #list is appended three more times but i cut this bit out# ##IF GTIN CODE EXISTS IN LIST## for word in ProductGtin: ##IF GTIN CODE EXISTS:## if word==findgtin: ##MAIN CODE HERE## ##IF GTIN CODE DOES NOT EXIST:## if word!=findgtin: print ("PRODUCT NOT FOUND") </code></pre> <p>findgtin is an input from the user and ProductGtin is a list that contains several 8-digit numbers. Whenever I run the program, I enter the first input and it prints "PRODUCT NOT FOUND" three times. There are four items in the list. The input, 56231878 is the first in the ProductGtin list.</p> <p>I kind of know what is happening here, the program finds the input in the list and runs the main program and then checks the same input against the other items in the list as well, returning PRODUCT NOT FOUND. I have tried re-ordering the if and elif statements and this did not work. I would appreciate any help, thank you! :)</p>
0debug
What is service worker in react js : <p>When creating a react app, service worker is invoked by default. Why service worker is used? What is the reason for default invoking?</p>
0debug
AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_size, int phase_shift, int linear, double cutoff){ AVResampleContext *c= av_mallocz(sizeof(AVResampleContext)); double factor= FFMIN(out_rate * cutoff / in_rate, 1.0); int phase_count= 1<<phase_shift; if (!c) return NULL; c->phase_shift= phase_shift; c->phase_mask= phase_count-1; c->linear= linear; c->filter_length= FFMAX((int)ceil(filter_size/factor), 1); c->filter_bank= av_mallocz(c->filter_length*(phase_count+1)*sizeof(FELEM)); if (!c->filter_bank) goto error; if (build_filter(c->filter_bank, factor, c->filter_length, phase_count, 1<<FILTER_SHIFT, WINDOW_TYPE)) goto error; memcpy(&c->filter_bank[c->filter_length*phase_count+1], c->filter_bank, (c->filter_length-1)*sizeof(FELEM)); c->filter_bank[c->filter_length*phase_count]= c->filter_bank[c->filter_length - 1]; c->src_incr= out_rate; c->ideal_dst_incr= c->dst_incr= in_rate * phase_count; c->index= -phase_count*((c->filter_length-1)/2); return c; error: av_free(c->filter_bank); av_free(c); return NULL; }
1threat
Node JS addons - NAN vs N-API? : <p>I am looking to working on a project using node js addons with C++. I came across two abstract library NAN and N-API that I can use. However I am unable to decide which one I should use. I was not able to find proper comparison between these two libraries.</p> <p>What are the pros, cons and differences of both? How to choose between them?</p> <p>So far I have found that NAN has more online tutorials/articles regarding async calls. But N-API is officially supported by Node (and was created after NAN as a better alternative, although not sure.)</p>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
Enabling auto scroll in Visual Studio Code : <p>Is there any way that we can enable auto scroll in Visual Studio Code? I have been looking in the settings but could not find anything(unless i missed something).</p> <p>I am reviewing a log file and as it gets updated, its refreshed on my side. But it is not showing the latest logs but just stays where my cursor was and highlights everything that gets populated after that.</p>
0debug
Is GraphQL an ORM? : <p>Is GraphQL an ORM? It seems like it is. At the end of the day it needs to query the database for information. You need to give it a schema (just like an ORM). From my understanding, on the front end you pass it the specifics that you want and GraphQL on the back end will give you <em>just</em> the info you requested.</p> <p>The only difference I see from traditional ORMs, such as Sequelize or ActiveRecord, is that GraphQL will give you only what you want, making it very attractive and flexible. I suspect though that whatever's going on under the hood may leave you with some inefficient queries (common to ORMs). So is GraphQL simply an ORM that gives you 100% flexibility in what you ask for and receive?</p>
0debug
Segmentation fault with std::function and lambda parameters : <p>Can you please explain why this code crashes? I would expect output of "a", but I get segmentation fault.</p> <pre><code>#include &lt;functional&gt; #include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;string&gt; using namespace std; struct MyStruct { vector&lt;string&gt; a; vector&lt;string&gt; b; }; void out_data(const MyStruct&amp; my_struct, const std::function&lt;const vector&lt;string&gt;&amp;(const MyStruct&amp;)&gt; getter) { cout &lt;&lt; getter(my_struct)[0] &lt;&lt; endl; } int main(int argc, char** argv) { MyStruct my_struct; my_struct.a.push_back("a"); my_struct.b.push_back("b"); out_data(my_struct, [](const MyStruct&amp; in) {return in.a;}); return 0; } </code></pre>
0debug
Why is my CSS not adding what I added to it today on the live server? : <p>I'm trying to get my code to work for my html page for class but the parts on my css that I added today are not showing up. Here is the link to the site and css if you anyone could take a look at it and give me some help! </p> <ul> <li>Carson</li> </ul> <p><a href="http://pages.iu.edu/~ctkeller/i101/css2.html" rel="nofollow noreferrer">http://pages.iu.edu/~ctkeller/i101/css2.html</a></p> <p><a href="http://pages.iu.edu/~ctkeller/i101/css2.css" rel="nofollow noreferrer">http://pages.iu.edu/~ctkeller/i101/css2.css</a></p>
0debug
aggregate function or the GROUP BY clause MSSQL : I want to get the sum per day by its specified date , show the sum and the tenant name on it. It should be like this. Does it have any possible way to construct it right?? ----------------------------------- tenant_id tenant_name Total Amount 123 SAMPLE 37100 ----------------------------------- [enter image description here][1] [1]: https://i.stack.imgur.com/hFFr9.png
0debug
Xcode 9: how to install ios 10 sdk : <p>Given the fact that currently Xcode 9 is beta and the main interest today is getting knowledge of iOS 11 the question is admittedly odd...</p> <p>Is there a way to target iOS 10 as base sdk while working in Xcode 9 beta? Is there need for Apple to package the SDK for Xcode 9 the same way they do for previous OS's in Xc8?</p> <p>Why would one want this? </p> <p>a) The first thing that comes to mind is to use Xcode 9 nice new refactoring tools on a project that involves code that needs changes from iOS 10 to 11, but has currently to run on iOS 10.</p> <p>b) the sake of experimenting..</p>
0debug
PPC_OP(tlbie) { do_tlbie(); RETURN(); }
1threat
In a list of integers, how to subtract a number from one of the elements, if it doesnt meet a condition : <p>I have a list of integers and I want to subtract 26 from any of the elements if they are greater than 27. For example: if one of the list elements was 32, it would return (32-26)=6 because it is greater than 27.</p> <p>So say I had a list of integers list1=[4,34,56,20...] How could I check each value in turn to see if it exceeds 27 and then subtract 26 to form a new list??</p> <p>Thanks :)</p>
0debug
static void RENAME(yuv2yuyv422_1)(SwsContext *c, const uint16_t *buf0, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, enum PixelFormat dstFormat, int flags, int y) { const uint16_t *buf1= buf0; if (uvalpha < 2048) { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2PACKED1(%%REGBP, %5) WRITEYUY2(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); } else { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2PACKED1b(%%REGBP, %5) WRITEYUY2(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither) ); } }
1threat
How to build project sharing "system calls" to bootloader, as members of a class without linker error? : I'm trying to build a solution, where there would be two projects: 'bootloader' (starting after reset and doing smth), and 'mainApplication' getting the control from bootloader. Initially i've just reproduced the example from here: https://visualgdb.com/tutorials/arm/bootloader/ The final part of this tutorial describes "system call" - passing the pointer to some function residing in bootloader to the main application and then making a call to this function from there. The intention is to pass not a pointer to a function, but say pointer to an object of a class. Modified example from tutorial looks like this: **Bootloader:** ``` //sys.h class SysCalls { public: SysCalls(); int sum(int, int); }; //sys.cpp #include "sys.h" SysCalls::SysCalls() { } int SysCalls::sum(int a, int b) { return a + b; } // main.cpp #include <sys.h> ... SysCalls _sys; void *g_Syscalls[] __attribute__((section(".syscalls"))) = { (void *)&_sys }; ```` **Main Application:** ``` //main.cpp #include <sys.h> // the same header as in bootloader extern "C" void *g_Syscalls[]; SysCalls *_sys = (SysCalls*) g_Syscalls[0]; int main(void) { ... int sum = _sys->sum(1, 2); ... ``` I get an linker error: undefined reference to `SysCalls::sum(int, int)' which is predictable, but... Is there any good way to build this, i wonder? some linker config? or should i include sys.cpp to mainApplication also, and make the content not to be included in final binary somehow? Also, looking forward - if talking about simple staff like shown sum function, which uses only stack, it is only a linker issue, but if i want to create a kind of 'system service', say singleton object with some heap usage, then the question would be - if there is any good way to freeze the part of heap used by this object when transferring control from bootloader, where it was created to main Application, which should use it...
0debug
int qemu_uuid_parse(const char *str, QemuUUID *uuid) { unsigned char *uu = &uuid->data[0]; int ret; if (strlen(str) != 36) { return -1; } ret = sscanf(str, UUID_FMT, &uu[0], &uu[1], &uu[2], &uu[3], &uu[4], &uu[5], &uu[6], &uu[7], &uu[8], &uu[9], &uu[10], &uu[11], &uu[12], &uu[13], &uu[14], &uu[15]); if (ret != 16) { return -1; } return 0; }
1threat
static void blk_mig_unlock(void) { qemu_mutex_unlock(&block_mig_state.lock); }
1threat
Expected identifier or '(' before numeric constantATMEGA : I want to connect atmega32 with MMC/SD Card, but I have problem is that : ` #define F_CPU 8000000UL void uart_init(unsigned int BAUD) unsigned long int temp_BAUD;unsigned char F_CPU; temp_BAUD=(F_CPU)/16; temp_BAUD/=BAUD; temp_BAUD--; ` The problem is : **expected identifier or '(' before numeric constant ** Could any tell me what is this problem and how to solve this problem ? Thanks for reading !
0debug
One last function before application closes? (Python) : Ok so look, I'm getting desperate since I've already been all over the internet trying to find the answer to this question. so sorry if this has been answered somewhere else, I couldn't find it just give me the link. So basically I have a python file that is constantly using the ```f.write()``` function to write to another text file, however, the script doesn't stop writing to the file until it's closed manually. This is all fine and dandy, except for the fact that any delay greater than 0.01 doesn't seem to save my edits to the text file, so doing a little bit of investigation, an easy fix is the ```f.close()``` function. So what I need is a line of code that can detect once the script has been stopped, and put out one last function before being fully closed.
0debug
Get list of data types from schema in Apache Spark : <p>I have the following code in Spark-Python to get the list of names from the schema of a DataFrame, which works fine, but how can I get the list of the data types?</p> <pre><code>columnNames = df.schema.names </code></pre> <p>For example, something like: </p> <pre><code>columnTypes = df.schema.types </code></pre> <p>Is there any way to get a separate list of the data types contained in a DataFrame schema?</p>
0debug
CMD: save website as textfile : <p>CMD: save website as Textfile how do I do that?</p> <p>for example from this Website: <a href="http://steamcommunity.com/groups/anomalygroup/memberslistxml/?xml=1" rel="nofollow noreferrer">http://steamcommunity.com/groups/anomalygroup/memberslistxml/?xml=1</a></p> <p>thank you for helping!</p>
0debug
How to disable PyCharm from automatically updating Python interpreter on startup : <p>It seems that PyCharm always updates the connected Python interpreter on startup and also scans and updates all packages if needed. For me this means whenever I open PyCharm there will be updating processes running in background and I have to wait sometimes for as good as a whole minute, which I find quite annoying.</p> <p>So the question is: does there exist any way to disable this automatic update mechanism? It would be best if I can manually update Python interpreter and the packages <em>only if I want to</em>.</p>
0debug
jQuery Select Failed To Change Input Value : <p>I have this jquery inside PHP code :</p> <pre><code>echo '&lt;select id="state" name="state" onchange="document.getElementById(\'state_text_content\').value=this.options[this.selectedIndex].text&gt; '.$list_state.' &lt;/select&gt; &lt;input type="hidden" name="state_text" id="state_text_content" value="" /&gt;'; </code></pre> <p>why onchange function doesn't update <code>#state_text_content</code> value? thank you.</p>
0debug
Set object property key to variable value : <p>I am creating an object dynamically and would like to set a property (also an object) to be the value of a variable. </p> <p>My code:</p> <pre><code>var guid, block, lot, muni, county, owner, prop_loc; guid = 'Some unique value'; //code to set the other variable values here... var menuItem = new MenuItem({ id: 'basic', label: 'Report', onClick: lang.hitch(this, function () { topic.publish('basicReportWidget/reportFromIdentify', { guid : { //set this to the guid string value block: block, lot: lot, muni: muni, county: county, owner: owner, prop_loc: prop_loc, type: 'basic' } }); }) }); </code></pre>
0debug
Read ints recusively from file into array, the second last element always wrong : <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; using namespace std; int fillArray(ifstream&amp; ifs, int array[]){ int cur; int counter = 0; if(ifs&gt;&gt;cur){ counter = fillArray(ifs, array) + 1; array[counter-1] = cur; } return counter; } int main(int argc, const char * argv[]) { int count; int array[] = {0}; ifstream myfile ("/Users/Desktop/example.txt"); count = fillArray(myfile, array); for (int i = 0; i&lt;count; i++){ cout&lt;&lt;array[i]&lt;&lt;endl; } myfile.close(); return 0; } </code></pre> <p>For example, if the input file is "1 2 3 100 19 16 33", the resulted array is "33 7 19 100 3 2 1". if the input file is"1 2 3 4 5", the array will be "5 5 3 2 1". I don't mind ints are filled in reversely, but I don't understand what happened to the second last ints. </p> <p>And this code works fine in VS, it only has problem in xcode. </p>
0debug
how do I access the value in my database using php mvc session? : [I am trying to access the class accountPass][1] [But I don`t seem to understand why the result is false here.][2] [1]: https://i.stack.imgur.com/JBqyU.png [2]: https://i.stack.imgur.com/k6aiJ.png
0debug
How to get a variable from array when getting response from api call? : After successfully logging in for a 3rd party API access, using the following code: $response = Requests::post('https://apidomain.com/v3/account/login/api', $headers, $data); When I print: echo '<pre>'; print_r($response); echo '</pre>'; I get the following: Requests_Response Object ( [body] => {"access_token":"blabla",".issued":"2019-07-30T02:47:14.4326684Z",".expires":"2019-08-01T02:47:14.4326686Z"} [raw] => HTTP/1.1 200 OK etc... Now I want to access the access_token as a variable so that I can pass for further processing. I tried to access like: $access_token=$response[body'] and $access_token=$response[1][body'] Unfortunately nothing worked. Any help will be appreciated.
0debug
Subsetting an R Matrix : <p>in R programming, how do I subset a matrix so that I can skip columns in between? I only know how to do it continuously such as 1:4, but what if I want the first, second, and fourth colum</p>
0debug
void op_mfc0_ebase (void) { T0 = (int32_t)env->CP0_EBase; RETURN(); }
1threat
How to define UUID property in JSON Schema and Open API (OAS) : <p>When using <a href="http://json-schema.org/" rel="noreferrer">JSON Schema</a> and <a href="https://github.com/OAI/OpenAPI-Specification" rel="noreferrer">Open API specification (OAS)</a> to document a REST API, how do I define the <a href="https://en.wikipedia.org/wiki/Universally_unique_identifier" rel="noreferrer">UUID</a> property?</p>
0debug
Query size limits in DynamoDB : <p>I don't get the concept of limits for query/scan in DynamoDb. According to the docs:</p> <blockquote> <p>A single Query operation can retrieve a maximum of 1 MB of data.This limit applies before any FilterExpression is applied to the results.</p> </blockquote> <p>Let's say I have 10k items, 250kb per item, all of them fit query params.</p> <ol> <li>If I run a simple query, I get only 4 items?</li> <li>If I use ProjectionExpression to retrieve only single attribute (1kb in size), will I get 1k items?</li> <li>If I only need to count items (select: 'COUNT'), will it count all items (10k)?</li> </ol>
0debug
static int kvm_arch_sync_sregs(CPUState *cenv) { struct kvm_sregs sregs; int ret; if (cenv->excp_model == POWERPC_EXCP_BOOKE) { return 0; } else { if (!cap_segstate) { return 0; } } ret = kvm_vcpu_ioctl(cenv, KVM_GET_SREGS, &sregs); if (ret) { return ret; } sregs.pvr = cenv->spr[SPR_PVR]; return kvm_vcpu_ioctl(cenv, KVM_SET_SREGS, &sregs); }
1threat
How to static cast throwing function pointer to noexcept in C++17? : <p>C++17 makes <code>noexcept</code> part of a function's type. It also allows implicit conversions from <code>noexcept</code> function pointers to potentially throwing function pointers.</p> <pre><code>void (*ptr_to_noexcept)() noexcept = nullptr; void (*ptr_to_throwing)() = ptr_to_noexcept; // implicit conversion </code></pre> <p><a href="http://eel.is/c++draft/expr.static.cast#7" rel="noreferrer">http://eel.is/c++draft/expr.static.cast#7</a> says that <code>static_cast</code> can perform the inverse of such a conversion.</p> <pre><code>void (*noexcept_again)() noexcept = static_cast&lt;void(*)() noexcept&gt;(ptr_to_throwing); </code></pre> <p>Unfortunately, both GCC and clang tell me otherwise: <a href="https://godbolt.org/z/TgrL7q" rel="noreferrer">https://godbolt.org/z/TgrL7q</a></p> <p>What is the correct way to do this? Are <code>reinterpret_cast</code> and C style cast my only options?</p>
0debug
Aml *aml_shiftright(Aml *arg1, Aml *count) { Aml *var = aml_opcode(0x7A ); aml_append(var, arg1); aml_append(var, count); build_append_byte(var->buf, 0x00); return var; }
1threat
Please help... My app crashed. when open camera ... android 7.0 : Please help... My app crashed. when open camera ... android 7.0 File captureFilePath = new File(cachePath, CommonUtil.getDateTimeForFileName(System.currentTimeMillis())+".jpg"); Uri uri = Uri.fromFile(captureFilePath); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, uri); startActivityForResult(intent, REQUEST_CAPTURE_IMAGE); CAPTURE_IMAGE_PATH = captureFilePath.getAbsolutePath();
0debug
regular expression Python with at least 3 upper cases : <p>I need a regular Expression that Matches a string that mustn't contain digits. The string should have at least 3 upper cases. In addition, the string should contain 6 to 40 chars.</p> <p>Here is my Approach, but it doesnt work as I expect it to:</p> <pre><code>re.findall("\\n(?=(?:[^A-Z]*[A-Z]){3})[^0-9]{6,40}:\\n",text, flags=re.MULTILINE) </code></pre>
0debug
consumer: Cannot connect to amqp://user:**@localhost:5672//: [Errno 111] Connection refused : <p>I am trying to build my airflow using docker and rabbitMQ. I am using rabbitmq:3-management image. And I am able to access rabbitMQ UI, and API.</p> <p>In airflow I am building airflow webserver, airflow scheduler, airflow worker and airflow flower. Airflow.cfg file is used to config airflow.</p> <p>Where I am using <code>broker_url = amqp://user:password@127.0.0.1:5672/</code> and <code>celery_result_backend = amqp://user:password@127.0.0.1:5672/</code></p> <p>My docker compose file is as follows</p> <pre><code>version: '3' services: rabbit1: image: "rabbitmq:3-management" hostname: "rabbit1" environment: RABBITMQ_ERLANG_COOKIE: "SWQOKODSQALRPCLNMEQG" RABBITMQ_DEFAULT_USER: "user" RABBITMQ_DEFAULT_PASS: "password" RABBITMQ_DEFAULT_VHOST: "/" ports: - "5672:5672" - "15672:15672" labels: NAME: "rabbitmq1" webserver: build: "airflow/" hostname: "webserver" restart: always environment: - EXECUTOR=Celery ports: - "8080:8080" depends_on: - rabbit1 command: webserver scheduler: build: "airflow/" hostname: "scheduler" restart: always environment: - EXECUTOR=Celery depends_on: - webserver - flower - worker command: scheduler worker: build: "airflow/" hostname: "worker" restart: always depends_on: - webserver environment: - EXECUTOR=Celery command: worker flower: build: "airflow/" hostname: "flower" restart: always environment: - EXECUTOR=Celery ports: - "5555:5555" depends_on: - rabbit1 - webserver - worker command: flower </code></pre> <p>I am able to build images using docker compose. However, I am not able to connect my airflow scheduler to rabbitMQ. I am getting following error:</p> <blockquote> <p>consumer: Cannot connect to amqp://user:**@localhost:5672//: [Errno 111] Connection refused.</p> </blockquote> <p>I have tried using 127.0.0.1 and localhost both.</p> <p>What I am doing wrong ?</p>
0debug
Randomizing a list in Python : <p>I am wondering if there is a good way to "shake up" a list of items in Python. For example <code>[1,2,3,4,5]</code> might get shaken up / randomized to <code>[3,1,4,2,5]</code> (any ordering equally likely).</p>
0debug
Find min and max of every column for every label in pandas.DataFrame : <p>I have a <code>DataFrame</code> called <code>df</code> and it has 4 columns, like the one presented below: </p> <pre><code>A B C Class 12 13 22 1 8 15 20 1 9 14 25 1 18 9 35 2 5 14 30 2 4 12 28 2 35 87 67 3 35 82 66 3 20 7 32 4 10 8 32 4 22 7 31 4 ... ... ... ... </code></pre> <p>What I want is to find the min and max for every column with respect to the class. In other words, I would like to get a result similar to the one below: </p> <pre><code>Class: 1 A: [8, 12] B: [13, 15] C: [20, 25] Class: 2 A: [4, 18] B: [9, 14] C: [28, 35] Class: 3 A: [35, 35] B: [82, 87] C: [66, 67] ... </code></pre>
0debug
Any way to use CSS Variables in SASS functions? : <p>I have defined a color in my root:</p> <pre><code>:root { --purple: hsl(266, 35%, 70%); } </code></pre> <p>And I'm trying to use it in a SASS function to give it transparency: </p> <pre><code>.purple { background: transparentize(#{"var(--primary-color)"}, 0.7) } </code></pre> <p>Does anyone know of a way to get this to work? Or is it just not possible? </p>
0debug
can i use grid everywhere i want? : <ul class="list-inline col-md-8 col-md-offset-4"> <li class="col-md-3"> <select class="form-control"> <option> Voice over category </option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select> </li> <li class="col-md-3"> <div class="input-group"> <input type="text" class="form-control" placeholder="zip"> <span class="input-group-btn"> <button type="button" class="btn btn-primary"> Find Coaches </button> </span> </div> </li> </ul> can i use grid system like this? i was trying to make those list time side by side but one element goes down.margin wont't work but only position: relatives works but it does not make it responsive. So i used grid system. Is it bad practice?
0debug
std::List, cant access object : Im new to cpp and want to learn about list. When i run my program it compiles fine but i dont get the result im expecting. This gives me the output "Legs: 0 Name: " It should be "Legs 4 Name: dog". Can any one see the problem? As in the comment section, i have tried for over an hour and get get this to work, cant see the problem. //Header file! using namespace std; #ifndef ANIMAL_H #define ANIMAL_H class Animal { public: Animal(); Animal(const Animal& orig); virtual ~Animal(); int _Legs; void SetName(string name); string GetName(); private: string _Name; }; #endif /* ANIMAL_H */ //Animal.cpp Animal::Animal() { } Animal::Animal(const Animal& orig) { } Animal::~Animal() { } string Animal::GetName(){return _Name;} void Animal::SetName(string name){_Name = name;}; //Mainfile! void List() { std::list<Animal> animal_list; Animal temp; temp = Animal(); temp._Legs = 4; temp.SetName("Dog"); animal_list.push_back(temp); for(std::list<Animal>::iterator list_iter = animal_list.begin(); list_iter != animal_list.end(); list_iter++) { std::cout<< "Legs:" << list_iter->_Legs << " Name: " << list_iter->GetName() << endl; } } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { List(); return 0; }
0debug
void ff_vdpau_h264_picture_complete(MpegEncContext *s) { H264Context *h = s->avctx->priv_data; struct vdpau_render_state *render; int i; render = (struct vdpau_render_state *)s->current_picture_ptr->data[0]; assert(render); render->info.h264.slice_count = h->slice_num; if (render->info.h264.slice_count < 1) return; for (i = 0; i < 2; ++i) { int foc = s->current_picture_ptr->field_poc[i]; if (foc == INT_MAX) foc = 0; render->info.h264.field_order_cnt[i] = foc; } render->info.h264.is_reference = (s->current_picture_ptr->reference & 3) ? VDP_TRUE : VDP_FALSE; render->info.h264.frame_num = h->frame_num; render->info.h264.field_pic_flag = s->picture_structure != PICT_FRAME; render->info.h264.bottom_field_flag = s->picture_structure == PICT_BOTTOM_FIELD; render->info.h264.num_ref_frames = h->sps.ref_frame_count; render->info.h264.mb_adaptive_frame_field_flag = h->sps.mb_aff && !render->info.h264.field_pic_flag; render->info.h264.constrained_intra_pred_flag = h->pps.constrained_intra_pred; render->info.h264.weighted_pred_flag = h->pps.weighted_pred; render->info.h264.weighted_bipred_idc = h->pps.weighted_bipred_idc; render->info.h264.frame_mbs_only_flag = h->sps.frame_mbs_only_flag; render->info.h264.transform_8x8_mode_flag = h->pps.transform_8x8_mode; render->info.h264.chroma_qp_index_offset = h->pps.chroma_qp_index_offset[0]; render->info.h264.second_chroma_qp_index_offset = h->pps.chroma_qp_index_offset[1]; render->info.h264.pic_init_qp_minus26 = h->pps.init_qp - 26; render->info.h264.num_ref_idx_l0_active_minus1 = h->pps.ref_count[0] - 1; render->info.h264.num_ref_idx_l1_active_minus1 = h->pps.ref_count[1] - 1; render->info.h264.log2_max_frame_num_minus4 = h->sps.log2_max_frame_num - 4; render->info.h264.pic_order_cnt_type = h->sps.poc_type; render->info.h264.log2_max_pic_order_cnt_lsb_minus4 = h->sps.log2_max_poc_lsb - 4; render->info.h264.delta_pic_order_always_zero_flag = h->sps.delta_pic_order_always_zero_flag; render->info.h264.direct_8x8_inference_flag = h->sps.direct_8x8_inference_flag; render->info.h264.entropy_coding_mode_flag = h->pps.cabac; render->info.h264.pic_order_present_flag = h->pps.pic_order_present; render->info.h264.deblocking_filter_control_present_flag = h->pps.deblocking_filter_parameters_present; render->info.h264.redundant_pic_cnt_present_flag = h->pps.redundant_pic_cnt_present; memcpy(render->info.h264.scaling_lists_4x4, h->pps.scaling_matrix4, sizeof(render->info.h264.scaling_lists_4x4)); memcpy(render->info.h264.scaling_lists_8x8, h->pps.scaling_matrix8, sizeof(render->info.h264.scaling_lists_8x8)); ff_draw_horiz_band(s, 0, s->avctx->height); render->bitstream_buffers_used = 0; }
1threat
VueJS + VUEX + Firebase: Where To Hook Up Firebase? : <p>I would like to integrate <strong>Firebase</strong> in my <strong>Vue.JS</strong> app.</p> <p>I wonder WHERE to put the <strong>references</strong> to Firebase.</p>
0debug
How to Make a Photo Taken Open Up in a New Activity? : <p>I coded when you click the button the camera opens and takes a new picture. I want that picture to turn into an ImageView on a new Activity. So I created the new activity and placed an ImageView on it:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.amy.teacherfilesapp.Upload"&gt; &lt;ImageView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/imageView" android:scaleType="centerCrop" /&gt; &lt;/android.support.constraint.ConstraintLayout&gt; </code></pre> <p>And then on the Main Activity I put(this whole thing applies to <code>btn2</code>so you can ignore btn1 &amp; btn3, thanks):`package com.example.amy.teacherfilesapp;</p> <pre><code>import android.content.Intent; import android.graphics.Bitmap; import android.provider.MediaStore; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.ImageView; public class MainActivity extends AppCompatActivity { Button btn1; Button btn2; Button btn3; ImageView imgTakenPic; private static final int CAM_REQUEST=1313; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btn2 = (Button) findViewById(R.id.drawer_two); imgTakenPic = (ImageView)findViewById(R.id.imageView); btn2.setOnClickListener(new btnTakePhotoClicker()); btn1 = (Button)findViewById(R.id.drawer_one); btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent openCabinet = new Intent(MainActivity.this,MyCabinet.class); startActivity(openCabinet); } }); btn2 =(Button)findViewById(R.id.drawer_two); btn2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent upload = new Intent("android.media.action.IMAGE_CAPTURE"); startActivity(upload); } }); btn3 = (Button)findViewById(R.id.drawer_three); btn3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent settings = new Intent(MainActivity.this, Settings.class); startActivity(settings); } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if(requestCode == CAM_REQUEST){ Bitmap bitmap = (Bitmap) data.getExtras().get("data"); imgTakenPic.setImageBitmap(bitmap); } } class btnTakePhotoClicker implements Button.OnClickListener{ @Override public void onClick(View view) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent,CAM_REQUEST); } } } </code></pre> <p>`</p> <p>This didn't work as it didn't display the image anywhere I could see. </p> <p>I would be very grateful if you could help me. Thanks.</p>
0debug
adding 'lat' and 'lng' to existing array : I have an array for a polygon and it isn't formatted correctly for google maps API. It's a simple javascript solution i'm sure, but I'm new to JS so wondering if you can tell me what I have wrong in the code below. I know i'm close with the code below. ``` let path = [[59.523341487842316, -9.193736158410616], [59.535126839526605, -9.175282560388155], [59.529311101819324, -9.147215925256319], [59.51395167489177, -9.158202253381319], [59.51139973569412, -9.190560422936983], [59.521402457849575, -9.174424253503389], [59.50946015912328, -9.207211576501436]]; path.map ( e => ({lat: e[0], lng: e[1]}) ) console.log(path); // Construct the polygon. var geoFences = new google.maps.Polygon({ paths: path, strokeColor: '#FF0000', strokeOpacity: 0.8, strokeWeight: 2, fillColor: '#FF0000', fillOpacity: 0.35 });``` You can see i'm setting path variable to what I have in terms of x,y coordinates and using .map to try and add proper json and lat lng text. I need the output to look like this: path = [ {lat: 59.523341487842316, lng: -7.193736158410616}, {lat: 59.535126839526605, lng: -7.175282560388155}, etc... ];
0debug
How to indent the button? : <p>I have following SAPUI5 app:</p> <pre><code>[Codepen](https://codepen.io/bifunctor/project/editor/XaOapY#) </code></pre> <p>I would like to indent the query button on the same like from input. </p> <p>How to accomplish that?</p>
0debug
How to check if a string contains a substring and does not in Bash : <p>I am wanting to use a switch/ case statement in bash to check if a file name which is a string contains something but also does not.</p> <p>Here is my case:</p> <pre><code>case "$fileName" in *Failed|!cp*) echo "match" ;; esac </code></pre> <p>But this does not work currently, how can I see if the string matches "Failed" but also does not contain "cp"?</p> <p>It would be great if this could be done in a switch/ case as well</p>
0debug
static void ppc_heathrow_init (int ram_size, int vga_ram_size, const char *boot_device, DisplayState *ds, const char **fd_filename, int snapshot, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { CPUState *env = NULL, *envs[MAX_CPUS]; char buf[1024]; qemu_irq *pic, **heathrow_irqs; nvram_t nvram; m48t59_t *m48t59; int linux_boot, i; unsigned long bios_offset, vga_bios_offset; uint32_t kernel_base, kernel_size, initrd_base, initrd_size; PCIBus *pci_bus; MacIONVRAMState *nvr; int vga_bios_size, bios_size; qemu_irq *dummy_irq; int pic_mem_index, nvram_mem_index, dbdma_mem_index, cuda_mem_index; int ppc_boot_device = boot_device[0]; linux_boot = (kernel_filename != NULL); if (cpu_model == NULL) cpu_model = "default"; for (i = 0; i < smp_cpus; i++) { env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find PowerPC CPU definition\n"); exit(1); } cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); env->osi_call = vga_osi_call; qemu_register_reset(&cpu_ppc_reset, env); register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); envs[i] = env; } if (env->nip < 0xFFF80000) { cpu_abort(env, "G3BW Mac hardware can not handle 1 MB BIOS\n"); } cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); bios_offset = ram_size + vga_ram_size; if (bios_name == NULL) bios_name = BIOS_FILENAME; snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name); bios_size = load_image(buf, phys_ram_base + bios_offset); if (bios_size < 0 || bios_size > BIOS_SIZE) { cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf); exit(1); } bios_size = (bios_size + 0xfff) & ~0xfff; if (bios_size > 0x00080000) { cpu_abort(env, "G3BW Mac hardware can not handle 1 MB BIOS\n"); } cpu_register_physical_memory((uint32_t)(-bios_size), bios_size, bios_offset | IO_MEM_ROM); vga_bios_offset = bios_offset + bios_size; snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_FILENAME); vga_bios_size = load_image(buf, phys_ram_base + vga_bios_offset + 8); if (vga_bios_size < 0) { fprintf(stderr, "qemu: warning: could not load VGA bios '%s'\n", buf); vga_bios_size = 0; } else { phys_ram_base[vga_bios_offset] = 'N'; phys_ram_base[vga_bios_offset + 1] = 'D'; phys_ram_base[vga_bios_offset + 2] = 'R'; phys_ram_base[vga_bios_offset + 3] = 'V'; cpu_to_be32w((uint32_t *)(phys_ram_base + vga_bios_offset + 4), vga_bios_size); vga_bios_size += 8; } vga_bios_size = (vga_bios_size + 0xfff) & ~0xfff; if (linux_boot) { kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_image(kernel_filename, phys_ram_base + kernel_base); if (kernel_size < 0) { cpu_abort(env, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } if (initrd_filename) { initrd_base = INITRD_LOAD_ADDR; initrd_size = load_image(initrd_filename, phys_ram_base + initrd_base); if (initrd_size < 0) { cpu_abort(env, "qemu: could not load initial ram disk '%s'\n", initrd_filename); exit(1); } } else { initrd_base = 0; initrd_size = 0; } ppc_boot_device = 'm'; } else { kernel_base = 0; kernel_size = 0; initrd_base = 0; initrd_size = 0; } isa_mem_base = 0x80000000; isa_mmio_init(0xfe000000, 0x00200000); heathrow_irqs = qemu_mallocz(smp_cpus * sizeof(qemu_irq *)); heathrow_irqs[0] = qemu_mallocz(smp_cpus * sizeof(qemu_irq) * 1); for (i = 0; i < smp_cpus; i++) { switch (PPC_INPUT(env)) { case PPC_FLAGS_INPUT_6xx: heathrow_irqs[i] = heathrow_irqs[0] + (i * 1); heathrow_irqs[i][0] = ((qemu_irq *)env->irq_inputs)[PPC6xx_INPUT_INT]; break; default: cpu_abort(env, "Bus model not supported on OldWorld Mac machine\n"); exit(1); } } if (PPC_INPUT(env) != PPC_FLAGS_INPUT_6xx) { cpu_abort(env, "Only 6xx bus is supported on heathrow machine\n"); exit(1); } pic = heathrow_pic_init(&pic_mem_index, 1, heathrow_irqs); pci_bus = pci_grackle_init(0xfec00000, pic); pci_vga_init(pci_bus, ds, phys_ram_base + ram_size, ram_size, vga_ram_size, vga_bios_offset, vga_bios_size); dummy_irq = i8259_init(NULL); serial_init(0x3f8, dummy_irq[4], serial_hds[0]); for(i = 0; i < nb_nics; i++) { if (!nd_table[i].model) nd_table[i].model = "ne2k_pci"; pci_nic_init(pci_bus, &nd_table[i], -1); } pci_cmd646_ide_init(pci_bus, &bs_table[0], 0); cuda_init(&cuda_mem_index, pic[0x12]); adb_kbd_init(&adb_bus); adb_mouse_init(&adb_bus); nvr = macio_nvram_init(&nvram_mem_index, 0x2000); pmac_format_nvram_partition(nvr, 0x2000); dbdma_init(&dbdma_mem_index); macio_init(pci_bus, 0x0017, 1, pic_mem_index, dbdma_mem_index, cuda_mem_index, nvr, 0, NULL); if (usb_enabled) { usb_ohci_init_pci(pci_bus, 3, -1); } if (graphic_depth != 15 && graphic_depth != 32 && graphic_depth != 8) graphic_depth = 15; m48t59 = m48t59_init(dummy_irq[8], 0xFFF04000, 0x0074, NVRAM_SIZE, 59); nvram.opaque = m48t59; nvram.read_fn = &m48t59_read; nvram.write_fn = &m48t59_write; PPC_NVRAM_set_params(&nvram, NVRAM_SIZE, "HEATHROW", ram_size, ppc_boot_device, kernel_base, kernel_size, kernel_cmdline, initrd_base, initrd_size, 0, graphic_width, graphic_height, graphic_depth); register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL); }
1threat
How to UnBlur Blurry image on touch as square pointer android : What I want to do: > on mouse hover of Blurry image, it shows unblur same image in square shape like following image. (image is completely blur, on mouse hover unblur image shown in square shape) What I done: > I set blur image using following code ([link][1]) img.getDrawable().setColorFilter(0x76ffffff, PorterDuff.Mode.MULTIPLY ); can anyone help me to achieve this! Thank you in advance. [![enter image description here][2]][2] [1]: https://stackoverflow.com/questions/41355433/how-to-apply-different-colour-filters-on-an-image-in-android/41355628#41355628 [2]: https://i.stack.imgur.com/q8mfC.jpg
0debug
Can not use keyword 'await' outside an async function in a custom React hook : <p>I'm trying to create a custom hook, but I keep getting the error for the <code>getToken()</code> function: </p> <blockquote> <p>Can not use keyword 'await' outside an async function</p> </blockquote> <p>How do I get around this issue?</p> <pre class="lang-js prettyprint-override"><code>export const useExistingToken = async () =&gt; { const [existingToken, setExistingToken] = useState('') const [tokenLocallyExists, tokenLocalCheck] = useState() useEffect(() =&gt; { if (!tokenLocallyExists) { const token = await getToken() // issue here setExistingToken(token) } }, []) return [existingToken, tokenLocalCheck] } </code></pre>
0debug
void put_pixels8_xy2_altivec(uint8_t *block, const uint8_t *pixels, int line_size, int h) { POWERPC_TBL_DECLARE(altivec_put_pixels8_xy2_num, 1); #ifdef ALTIVEC_USE_REFERENCE_C_CODE int j; POWERPC_TBL_START_COUNT(altivec_put_pixels8_xy2_num, 1); for (j = 0; j < 2; j++) { int i; const uint32_t a = (((const struct unaligned_32 *) (pixels))->l); const uint32_t b = (((const struct unaligned_32 *) (pixels + 1))->l); uint32_t l0 = (a & 0x03030303UL) + (b & 0x03030303UL) + 0x02020202UL; uint32_t h0 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2); uint32_t l1, h1; pixels += line_size; for (i = 0; i < h; i += 2) { uint32_t a = (((const struct unaligned_32 *) (pixels))->l); uint32_t b = (((const struct unaligned_32 *) (pixels + 1))->l); l1 = (a & 0x03030303UL) + (b & 0x03030303UL); h1 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2); *((uint32_t *) block) = h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL); pixels += line_size; block += line_size; a = (((const struct unaligned_32 *) (pixels))->l); b = (((const struct unaligned_32 *) (pixels + 1))->l); l0 = (a & 0x03030303UL) + (b & 0x03030303UL) + 0x02020202UL; h0 = ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2); *((uint32_t *) block) = h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL); pixels += line_size; block += line_size; } pixels += 4 - line_size * (h + 1); block += 4 - line_size * h; } POWERPC_TBL_STOP_COUNT(altivec_put_pixels8_xy2_num, 1); #else register int i; register vector unsigned char pixelsv1, pixelsv2, pixelsavg; register vector unsigned char blockv, temp1, temp2; register vector unsigned short pixelssum1, pixelssum2, temp3; register const vector unsigned char vczero = (const vector unsigned char)vec_splat_u8(0); register const vector unsigned short vctwo = (const vector unsigned short)vec_splat_u16(2); temp1 = vec_ld(0, pixels); temp2 = vec_ld(16, pixels); pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(0, pixels)); if ((((unsigned long)pixels) & 0x0000000F) == 0x0000000F) { pixelsv2 = temp2; } else { pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(1, pixels)); } pixelsv1 = vec_mergeh(vczero, pixelsv1); pixelsv2 = vec_mergeh(vczero, pixelsv2); pixelssum1 = vec_add((vector unsigned short)pixelsv1, (vector unsigned short)pixelsv2); pixelssum1 = vec_add(pixelssum1, vctwo); POWERPC_TBL_START_COUNT(altivec_put_pixels8_xy2_num, 1); for (i = 0; i < h ; i++) { int rightside = ((unsigned long)block & 0x0000000F); blockv = vec_ld(0, block); temp1 = vec_ld(line_size, pixels); temp2 = vec_ld(line_size + 16, pixels); pixelsv1 = vec_perm(temp1, temp2, vec_lvsl(line_size, pixels)); if (((((unsigned long)pixels) + line_size) & 0x0000000F) == 0x0000000F) { pixelsv2 = temp2; } else { pixelsv2 = vec_perm(temp1, temp2, vec_lvsl(line_size + 1, pixels)); } pixelsv1 = vec_mergeh(vczero, pixelsv1); pixelsv2 = vec_mergeh(vczero, pixelsv2); pixelssum2 = vec_add((vector unsigned short)pixelsv1, (vector unsigned short)pixelsv2); temp3 = vec_add(pixelssum1, pixelssum2); temp3 = vec_sra(temp3, vctwo); pixelssum1 = vec_add(pixelssum2, vctwo); pixelsavg = vec_packsu(temp3, (vector unsigned short) vczero); if (rightside) { blockv = vec_perm(blockv, pixelsavg, vcprm(0, 1, s0, s1)); } else { blockv = vec_perm(blockv, pixelsavg, vcprm(s0, s1, 2, 3)); } vec_st(blockv, 0, block); block += line_size; pixels += line_size; } POWERPC_TBL_STOP_COUNT(altivec_put_pixels8_xy2_num, 1); #endif }
1threat
C# - Upload and rename file via SFTP : <p>In my C# project I have to implement a method that must transfer a file to sftp and then rename the file. Is there a C# or a dll free to add that does this? Thank you</p>
0debug
Undefined index text input php? : <p>i want get text input value from php web file for save values to database, but text input not work with php file. And show this error:</p> <blockquote> <p>Notice: Undefined index: txtUsername in C:/...... line 7 Notice: Undefined index: txtPassword in C:/...... line 8</p> </blockquote> <p>my html:</p> <pre><code>&lt;form action="../Controller/LoginController.php"&gt; &lt;input type="text" id="txtUsername" /&gt; &lt;input type="text" id="txtPassword" /&gt; &lt;input type="submit" name="btnLogin" value="login" /&gt; &lt;/form&gt; </code></pre> <p>my php file:</p> <pre><code>$strUsername = $_POST["txtUsername"]; //line 7 $strPassword = $_POST["txtPassword"]; //line 8 </code></pre>
0debug
How to stop js from running ? : I have seen a video tutorial on Youtbe about [Dynamic Content][1] that when user reaches the bottom of a page ,it automatically loads new div. (Something like facebook homepage). But it just keeps loading & never stop that! I don't know how to stop that. Here's the full code: <!DOCTYPE html> <html> <head> <script> function yHandler(){ // Watch video for line by line explanation of the code // http://www.youtube.com/watch?v=eziREnZPml4 var wrap = document.getElementById('wrap'); var contentHeight = wrap.offsetHeight; var yOffset = window.pageYOffset; var y = yOffset + window.innerHeight; if(y >= contentHeight){ // Ajax call to get more dynamic data goes here wrap.innerHTML += '<div class="newData"></div>'; } var status = document.getElementById('status'); status.innerHTML = contentHeight+" | "+y; } window.onscroll = yHandler; </script> <style> div#status{position:fixed; font-size:24px;} div#wrap{width:800px; margin:0px auto;} div.newData{height:1000px; background:#09F; margin:10px 0px;} </style> </head> <body> <div id="status">0 | 0</div> <div id="wrap"><img src="temp9.jpg"></div> </body> </html> **To test it on your desktop ,plz make sure you have the image with the name of *temp9.jpg*** [1]: https://www.youtube.com/watch?v=eziREnZPml4&index=37&list=PLGlcsQuIFMgJBt-4GDm8ZZpR_nnKPW9g4
0debug
static inline void RENAME(rgb15to16)(const uint8_t *src, uint8_t *dst, long src_size) { register const uint8_t* s=src; register uint8_t* d=dst; register const uint8_t *end; const uint8_t *mm_end; end = s + src_size; #if COMPILE_TEMPLATE_MMX __asm__ volatile(PREFETCH" %0"::"m"(*s)); __asm__ volatile("movq %0, %%mm4"::"m"(mask15s)); mm_end = end - 15; while (s<mm_end) { __asm__ volatile( PREFETCH" 32%1 \n\t" "movq %1, %%mm0 \n\t" "movq 8%1, %%mm2 \n\t" "movq %%mm0, %%mm1 \n\t" "movq %%mm2, %%mm3 \n\t" "pand %%mm4, %%mm0 \n\t" "pand %%mm4, %%mm2 \n\t" "paddw %%mm1, %%mm0 \n\t" "paddw %%mm3, %%mm2 \n\t" MOVNTQ" %%mm0, %0 \n\t" MOVNTQ" %%mm2, 8%0" :"=m"(*d) :"m"(*s) ); d+=16; s+=16; } __asm__ volatile(SFENCE:::"memory"); __asm__ volatile(EMMS:::"memory"); #endif mm_end = end - 3; while (s < mm_end) { register unsigned x= *((const uint32_t *)s); *((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0); d+=4; s+=4; } if (s < end) { register unsigned short x= *((const uint16_t *)s); *((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0); } }
1threat
static void flat_print_int(WriterContext *wctx, const char *key, long long int value) { flat_print_key_prefix(wctx); printf("%s=%lld\n", key, value); }
1threat
Add id's to <p> using javascript or jQuery or Angular : I have a HTML document which is dynamically generated. It has a bunch of <p> tags which has text in it. I am trying to select the <p> when user clicks on that specific text. Unfortunately I am not allowed to add id's to the '<p>' tags which I could use to select the specific block of test. So I need to find a way to dynamically add id's to the <p> tags using javascript or jQuery or angular. I have seen some solutions which uses jQuery .attr("id", "newId") but it needs a selector and I don't know what to use as a selector. Can anyone suggest something.
0debug
static int handle_name_to_path(FsContext *ctx, V9fsPath *dir_path, const char *name, V9fsPath *target) { char buffer[PATH_MAX]; struct file_handle *fh; int dirfd, ret, mnt_id; struct handle_data *data = (struct handle_data *)ctx->private; if (!strcmp(name, ".") || !strcmp(name, "..")) { errno = EINVAL; return -1; } if (dir_path) { dirfd = open_by_handle(data->mountfd, dir_path->data, O_PATH); } else { dirfd = open(rpath(ctx, ".", buffer), O_DIRECTORY); } if (dirfd < 0) { return dirfd; } fh = g_malloc(sizeof(struct file_handle) + data->handle_bytes); fh->handle_bytes = data->handle_bytes; snprintf(buffer, PATH_MAX, "./%s", name); ret = name_to_handle(dirfd, buffer, fh, &mnt_id, 0); if (!ret) { target->data = (char *)fh; target->size = sizeof(struct file_handle) + data->handle_bytes; } else { g_free(fh); } close(dirfd); return ret; }
1threat
Linux grep command with relevant values as outout : Content : 1. Name : Jack Address : Toronto Age : 21 2. Name : Mitchelle Address : Newyork Age : 67 3. Name : John Address : Toronto Age : 33 Command "grep Toronto" gives me -> Address : Toronto Address : Toronto Expected Result: 1. Name : Jack Address : Toronto Age : 21 3. Name : John Address : Toronto Age : 33
0debug
How can I test app on my phone without usb connection with my laptop? : <p>Is there any way I can test my apps on phone without it being connected with usb cable ? I want that because when i plug my phone in laptop it starts charging and draining laptops battery, so I would like to be able to test app on real phone without it being connected to laptop.</p>
0debug
static int i2c_slave_qdev_init(DeviceState *dev) { I2CSlave *s = I2C_SLAVE(dev); I2CSlaveClass *sc = I2C_SLAVE_GET_CLASS(s); return sc->init(s); }
1threat
static void escaped_string(void) { int i; struct { const char *encoded; const char *decoded; int skip; } test_cases[] = { { "\"\\b\"", "\b" }, { "\"\\f\"", "\f" }, { "\"\\n\"", "\n" }, { "\"\\r\"", "\r" }, { "\"\\t\"", "\t" }, { "\"/\"", "/" }, { "\"\\/\"", "/", .skip = 1 }, { "\"\\\\\"", "\\" }, { "\"\\\"\"", "\"" }, { "\"hello world \\\"embedded string\\\"\"", "hello world \"embedded string\"" }, { "\"hello world\\nwith new line\"", "hello world\nwith new line" }, { "\"single byte utf-8 \\u0020\"", "single byte utf-8 ", .skip = 1 }, { "\"double byte utf-8 \\u00A2\"", "double byte utf-8 \xc2\xa2" }, { "\"triple byte utf-8 \\u20AC\"", "triple byte utf-8 \xe2\x82\xac" }, { "'\\b'", "\b", .skip = 1 }, { "'\\f'", "\f", .skip = 1 }, { "'\\n'", "\n", .skip = 1 }, { "'\\r'", "\r", .skip = 1 }, { "'\\t'", "\t", .skip = 1 }, { "'\\/'", "/", .skip = 1 }, { "'\\\\'", "\\", .skip = 1 }, {} }; for (i = 0; test_cases[i].encoded; i++) { QObject *obj; QString *str; obj = qobject_from_json(test_cases[i].encoded, NULL); str = qobject_to_qstring(obj); g_assert(str); g_assert_cmpstr(qstring_get_str(str), ==, test_cases[i].decoded); if (test_cases[i].skip == 0) { str = qobject_to_json(obj); g_assert_cmpstr(qstring_get_str(str), ==, test_cases[i].encoded); qobject_decref(obj); } QDECREF(str); } }
1threat
Ruby on rails: 2 records from diffrent tables in one view : I want to display informations from 2 diffrent tables in one page. For example, I want to show user last name from one table, and url to attached file from the second. How can I refference to the 2nd table in my view?
0debug
static void kzm_init(MachineState *machine) { IMX31KZM *s = g_new0(IMX31KZM, 1); unsigned int ram_size; unsigned int alias_offset; unsigned int i; object_initialize(&s->soc, sizeof(s->soc), TYPE_FSL_IMX31); object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc), &error_abort); object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fatal); if (machine->ram_size > (FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE)) { error_report("WARNING: RAM size " RAM_ADDR_FMT " above max supported, " "reduced to %x", machine->ram_size, FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE); machine->ram_size = FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE; } memory_region_allocate_system_memory(&s->ram, NULL, "kzm.ram", machine->ram_size); memory_region_add_subregion(get_system_memory(), FSL_IMX31_SDRAM0_ADDR, &s->ram); for (i = 0, ram_size = machine->ram_size, alias_offset = 0; (i < 2) && ram_size; i++) { unsigned int size; static const struct { hwaddr addr; unsigned int size; } ram[2] = { { FSL_IMX31_SDRAM0_ADDR, FSL_IMX31_SDRAM0_SIZE }, { FSL_IMX31_SDRAM1_ADDR, FSL_IMX31_SDRAM1_SIZE }, }; size = MIN(ram_size, ram[i].size); ram_size -= size; if (size < ram[i].size) { memory_region_init_alias(&s->ram_alias, NULL, "ram.alias", &s->ram, alias_offset, ram[i].size - size); memory_region_add_subregion(get_system_memory(), ram[i].addr + size, &s->ram_alias); } alias_offset += ram[i].size; } if (nd_table[0].used) { lan9118_init(&nd_table[0], KZM_LAN9118_ADDR, qdev_get_gpio_in(DEVICE(&s->soc.avic), 52)); } if (serial_hds[2]) { serial_mm_init(get_system_memory(), KZM_FPGA_ADDR+0x10, 0, qdev_get_gpio_in(DEVICE(&s->soc.avic), 52), 14745600, serial_hds[2], DEVICE_NATIVE_ENDIAN); } kzm_binfo.ram_size = machine->ram_size; kzm_binfo.kernel_filename = machine->kernel_filename; kzm_binfo.kernel_cmdline = machine->kernel_cmdline; kzm_binfo.initrd_filename = machine->initrd_filename; kzm_binfo.nb_cpus = 1; if (!qtest_enabled()) { arm_load_kernel(&s->soc.cpu, &kzm_binfo); } }
1threat
How to check if a data is present in sql table column where the data re inserted in inverted commas : I have added some data valus as 'a','b','c' (same as this) in sql table column how can i check if a or b or c is present in this table value or not s
0debug
Error during database creation : I am trying to create a new table on a database but i am getting an error which says: **Exception in thread "main" java.sql.SQLSyntaxErrorException: Table/View 'USERPRIVACYDB' does not exist.** Please can someone help me. Thanks.
0debug
static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, void *dst, const int type) { int i, j, count = 0; int last, t; int A, B, L, L2, R, R2; int pos = s->pos; uint32_t crc = s->sc.crc; uint32_t crc_extra_bits = s->extra_sc.crc; int16_t *dst16 = dst; int32_t *dst32 = dst; float *dstfl = dst; const int channel_pad = s->avctx->channels - 2; if(s->samples_left == s->samples) s->one = s->zero = s->zeroes = 0; do{ L = wv_get_value(s, gb, 0, &last); if(last) break; R = wv_get_value(s, gb, 1, &last); if(last) break; for(i = 0; i < s->terms; i++){ t = s->decorr[i].value; if(t > 0){ if(t > 8){ if(t & 1){ A = 2 * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1]; B = 2 * s->decorr[i].samplesB[0] - s->decorr[i].samplesB[1]; }else{ A = (3 * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1]) >> 1; B = (3 * s->decorr[i].samplesB[0] - s->decorr[i].samplesB[1]) >> 1; } s->decorr[i].samplesA[1] = s->decorr[i].samplesA[0]; s->decorr[i].samplesB[1] = s->decorr[i].samplesB[0]; j = 0; }else{ A = s->decorr[i].samplesA[pos]; B = s->decorr[i].samplesB[pos]; j = (pos + t) & 7; } if(type != AV_SAMPLE_FMT_S16){ L2 = L + ((s->decorr[i].weightA * (int64_t)A + 512) >> 10); R2 = R + ((s->decorr[i].weightB * (int64_t)B + 512) >> 10); }else{ L2 = L + ((s->decorr[i].weightA * A + 512) >> 10); R2 = R + ((s->decorr[i].weightB * B + 512) >> 10); } if(A && L) s->decorr[i].weightA -= ((((L ^ A) >> 30) & 2) - 1) * s->decorr[i].delta; if(B && R) s->decorr[i].weightB -= ((((R ^ B) >> 30) & 2) - 1) * s->decorr[i].delta; s->decorr[i].samplesA[j] = L = L2; s->decorr[i].samplesB[j] = R = R2; }else if(t == -1){ if(type != AV_SAMPLE_FMT_S16) L2 = L + ((s->decorr[i].weightA * (int64_t)s->decorr[i].samplesA[0] + 512) >> 10); else L2 = L + ((s->decorr[i].weightA * s->decorr[i].samplesA[0] + 512) >> 10); UPDATE_WEIGHT_CLIP(s->decorr[i].weightA, s->decorr[i].delta, s->decorr[i].samplesA[0], L); L = L2; if(type != AV_SAMPLE_FMT_S16) R2 = R + ((s->decorr[i].weightB * (int64_t)L2 + 512) >> 10); else R2 = R + ((s->decorr[i].weightB * L2 + 512) >> 10); UPDATE_WEIGHT_CLIP(s->decorr[i].weightB, s->decorr[i].delta, L2, R); R = R2; s->decorr[i].samplesA[0] = R; }else{ if(type != AV_SAMPLE_FMT_S16) R2 = R + ((s->decorr[i].weightB * (int64_t)s->decorr[i].samplesB[0] + 512) >> 10); else R2 = R + ((s->decorr[i].weightB * s->decorr[i].samplesB[0] + 512) >> 10); UPDATE_WEIGHT_CLIP(s->decorr[i].weightB, s->decorr[i].delta, s->decorr[i].samplesB[0], R); R = R2; if(t == -3){ R2 = s->decorr[i].samplesA[0]; s->decorr[i].samplesA[0] = R; } if(type != AV_SAMPLE_FMT_S16) L2 = L + ((s->decorr[i].weightA * (int64_t)R2 + 512) >> 10); else L2 = L + ((s->decorr[i].weightA * R2 + 512) >> 10); UPDATE_WEIGHT_CLIP(s->decorr[i].weightA, s->decorr[i].delta, R2, L); L = L2; s->decorr[i].samplesB[0] = L; } } pos = (pos + 1) & 7; if(s->joint) L += (R -= (L >> 1)); crc = (crc * 3 + L) * 3 + R; if(type == AV_SAMPLE_FMT_FLT){ *dstfl++ = wv_get_value_float(s, &crc_extra_bits, L); *dstfl++ = wv_get_value_float(s, &crc_extra_bits, R); dstfl += channel_pad; } else if(type == AV_SAMPLE_FMT_S32){ *dst32++ = wv_get_value_integer(s, &crc_extra_bits, L); *dst32++ = wv_get_value_integer(s, &crc_extra_bits, R); dst32 += channel_pad; } else { *dst16++ = wv_get_value_integer(s, &crc_extra_bits, L); *dst16++ = wv_get_value_integer(s, &crc_extra_bits, R); dst16 += channel_pad; } count++; }while(!last && count < s->max_samples); s->samples_left -= count; if(!s->samples_left){ wv_reset_saved_context(s); if(crc != s->CRC){ av_log(s->avctx, AV_LOG_ERROR, "CRC error\n"); return -1; } if(s->got_extra_bits && crc_extra_bits != s->crc_extra_bits){ av_log(s->avctx, AV_LOG_ERROR, "Extra bits CRC error\n"); return -1; } }else{ s->pos = pos; s->sc.crc = crc; s->sc.bits_used = get_bits_count(&s->gb); if(s->got_extra_bits){ s->extra_sc.crc = crc_extra_bits; s->extra_sc.bits_used = get_bits_count(&s->gb_extra_bits); } } return count * 2; }
1threat
static void bmdma_writeb(void *opaque, uint32_t addr, uint32_t val) { BMDMAState *bm = opaque; PCIIDEState *pci_dev = pci_from_bm(bm); #ifdef DEBUG_IDE printf("bmdma: writeb 0x%02x : 0x%02x\n", addr, val); #endif switch(addr & 3) { case 1: pci_dev->dev.config[MRDMODE] = (pci_dev->dev.config[MRDMODE] & ~0x30) | (val & 0x30); cmd646_update_irq(pci_dev); break; case 2: bm->status = (val & 0x60) | (bm->status & 1) | (bm->status & ~val & 0x06); break; case 3: if (bm->unit == 0) pci_dev->dev.config[UDIDETCR0] = val; else pci_dev->dev.config[UDIDETCR1] = val; break; } }
1threat
How @Repository annotation works internally in spring MVC? : <p>I am working on Spring project and there is a requirement to use stereotype annotations in project. I am trying understand how stereotype annotation @Repository works in Spring MVC application?</p>
0debug
provideRouter and RouterConfig not found in new @angular/router 3.0.0-alpha.3^ : <p>I am migrating an angular2 app to RC2 and trying to use the router's version 3 alpha.</p> <p>I have followed the set up of the <a href="http://plnkr.co/edit/ER0tf8fpGHZiuVWB7Q07?p=preview">plunker given</a> by the <a href="https://angular.io/docs/ts/latest/guide/router.html">angular docs</a> for routing But i keep getting the following errors:</p> <blockquote> <p>/@angular/router/index"' has no exported member 'provideRouter'</p> <p>/@angular/router/index"' has no exported member 'RouterConfig'</p> </blockquote> <p>when trying to use the following imports in my app.router.ts file:</p> <pre><code>import { provideRouter, RouterConfig } from '@angular/router'; </code></pre> <p>I am using typescript in visual studio with commonjs module format.</p> <p>Here are the dependecies from my packages.json</p> <pre><code>"@angular/common": "2.0.0-rc.2", "@angular/compiler": "2.0.0-rc.2", "@angular/core": "2.0.0-rc.2", "@angular/http": "2.0.0-rc.2", "@angular/platform-browser": "2.0.0-rc.2", "@angular/platform-browser-dynamic": "2.0.0-rc.2", "@angular/router": "3.0.0-alpha.3", "@angular/router-deprecated": "2.0.0-rc.2", "@angular/upgrade": "2.0.0-rc.2", "systemjs": "0.19.27", "core-js": "^2.4.0", "reflect-metadata": "^0.1.3", "rxjs": "5.0.0-beta.6", "zone.js": "^0.6.12", "angular2-in-memory-web-api": "0.0.12" </code></pre> <p>Even if I set the angular/route to the npm cdn in my system.config.js like so:</p> <blockquote> <p>'@angular/router': '<a href="https://npmcdn.com/@angular/router@3.0.0-alpha.3">https://npmcdn.com/@angular/router@3.0.0-alpha.3</a>'</p> </blockquote> <p>I still get the error.</p> <p>I even tried using the alpha.4, alpha.5 and latest alpha.6 version.</p> <p>I tried deleting the nodule module folder and forcing the npm install to get new files.</p> <p>QUESTION:</p> <p>Can someone help me figure out why the exported memebers <strong>provideRouter</strong>, <strong>RouterConfig</strong> can not be found?</p> <p>Thanks</p>
0debug
[Python 3]How can I get two functions working together : I'm feerly new to python and is still in the learning fase. I recently tried to write errors to a file witch i managed to do after some research. The problem now is I'm trying to write calculation results to a file, but i can't seem to get the two functions I use to work together... Can someone take a look at my code and help me? I appreciate the help. (as of now have I commented out my function attempt to write the result I get from calculator() to a separat file called "result.txt") import sys import logging WRITE = "w" APPEND = "a" READWRITE = "r+" fileName = "error.txt" fileName2 = "result.txt" logging.basicConfig(filename=fileName, level=logging.ERROR) def main(): checkError() return def calculator(): firstNumber = int(input("Pleas enter a number: ")) secondNumber = int(input("Pleas enter a number: ")) result = firstNumber / secondNumber print(result) return def checkError(): try: calculator() except: error = sys.exc_info()[0] logging.error(msg=error) print("Error logged to:",fileName ) return # def writeResult(): # myFile = open(fileName2, mode= WRITE) # myFile.write() # myFile.close() # return main()
0debug
def get_Min_Squares(n): if n <= 3: return n; res = n for x in range(1,n + 1): temp = x * x; if temp > n: break else: res = min(res,1 + get_Min_Squares(n - temp)) return res;
0debug
void blk_remove_bs(BlockBackend *blk) { BlockDriverState *bs; ThrottleTimers *tt; notifier_list_notify(&blk->remove_bs_notifiers, blk); if (blk->public.throttle_group_member.throttle_state) { tt = &blk->public.throttle_group_member.throttle_timers; bs = blk_bs(blk); bdrv_drained_begin(bs); throttle_timers_detach_aio_context(tt); bdrv_drained_end(bs); } blk_update_root_state(blk); bdrv_root_unref_child(blk->root); blk->root = NULL; }
1threat
Equivalent of return in lua? : <p>I have a loop in lua and when a certain thing happens I want it to start the loop over. However when I do return it just ends the loop. </p> <pre><code>wrong = false while true do if wrong then return end print 'Not wrong' end </code></pre>
0debug
build_append_notify(GArray *device, const char *name, const char *format, int skip, int count) { int i; GArray *method = build_alloc_array(); uint8_t op = 0x14; build_append_nameseg(method, "%s", name); build_append_byte(method, 0x02); for (i = skip; i < count; i++) { GArray *target = build_alloc_array(); build_append_nameseg(target, format, i); assert(i < 256); build_append_notify_target(method, target, i, 1); build_free_array(target); } build_package(method, op, 2); build_append_array(device, method); build_free_array(method); }
1threat
Ruby geting index of a part of an array element : My question is how can I get the index of a part of an array element? For example I have an array like: array = [ username=stackoverflow, password=12345, id= 6] My wish is searching like " id " in that array, and the code returns me index of the " id=6" element( returns me 3). Is that possible in ruby?
0debug
How to securely connect to Cloud SQL from Cloud Run? : <p>How do I connect to the database on Cloud SQL without having to add my credentials file inside the container?</p>
0debug
How can i call JUST ONCE a function when a variable changes its value? c# : <p>Imagine I have an <strong>int count</strong>, and every time it gets changed i want to call the function <strong>DoSomething()</strong> how could i do it?</p> <p>I think i have to use properties somehow (and would like how to know how to do it with a property), but any help will be great.</p>
0debug
How to redirect TensorFlow logging to a file? : <p>I'm using TensorFlow-Slim, which has some useful logging printed out to console by <code>tf.logging</code>. I would like to redirect those loggings to a text file, but couldn't find a way doing so. I looked at the <code>tf_logging.py</code> source code, which exposes the following, but doesn't seem to have the option to write logs to a file. Please let me know if I missed something.</p> <pre><code>__all__ = ['log', 'debug', 'error', 'fatal', 'info', 'warn', 'warning', 'DEBUG', 'ERROR', 'FATAL', 'INFO', 'WARN', 'flush', 'log_every_n', 'log_first_n', 'vlog', 'TaskLevelStatusMessage', 'get_verbosity', 'set_verbosity'] </code></pre>
0debug
Can someone explain Fetch APIs in detail? : <p>Whats the use of Fetch API and what are promises and responses? I heard it is just used for fetching or extracting the data from the server.</p>
0debug
static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn, TCGv r_cond, TCGv r_reg) { unsigned int cond = GET_FIELD_SP(insn, 25, 27), a = (insn & (1 << 29)); target_ulong target = dc->pc + offset; flush_cond(dc, r_cond); gen_cond_reg(r_cond, cond, r_reg); if (a) { gen_branch_a(dc, target, dc->npc, r_cond); dc->is_br = 1; } else { dc->pc = dc->npc; dc->jump_pc[0] = target; dc->jump_pc[1] = dc->npc + 4; dc->npc = JUMP_PC; } }
1threat