problem
stringlengths
26
131k
labels
class label
2 classes
static int max7310_tx(I2CSlave *i2c, uint8_t data) { MAX7310State *s = MAX7310(i2c); uint8_t diff; int line; if (s->len ++ > 1) { #ifdef VERBOSE printf("%s: message too long (%i bytes)\n", __FUNCTION__, s->len); #endif return 1; } if (s->i2c_command_byte) { s->command = data; s->i2c_command_byte = 0; return 0; } switch (s->command) { case 0x01: for (diff = (data ^ s->level) & ~s->direction; diff; diff &= ~(1 << line)) { line = ffs(diff) - 1; if (s->handler[line]) qemu_set_irq(s->handler[line], (data >> line) & 1); } s->level = (s->level & s->direction) | (data & ~s->direction); break; case 0x02: s->polarity = data; break; case 0x03: s->level &= ~(s->direction ^ data); s->direction = data; break; case 0x04: s->status = data; break; case 0x00: break; default: #ifdef VERBOSE printf("%s: unknown register %02x\n", __FUNCTION__, s->command); #endif return 1; } return 0; }
1threat
PHP format multiple entries from textarea regex : <p>I can get the number from a file using Regex and PHP for example:</p> <pre><code>&lt;?PHP $txt='house.1x01.pilot.ws_dvdrip_xvid-fov.mp4'; if ($c=preg_match_all ("/.*?(\\d+).*?(\\d+)/is", $txt, $matches)) { $int1=$matches[1][0]; $int2=$matches[2][0]; print "($int1) ($int2) \n"; } ?&gt; </code></pre> <p>but what i want to do is for instance, enter multiple file names in a text área and convert this:</p> <pre><code>house.1x02.paternity.ws_dvdrip_xvid-fov.mp4 house.1x03.occams_razor.ws_dvdrip_xvid-fov.mp4 house.s04e15.dvdrip.xvid-orpheus.mp4 </code></pre> <p>into this</p> <pre><code>INSERT INTO `tvshow` (`id`, `show_id`, `season`, `episode`, `file`) VALUES (NULL, '18', '1', '2', 'house.1x02.paternity.ws_dvdrip_xvid-fov.mp4'); INSERT INTO `tvshow` (`id`, `show_id`, `season`, `episode`, `file`) VALUES (NULL, '18', '1', '3', 'house.1x03.occams_razor.ws_dvdrip_xvid-fov.mp4'); INSERT INTO `tvshow` (`id`, `show_id`, `season`, `episode`, `file`) VALUES (NULL, '18', '4', '15', 'house.s04e15.dvdrip.xvid-orpheus.mp4'); </code></pre> <p>Format it for SQL, removing the 0 just keeping the 1 2 3, etc. and not 01 02 03 make it easier to copy-paste the query and insert into the database. As there is so many file names, kind of time-consuming doing it one by one.</p> <p>is there any better way to acquire this?</p>
0debug
Ruby regex for chemical formulat subscript/superscript : I want to substitute sub and sup tags into a chemical formula, for example C7[2H]5NaO2, and get as as result: C<sub>7</sub>[<sup>2</sup>H]<sub>5</sub>NaO<sub>2</sub> The numbers inside the tags can be two digit numbers. I know so far that /(\d+) / will match all digits, and /\[(\d+)/ matches the digit after the [, but I don't know how to combine these two. Thanks in advance.
0debug
document.getElementById('input').innerHTML = user_input;
1threat
Removing specific duplicated characters from a string in Python : <p>How i can delete specific duplicated characters from a string only if they goes one after one in Python? For example:</p> <p>A have string</p> <pre><code>string = "Hello _my name is __Alex" </code></pre> <p>I need to delete duplicate _ only if they goes one after one __ and get string like this:</p> <pre><code>string = "Hello _my name is _Alex" </code></pre> <p>If i use set i got this:</p> <pre><code>string = "_yoiHAemnasxl" </code></pre>
0debug
Change specific word in HTML with JavaScript : <p>I want to chane averey word "morr" in the HTML using JavaScript. I'm not allowed to touch the HTML so i cant use span or id. Can anyone help me? Here's the HTML: </p> <h2>Morrhår</h2> <p> Är katten skrämd lägger den morrhåren bakåt, detsamma gör den vid slagsmål för att skydda morrhåren. Om katten är nyfiken vinklar den morrhåren framåt. </p>
0debug
static int get_buffer_internal(AVCodecContext *avctx, AVFrame *frame, int flags) { const AVHWAccel *hwaccel = avctx->hwaccel; int override_dimensions = 1; int ret; if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { if ((ret = av_image_check_size2(avctx->width, avctx->height, avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx)) < 0 || avctx->pix_fmt<0) { av_log(avctx, AV_LOG_ERROR, "video_get_buffer: image parameters invalid\n"); return AVERROR(EINVAL); } if (frame->width <= 0 || frame->height <= 0) { frame->width = FFMAX(avctx->width, AV_CEIL_RSHIFT(avctx->coded_width, avctx->lowres)); frame->height = FFMAX(avctx->height, AV_CEIL_RSHIFT(avctx->coded_height, avctx->lowres)); override_dimensions = 0; } if (frame->data[0] || frame->data[1] || frame->data[2] || frame->data[3]) { av_log(avctx, AV_LOG_ERROR, "pic->data[*]!=NULL in get_buffer_internal\n"); return AVERROR(EINVAL); } } ret = ff_decode_frame_props(avctx, frame); return ret; if (hwaccel) { if (hwaccel->alloc_frame) { ret = hwaccel->alloc_frame(avctx, frame); goto end; } } else avctx->sw_pix_fmt = avctx->pix_fmt; ret = avctx->get_buffer2(avctx, frame, flags); if (ret >= 0) validate_avframe_allocation(avctx, frame); end: if (avctx->codec_type == AVMEDIA_TYPE_VIDEO && !override_dimensions && !(avctx->codec->caps_internal & FF_CODEC_CAP_EXPORTS_CROPPING)) { frame->width = avctx->width; frame->height = avctx->height; } return ret; }
1threat
macro to copy column I, F, G from one worksheet into column A, B and C : really new to VBA, wondering how to write a macro to copy column I, F, G from one worksheet into column A, B and C? any help would be much appreciated. Thanks
0debug
Is a Slack channel id unique across teams? : <p>Is a Slack <a href="https://api.slack.com/types/channel" rel="noreferrer">channel</a>/<a href="https://api.slack.com/types/group" rel="noreferrer">group</a>/<a href="https://api.slack.com/types/im" rel="noreferrer">im</a>/<a href="https://api.slack.com/types/mpim" rel="noreferrer">mpim</a> id unique across different teams? In other words, can two teams have channels with the same id?</p> <p>I read the docs, searched on Google and here on SO, but could not get confirmation if channel IDs are unique or not.</p>
0debug
(c++) I'm curious of the implementation of std::getline() : I'm reading a .txt file with using std::getline. I coded like this, and I became so much curious of the return value of std::getline(). (file is an ifstream variable.) while(!file.eof()) { string line; getline(in,line); cout<<line<<endl; } So, what I want to know is why getline can get all lines in the file. Does getline have an iterator? I want to know how it's file cursor moves.
0debug
Loaded runtime CuDNN library: 5005 (compatibility version 5000) but source was compiled with 5103 (compatibility version 5100) : <p>I've the following error. I'm using a conda installation of tensorflow. I'm struggling to try to use it with my GPU.</p> <p><code> Loaded runtime CuDNN library: 5005 (compatibility version 5000) but source was compiled with 5103 (compatibility version 5100). If using a binary install, upgrade your CuDNN library to match. If building from sources, make sure the library loaded at runtime matches a compatible version specified during compile configuration. F tensorflow/core/kernels/conv_ops.cc:526] Check failed: stream-&gt;parent()-&gt;GetConvolveAlgorithms(&amp;algorithms) Aborted (core dumped) </code></p> <p>which nvcc returns <code>/usr/local/cuda-7.5/bin/nvcc</code></p> <p>nvcc version returns <code>Cuda compilation tools, release 7.5, V7.5.17</code></p> <p>I tried downloading CuDNN v5.1 and did the following but it didn't work either ``` sudo cp lib* /usr/local/cuda-7.5/lib64/ sudo cp include/cudnn.h /usr/local/cuda-7.5/include/ sudo ldconfig</p> <p>```</p> <p>I tried on the other folder too <code> sudo cp lib* /usr/local/cuda/lib64/ sudo cp include/cudnn.h /usr/local/cuda/include/ sudo ldconfig </code></p>
0debug
How to upload a json file with secret keys to Heroku : <p>I'm building a rails app that pulls data from Google Analytics using the Google Api Client Library for Ruby.</p> <p>I'm using OAuth2 and can get everything working in development on a local machine. My issue is that the library uses a downloaded file, <code>client_secrets.json</code>, to store two secret keys.</p> <p><strong>Problem:I'm using Heroku and need a way to get the file to their production servers.</strong> </p> <p>I don't want to add this file to my github repo as the project is public. </p> <p>If there is a way to temporarily add the file to git, push to Heroku, and remove from git that would be fine. My sense is that the keys will be in the commits and very hard to prevent from showing on github. </p> <p><strong>Tried:</strong> As far I can tell you cannot SCP a file to Heroku via a Bash console. I believe when doing this you get a new Dyno and anything you add would be only be temporary. I tried this but couldn't get SCP to work properly, so not 100% sure about this.</p> <p><strong>Tried:</strong> I looked at storing the JSON file in an Environment or Config Var, but couldn't get it to work. This seems like the best way to go if anyone has a thought. I often run into trouble when ruby converts JSON into a string or hash, so possibly I just need guidance here. </p> <p><strong>Tried:</strong> Additionally I've tried to figure out a way to just pull out the keys from the JSON file, put them into Config Vars, and add the JSON file to git. I can't figure out a way to put <code>ENV["KEY"]</code> in a JSON file though. </p> <hr> <p><strong>Example Code</strong> The <a href="https://developers.google.com/api-client-library/ruby/auth/web-app" rel="noreferrer">Google library has a method</a> that loads the JSON file to create an authorization client. The client then fetches a token (or gives a authorization url).</p> <pre><code>client_secrets = Google::APIClient::ClientSecrets.load('client_secrets.json') auth_client = client_secrets.to_authorization </code></pre> <p>** note that the example on google page doesn't show a filename because it uses a default ENV Var thats been set to a path</p> <p>I figure this would all be a lot easier if the <code>ClientSecrets.load()</code> method would just take JSON, a string or a hash which could go into a Config Var. </p> <p>Unfortunately it always seems to want a file path. When I feed it JSON, a string or hash, it blows up. <a href="http://ar.zu.my/how-to-store-private-key-files-in-heroku/" rel="noreferrer">I've seen someone get around the issue with a p12 key here</a>, but I'm not sure how to replicate that in my situation. </p> <p><strong>Haven't Tried:</strong> My only other though (aside from moving to AWS) is to put the JSON file on AWS and have rails pull it when needed. I'm not sure if this can be done on the fly or if the file would need to be pulled down when the rails server boots up. Seems like too much work, but at this point I've spend a few hours on it so ready to attempt. </p> <p>This is the specific controller I am working on: <a href="https://github.com/dladowitz/slapafy/blob/master/app/controllers/welcome_controller.rb" rel="noreferrer">https://github.com/dladowitz/slapafy/blob/master/app/controllers/welcome_controller.rb</a></p>
0debug
Why does my code result in a compiler error? : <p>I'm trying to understand why my code causes an compiler error. Can someone explain it to me?</p> <pre><code>public class Employee { private String name; public Employee(String name) { this.name = name; } } public class Test { public static void main(String[] JavaLatte) { Employee e = new Employee("JavaDeveloper"); System.out.println("Emp Name : " + e.name); } } </code></pre>
0debug
static CharDriverState *text_console_init(ChardevVC *vc) { CharDriverState *chr; QemuConsole *s; unsigned width = 0; unsigned height = 0; chr = g_malloc0(sizeof(CharDriverState)); if (vc->has_width) { width = vc->width; } else if (vc->has_cols) { width = vc->cols * FONT_WIDTH; } if (vc->has_height) { height = vc->height; } else if (vc->has_rows) { height = vc->rows * FONT_HEIGHT; } trace_console_txt_new(width, height); if (width == 0 || height == 0) { s = new_console(NULL, TEXT_CONSOLE, 0); } else { s = new_console(NULL, TEXT_CONSOLE_FIXED_SIZE, 0); s->surface = qemu_create_displaysurface(width, height); } if (!s) { g_free(chr); return NULL; } s->chr = chr; chr->opaque = s; chr->chr_set_echo = text_console_set_echo; chr->explicit_be_open = true; if (display_state) { text_console_do_init(chr, display_state); } return chr; }
1threat
how to write this function in python? : i have a list ,for example ,like this jj = [[2,3],[3,4],[1,2],[4,7],[1,7]] every element is [x,y], if element A and B in jj follow this: A[1]==B[0], then this 2 element will fuse into a single element C=[a[0],b[1]],so after that,the length of new jj reduced by one. please write a program check if the input list jj after several times inner element fusion, is there same element exist in new jj? if yes, return True else return False.
0debug
To import Sass files, you first need to install node-sass : <p>Running create-react-app, I get the error in my create-react-app application:</p> <blockquote> <p>To import Sass files, you first need to install node-sass. Run <code>npm install node-sass</code> or <code>yarn add node-sass</code> inside your workspace.</p> </blockquote> <p>I do have node-sass installed. </p> <p>package.json:</p> <pre><code> "devDependencies": { "node-sass": "^4.13.0" } </code></pre> <p>project node_modules folder:</p> <p><a href="https://i.stack.imgur.com/VcL3X.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VcL3X.png" alt="enter image description here"></a></p> <p>I've uninstalled, reinstalled, updated, cleaned cache, etc. How do I fix?</p>
0debug
Pyreverse complaining even after having Graphviz : <p>I want to be able to save the output in PNG and have installed Graphviz. Still it complains saying Graphviz is not installed:</p> <blockquote> <p>The output format 'output.png' is currently not available. Please install 'Graphviz' to have other output formats than 'dot' or 'vcg'.</p> </blockquote>
0debug
How to receive parameters in GET request : I am tried to implement search filter using Querydsl. my search filter functionality is working fine.But I tested this by giving hard coded values in controller. Now I want to take that search parameter from Angular application. In get request how to receive this parameters from angular`sClientAcctId, sAcctDesc,sInvestigatorName,sClientDeptId` Can any one please suggest me how to do that? **AccountController.java** @GetMapping("/findAccountData") public ResponseEntity<List<Tuple>> populateGridViews(String sClientAcctId, String sAcctDesc,String sInvestigatorName,String sClientDeptId) throws Exception { return ResponseEntity.ok(accService.populateGridViews(sClientAcctId, sAcctDesc,sInvestigatorName,sClientDeptId)); }
0debug
Uploading a pdf a file ina folder in a database and saving the path in table : I am using Sql compact 3.5, I have some 500 .pdf files to upload in my database, i want to upload the .pdf file in a folder in database and save the path of that .pdf in a table containing the Products list for which this .pdf files belongs to.., I have a scenario that where a single .pdf file belongs many products. Can you please suggest me that how can I achieve uploading one .pdf for many products and downloading the same .pdf when I search many products...(C#, Windows application)
0debug
Display time in 24 format : I wanted to get date and time in this format. "2017-02-05 20:20:03". I used following code to get the result. But it didn't work out. System.out.println(new SimpleDateFormat("yyyy-mm-dd HH:mm:ss").format(new Date()));e
0debug
python One hot encoding for comma separated values : <p>my dataset looks like this</p> <pre><code>Type Date Issues M 1 Jan 2019 A12,B56,C78 K 2 May 2019 B56, D90 M 5 Feb 2019 A12,K31 K 3 Jan 2019 A12,B56,K31,F66 . . . </code></pre> <p>I want to do one hot encoding for the issues column</p> <p>so my dataset looks like this</p> <pre><code>Type Date A12 B56 C78 D90 E88 K31 F66 M 1 Jan 2019 1 1 1 0 0 0 0 K 2 May 2019 0 1 0 1 0 0 0 M 5 Feb 2019 1 0 0 0 0 1 0 K 3 Jan 2019 1 1 0 0 0 1 1 . . . </code></pre> <p>How to do that in Python</p>
0debug
Revert Values (Array) : I would like to understand this code that I found online, I just started learning to programm with arrays which have saved me a lot of lines of code, but I do not understand this code at all // C++ Program to reverse an array #include <iostream> using namespace std; int main(){ int input[500], output[500], count, i; cout << "Enter number of elements in array\n"; cin >> count; cout << "Enter " << count << " numbers \n"; for(i = 0; i < count; i++){ cin >> input[i]; } // Copy numbers from inputArray to outputArray in // reverse order for(i = 0; i < count; i++){ output[i] = input[count-i-1]; } // Print Reversed array cout << "Reversed Array\n"; for(i = 0; i < count; i++){ cout << output[i] << " "; } return 0; } The part where it says that it copies the input array to output array in reverse really confuses me, I do not understand how it reverts the values. for(i = 0; i < count; i++){ output[i] = input[count-i-1]; } Could anyone explain me how that part works?
0debug
Is the most recent AWSALB cookie required? (AWS ELB Application Load Balancer) : <h2>Observations</h2> <p>When using an Amazon ELB <em>Application Load Balancer</em> and working with <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html#sticky-sessions" rel="noreferrer">Sticky Sessions</a> the load balancer inserts a cookie named <code>AWSALB</code> in the first request. To let the next request stick to the same target node (EC2 instance) the cookie should be included in that request. When doing so, it seems that the load balancer inserts a different cookie value in the response to the 2nd request. When including this new cookie value on the 3rd request, we get yet a new cookie value in the response. And so forth…</p> <p>(This is different from how <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-sticky-sessions.html" rel="noreferrer">Sticky Sessions works with the Classic Load Balancer</a> where the cookie is named <code>AWSELB</code> and retains its value until discarded by the client or the load balancer.)</p> <p>The reason the <code>AWSALB</code> cookie changes value all the time seems to be (as stated by the <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html#sticky-sessions" rel="noreferrer">docs</a>):</p> <blockquote> <p>The name of the cookie is AWSALB. The contents of these cookies are encrypted using a rotating key. You cannot decrypt or modify load balancer-generated cookies.</p> </blockquote> <p>So even though the contents of the cookie might be the same, we cannot tell.</p> <h2>Question</h2> <p>The question is whether a request to the load balancer must <em>always</em> include the most recently received value of the <code>AWSALB</code> cookie or if it ok to send some previously received value (from the same sticky session, of course).</p> <p>If this is a requirement the AWS ELB Application Load Balancer would not be able to serve a client that performs multiple parallel requests (after having received the first <code>AWSALB</code> cookie) but only clients that performs all requests in a sequential fashion (one at a time).</p> <p>Can anybody shed some light on this?</p>
0debug
Activate function based on URL rather than click : <p>I have a toggle function that scrolls the page to a section and opens a tab, based on a click on the left side nav (based the id of the link):</p> <pre><code>&lt;script&gt; $(document).ready(function(){ //Hide (Collapse) the toggle containers on load $(".toggle_container3").hide(); //Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state) $(".trigger3").click(function(){ $(this).toggleClass("active").next().slideToggle("slow"); return false; //Prevent the browser jump to the link anchor }).first().click() }); &lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $("#over_left a").click(function(){ var id = $(this).attr("href"); $(id).addClass("active").next().show("slow"); }) }); &lt;/script&gt; </code></pre> <p>Instead of the click being the trigger, I'd like the same loaded URL be the trigger. So, if <a href="https://www.sea.edu/sea_research/climate_change#news" rel="nofollow noreferrer">https://www.sea.edu/sea_research/climate_change#news</a> would also scroll to the News tab and open it (change the class to active) just like the link on the page does. It can be the same tab ID each time - for now only one tab on each page needs to have this treatment.</p> <p>I don't know what to search for, but something like:</p> <pre><code> $("URL#news").onload{function() </code></pre>
0debug
void virtio_scsi_common_realize(DeviceState *dev, Error **errp, HandleOutput ctrl, HandleOutput evt, HandleOutput cmd) { VirtIODevice *vdev = VIRTIO_DEVICE(dev); VirtIOSCSICommon *s = VIRTIO_SCSI_COMMON(dev); int i; virtio_init(vdev, "virtio-scsi", VIRTIO_ID_SCSI, sizeof(VirtIOSCSIConfig)); if (s->conf.num_queues <= 0 || s->conf.num_queues > VIRTIO_PCI_QUEUE_MAX) { error_setg(errp, "Invalid number of queues (= %" PRId32 "), " "must be a positive integer less than %d.", s->conf.num_queues, VIRTIO_PCI_QUEUE_MAX); return; } s->cmd_vqs = g_malloc0(s->conf.num_queues * sizeof(VirtQueue *)); s->sense_size = VIRTIO_SCSI_SENSE_SIZE; s->cdb_size = VIRTIO_SCSI_CDB_SIZE; s->ctrl_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE, ctrl); s->event_vq = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE, evt); for (i = 0; i < s->conf.num_queues; i++) { s->cmd_vqs[i] = virtio_add_queue(vdev, VIRTIO_SCSI_VQ_SIZE, cmd); } if (s->conf.iothread) { virtio_scsi_set_iothread(VIRTIO_SCSI(s), s->conf.iothread); } }
1threat
Trying to create a image slider without jquery : So trying to get this image slider to work without jquery. using font awesome icons as my next and previous buttons.When i change the value of the imgCounter variable the image changes however i cant get it to work properly. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> var $= function(id){ return document.getElementById(id); } var imgCounter=0; var next = function(){ if(imgCounter<6){ imgCounter++; } else{ imgCounter=0; } } window.onload=function(){ // where image will display var imageNode = $('display'); var slideNode=$('slides'); // gathers all the images in an array var slides = document.getElementsByClassName('img'); `` //to target a specific index imgCounter= imgCounter% slides.length; var image= slides[imgCounter]; //to switch the current photo with the next one in the array imageNode.src=image.src; $('right').onclick= next; }; <!-- language: lang-html --> <section id="slider"> <img id="display" src=""> <i id="left"class="fa fa-arrow-left fa-4x"aria-hidden="true" ></i> <i id="right" class="fa fa-arrow-right fa-4x" aria-hidden="true"></i> <div id="slides"> <img class="img" src="images/20anniversary-large.png"> <img class="img"src= "images/53rd.jpg"> <img class="img"src="images/Award.png"> <img class="img"src="images/rotator-03-lg.jpg"> <img class="img"src= "images/rotator01lg.jpg"> <img class="img"src="images/rotator-02-lg.jpg"> </div> </div> </section> <!-- end snippet -->
0debug
Custom Authentication in ASP.Net-Core : <p>I am working on a web app that needs to integrate with an existing user database. I would still like to use the <code>[Authorize]</code> attributes, but I don't want to use the Identity framework. If I did want to use the Identity framework I would add something like this in the startup.cs file:</p> <pre><code>services.AddIdentity&lt;ApplicationUser, IdentityRole&gt;(options =&gt; { options.Password.RequireNonLetterOrDigit = false; }).AddEntityFrameworkStores&lt;ApplicationDbContext&gt;() .AddDefaultTokenProviders(); </code></pre> <p>I'm assuming I have to add something else there, and then create some kind of class that implements a specific interface? Can somebody point me in the right direction? I'm using RC1 of of asp.net 5 right now.</p>
0debug
static int get_physical_address_code(CPUState *env, target_phys_addr_t *physical, int *prot, target_ulong address, int is_user) { target_ulong mask; unsigned int i; if ((env->lsu & IMMU_E) == 0) { *physical = address; *prot = PAGE_EXEC; return 0; } for (i = 0; i < 64; i++) { switch ((env->itlb_tte[i] >> 61) & 3) { default: case 0x0: mask = 0xffffffffffffe000ULL; break; case 0x1: mask = 0xffffffffffff0000ULL; break; case 0x2: mask = 0xfffffffffff80000ULL; break; case 0x3: mask = 0xffffffffffc00000ULL; break; } if (env->dmmuregs[1] == (env->itlb_tag[i] & 0x1fff) && (address & mask) == (env->itlb_tag[i] & mask) && (env->itlb_tte[i] & 0x8000000000000000ULL)) { if ((env->itlb_tte[i] & 0x4) && is_user) { if (env->immuregs[3]) env->immuregs[3] = 2; env->immuregs[3] |= (is_user << 3) | 1; env->exception_index = TT_TFAULT; #ifdef DEBUG_MMU printf("TFAULT at 0x%" PRIx64 "\n", address); #endif return 1; } *physical = ((env->itlb_tte[i] & mask) | (address & ~mask)) & 0x1ffffffe000ULL; *prot = PAGE_EXEC; return 0; } } #ifdef DEBUG_MMU printf("TMISS at 0x%" PRIx64 "\n", address); #endif env->immuregs[6] = (address & ~0x1fffULL) | (env->dmmuregs[1] & 0x1fff); env->exception_index = TT_TMISS; return 1; }
1threat
Unable to resolve the issue : While running the application, its throwing an exception of unable to create bean for service class though I have @Service annotation on my Service Interface. I have included the context-component-scan-base-package too but still it is unable to scan my service class package. Even If I place my @Service Annotation on my Service class implementation instead of my Service class interface, it gives the same error. There is a problem in component scanning or with the autowiring of service class. Please help This is the error that pops up **Error** org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'medicalController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.bhargav.mim.service.MedicalService com.bhargav.mim.rest.web.api.controller.MedicalController.medicalService; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.bhargav.mim.service.MedicalService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:293) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1186) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475) org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:706) org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762) org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482) org.springframework.web.servlet.FrameworkServlet.configureAndRefreshWebApplicationContext(FrameworkServlet.java:658) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:624) org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:672) org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:543) org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:484) org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:136) javax.servlet.GenericServlet.init(GenericServlet.java:158) org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445) org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115) org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637) org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run(Thread.java:748) MedicalController.java **Controller class:** package com.bhargav.mim.rest.web.api.controller; import com.bhargav.mim.entity.Inventory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.bhargav.mim.service.MedicalService; import java.util.List; @Controller public class MedicalController { @Autowired private MedicalService medicalService; @RequestMapping(value = "/CompleteInventory", method = {RequestMethod.GET}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public List<Inventory> getAllInventory(){ return this.medicalService.getAllInventory(); } @RequestMapping("/productName/{productName}") @ResponseBody public List<Inventory> searchByName(@PathVariable("productName") String productName){ return medicalService.searchByName(productName); } @RequestMapping("/productName/{productID}") @ResponseBody public List<Inventory> searchByName(@PathVariable("productID") int productID){ return medicalService.searchByID(productID); } @RequestMapping(value = "/addInventory", method = {RequestMethod.POST}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public void addInventory(@RequestParam int productId, @RequestParam String productName, @RequestParam int productPrice, @RequestParam int productQuantity, @RequestParam String productCategory) throws Exception { Inventory inventory = new Inventory(); inventory.setProductId(productId); inventory.setProductName(productName); inventory.setProductCategory(productCategory); inventory.setProductPrice(productPrice); inventory.setProductQuantity(productQuantity); this.medicalService.addInventory(inventory); } @RequestMapping(value = "/update", method = {RequestMethod.POST}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public void updateCustomerRule(@RequestParam String productName, @RequestParam Double productPrice, @RequestParam int productQuantity, @RequestParam String productCategory, @PathVariable int productId) throws Exception { Inventory inventory = new Inventory(); this.medicalService.updateInventory(inventory); } @RequestMapping(value = "/delete/{productId}", method = {RequestMethod.DELETE}, produces = {MediaType.APPLICATION_JSON_VALUE}, consumes = {MediaType.APPLICATION_JSON_VALUE}) @ResponseBody public void deleteInventory(@PathVariable("productId") int productId) throws Exception { this.medicalService.deleteInventory(productId); } @RequestMapping("/productNameQueryBased/{productName}") @ResponseBody public List<Inventory> findByName(@PathVariable("productName") String productName){ return medicalService.findByName(productName); } @RequestMapping("/productNameQueryBased/{productID}") @ResponseBody public List<Inventory> findByName(@PathVariable("productID") int productID){ return medicalService.findByID(productID); } } **Service Interface** package com.bhargav.mim.service; import com.bhargav.mim.entity.Inventory; import org.springframework.stereotype.Service; import javax.transaction.Transactional; import java.util.List; @Service public interface MedicalService { List<Inventory> getAllInventory(); List<Inventory> searchByID(int productID); void addInventory(Inventory inventory); List<Inventory> searchByName(String productName); void updateInventory(Inventory inventory); void deleteInventory(int productID); List<Inventory> findByID(int productID); List<Inventory> findByName(String productName); } **Service Class Impl** package com.bhargav.mim.service.Impl; import com.bhargav.mim.dao.MedicalRepository; import com.bhargav.mim.dao.MedicalRepositoryQueryBased; import com.bhargav.mim.entity.Inventory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import com.bhargav.mim.service.MedicalService; import org.springframework.stereotype.Service; import java.util.List; public class MedicalServiceImpl implements MedicalService { @Autowired private MedicalRepository medicalRepository; @Autowired private MedicalRepositoryQueryBased medicalRepositoryQueryBased; public List<Inventory> getAllInventory() { return (List<Inventory>) this.medicalRepository.findAll(); } public List<Inventory> searchByID(int productID) { return this.medicalRepository.findByProductId(productID); } public void addInventory(Inventory inventory) { this.medicalRepository.save(inventory); } public List<Inventory> searchByName(String productName) { return this.medicalRepository.findByProductName(productName); } public void updateInventory(Inventory inventory) { Inventory savedInventory = this.medicalRepository.findOne(inventory.getProductId()); BeanUtils.copyProperties(inventory, savedInventory); this.medicalRepository.delete(inventory.getProductId()); this.medicalRepository.save(inventory); } public void deleteInventory(int productID){ this.medicalRepository.delete(productID); } public List<Inventory> findByName(String productName) { return this.medicalRepositoryQueryBased.findByProductName(productName); } public List<Inventory> findByID(int productID) { return this.medicalRepositoryQueryBased.findByProductId(productID); } } **project-context.xml** <beans xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd" xmlns:jpa="http://www.springframework.org/schema/data/jpa" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"> <!-- <context:component-scan base-package="org.product" /> --> <context:component-scan base-package="com.bhargav.mim"> </context:component-scan> <mvc:annotation-driven /> <tx:annotation-driven /> <bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource"> <property value="org.postgresql.Driver" name="driverClassName" /> <property value="jdbc:postgresql://localhost/testdb" name="url" /> <property value="testuser" name="username" /> </bean> <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"> <!-- THIS IS WHERE THE MODELS ARE --> <property name="packagesToScan" value="com.bhargav.mim.entity" /> <property name="dataSource" ref="dataSource" /> <property name="jpaVendorAdapter"> <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"> <property name="showSql" value="true" /> <property name="generateDdl" value="true" /> <property name="databasePlatform" value="org.hibernate.dialect.PostgreSQLDialect" /> </bean> </property> <property name="jpaProperties"> <value> hibernate.cache.provider_class=org.hibernate.cache.EhCacheProvider hibernate.cache.use_second_level_cache=true </value> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"> <property name="entityManagerFactory" ref="entityManagerFactory" /> </bean> <jpa:repositories base-package="com.bhargav.mim.dao" /> <!-- <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="annotatedClasses"> <list> <value>org.product.entity.Product</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop> <prop key="hibernate.hbm2ddl.auto">create-drop</prop> <prop key="hibernate.show_sql">true</prop> <prop key="hibernate.current_session_context_class">thread</prop> </props> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> --> </beans> **web.xml** <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:project-context.xml</param-value> <param-value>classpath*:serviceContext.xml</param-value> <param-value>classpath*:persistenceContext.xml</param-value> <param-value>classpath*:entityContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>appServlet</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:project-context.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>appServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
0debug
generics vs viewset in django rest framework, how to prefer which one to use? : <p>How to prefer which one of generics and viewset to use? in other words when should I use generics and when should i use viewset for building api. I know that it does the same thing, but viewset has routers, so in what situation generics is better then viewset?</p>
0debug
Dart Multiple Constructors : <p>Is it really not possible to create multiple constructors for a class in dart?</p> <p>in my Player Class, If I have this constructor</p> <pre><code>Player(String name, int color) { this._color = color; this._name = name; } </code></pre> <p>Then I try to add this constructor:</p> <pre><code>Player(Player another) { this._color = another.getColor(); this._name = another.getName(); } </code></pre> <p>I get the following error: </p> <blockquote> <p>The default constructor is already defined.</p> </blockquote> <p>I'm not looking for a workaround by creating one Constructor with a bunch of non required arguments. </p> <p>Is there a nice way to solve this?</p>
0debug
Viewing a web page in Android : <p>I'm trying to get this web page and extract the list of android apps in the background:</p> <p><a href="https://play.google.com/store/account?purchaseFilter=apps" rel="nofollow noreferrer">https://play.google.com/store/account?purchaseFilter=apps</a></p> <p>The page requires a log-in in order to view it, so how do I do it? I can't find any tutorials on the web about this.</p>
0debug
int ff_xvmc_field_start(MpegEncContext*s, AVCodecContext *avctx) { struct xvmc_pixfmt_render *last, *next, *render = (struct xvmc_pixfmt_render*)s->current_picture.data[2]; const int mb_block_count = 4 + (1 << s->chroma_format); assert(avctx); if (!render || render->magic_id != AV_XVMC_RENDER_MAGIC || !render->data_blocks || !render->mv_blocks){ av_log(avctx, AV_LOG_ERROR, "Render token doesn't look as expected.\n"); return -1; } render->picture_structure = s->picture_structure; render->flags = s->first_field ? 0 : XVMC_SECOND_FIELD; if (render->filled_mv_blocks_num) { av_log(avctx, AV_LOG_ERROR, "Rendering surface contains %i unprocessed blocks.\n", render->filled_mv_blocks_num); return -1; } if (render->total_number_of_mv_blocks < 1 || render->total_number_of_data_blocks < mb_block_count) { av_log(avctx, AV_LOG_ERROR, "Rendering surface doesn't provide enough block structures to work with.\n"); return -1; } if (render->total_number_of_mv_blocks < 1 || render->total_number_of_data_blocks < mb_block_count) { av_log(avctx, AV_LOG_ERROR, "Rendering surface doesn't provide enough block structures to work with.\n"); return -1; } render->p_future_surface = NULL; render->p_past_surface = NULL; switch(s->pict_type) { case FF_I_TYPE: return 0; case FF_B_TYPE: next = (struct xvmc_pixfmt_render*)s->next_picture.data[2]; if (!next) return -1; if (next->magic_id != AV_XVMC_RENDER_MAGIC) return -1; render->p_future_surface = next->p_surface; case FF_P_TYPE: last = (struct xvmc_pixfmt_render*)s->last_picture.data[2]; if (!last) last = render; if (last->magic_id != AV_XVMC_RENDER_MAGIC) return -1; render->p_past_surface = last->p_surface; return 0; } return -1; }
1threat
Event Time and Watermarks can u explain it : I am new to flink. and trying to learn the Event Time and Watermarks section (without success so far). https://ci.apache.org/projects/flink/flink-docs-release-1.4/dev/event_time.html#event-time-and-watermarks can you explain what is it watermarks, what is solves? the example is not clear to me thanks.
0debug
OpenCV !_src.empty() in function 'cvtColor' error : <p>I am trying to do a basic colour conversion in python however I can't seem to get past the below error. I have re-installed python, opencv and tried on both python 3.4.3 (latest) and python 2.7 (which is on my Mac).</p> <p>I installed opencv using python's package manager opencv-python. </p> <p>Here is the code that fails:</p> <pre><code>frame = cv2.imread('frames/frame%d.tiff' % count) frame_HSV= cv2.cvtColor(frame,cv2.COLOR_RGB2HSV) </code></pre> <p>This is the error message:</p> <pre><code>cv2.error: OpenCV(3.4.3) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.cpp:181: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor' </code></pre>
0debug
How can i convert days names to dates of the current month? : <p>I have an array of days in a month excluding friday and sunday as they aren't inculded in policy, i want to convert the array of days names to the dates of the current month but when i convert it is in incorrect format because it shows for different month <a href="https://i.stack.imgur.com/gTQ3u.png" rel="nofollow noreferrer">enter image description here</a></p>
0debug
Do While Loop menu in C++ : <p>I'm having trouble with this do-while loop menu for a program I'm working on for school. I've checked, and as far as I'm concerned I have written the code correctly. However, when testing, if I type 'y' or 'n' the result is the same: the menu streaming down 100's of times non stop until I exit the program. Any idea on what I'm doing wrong and how I can get it to display the menu properly every time? Thanks in advance. </p> <pre><code>#include &lt;iostream&gt; #include &lt;iomanip&gt; #include &lt;string&gt; #include "CashRegister.h" #include "InventoryItem.h" using namespace std; int main() { // Variables int selection, numUnits, cont; double price; // Use the first constructor for the first item InventoryItem item1; item1.setCost(5.0); item1.setDescription("Adjustable Wrench"); item1.setUnits(10); // Use the second constructor for the second item InventoryItem item2("Screwdriver"); item2.setCost(3.0); item2.setUnits(20); // Use the third constructor for the remaining items InventoryItem item3("Pliers", 7.0, 35); InventoryItem item4("Ratchet", 10.0, 10); InventoryItem item5("Socket Wrench", 15.0, 7); do { cout &lt;&lt; "#\t" &lt;&lt; "Item\t\t\t" &lt;&lt; "qty on Hand" &lt;&lt; endl; cout &lt;&lt; "------------------------------------------------------------------" &lt;&lt; endl; cout &lt;&lt; "1\t" &lt;&lt; item1.getDescription() &lt;&lt; "\t" &lt;&lt; setw(3) &lt;&lt; item1.getUnits() &lt;&lt; endl; cout &lt;&lt; "2\t" &lt;&lt; item2.getDescription() &lt;&lt; "\t\t" &lt;&lt; setw(3) &lt;&lt; item2.getUnits() &lt;&lt; endl; cout &lt;&lt; "3\t" &lt;&lt; item3.getDescription() &lt;&lt; "\t\t\t" &lt;&lt; setw(3) &lt;&lt; item3.getUnits() &lt;&lt; endl; cout &lt;&lt; "4\t" &lt;&lt; item4.getDescription() &lt;&lt; "\t\t\t" &lt;&lt; setw(3) &lt;&lt; item4.getUnits() &lt;&lt; endl; cout &lt;&lt; "5\t" &lt;&lt; item5.getDescription() &lt;&lt; "\t\t" &lt;&lt; setw(3) &lt;&lt; item5.getUnits() &lt;&lt; endl; cout &lt;&lt; "Which item above is being purchased? "; cin &gt;&gt; selection; // Validate the selection while (selection &lt; 1 || selection &gt; 5) { cout &lt;&lt; "Error, please make a valid item selection: "; cin &gt;&gt; selection; } cout &lt;&lt; "How many units? "; cin &gt;&gt; numUnits; // Validate the quantity of units to make sure it isn't a negative value while (numUnits &lt; 0) { cout &lt;&lt; "Error, please enter a valid quantity: "; cin &gt;&gt; numUnits; } // Use a switch statement to figure out which cost to pull switch (selection) { case 1: {price = item1.getCost(); item1.changeUnits(numUnits); } break; case 2: {price = item2.getCost(); item2.changeUnits(numUnits); } break; case 3: {price = item3.getCost(); item3.changeUnits(numUnits); } break; case 4: {price = item4.getCost(); item4.changeUnits(numUnits); } break; case 5: {price = item5.getCost(); item5.changeUnits(numUnits); } break; } // Create a CashRegister object for this particular selection CashRegister transaction(price, numUnits); // Display the totals cout &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; setprecision(2); cout &lt;&lt; "Subtotal: $" &lt;&lt; transaction.getSubtotal() &lt;&lt; endl; cout &lt;&lt; "Sales Tax: $" &lt;&lt; transaction.getSalesTax() &lt;&lt; endl; cout &lt;&lt; "Total: $" &lt;&lt; transaction.getPurchaseTotal() &lt;&lt; endl; // Find out if the user wants to purchase another item cout &lt;&lt; "Do you want to purchase another item? Enter y/n: "; cin &gt;&gt; cont; } while (cont != 'n' &amp;&amp; cont != 'N'); system("pause"); return 0; </code></pre> <p>}</p>
0debug
pg_dump: [archiver (db)] query failed: ERROR: permission denied for relation abouts : <p>I'm trying to dump my pg db but got these errors please suggest</p> <pre><code>pg_dump: [archiver (db)] query failed: ERROR: permission denied for relation abouts pg_dump: [archiver (db)] query was: LOCK TABLE public.abouts IN ACCESS SHARE MODE </code></pre>
0debug
static void load_symbols(struct elfhdr *hdr, int fd) { unsigned int i, nsyms; struct elf_shdr sechdr, symtab, strtab; char *strings; struct syminfo *s; struct elf_sym *syms; lseek(fd, hdr->e_shoff, SEEK_SET); for (i = 0; i < hdr->e_shnum; i++) { if (read(fd, &sechdr, sizeof(sechdr)) != sizeof(sechdr)) return; #ifdef BSWAP_NEEDED bswap_shdr(&sechdr); #endif if (sechdr.sh_type == SHT_SYMTAB) { symtab = sechdr; lseek(fd, hdr->e_shoff + sizeof(sechdr) * sechdr.sh_link, SEEK_SET); if (read(fd, &strtab, sizeof(strtab)) != sizeof(strtab)) return; #ifdef BSWAP_NEEDED bswap_shdr(&strtab); #endif goto found; } } return; found: s = malloc(sizeof(*s)); syms = malloc(symtab.sh_size); if (!syms) return; s->disas_strtab = strings = malloc(strtab.sh_size); if (!s->disas_strtab) return; lseek(fd, symtab.sh_offset, SEEK_SET); if (read(fd, syms, symtab.sh_size) != symtab.sh_size) return; nsyms = symtab.sh_size / sizeof(struct elf_sym); i = 0; while (i < nsyms) { #ifdef BSWAP_NEEDED bswap_sym(syms + i); #endif if (syms[i].st_shndx == SHN_UNDEF || syms[i].st_shndx >= SHN_LORESERVE || ELF_ST_TYPE(syms[i].st_info) != STT_FUNC) { nsyms--; if (i < nsyms) { syms[i] = syms[nsyms]; } continue; } #if defined(TARGET_ARM) || defined (TARGET_MIPS) syms[i].st_value &= ~(target_ulong)1; #endif i++; } syms = realloc(syms, nsyms * sizeof(*syms)); qsort(syms, nsyms, sizeof(*syms), symcmp); lseek(fd, strtab.sh_offset, SEEK_SET); if (read(fd, strings, strtab.sh_size) != strtab.sh_size) return; s->disas_num_syms = nsyms; #if ELF_CLASS == ELFCLASS32 s->disas_symtab.elf32 = syms; s->lookup_symbol = lookup_symbolxx; #else s->disas_symtab.elf64 = syms; s->lookup_symbol = lookup_symbolxx; #endif s->next = syminfos; syminfos = s; }
1threat
PassWord Validation : @"^(?=.*[0-9]+.*)(?=.*[a-zA-Z]+.*)[0-9a-zA-Z]{6,}$" Hi, I am using this regular expression for password validation, which gives one upper case, one lowercase and a number, but what I want is a special character in it but it should optional but above mentioned must be mandatory Thanks in advance
0debug
aio_write_done(void *opaque, int ret) { struct aio_ctx *ctx = opaque; struct timeval t2; gettimeofday(&t2, NULL); if (ret < 0) { printf("aio_write failed: %s\n", strerror(-ret)); return; } if (ctx->qflag) { return; } t2 = tsub(t2, ctx->t1); print_report("wrote", &t2, ctx->offset, ctx->qiov.size, ctx->qiov.size, 1, ctx->Cflag); qemu_io_free(ctx->buf); free(ctx); }
1threat
static int find_pte64 (mmu_ctx_t *ctx, int h, int rw) { return _find_pte(ctx, 1, h, rw); }
1threat
Are there any way to make implementation for abstact class which is multipely inheriting from other abstract classes in c++? : I have two 'interface' classes : AbstractAccess and AbstractPrint, and AbstractRun class inheriting from them and using their methods. Also I have two implementation of interfaces: Accessor for AbstractAccess and Print for Abstract Print #include <iostream> using namespace std; class AbstractAccess { public: virtual string access (void) = 0; }; class AbstractPrint { public: virtual void print (string) = 0; }; class AbstractRun : virtual public AbstractAccess, virtual public AbstractPrint { public: void run (void) { print(access()); } }; class Accessor : virtual public AbstractAccess { public: string access (void){ return name; } void setName(string name) { this->name = name; } private: string name; }; class Print: public virtual AbstractPrint { public: void print (string s) { cout << s << endl; } }; Are there any ways to cast interfaces in AbstractRun to their implementations or to create implementation class Run that will only use AbstractRun's 'run' method but with implemented interfaces?
0debug
removing space in between photos : <p>I want to remove all the space (padding if any) in between 4 photos and to be in full width of the browser without space. I tried many things including setting the padding to 0 but, I got success to a certain extent, still I get tiny white space between photos. Do anyone have idea what this white space occurs even when padding is set to 0.</p> <pre><code> &lt;!DOCTYPE html&gt; &lt;html lang="en" class="no-js"&gt; &lt;head&gt; &lt;script&gt; /* Modernizr 2.6.2 (Custom Build) | MIT &amp; BSD * Build: http://modernizr.com/download/#-touch-shiv-cssclasses-teststyles-prefixes-load */ ;window.Modernizr=function(a,b,c){function w(a){j.cssText=a}function x(a,b){return w(m.join(a+";")+(b||""))}function y(a,b){return typeof a===b}function z(a,b){return!!~(""+a).indexOf(b)}function A(a,b,d){for(var e in a){var f=b[a[e]];if(f!==c)return d===!1?a[e]:y(f,"function")?f.bind(d||b):f}return!1}var d="2.6.2",e={},f=!0,g=b.documentElement,h="modernizr",i=b.createElement(h),j=i.style,k,l={}.toString,m=" -webkit- -moz- -o- -ms- ".split(" "),n={},o={},p={},q=[],r=q.slice,s,t=function(a,c,d,e){var f,i,j,k,l=b.createElement("div"),m=b.body,n=m||b.createElement("body");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),l.appendChild(j);return f=["&amp;#173;",'&lt;style id="s',h,'"&gt;',a,"&lt;/style&gt;"].join(""),l.id=h,(m?l:n).innerHTML+=f,n.appendChild(l),m||(n.style.background="",n.style.overflow="hidden",k=g.style.overflow,g.style.overflow="hidden",g.appendChild(n)),i=c(l,a),m?l.parentNode.removeChild(l):(n.parentNode.removeChild(n),g.style.overflow=k),!!i},u={}.hasOwnProperty,v;!y(u,"undefined")&amp;&amp;!y(u.call,"undefined")?v=function(a,b){return u.call(a,b)}:v=function(a,b){return b in a&amp;&amp;y(a.constructor.prototype[b],"undefined")},Function.prototype.bind||(Function.prototype.bind=function(b){var c=this;if(typeof c!="function")throw new TypeError;var d=r.call(arguments,1),e=function(){if(this instanceof e){var a=function(){};a.prototype=c.prototype;var f=new a,g=c.apply(f,d.concat(r.call(arguments)));return Object(g)===g?g:f}return c.apply(b,d.concat(r.call(arguments)))};return e}),n.touch=function(){var c;return"ontouchstart"in a||a.DocumentTouch&amp;&amp;b instanceof DocumentTouch?c=!0:t(["@media (",m.join("touch-enabled),("),h,")","{#modernizr{top:9px;position:absolute}}"].join(""),function(a){c=a.offsetTop===9}),c};for(var B in n)v(n,B)&amp;&amp;(s=B.toLowerCase(),e[s]=n[B](),q.push((e[s]?"":"no-")+s));return e.addTest=function(a,b){if(typeof a=="object")for(var d in a)v(a,d)&amp;&amp;e.addTest(d,a[d]);else{a=a.toLowerCase();if(e[a]!==c)return e;b=typeof b=="function"?b():b,typeof f!="undefined"&amp;&amp;f&amp;&amp;(g.className+=" "+(b?"":"no-")+a),e[a]=b}return e},w(""),i=k=null,function(a,b){function k(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x&lt;style&gt;"+b+"&lt;/style&gt;",d.insertBefore(c.lastChild,d.firstChild)}function l(){var a=r.elements;return typeof a=="string"?a.split(" "):a}function m(a){var b=i[a[g]];return b||(b={},h++,a[g]=h,i[h]=b),b}function n(a,c,f){c||(c=b);if(j)return c.createElement(a);f||(f=m(c));var g;return f.cache[a]?g=f.cache[a].cloneNode():e.test(a)?g=(f.cache[a]=f.createElem(a)).cloneNode():g=f.createElem(a),g.canHaveChildren&amp;&amp;!d.test(a)?f.frag.appendChild(g):g}function o(a,c){a||(a=b);if(j)return a.createDocumentFragment();c=c||m(a);var d=c.frag.cloneNode(),e=0,f=l(),g=f.length;for(;e&lt;g;e++)d.createElement(f[e]);return d}function p(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return r.shivMethods?n(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&amp;&amp;("+l().join().replace(/\w+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(r,b.frag)}function q(a){a||(a=b);var c=m(a);return r.shivCSS&amp;&amp;!f&amp;&amp;!c.hasCSS&amp;&amp;(c.hasCSS=!!k(a,"article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}mark{background:#FF0;color:#000}")),j||p(a,c),a}var c=a.html5||{},d=/^&lt;|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,e=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,f,g="_html5shiv",h=0,i={},j;(function(){try{var a=b.createElement("a");a.innerHTML="&lt;xyz&gt;&lt;/xyz&gt;",f="hidden"in a,j=a.childNodes.length==1||function(){b.createElement("a");var a=b.createDocumentFragment();return typeof a.cloneNode=="undefined"||typeof a.createDocumentFragment=="undefined"||typeof a.createElement=="undefined"}()}catch(c){f=!0,j=!0}})();var r={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,supportsUnknownElements:j,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:q,createElement:n,createDocumentFragment:o};a.html5=r,q(b)}(this,b),e._version=d,e._prefixes=m,e.testStyles=t,g.className=g.className.replace(/(^|\s)no-js(\s|$)/,"$1$2")+(f?" js "+q.join(" "):""),e}(this,this.document),function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&amp;&amp;g(l.readyState)&amp;&amp;(u.r=o=1,!q&amp;&amp;h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&amp;&amp;m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&amp;&amp;y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&amp;&amp;(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&amp;&amp;(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&amp;&amp;h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&amp;&amp;!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&amp;&amp;"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&amp;&amp;!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&amp;&amp;(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f&lt;d;f++)g=a[f].split("="),(e=z[g.shift()])&amp;&amp;(c=e(c,g));for(f=0;f&lt;b;f++)c=x[f](c);return c}function g(a,e,f,g,h){var i=b(a),j=i.autoCallback;i.url.split(".").pop().split("?").shift(),i.bypass||(e&amp;&amp;(e=d(e)?e:e[a]||e[g]||e[a.split("/").pop().split("?")[0]]),i.instead?i.instead(a,e,f,g,h):(y[i.url]?i.noexec=!0:y[i.url]=1,f.load(i.url,i.forceCSS||!i.forceJS&amp;&amp;"css"==i.url.split(".").pop().split("?").shift()?"c":c,i.noexec,i.attrs,i.timeout),(d(e)||d(j))&amp;&amp;f.load(function(){k(),e&amp;&amp;e(i.origUrl,h,g),j&amp;&amp;j(i.origUrl,h,g),y[i.url]=2})))}function h(a,b){function c(a,c){if(a){if(e(a))c||(j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}),g(a,j,b,0,h);else if(Object(a)===a)for(n in m=function(){var b=0,c;for(c in a)a.hasOwnProperty(c)&amp;&amp;b++;return b}(),a)a.hasOwnProperty(n)&amp;&amp;(!c&amp;&amp;!--m&amp;&amp;(d(j)?j=function(){var a=[].slice.call(arguments);k.apply(this,a),l()}:j[n]=function(a){return function(){var b=[].slice.call(arguments);a&amp;&amp;a.apply(this,b),l()}}(k[n])),g(a[n],j,b,n,h))}else!c&amp;&amp;l()}var h=!!a.test,i=a.load||a.both,j=a.callback||f,k=j,l=a.complete||f,m,n;c(h?a.yep:a.nope,!!i),i&amp;&amp;c(i)}var i,j,l=this.yepnope.loader;if(e(a))g(a,0,l,0);else if(w(a))for(i=0;i&lt;a.length;i++)j=a[i],e(j)?g(j,0,l,0):w(j)?B(j):Object(j)===j&amp;&amp;h(j,l);else Object(a)===a&amp;&amp;h(a,l)},B.addPrefix=function(a,b){z[a]=b},B.addFilter=function(a){x.push(a)},B.errorTimeout=1e4,null==b.readyState&amp;&amp;b.addEventListener&amp;&amp;(b.readyState="loading",b.addEventListener("DOMContentLoaded",A=function(){b.removeEventListener("DOMContentLoaded",A,0),b.readyState="complete"},0)),a.yepnope=k(),a.yepnope.executeStack=h,a.yepnope.injectJs=function(a,c,d,e,i,j){var k=b.createElement("script"),l,o,e=e||B.errorTimeout;k.src=a;for(o in d)k.setAttribute(o,d[o]);c=j?h:c||f,k.onreadystatechange=k.onload=function(){!l&amp;&amp;g(k.readyState)&amp;&amp;(l=1,c(),k.onload=k.onreadystatechange=null)},m(function(){l||(l=1,c(1))},e),i?k.onload():n.parentNode.insertBefore(k,n)},a.yepnope.injectCss=function(a,c,d,e,g,i){var e=b.createElement("link"),j,c=i?h:c||f;e.href=a,e.rel="stylesheet",e.type="text/css";for(j in d)e.setAttribute(j,d[j]);g||(n.parentNode.insertBefore(e,n),m(c,0))}}(this,document),Modernizr.load=function(){yepnope.apply(window,[].slice.call(arguments,0))}; &lt;/script&gt; &lt;style type="text/css"&gt; /* */ .grid { /* padding: 20px 20px 100px 20px;*/ padding: 0px 0px 0px 0px; /*max-width: 1300px;*/ max-width: 100%; /* margin: 0 auto; */ margin: 0px 0px 0px 0px; !important list-style: none; text-align: center; } .grid li { display: inline-block; width: 24.75%; margin: 0px 0px 0px 0px; padding: 0px; text-align: left; position: relative; } .grid figure { margin: 0; position: relative; } .grid figure img { max-width: 100%; display: block; position: relative; } .grid figcaption { position: absolute; top: 0; left: 0; padding: 20px; background: #2c3f52; color: #ed4e6e; } .grid figcaption h3 { margin: 0; padding: 0; color: #fff; } .grid figcaption span:before { content: 'by '; } .grid figcaption a { text-align: center; padding: 5px 10px; border-radius: 2px; display: inline-block; background: #ed4e6e; color: #fff; } /* Caption Style 4 */ .cs-style-4 li { -webkit-perspective: 1700px; -moz-perspective: 1700px; perspective: 1700px; -webkit-perspective-origin: 0 50%; -moz-perspective-origin: 0 50%; perspective-origin: 0 50%; } .cs-style-4 figure { -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; transform-style: preserve-3d; } .cs-style-4 figure &gt; div { overflow: hidden; } .cs-style-4 figure img { -webkit-transition: -webkit-transform 0.4s; -moz-transition: -moz-transform 0.4s; transition: transform 0.4s; } .no-touch .cs-style-4 figure:hover img, .cs-style-4 figure.cs-hover img { -webkit-transform: translateX(25%); -moz-transform: translateX(25%); -ms-transform: translateX(25%); transform: translateX(25%); } .cs-style-4 figcaption { height: 100%; width: 50%; opacity: 0; -webkit-backface-visibility: hidden; -moz-backface-visibility: hidden; backface-visibility: hidden; -webkit-transform-origin: 0 0; -moz-transform-origin: 0 0; transform-origin: 0 0; -webkit-transform: rotateY(-90deg); -moz-transform: rotateY(-90deg); transform: rotateY(-90deg); -webkit-transition: -webkit-transform 0.4s, opacity 0.1s 0.3s; -moz-transition: -moz-transform 0.4s, opacity 0.1s 0.3s; transition: transform 0.4s, opacity 0.1s 0.3s; } .no-touch .cs-style-4 figure:hover figcaption, .cs-style-4 figure.cs-hover figcaption { opacity: 1; -webkit-transform: rotateY(0deg); -moz-transform: rotateY(0deg); transform: rotateY(0deg); -webkit-transition: -webkit-transform 0.4s, opacity 0.1s; -moz-transition: -moz-transform 0.4s, opacity 0.1s; transition: transform 0.4s, opacity 0.1s; } .cs-style-4 figcaption a { position: absolute; bottom: 20px; right: 20px; } @media screen and (max-width: 31.5em) { .grid { /*padding: 10px 10px 100px 10px;*/ padding: 0px 0px 0px 0px; } .grid li { width: 100%; min-width: 300px; } } *, *:after, *:before { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } body, html { font-size: 100%; padding: 0; margin: 0;} /* Clearfix hack by Nicolas Gallagher: http://nicolasgallagher.com/micro-clearfix-hack/ */ .clearfix:before, .clearfix:after { content: " "; display: table; } .clearfix:after { clear: both; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="container demo-3"&gt; &lt;ul class="grid cs-style-4"&gt; &lt;li&gt; &lt;figure&gt; &lt;div&gt;&lt;img src="images/5.png" alt="img05"&gt;&lt;/div&gt; &lt;figcaption&gt; &lt;h3&gt;Safari&lt;/h3&gt; &lt;span&gt;Jacob Cummings&lt;/span&gt; &lt;a href="http://dribbble.com/shots/1116775-Safari"&gt;Take a look&lt;/a&gt; &lt;/figcaption&gt; &lt;/figure&gt; &lt;/li&gt; &lt;li&gt; &lt;figure&gt; &lt;div&gt;&lt;img src="images/6.png" alt="img06"&gt;&lt;/div&gt; &lt;figcaption&gt; &lt;h3&gt;Game Center&lt;/h3&gt; &lt;span&gt;Jacob Cummings&lt;/span&gt; &lt;a href="http://dribbble.com/shots/1118904-Game-Center"&gt;Take a look&lt;/a&gt; &lt;/figcaption&gt; &lt;/figure&gt; &lt;/li&gt; &lt;li&gt; &lt;figure&gt; &lt;div&gt;&lt;img src="images/2.png" alt="img02"&gt;&lt;/div&gt; &lt;figcaption&gt; &lt;h3&gt;Music&lt;/h3&gt; &lt;span&gt;Jacob Cummings&lt;/span&gt; &lt;a href="http://dribbble.com/shots/1115960-Music"&gt;Take a look&lt;/a&gt; &lt;/figcaption&gt; &lt;/figure&gt; &lt;/li&gt; &lt;li&gt; &lt;figure&gt; &lt;div&gt;&lt;img src="images/4.png" alt="img04"&gt;&lt;/div&gt; &lt;figcaption&gt; &lt;h3&gt;Settings&lt;/h3&gt; &lt;span&gt;Jacob Cummings&lt;/span&gt; &lt;a href="http://dribbble.com/shots/1116685-Settings"&gt;Take a look&lt;/a&gt; &lt;/figcaption&gt; &lt;/figure&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;&lt;!-- /container --&gt; &lt;script&gt; /** Used Only For Touch Devices **/ ( function( window ) { // for touch devices: add class cs-hover to the figures when touching the items if( Modernizr.touch ) { // classie.js https://github.com/desandro/classie/blob/master/classie.js // class helper functions from bonzo https://github.com/ded/bonzo function classReg( className ) { return new RegExp("(^|\\s+)" + className + "(\\s+|$)"); } // classList support for class management // altho to be fair, the api sucks because it won't accept multiple classes at once var hasClass, addClass, removeClass; if ( 'classList' in document.documentElement ) { hasClass = function( elem, c ) { return elem.classList.contains( c ); }; addClass = function( elem, c ) { elem.classList.add( c ); }; removeClass = function( elem, c ) { elem.classList.remove( c ); }; } else { hasClass = function( elem, c ) { return classReg( c ).test( elem.className ); }; addClass = function( elem, c ) { if ( !hasClass( elem, c ) ) { elem.className = elem.className + ' ' + c; } }; removeClass = function( elem, c ) { elem.className = elem.className.replace( classReg( c ), ' ' ); }; } function toggleClass( elem, c ) { var fn = hasClass( elem, c ) ? removeClass : addClass; fn( elem, c ); } var classie = { // full names hasClass: hasClass, addClass: addClass, removeClass: removeClass, toggleClass: toggleClass, // short names has: hasClass, add: addClass, remove: removeClass, toggle: toggleClass }; // transport if ( typeof define === 'function' &amp;&amp; define.amd ) { // AMD define( classie ); } else { // browser global window.classie = classie; } [].slice.call( document.querySelectorAll( 'ul.grid &gt; li &gt; figure' ) ).forEach( function( el, i ) { el.querySelector( 'figcaption &gt; a' ).addEventListener( 'touchstart', function(e) { e.stopPropagation(); }, false ); el.addEventListener( 'touchstart', function(e) { classie.toggle( this, 'cs-hover' ); }, false ); } ); } })( window ); &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
0debug
Kindly explain why in following example the output is 'undefined'? : <p>Why the value of outcome is 'undefined' in the following example? Kindly explain someone how is this calculated? </p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script&gt; var foo = { bar: function() { return this.baz; }, baz: 1 }; var a = (function(){ return typeof arguments[0](); })(foo.bar); console.log(a); &lt;/script&gt;</code></pre> </div> </div> </p> <blockquote> <p>Note: I've been through following link and it doesn't explain this example. There is no constructor function here ... <a href="https://stackoverflow.com/questions/20279484/how-to-access-the-correct-this-inside-a-callback">How to access the correct `this` inside a callback?</a></p> </blockquote>
0debug
static void vaapi_encode_h264_write_pps(PutBitContext *pbc, VAAPIEncodeContext *ctx) { VAEncPictureParameterBufferH264 *vpic = ctx->codec_picture_params; VAAPIEncodeH264Context *priv = ctx->priv_data; VAAPIEncodeH264MiscSequenceParams *mseq = &priv->misc_sequence_params; vaapi_encode_h264_write_nal_header(pbc, NAL_PPS, 3); ue(vpic_var(pic_parameter_set_id)); ue(vpic_var(seq_parameter_set_id)); u(1, vpic_field(entropy_coding_mode_flag)); u(1, mseq_var(bottom_field_pic_order_in_frame_present_flag)); ue(mseq_var(num_slice_groups_minus1)); if (mseq->num_slice_groups_minus1 > 0) { ue(mseq_var(slice_group_map_type)); av_assert0(0 && "slice groups not supported"); } ue(vpic_var(num_ref_idx_l0_active_minus1)); ue(vpic_var(num_ref_idx_l1_active_minus1)); u(1, vpic_field(weighted_pred_flag)); u(2, vpic_field(weighted_bipred_idc)); se(vpic->pic_init_qp - 26, pic_init_qp_minus26); se(mseq_var(pic_init_qs_minus26)); se(vpic_var(chroma_qp_index_offset)); u(1, vpic_field(deblocking_filter_control_present_flag)); u(1, vpic_field(constrained_intra_pred_flag)); u(1, vpic_field(redundant_pic_cnt_present_flag)); u(1, vpic_field(transform_8x8_mode_flag)); u(1, vpic_field(pic_scaling_matrix_present_flag)); if (vpic->pic_fields.bits.pic_scaling_matrix_present_flag) { av_assert0(0 && "scaling matrices not supported"); } se(vpic_var(second_chroma_qp_index_offset)); vaapi_encode_h264_write_trailing_rbsp(pbc); }
1threat
int bdrv_inactivate_all(void) { BlockDriverState *bs = NULL; BdrvNextIterator it; int ret = 0; int pass; for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { aio_context_acquire(bdrv_get_aio_context(bs)); } for (pass = 0; pass < 2; pass++) { for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { ret = bdrv_inactivate_recurse(bs, pass); if (ret < 0) { goto out; } } } out: for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { aio_context_release(bdrv_get_aio_context(bs)); } return ret; }
1threat
Ionic Jasmine : env.stopOnSpecFailure is not a function after compiled successfully : <p>Using Ionic with jasmine-karma, while run test, getting success compile but in jasmine dashboard getting empty screen with error in console.</p> <p>Following tutorial : <a href="https://leifwells.github.io/2017/08/27/testing-in-ionic-configure-existing-projects-for-testing/" rel="noreferrer">https://leifwells.github.io/2017/08/27/testing-in-ionic-configure-existing-projects-for-testing/</a></p> <pre><code>"ts-loader": "^4.1.0", "jasmine-core": "^2.99.1" </code></pre> <p>Error Messages :</p> <pre><code>TypeError: env.stopOnSpecFailure is not a function at adapter.js:26 Error: Module build failed: TypeError: Cannot read property 'afterCompile' of undefined </code></pre>
0debug
iOS App: Terminated due to memory issue [Related to swiftSlowAlloc or UIImage] : <p>Currently I am facing a memory issue problem in building iOS app. I checked for Memory leaks using Instruments. I found that there is one kind of leaks that keeps on showing up named swift_slowAlloc, which I don't have idea about. An snippet of the error is given below. </p> <p><a href="https://i.stack.imgur.com/JBe1r.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/JBe1r.jpg" alt="Memory Leaks"></a></p> <p>Another reason I think could happen is due to loading of several UIImages in my app. Just to provide a background, I take various portions of an original image in my app and do some processing on them. However, I don't need to keep the images for further calculations. I used autoreleasepool to release the UIImage; but I doubt that it is working. An example is given below:</p> <pre><code> @autoreleasepool { UIImage *imageResized = MatToUIImage(resized28); // MARK: Send resized28 to CNN and get the output. Fill the dict then NSString *CNNScore; CNNScore = [myclass CNNfloat:imageResized W1:W1 W2:W2 Wf1:Wf1 Wf2:Wf2 B1:B1 B2:B2 Bf1:Bf1 Bf2:Bf2]; imageResized = nil; xtn = [NSNumber numberWithInteger:xt]; xbn = [NSNumber numberWithInteger:xb]; ytn = [NSNumber numberWithInteger:yt]; ybn = [NSNumber numberWithInteger:yb]; symbol = [NSString stringWithFormat:@"%@", CNNScore]; symtype = [NSString stringWithFormat:@"%@", [scoreDic objectForKey: symbol]]; numberInDict = [NSString stringWithFormat:@"%i", n]; inToMaroof = [NSArray arrayWithObjects: xtn, xbn, ytn, ybn, symbol,symtype, nil]; [toMaroof setObject: inToMaroof forKey: numberInDict]; } } </code></pre> <p>Can someone suggest anything on this issue?</p>
0debug
Python return function reasoning : <p>What is the <strong>reason</strong> behind having return after defining a function? Please explain in non coding terms. I am trying to understand why to do return and what it actually does instead of just being told to do it.</p>
0debug
How to access a gmail account I own using Gmail API? : <p>I want to run a node script as a cronjob which uses Gmail's API to poll a gmail account I own.</p> <p>I am following <a href="https://developers.google.com/gmail/api/quickstart/nodejs#prerequisites" rel="noreferrer">these quickstart instructions</a>:</p> <p><a href="https://i.stack.imgur.com/0EgAo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0EgAo.png" alt="quickstart"></a></p> <p>I'm stuck on the first step. When requesting credentials for a cron script it tells me that "User data cannot be accessed from a platform without a UI because it requires user interaction for sign-in":</p> <p><a href="https://i.stack.imgur.com/LUh8X.png" rel="noreferrer"><img src="https://i.stack.imgur.com/LUh8X.png" alt="enter image description here"></a> </p> <p>The docs are confusing in general, and mention "service accounts," "OAuth," and other things -- I cannot tell which apply to my use-case and which don't. I've used many SaaS APIs, and the typical workflow is to login to your account, get an API key and secret, and use those in your script to access the API. It seems this is <em>not</em> the paradigm used by the Gmail API, so I'd appreciate any guidance or links to clearer instructions.</p>
0debug
static void register_multipage(AddressSpaceDispatch *d, MemoryRegionSection *section) { hwaddr start_addr = section->offset_within_address_space; uint16_t section_index = phys_section_add(section); uint64_t num_pages = int128_get64(int128_rshift(section->size, TARGET_PAGE_BITS)); assert(num_pages); phys_page_set(d, start_addr >> TARGET_PAGE_BITS, num_pages, section_index); }
1threat
import re def match_num(string): text = re.compile(r"^5") if text.match(string): return True else: return False
0debug
In Visual Studio 2019 how can I remove unused usings on format document? : <p>In Visual Studio 2019 how can I remove unused usings on format document? </p> <p>I have found instructions for previous versions of Visual Studio (Go to Tools > Options > Text Editor > C# > Code Style > Formatting.). I don't see that in Visual Studio 2019.</p>
0debug
static av_cold int vorbis_encode_init(AVCodecContext *avccontext) { vorbis_enc_context *venc = avccontext->priv_data; if (avccontext->channels != 2) { av_log(avccontext, AV_LOG_ERROR, "Current Libav Vorbis encoder only supports 2 channels.\n"); return -1; } create_vorbis_context(venc, avccontext); if (avccontext->flags & CODEC_FLAG_QSCALE) venc->quality = avccontext->global_quality / (float)FF_QP2LAMBDA / 10.; else venc->quality = 0.03; venc->quality *= venc->quality; avccontext->extradata_size = put_main_header(venc, (uint8_t**)&avccontext->extradata); avccontext->frame_size = 1 << (venc->log2_blocksize[0] - 1); avccontext->coded_frame = avcodec_alloc_frame(); avccontext->coded_frame->key_frame = 1; return 0; }
1threat
HOW TO MAKE OUTPUT FILE OF ONE SCRIPT, AS AN INPUT FILE FOR THE ANOTHER SCRIPT? : i am currently working on a project where in i am using perl language to create command line application of one online tool. There are total nine modules(for each module there is separate perl script). THIS COMMAND LINE APPLICATION SHOULD WORK IN A FOLLOWING WAY- 1.Out of these nine modules user would be able to select any number of modules.(in short pipeline should be built). 2.after running first selected module ,output files are generated. 3.output file of first module should be taken as an input file by the next module selected by the user. my doubt is how we can make output file of first module as an input file for the next selected module. It will be a great help if you solve my doubt as i am new to perl programming. Thanking you!
0debug
Reading a ~180KB file line by line results in StackOverflowException : <p>This text file has ~15,000 short lines. I read it this way:</p> <pre><code>using (var reader = new StreamReader("words.txt")) { while (reader.Peek() &gt;= 0) { list.Add(reader.ReadLine()); } var r = new Random(); var randomLineNumber = r.Next(0, list.Count - 1); InterfacePassword.Text = list[randomLineNumber].ToString(); } </code></pre> <p>It's frankensteined from other SO answers, I'm not sure if it would actually do what I want. Unfortunately it results in <code>StackOverflowException</code> and I don't understand why - I loaded files of larger sizes before.</p>
0debug
static inline int compare_masked(uint64_t x, uint64_t y, uint64_t mask) { return (x & mask) == (y & mask); }
1threat
How to SECURE my FLUTTER Mobile Application? (Flutter App Penetration Testing Result) : <p><strong>Where can I get Flutter App security documentation or best practice?</strong> I am nearly ready to publish my app. I use online (free version) <a href="https://www.ostorlab.co/report/" rel="noreferrer">https://www.ostorlab.co/report/</a> and check the security of my app.</p> <p>I have a main question above and some more question in below. </p> <ul> <li>How to disable debug mode? </li> <li>How to disable backup mode? </li> <li>How to prevent my google map api key in AndroidManifest or similar?</li> </ul> <p>These are the security issue that I am facing. —————————————————————————————————</p> <p><strong>High Debug mode enabled Description</strong></p> <p>The application is compiled with debug mode allowing attackers to attach a debugger to access sensitive data or perform malicious actions.Attacker can debug the application without access to source code and leverage it to perform malicious actions on behalf ot the user, modify the application behavior or access sensitive data like credentials and session cookies.</p> <p><strong>Recommendation</strong></p> <p>Disable debug mode by setting the attribute android:debuggeable to false in the application tag. </p> <p>References • DRD10-J Do not relase apps that are debuggable (CERT Secure Coding)</p> <p><strong>Ex: AndroidManifest:</strong> </p> <pre><code>&lt;activity android:name="com.apptreesoftware.mapview.MapActivity" android:theme="@7F0C0102"&gt; &lt;/activity&gt; &lt;meta-data android:name="com.google.android.maps.v2.API_KEY" android:value=“****************************”&gt;&lt;/meta-data&gt; &lt;meta-data android:name="com.google.android.gms.version" android:value="@7F080004"&gt;&lt;/meta-data&gt; </code></pre> <p>————————————————————————————</p> <p><strong>Potentially Backup mode enabled Description</strong></p> <p>Android performs by default a full backup of applications including the private files stored on /data partition. The Backup Manager service uploads those data to the user's Google Drive account.</p> <p><strong>Recommendation</strong></p> <p>if the application contains sensitive data that you don't want to be restored, you can disable backup mode by setting the attribute android:allowBackup to false in the application tag.</p> <p>References • Random Musings on the M Developer Preview: the Ugly (Part Two) • DRD22. Do not cache sensitive information</p> <p>————————————————————————————</p> <p><strong>Potentially Services declared without permissions Description</strong></p> <p>service is an application component that can take care of actions to be done in the background, without user interaction. service can also be used to expose functionalities to other applications. This corresponds to calls to Context.bindService() to establish a connection to the service and interact with it. Unprotected services can be invoked by other applications and potentially access sensitive information or perform privileged actions</p> <p><strong>Recommendation</strong></p> <p>service can expose several methods to external componenets. It is possible to define arbitrary permissions for each method using the method checkPermission. It is also possible to seperate services and restrict access by enforcing permissions in the manifest's tag.</p> <pre><code>&lt;permission android:name="co.ostorlab.custom_permission" android:label="custom_permission" android:protectionLevel="dangerous"&gt;&lt;/permission&gt; &lt;service android:name="co.ostorlab.custom_service" android:permission="co.ostorlab.custom_permission"&gt; &lt;intent-filter&gt; &lt;action android:name="co.ostorlab.ACTION" /&gt; &lt;/intent-filter&gt; &lt;/service&gt; </code></pre> <p>The service can enforce permissions on individual IPC calls by calling the method checkCallingPermissionbefore executing the implementation of that call.</p> <p>References • CWE-280: Improper Handling of Insufficient Permissions or Privileges • Security Decisions Via Untrusted Inputs (OWASP Mobile Top 10) • Service (Android Developper Documentation)</p> <p><strong>Technical details False Positive Services definition in AndroidManifest.xml:</strong></p> <pre><code>&lt;service android:name="com.mobile.niyazibank.MyFirebaseMessagingService"&gt; &lt;intent-filter&gt; &lt;action android:name="com.google.firebase.MESSAGING_EVENT"&gt; &lt;/action&gt; &lt;/intent-filter&gt; &lt;/service&gt; &lt;service android:name="com.mobile.niyazibank.MyFirebaseInstanceIDService"&gt; &lt;intent-filter&gt; &lt;action android:name="com.google.firebase.INSTANCE_ID_EVENT"&gt; &lt;/action&gt; &lt;/intent-filter&gt; &lt;/service&gt; &lt;service android:name="io.flutter.plugins.firebasemessaging.FlutterFirebaseInstanceIDService"&gt; &lt;intent-filter&gt; &lt;action android:name="com.google.firebase.INSTANCE_ID_EVENT"&gt; &lt;/action&gt; &lt;/intent-filter&gt; &lt;/service&gt; &lt;service android:name="io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService"&gt; &lt;intent-filter&gt; &lt;action android:name="com.google.firebase.MESSAGING_EVENT"&gt; &lt;/action&gt; &lt;/intent-filter&gt; &lt;/service&gt; &lt;service android:exported="true" android:name="com.google.firebase.messaging.FirebaseMessagingService"&gt; &lt;intent-filter android:priority="-500"&gt; &lt;action android:name="com.google.firebase.MESSAGING_EVENT"&gt; &lt;/action&gt; &lt;/intent-filter&gt; &lt;/service&gt; &lt;service android:exported="true" android:name="com.google.firebase.iid.FirebaseInstanceIdService"&gt; &lt;intent-filter android:priority="-500"&gt; &lt;action android:name="com.google.firebase.INSTANCE_ID_EVENT"&gt; &lt;/action&gt; &lt;/intent-filter&gt; &lt;/service&gt; </code></pre> <p>————————————————————</p> <p><strong>Important Exported activites, services and broadcast receivers list Description</strong></p> <p>List of all exported components in the application. Exported component are accessible to external applications and present an entry point to the application.</p> <p><strong>Recommendation</strong></p> <p>This entry is informative, no recommendations applicable.</p> <p>References • Content Provider (Android Developper Documentation) • Activity (Android Developper Documentation) • Broadcast Receiver (Android Developper Documentation) • Service (Android Developper Documentation)</p>
0debug
excel vba - to write data in particular column from user form : this is mohan. i am new and know the basic excel vba, now i am trying one of the logic, i have the user form and the data which we enter in user form that it should store in particular table, like in that excel sheet i have the predefined table, in that for example -> D5 & E5 is the cells contain table header,, so whenever i am entering the data first time, the data should store in D6 & E6 accordingly,,likewise i want to store data next to next in under D & E coloumn ? anyone help to complete this code!
0debug
Return only arrays with values laravel 5.6 : <p>I have this array structure, I want the filtered version without the NULL array.</p> <p><a href="https://i.stack.imgur.com/5PuMj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5PuMj.png" alt="enter image description here"></a></p>
0debug
TypeError: input expected at most 1 arguments, got 4? Python x and o's Game : <p>So i'm working on this X and O's game and when testing i got this error and i don't know why or how to fix it. It happens when i trigger the intro function and the user has to choose there mode.</p> <pre><code>####PROGRAM IMPORTS BELOW#### import time import random ####PROGRAM CLASSES#### ####PROGRAM FUNCTIONS BELOW#### def choosemode(): desiredmode = int(input("PLEASE ENTER 1 OR 2 TO PLAY" , '\n' , "OR 3 FOR HTP" , '\n' )) if desiredmode == 1 : onep() elif desiredmode == 2 : twop() elif desiredmode == 3 : HTP() else : choosemode() def gamemodes(): gm1 , gm2 , gm3 = (" 1 PLAYER" , " 2 PLAYER" , " HOW TO PLAY") print ( '\n' , gm1 , '\n' , gm2 , '\n' , gm3 , '\n' ) return def boardformat(): print (" 0 | 1 | 2 ") print ("-----------") print (" 3 | 4 | 5 ") print ("-----------") print (" 6 | 7 | 8 ") def boardatplay(): print ( b0, "|" ,b1, "|" ,b2 ) print ("--------------------") print ( b3, "|" ,b4, "|" ,b5 ) print ("--------------------") print ( b6, "|" ,b7, "|" ,b8 ) def restartboard(): b0 = b1 = b2 = b3 = b4 = b5 = b6 = b7 = b8 = (" ") def checkforwinx(): if b0 &amp; b1 &amp; b2 == "X" or b3 &amp; b4 &amp; b5 == "X" or b6 &amp; b7 &amp; b8 == "X" or b0 &amp; b3 &amp; b6 == "X" or b1 &amp; b4 &amp; b7 == "X" or b2 &amp; b5 &amp; b8 == "X" or b0 &amp; b4 &amp; b8 == "X" or b2 &amp; b4 &amp; b6 == "X" : print ("X WINS!") def checkforwino(): if b0 &amp; b1 &amp; b2 == "O" or b3 &amp; b4 &amp; b5 == "O" or b6 &amp; b7 &amp; b8 == "O" or b0 &amp; b3 &amp; b6 == "O" or b1 &amp; b4 &amp; b7 == "O" or b2 &amp; b5 &amp; b8 == "O" or b0 &amp; b4 &amp; b8 == "O" or b2 &amp; b4 &amp; b6 == "O" : print ("O WINS!") def intro(): print ("WELCOME TO X and O's PYTHON EDITION!", '\n' ,"WHAT WOULD YOU LIKE TO PLAY?") gamemodes() choosemode() def onep(): print ( "ONE PLAYER SELECTED!" ) print ( "PLEASE ENTER YOUR NAME" ) name1 = input() print ( name1 , "VS COMPUTER" ) print ( "PRESS ENTER WHEN READY!") input() def twop(): print ( "TWO PLAYER SELECTED!" ) def HTP(): print( "1) To plot a point type the number of the area you want plot in" ) boardformat() print( "2) " ) ####PROGRAM BEGINS BELOW#### restartboard() print ( "LOADING..." ) time.sleep(4) print ( "READY!" ) time.sleep(2) print ( "A EUAN DEAS PRODUCTION" + '\n' ) time.sleep(2) intro() </code></pre> <p>I get the error :</p> <pre><code>Traceback (most recent call last): File "C:\Users\Euan\Desktop\Programming stuff\Python\X and O's.py", line 81, in &lt;module&gt; intro() File "C:\Users\Euan\Desktop\Programming stuff\Python\X and O's.py", line 54, in intro choosemode() File "C:\Users\Euan\Desktop\Programming stuff\Python\X and O's.py", line 11, in choosemode desiredmode = int(input("PLEASE ENTER 1 OR 2 TO PLAY" , '\n' , "OR 3 FOR HTP" , '\n' )) TypeError: input expected at most 1 arguments, got 4 </code></pre>
0debug
PHP - How to fix undefined index error elegantly? : This is probably a generic question and 99% of the solutions I've read is to just use `isset` to be safe and verbose. However, I still think it's not that elegant and also a bit repetitive. To understand my question a bit better, here's a general pattern on my code: class User { protected $name; protected $address; public function __construct() { .. } public function getName() { .. } public function setName() { .. } public function getAddress() { .. } public function setAddress() { .. } public static function buildObject(array $userProperties) { // Here, I'm building a user from an associative array. // If the developer passes in an array with missing name or address, // this will generate an undefined index error! $user = new User(); $user->setName($userProperties['name']); $user->setAddress($userProperties['address']); return $user; } } What I've tried so far: 1. Adding in `isset()` checks on all set calls. This might not be a bad idea for this example, but I have some huge classes with a lot of properties and it looks and feels very repetitive. 2. Making the array safe by looping over properties and setting them to null if they're not present in the array. This doesn't seem that bad in code but feels like a workaround. 3. Using null coalesce operator `?? null`. This also feels repetitive and not that readable. I'd prefer a simple solution that would not add much logic but will look elegant. I know it's preferable to have validation in here, but I'll encounter the same problem when handling optional fields.
0debug
Catch all error psql function exception : <p>I am writing an function with exception catching and ignoring. I want to catch all the exceptions and just ignore it. Is there anyway to catch all the exceptions and not individually?</p> <pre><code>CREATE OR REPLACE FUNCTION ADD_TABLE_TO_ARCHIVE (a TEXT, b TEXT) RETURNS INTEGER AS $SUCCESS$ DECLARE SUCCESS INTEGER; BEGIN SUCCESS = 0; BEGIN UPDATE ARCHIVE_STATUS SET ***** WHERE ***; SUCCESS = 1; EXCEPTION WHEN UNIQUE_VIOLATION SUCCESS = 0; END; RETURN SUCCESS; END; $SUCCESS$ LANGUAGE plpgsql; </code></pre> <p>In place of unique exception, it should be any exception...</p>
0debug
static inline int spx_strategy(AC3DecodeContext *s, int blk) { GetBitContext *bc = &s->gbc; int fbw_channels = s->fbw_channels; int dst_start_freq, dst_end_freq, src_start_freq, start_subband, end_subband, ch; if (s->channel_mode == AC3_CHMODE_MONO) { s->channel_uses_spx[1] = 1; } else { for (ch = 1; ch <= fbw_channels; ch++) s->channel_uses_spx[ch] = get_bits1(bc); } dst_start_freq = get_bits(bc, 2); start_subband = get_bits(bc, 3) + 2; if (start_subband > 7) start_subband += start_subband - 7; end_subband = get_bits(bc, 3) + 5; #if USE_FIXED s->spx_dst_end_freq = end_freq_inv_tab[end_subband-5]; #endif if (end_subband > 7) end_subband += end_subband - 7; dst_start_freq = dst_start_freq * 12 + 25; src_start_freq = start_subband * 12 + 25; dst_end_freq = end_subband * 12 + 25; if (start_subband >= end_subband) { av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension " "range (%d >= %d)\n", start_subband, end_subband); return AVERROR_INVALIDDATA; } if (dst_start_freq >= src_start_freq) { av_log(s->avctx, AV_LOG_ERROR, "invalid spectral extension " "copy start bin (%d >= %d)\n", dst_start_freq, src_start_freq); return AVERROR_INVALIDDATA; } s->spx_dst_start_freq = dst_start_freq; s->spx_src_start_freq = src_start_freq; if (!USE_FIXED) s->spx_dst_end_freq = dst_end_freq; decode_band_structure(bc, blk, s->eac3, 0, start_subband, end_subband, ff_eac3_default_spx_band_struct, &s->num_spx_bands, s->spx_band_sizes); return 0; }
1threat
how get the input field data stored in a state in 3 different component to my 4th component with CALL BACK FUNCTION? : I created 3 component first component having Check information fields second and third also same.4th component having save button i want ot send the the data stored in a state from 3 different state to save onClick
0debug
petalogix_ml605_init(MachineState *machine) { ram_addr_t ram_size = machine->ram_size; MemoryRegion *address_space_mem = get_system_memory(); DeviceState *dev, *dma, *eth0; Object *ds, *cs; MicroBlazeCPU *cpu; SysBusDevice *busdev; DriveInfo *dinfo; int i; MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1); MemoryRegion *phys_ram = g_new(MemoryRegion, 1); qemu_irq irq[32]; cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU)); object_property_set_int(OBJECT(cpu), 1, "use-fpu", &error_abort); object_property_set_bool(OBJECT(cpu), true, "dcache-writeback", &error_abort); object_property_set_bool(OBJECT(cpu), true, "endianness", &error_abort); object_property_set_bool(OBJECT(cpu), true, "realized", &error_abort); memory_region_init_ram(phys_lmb_bram, NULL, "petalogix_ml605.lmb_bram", LMB_BRAM_SIZE, &error_abort); vmstate_register_ram_global(phys_lmb_bram); memory_region_add_subregion(address_space_mem, 0x00000000, phys_lmb_bram); memory_region_init_ram(phys_ram, NULL, "petalogix_ml605.ram", ram_size, &error_abort); vmstate_register_ram_global(phys_ram); memory_region_add_subregion(address_space_mem, MEMORY_BASEADDR, phys_ram); dinfo = drive_get(IF_PFLASH, 0, 0); pflash_cfi01_register(FLASH_BASEADDR, NULL, "petalogix_ml605.flash", FLASH_SIZE, dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, (64 * 1024), FLASH_SIZE >> 16, 2, 0x89, 0x18, 0x0000, 0x0, 0); dev = qdev_create(NULL, "xlnx.xps-intc"); qdev_prop_set_uint32(dev, "kind-of-intr", 1 << TIMER_IRQ); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, INTC_BASEADDR); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(DEVICE(cpu), MB_CPU_IRQ)); for (i = 0; i < 32; i++) { irq[i] = qdev_get_gpio_in(dev, i); } serial_mm_init(address_space_mem, UART16550_BASEADDR + 0x1000, 2, irq[UART16550_IRQ], 115200, serial_hds[0], DEVICE_LITTLE_ENDIAN); dev = qdev_create(NULL, "xlnx.xps-timer"); qdev_prop_set_uint32(dev, "one-timer-only", 0); qdev_prop_set_uint32(dev, "clock-frequency", 100 * 1000000); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, TIMER_BASEADDR); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq[TIMER_IRQ]); qemu_check_nic_model(&nd_table[0], "xlnx.axi-ethernet"); eth0 = qdev_create(NULL, "xlnx.axi-ethernet"); dma = qdev_create(NULL, "xlnx.axi-dma"); object_property_add_child(qdev_get_machine(), "xilinx-eth", OBJECT(eth0), NULL); object_property_add_child(qdev_get_machine(), "xilinx-dma", OBJECT(dma), NULL); ds = object_property_get_link(OBJECT(dma), "axistream-connected-target", NULL); cs = object_property_get_link(OBJECT(dma), "axistream-control-connected-target", NULL); qdev_set_nic_properties(eth0, &nd_table[0]); qdev_prop_set_uint32(eth0, "rxmem", 0x1000); qdev_prop_set_uint32(eth0, "txmem", 0x1000); object_property_set_link(OBJECT(eth0), OBJECT(ds), "axistream-connected", &error_abort); object_property_set_link(OBJECT(eth0), OBJECT(cs), "axistream-control-connected", &error_abort); qdev_init_nofail(eth0); sysbus_mmio_map(SYS_BUS_DEVICE(eth0), 0, AXIENET_BASEADDR); sysbus_connect_irq(SYS_BUS_DEVICE(eth0), 0, irq[AXIENET_IRQ]); ds = object_property_get_link(OBJECT(eth0), "axistream-connected-target", NULL); cs = object_property_get_link(OBJECT(eth0), "axistream-control-connected-target", NULL); qdev_prop_set_uint32(dma, "freqhz", 100 * 1000000); object_property_set_link(OBJECT(dma), OBJECT(ds), "axistream-connected", &error_abort); object_property_set_link(OBJECT(dma), OBJECT(cs), "axistream-control-connected", &error_abort); qdev_init_nofail(dma); sysbus_mmio_map(SYS_BUS_DEVICE(dma), 0, AXIDMA_BASEADDR); sysbus_connect_irq(SYS_BUS_DEVICE(dma), 0, irq[AXIDMA_IRQ0]); sysbus_connect_irq(SYS_BUS_DEVICE(dma), 1, irq[AXIDMA_IRQ1]); { SSIBus *spi; dev = qdev_create(NULL, "xlnx.xps-spi"); qdev_prop_set_uint8(dev, "num-ss-bits", NUM_SPI_FLASHES); qdev_init_nofail(dev); busdev = SYS_BUS_DEVICE(dev); sysbus_mmio_map(busdev, 0, SPI_BASEADDR); sysbus_connect_irq(busdev, 0, irq[SPI_IRQ]); spi = (SSIBus *)qdev_get_child_bus(dev, "spi"); for (i = 0; i < NUM_SPI_FLASHES; i++) { qemu_irq cs_line; dev = ssi_create_slave(spi, "n25q128"); cs_line = qdev_get_gpio_in_named(dev, SSI_GPIO_CS, 0); sysbus_connect_irq(busdev, i+1, cs_line); } } cpu->env.pvr.regs[4] = 0xc56b8000; cpu->env.pvr.regs[5] = 0xc56be000; cpu->env.pvr.regs[10] = 0x0e000000; microblaze_load_kernel(cpu, MEMORY_BASEADDR, ram_size, machine->initrd_filename, BINARY_DEVICE_TREE_FILE, NULL); }
1threat
eval in javascript runs bad method : <p>In this code eval function is used: <a href="https://i.stack.imgur.com/HcUII.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HcUII.png" alt="code1"></a></p> <p>function in string has 3 params, but eval runs function with 2 params:</p> <p><a href="https://i.stack.imgur.com/Xqdl7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xqdl7.png" alt="code2"></a></p> <p>Why ?</p>
0debug
hi please help my multidex is not resolving : Gayatri Anushka 1 second ago hi please help, my android.support.multidex.MultiDexApplication is still red after all the steps :( please help, not able to resolve this. im following a course online but no help. can I omit multidex? android { compileSdkVersion 28 buildToolsVersion "29.0.2" defaultConfig { applicationId "com.example.ping" minSdkVersion 21 targetSdkVersion 28 multiDexEnabled true versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.core:core-ktx:1.0.2' implementation 'com.android.support:support-v4:28.0.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.android.support:multidex:1.0.3' implementation 'com.google.firebase:firebase-analytics:17.2.2' implementation 'com.google.firebase:firebase-auth:19.2.0' implementation 'com.google.firebase:firebase-firestore:21.4.0' implementation 'com.google.firebase:firebase-storage:19.1.1' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' } apply plugin: 'com.google.gms.google-services' manifest- <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.ping"> <application android:name="android.support.multidex.MultiDexApplication" (this part is showing error) >
0debug
static MachineClass *machine_parse(const char *name) { MachineClass *mc = NULL; GSList *el, *machines = object_class_get_list(TYPE_MACHINE, false); if (name) { mc = find_machine(name); } if (mc) { return mc; } if (name && !is_help_option(name)) { error_report("Unsupported machine type"); error_printf("Use -machine help to list supported machines!\n"); } else { printf("Supported machines are:\n"); for (el = machines; el; el = el->next) { MachineClass *mc = el->data; if (mc->alias) { printf("%-20s %s (alias of %s)\n", mc->alias, mc->desc, mc->name); } printf("%-20s %s%s\n", mc->name, mc->desc, mc->is_default ? " (default)" : ""); } } g_slist_free(machines); exit(!name || !is_help_option(name)); }
1threat
my first c++ program runtime is super long like 5 - 10 minutes on a fast CPU it's a very basic c++ program : <p>i just dont understand whats taking so long its the standard hello world program you write when you first start to learn a new language and its just so un-optimized</p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;vector&gt; #include &lt;sstream&gt; int main() { std::string hello_world = "HELLO WORLD!"; std::string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ !"; std::vector&lt;long&gt; positions; std::ostringstream oss; for(auto l : hello_world){ int position = 0; position = letters.find(l); positions.push_back(position); } for(long t = 0; t &lt;= 100000000000; t++){ if(t%256465445 == 0){ for(auto p : positions){ oss&lt;&lt;letters[p]; } } } std::cout&lt;&lt;"Hello World!"; } </code></pre>
0debug
invalid types ‘int[int]’ for array subscript in 2D array : <p>Working on a project that reads integers from a file and puts them into a 2D array. I tested it with a 1D array but when I tried it with a 2D array I kept getting this error "invalid types ‘int[int]’ for array subscript" in my class called "Image" in this function:</p> <pre><code>void Image::read(int* arr) { //Nested loop that reads the file for(int i = 0; i &lt; height; i++) { for(int k = 0; k &lt; width; k++) { inputFile &gt;&gt; arr[i][k]; //Here's where I get the error } } } </code></pre> <p>And here is my main function: </p> <pre><code>int main() { Image test("colorado1.dat"); //File with the integers test.setWidth(500); test.setHeight(500); int array[test.getHeight()][test.getWidth()]; test.read(array); //Loop to test if the function worked for(int i = 0; i &lt; 500; i++) { for(int k = 0; k &lt; 500; k++) { cout &lt;&lt; array[i][k] &lt;&lt; " "; } } } </code></pre>
0debug
Sending mail with php shows via : <p>I am sending mail with php mail() function. It shows via secureserver.net. Please see screenshot and how to remove it?<a href="https://i.stack.imgur.com/tKjnR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tKjnR.jpg" alt="enter image description here"></a></p>
0debug
Google Chrome Developer Tools : Android Debugging returns HTTP/1.1 404 Not Found. Why? : <p>This was working fine up until yesterday. Now when I connect my Android device for USB Debuggers. Chrome is no longer display my app. </p> <p>Now the popup window shows HTTP/1.1 404 Not Found.</p> <p>Looks to be connecting fine and the app runs fine on my Mobile Device.</p> <p><a href="https://i.stack.imgur.com/3OthL.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3OthL.png" alt="enter image description here"></a></p>
0debug
Interleave 4 lists of same length python : <p>I want interleave 4 lists of same length in python.</p> <p>I search this site and only see how to interleave 2 in python: <a href="https://stackoverflow.com/questions/7946798/interleaving-two-lists-in-python">Interleaving two lists in Python</a></p> <p>Can give advice for 4 lists?</p> <p>I have lists like this</p> <pre><code>l1 = ["a","b","c","d"] l2 = [1,2,3,4] l3 = ["w","x","y","z"] l4 = [5,6,7,8] </code></pre> <p>I want list like</p> <pre><code>l5 = ["a",1,"w",5,"b",2,"x",6,"c",3,"y",7,"d",4,"z",8] </code></pre>
0debug
static int roq_probe(AVProbeData *p) { if (p->buf_size < 6) return 0; if ((AV_RL16(&p->buf[0]) != RoQ_MAGIC_NUMBER) || (AV_RL32(&p->buf[2]) != 0xFFFFFFFF)) return 0; return AVPROBE_SCORE_MAX; }
1threat
static void test_submit(void) { WorkerTestData data = { .n = 0 }; thread_pool_submit(worker_cb, &data); qemu_aio_flush(); g_assert_cmpint(data.n, ==, 1); }
1threat
Select more values on clause IF in the Stored Procedure : I have a problem of sintaxe in my Stored Procedure when a select more values in my IF, on code snippet 37 OR 35. IF 37 OR 35 NOT IN (SELECT CodPerfilSistema FROM [BRSAODB09].[ADMIN].[dbo].[PERFIL_USUARIO] where CodUsuario = @pCodUsuario) BEGIN SET @CondicaoEmpresa = ' AND [Lote].CodEmpresa = ' + CONVERT(varchar(10), @pCodEmpresa); SET @CondicaoProjeto = ' AND [AUD_Projeto].CodProjeto = ' + CONVERT(varchar(10), @pCodProjeto); END Im tried the code above. And below is how the code is running IF 37 NOT IN (SELECT CodPerfilSistema FROM [BRSAODB09].[ADMIN].[dbo].[PERFIL_USUARIO] where CodUsuario = @pCodUsuario) BEGIN SET @CondicaoEmpresa = ' AND [Lote].CodEmpresa = ' + CONVERT(varchar(10), @pCodEmpresa); SET @CondicaoProjeto = ' AND [AUD_Projeto].CodProjeto = ' + CONVERT(varchar(10), @pCodProjeto); END I need the permission for Id 37 and 35. Thanks.
0debug
static inline uint8_t *get_seg_base(uint32_t e1, uint32_t e2) { return (uint8_t *)((e1 >> 16) | ((e2 & 0xff) << 16) | (e2 & 0xff000000)); }
1threat
Get sum of values from an Array of objects - Ruby : I have a data structure in ruby as below: [["N1-Alb", {Sun, 05 Feb 2017=>"", Mon, 06 Feb 2017=>"", Tue, 07 Feb 2017=>"", Wed, 08 Feb 2017=>"0.25", Thu, 09 Feb 2017=>"0.03", Fri, 10 Feb 2017=>"", Sat, 11 Feb 2017=>""}], ["N1-Cet", {Sun, 05 Feb 2017=>"", Mon, 06 Feb 2017=>"7.8", Tue, 07 Feb 2017=>"", Wed, 08 Feb 2017=>"0.00", Thu, 09 Feb 2017=>"", Fri, 10 Feb 2017=>"", Sat, 11 Feb 2017=>""}], ["N3-Tju", {Sun, 05 Feb 2017=>"", Mon, 06 Feb 2017=>"", Tue, 07 Feb 2017=>"", Wed, 08 Feb 2017=>"3.15", Thu, 09 Feb 2017=>"", Fri, 10 Feb 2017=>"8.0", Sat, 11 Feb 2017=>""}], ["N7-Mlp", {Sun, 05 Feb 2017=>"", Mon, 06 Feb 2017=>"", Tue, 07 Feb 2017=>"5.01", Wed, 08 Feb 2017=>"0.03", Thu, 09 Feb 2017=>"", Fri, 10 Feb 2017=>"", Sat, 11 Feb 2017=>"4"}]] How can I get sum for All Sundays, Mondays etc. up to Saturdays separately in to a Hash or an Array format? The Final Hash should be: result = { sun: '0', mon: '7.8', tue: '5.01', wed: '3.43', thu: '0.03', fri: '8.0', sat: '4' }
0debug
static void audio_print_settings (audsettings_t *as) { dolog ("frequency=%d nchannels=%d fmt=", as->freq, as->nchannels); switch (as->fmt) { case AUD_FMT_S8: AUD_log (NULL, "S8"); break; case AUD_FMT_U8: AUD_log (NULL, "U8"); break; case AUD_FMT_S16: AUD_log (NULL, "S16"); break; case AUD_FMT_U16: AUD_log (NULL, "U16"); break; case AUD_FMT_S32: AUD_log (NULL, "S32"); break; case AUD_FMT_U32: AUD_log (NULL, "U32"); break; default: AUD_log (NULL, "invalid(%d)", as->fmt); break; } AUD_log (NULL, " endianness="); switch (as->endianness) { case 0: AUD_log (NULL, "little"); break; case 1: AUD_log (NULL, "big"); break; default: AUD_log (NULL, "invalid"); break; } AUD_log (NULL, "\n"); }
1threat
Error: connect EINVAL 0.0.xx.xx:80 - Local (0.0.0.0:0) : <p>I'm trying to use hubot msg object to send http request, but finally get this error: Error: connect EINVAL 0.0.xx.xx:80 - Local (0.0.0.0:0)</p> <p>A similar question is saying this is caused by hosts file, but no detail.</p>
0debug
How to declare and import typescript interfaces in a separate file : <p>I want to define several interfaces in their own file in my typescript-based project, from which I'll implement classes for production as well as mocks for testing. However, I can't figure out what the correct syntax is. I've found plenty of tutorials on declaring interfaces and implementing them, but they all have a trivial implementation of both the interface and derived classes in the same file, which isn't very real-world. What's the right way to export and import the interfaces?</p>
0debug
int avfilter_graph_create_filter(AVFilterContext **filt_ctx, AVFilter *filt, const char *name, const char *args, void *opaque, AVFilterGraph *graph_ctx) { int ret; *filt_ctx = avfilter_graph_alloc_filter(graph_ctx, filt, name); if (!*filt_ctx) return AVERROR(ENOMEM); ret = avfilter_init_filter(*filt_ctx, args, opaque); if (ret < 0) goto fail; return 0; fail: if (*filt_ctx) avfilter_free(*filt_ctx); *filt_ctx = NULL; return ret; }
1threat
static inline short adpcm_ms_expand_nibble(ADPCMChannelStatus *c, int nibble) { int predictor; predictor = (((c->sample1) * (c->coeff1)) + ((c->sample2) * (c->coeff2))) / 64; predictor += ((nibble & 0x08)?(nibble - 0x10):(nibble)) * c->idelta; c->sample2 = c->sample1; c->sample1 = av_clip_int16(predictor); c->idelta = (ff_adpcm_AdaptationTable[(int)nibble] * c->idelta) >> 8; if (c->idelta < 16) c->idelta = 16; return c->sample1;
1threat
void spapr_events_init(sPAPREnvironment *spapr) { spapr->epow_irq = spapr_allocate_msi(0); spapr->epow_notifier.notify = spapr_powerdown_req; qemu_register_powerdown_notifier(&spapr->epow_notifier); spapr_rtas_register("check-exception", check_exception); }
1threat
Export Android Library as AAR file : <p>I have created an Android application say name <em>App</em>. Then I have created a library module inside the <em>App</em>.</p> <p>I want to share/publish this library with others. Sharing a .aar file would be fine now.</p> <p>I went through the article - <a href="https://developer.android.com/studio/projects/android-library" rel="noreferrer">https://developer.android.com/studio/projects/android-library</a></p> <p>I found these info related building .aar file from the article.</p> <ol> <li>When you want to build the AAR file, select the library module in the Project window and then click <strong>Build > Build APK</strong>.</li> <li>However, if you want to share your AAR file separately, you can find it in <strong>project-name/module-name/build/outputs/aar/</strong> and you can regenerate it by clicking <strong>Build > Make Project</strong>.</li> </ol> <p>I have tried these two options. I couldn't find <strong>/aar</strong> folder in the path <strong>project-name/module-name/build/outputs/</strong></p> <p>This is the first time I am building a library that needs to share with others. </p> <p>Is there something else I need to do? Please share your thoughts</p>
0debug
JSON Decodable Help Swift 4.1 : "count": 30, "recipes": [{"publisher": "Closet Cooking", "f2f_url": "http://food2fork.com/view/35382", "title": "Jalapeno Popper Grilled Cheese Sandwich", "source_url": "http://www.closetcooking.com/2011/04/jalapeno-popper-grilled-cheese-sandwich.html", "recipe_id": "35382", "image_url": "http://static.food2fork.com/Jalapeno2BPopper2BGrilled2BCheese2BSandwich2B12B500fd186186.jpg", "social_rank": 100.0, "publisher_url": "http://closetcooking.com"}, Could someone show me how to parse this JSON using swift4.1 Decodable please?
0debug
static uint64_t arm_sysctl_read(void *opaque, target_phys_addr_t offset, unsigned size) { arm_sysctl_state *s = (arm_sysctl_state *)opaque; switch (offset) { case 0x00: return s->sys_id; case 0x04: return 0; case 0x08: return s->leds; case 0x20: return s->lockval; case 0x0c: case 0x10: case 0x14: case 0x18: case 0x1c: case 0x24: return 0; case 0x28: return s->cfgdata1; case 0x2c: return s->cfgdata2; case 0x30: return s->flags; case 0x38: return s->nvflags; case 0x40: if (board_id(s) == BOARD_ID_VEXPRESS) { return 0; } return s->resetlevel; case 0x44: return 1; case 0x48: return s->sys_mci; case 0x4c: return 0; case 0x50: return s->sys_clcd; case 0x54: return 0; case 0x58: return 0; case 0x5c: return muldiv64(qemu_get_clock_ns(vm_clock), 24000000, get_ticks_per_sec()); case 0x60: return 0; case 0x84: return s->proc_id; case 0x88: return 0xff000000; case 0x64: case 0x68: case 0x6c: case 0x70: case 0x74: case 0x80: case 0x8c: case 0x90: case 0x94: case 0x98: case 0x9c: case 0xc0: case 0xc4: case 0xc8: case 0xcc: case 0xd0: return 0; case 0xa0: if (board_id(s) != BOARD_ID_VEXPRESS) { goto bad_reg; } return s->sys_cfgdata; case 0xa4: if (board_id(s) != BOARD_ID_VEXPRESS) { goto bad_reg; } return s->sys_cfgctrl; case 0xa8: if (board_id(s) != BOARD_ID_VEXPRESS) { goto bad_reg; } return s->sys_cfgstat; default: bad_reg: printf ("arm_sysctl_read: Bad register offset 0x%x\n", (int)offset); return 0; } }
1threat
keep getting "TypeError: 'int' object is not callable" : <p>I keep getting the same error and i dont know why, i am new to python and am trying out a little project to guess random numbers! Here is my code:</p> <pre><code>import random number_guess = int(input("Enter a random number between 1 - 100 please!")) random_number = random.randrange(0,100) if number_guess == random_number(): print("Correct! The number was " + random_number + "!") else: print("Wrong! The real number was " + random_number + "!") </code></pre>
0debug
PCIBus *typhoon_init(ram_addr_t ram_size, ISABus **isa_bus, qemu_irq *p_rtc_irq, AlphaCPU *cpus[4], pci_map_irq_fn sys_map_irq) { const uint64_t MB = 1024 * 1024; const uint64_t GB = 1024 * MB; MemoryRegion *addr_space = get_system_memory(); DeviceState *dev; TyphoonState *s; PCIHostState *phb; PCIBus *b; int i; dev = qdev_create(NULL, TYPE_TYPHOON_PCI_HOST_BRIDGE); qdev_init_nofail(dev); s = TYPHOON_PCI_HOST_BRIDGE(dev); phb = PCI_HOST_BRIDGE(dev); for (i = 0; i < 4; i++) { AlphaCPU *cpu = cpus[i]; s->cchip.cpu[i] = cpu; if (cpu != NULL) { cpu->alarm_timer = qemu_new_timer_ns(rtc_clock, typhoon_alarm_timer, (void *)((uintptr_t)s + i)); } } *p_rtc_irq = *qemu_allocate_irqs(typhoon_set_timer_irq, s, 1); memory_region_init_ram(&s->ram_region, OBJECT(s), "ram", ram_size); vmstate_register_ram_global(&s->ram_region); memory_region_add_subregion(addr_space, 0, &s->ram_region); memory_region_init_io(&s->pchip.region, OBJECT(s), &pchip_ops, s, "pchip0", 256*MB); memory_region_add_subregion(addr_space, 0x80180000000ULL, &s->pchip.region); memory_region_init_io(&s->cchip.region, OBJECT(s), &cchip_ops, s, "cchip0", 256*MB); memory_region_add_subregion(addr_space, 0x801a0000000ULL, &s->cchip.region); memory_region_init_io(&s->dchip_region, OBJECT(s), &dchip_ops, s, "dchip0", 256*MB); memory_region_add_subregion(addr_space, 0x801b0000000ULL, &s->dchip_region); memory_region_init(&s->pchip.reg_mem, OBJECT(s), "pci0-mem", 4*GB); memory_region_add_subregion(addr_space, 0x80000000000ULL, &s->pchip.reg_mem); memory_region_init(&s->pchip.reg_io, OBJECT(s), "pci0-io", 32*MB); memory_region_add_subregion(addr_space, 0x801fc000000ULL, &s->pchip.reg_io); b = pci_register_bus(dev, "pci", typhoon_set_irq, sys_map_irq, s, &s->pchip.reg_mem, &s->pchip.reg_io, 0, 64, TYPE_PCI_BUS); phb->bus = b; memory_region_init_io(&s->pchip.reg_iack, OBJECT(s), &alpha_pci_iack_ops, b, "pci0-iack", 64*MB); memory_region_add_subregion(addr_space, 0x801f8000000ULL, &s->pchip.reg_iack); memory_region_init_io(&s->pchip.reg_conf, OBJECT(s), &alpha_pci_conf1_ops, b, "pci0-conf", 16*MB); memory_region_add_subregion(addr_space, 0x801fe000000ULL, &s->pchip.reg_conf); { qemu_irq isa_pci_irq, *isa_irqs; *isa_bus = isa_bus_new(NULL, &s->pchip.reg_io); isa_pci_irq = *qemu_allocate_irqs(typhoon_set_isa_irq, s, 1); isa_irqs = i8259_init(*isa_bus, isa_pci_irq); isa_bus_irqs(*isa_bus, isa_irqs); } return b; }
1threat
Set response status in ASP.NET core middleware : <p>I have a middleware, which hides exception from client and returns 500 error in case of any exception:</p> <pre><code>public class ExceptionHandlingMiddleware { private readonly RequestDelegate _next; public ExceptionHandlingMiddleware(RequestDelegate next) { _next = next; } public async Task Invoke(HttpContext context) { try { await _next.Invoke(context); } catch (Exception exception) { var message = "Exception during processing request"; using (var writer = new StreamWriter(context.Response.Body)) { context.Response.StatusCode = 500; //works as it should, response status 500 await writer.WriteAsync(message); context.Response.StatusCode = 500; //response status 200 } } } } </code></pre> <p>My problem is that, if I set response status before writing body, client will see this status, but if I set status after writing message to body, client will receive response with status 200.</p> <p>Could somebody explain me why it's happening?</p> <p>P.S. I am using ASP.NET Core 1.1</p>
0debug
Spring Boot with datasource when testing : <p>I am using Spring Boot application and the auto cofiguration is enabled. The main Application file is marked as <code>@EnableAutoConfiguration</code>. The datasource is lookedup from JNDI is configured using java config and the class which create the datasource is marked as <code>@Configuration</code>.</p> <p>I have a test class as below.</p> <pre><code>@RunWith( SpringJUnit4ClassRunner.class ) @WebAppConfiguration @ContextConfiguration( classes = Application.class ) public class TestSomeBusiness {} </code></pre> <p>The issue is when I run the test case, the datasource jndi lookup happens, which fails because the test case is not running inside a server environment. As far as I know the classes in classpath marked with <code>@Configuration</code> are executed and that the reason the datasource lookup is being called.</p> <p>The work around for now I have found is instead of JNDI lookup create the datasource using <code>DriverManagerDataSource</code>, so that even if its not a server environment the datasource lookup won't fail.</p> <p>My questions are:</p> <p>1) How do we generally deal with datasource (when looking up from JNDI) in spring boot application for testing ?</p> <p>2) Is there a way to exclude the datasource configuration class from being called when executing test case ?</p> <p>3) Should I create an embedded server so that the JNDI lookup can be done when executing test case ?</p>
0debug
multiple boolean tests within one method : <p>I have a class with different boolean properties set and the method <code>test()</code> checks all these properties and returns a boolean value. </p> <p><strong>Which is the fastest way?</strong></p> <p><strong>version 1:</strong></p> <pre><code>public boolean test(){ if(!test1) return false; if(!test2) return false; if(!test3) return false; if(!test4) return false; if(!test5) return false; if(!test6) return false; if(!test7) return false; return true; } </code></pre> <p><strong>version 2:</strong></p> <pre><code>public boolean test(){ return test1 &amp;&amp; test2 &amp;&amp; test3 &amp;&amp; test4 &amp;&amp; test5 &amp;&amp; test6 &amp;&amp; test7; } </code></pre> <p><strong>version 3:</strong></p> <pre><code>public boolean test(){ Predicate&lt;Boolean&gt; test1 = c -&gt; getTest1(); Predicate&lt;Boolean&gt; test2 = c -&gt; getTest2(); Predicate&lt;Boolean&gt; test3 = c -&gt; getTest3(); Predicate&lt;Boolean&gt; test4 = c -&gt; getTest4(); Predicate&lt;Boolean&gt; test5 = c -&gt; getTest5(); Predicate&lt;Boolean&gt; test6 = c -&gt; getTest6(); Predicate&lt;Boolean&gt; test7 = c -&gt; getTest7(); return test1.and(test2).and(test3).and(test4).and(test5).and(test6).and(test7).test(true); } </code></pre> <p>I would prefer version 1, because it`s the cleanest way, however, which one is the fastest?</p>
0debug
Using the Facebook JS SDK in a Module (webpack) : <p>I'm using webpack to keep my JavaScript code organized in modules but I'm running into a problem trying to load the Facebook JS SDK. I've tried using the <code>externals</code> option of webpack but since the library is loaded asynchronously I don't think it will provide the answer I am looking for.</p> <p>There was an issue for webpack that addressed this problem. However, I don't think it works any longer. <a href="https://github.com/webpack/webpack/issues/367">https://github.com/webpack/webpack/issues/367</a></p> <p>What would be a good approach to this problem? Should I just load the SDK synchronously? </p>
0debug
Convert a nullable type to its non-nullable type? : <p>I have a bunch of beans that have nullable properties like so:</p> <pre><code>package myapp.mybeans; data class Foo(val name : String?); </code></pre> <p>And I have a method in the global space like so:</p> <pre><code>package myapp.global; public fun makeNewBar(name : String) : Bar { ... } </code></pre> <p>And somewhere else, I need to make a <code>Bar</code> from the stuff that's inside <code>Foo</code>. So, I do this:</p> <pre><code>package myapp.someplaceElse; public fun getFoo() : Foo? { } ... val foo : Foo? = getFoo(); if (foo == null) { ... return; } // I know foo isn't null and *I know* that foo.name isn't null // but I understand that the compiler doesn't. // How do I convert String? to String here? if I do not want // to change the definition of the parameters makeNewBar takes? val bar : Bar = makeNewBar(foo.name); </code></pre> <p>Also, doing some conversion here with <code>foo.name</code> to cleanse it every time with every little thing, while on the one hand provides me compile-time guarantees and safety it is a big bother most of the time. Is there some short-hand to get around these scenarios?</p>
0debug
how database will be accessed by users? : <p>I want to use database for android app which will be having many users,So how can these users can access this database and changes will reflected on each device running this app? and what database should i learn sqlite or realm?</p>
0debug
How to stop/kill a query in postgresql? : <p>This question is while postmaster is running your query in the background, how to kill or stop it?</p> <p>For example, your shell or any frontend may be disconnected due to network issue, you cannot use ctrl-D to kill it but the background postmaster is still running your query. How to kill it?</p>
0debug
PHP- Combine child element of an array into an array : <p>i had an array of data like this<br> <pre> array(3) { [0]=> array(5) { ["cate_title"]=> string(30) "Printer Line - Round With Date" ["attr_id"]=> string(2) "15" ["attr"]=> string(6) "asdasd" ["option"]=> string(6) "asdasd" ["data_name"]=> array(0) { } } [1]=> array(5) { ["cate_title"]=> string(1) "w" ["attr_id"]=> string(2) "14" ["attr"]=> string(4) "asda" ["option"]=> string(5) "sdasd" ["data_name"]=> array(0) { } } [2]=> array(5) { ["cate_title"]=> string(1) "w" ["attr_id"]=> string(2) "13" ["attr"]=> string(3) "aaa" ["option"]=> string(8) "checkbox" ["data_name"]=> array(1) { [0]=> string(3) "bbb" } } } </pre></p> <p>i want to combine 2 elenment that has the same <code>cate_title = w</code> into 1 array like this</p> <pre class="lang-html prettyprint-override"><code>&lt;pre&gt; array(3) { [0]=&gt; array(5) { ["cate_title"]=&gt; string(30) "Printer Line - Round With Date" ["attr_id"]=&gt; string(2) "15" ["attr"]=&gt; string(6) "asdasd" ["option"]=&gt; string(6) "asdasd" ["data_name"]=&gt; array(0) { } } [1]=&gt; array(2) { ["cate_title"]=&gt;string(1) "w" ["data-child"]=&gt;array(2){ [0]=&gt;array { ["attr_id"]=&gt;string(2) "14" ["attr"]=&gt;string(4) "asda" ["option"]=&gt;string(5) "sdasd" ["data_name"]=&gt; array(0) { } } [1]=&gt;array { ["attr_id"]=&gt;string(2) "13" ["attr"]=&gt;string(4) "aaa" ["option"]=&gt;string(5) "checkbox" ["data_name"]=&gt; array(1) { [0]=&gt; string(3) "bbb" } } } } &lt;/pre&gt; </code></pre> <p>please help me, i've searched everywhere but still no answers </p>
0debug
static av_cold int vsink_init(AVFilterContext *ctx, const char *args, void *opaque) { BufferSinkContext *buf = ctx->priv; av_unused AVBufferSinkParams *params; if (!opaque) { av_log(ctx, AV_LOG_ERROR, "No opaque field provided\n"); return AVERROR(EINVAL); } else { #if FF_API_OLD_VSINK_API buf->pixel_fmts = (const enum PixelFormat *)opaque; #else params = (AVBufferSinkParams *)opaque; buf->pixel_fmts = params->pixel_fmts; #endif } return common_init(ctx); }
1threat