problem
stringlengths
26
131k
labels
class label
2 classes
Pip install - Python 2.7 - Windows 7 : <p>I download the get-pip.py from <a href="https://pip.pypa.io/en/stable/installing/" rel="noreferrer">https://pip.pypa.io/en/stable/installing/</a> . Then i changed path in: system-variable environment into : C:\Python27\ArcGIS10.3\Lib\site-packages after that i tried to run in from the cmd and this is the result:</p> <p><a href="https://i.stack.imgur.com/emDPN.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/emDPN.jpg" alt="enter image description here"></a> </p>
0debug
Difficulty dynamically adding a border around a div using Javascript : <p>We have a "Terms and Conditions" checkbox, and when "Place Order" is clicked, among other things, I want to validate that Terms&amp;Conditions is checked, and if not, add a thin red border around the surrounding div. I am unable to get the following to work though.</p> <pre><code>if (!terms.checked) { console.log(terms.parentNode.parentNode); terms.parentNode.parentNode.style.border = '1px red'; //terms.parentNode.parentNode.style.borderWidth = '1px'; //terms.parentNode.parentNode.style.borderColor = 'red'; } </code></pre> <p>I know my Javascript is getting the correct node, as when I log it to console and then hover over it, it highlights the element. As you can see from the commented out lines I've tried adding <code>borderWidth</code> and <code>borderColor</code> individually, but also to no avail.</p> <p>I've referred to both <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/border" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/CSS/border</a> and <a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/style</a> and cannot figure out what I should be doing differently. I've also created the following fiddle to no avail: <a href="https://jsfiddle.net/LLdozham/" rel="nofollow noreferrer">https://jsfiddle.net/LLdozham/</a></p> <p><a href="https://i.stack.imgur.com/TKZEQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TKZEQ.png" alt="enter image description here"></a></p>
0debug
In Xamarin XAML, how do I set a Constraint on a RelativeLayout using a Style? : <p>I am struggling to work out the XAML syntax to apply constraints to a <code>RelativeLayout</code> using a <code>Style</code>.</p> <p>The first piece of Xamarin XAML below shows a pair of nested <code>RelativeLayout</code> elements used to construct a simple layout (the inner element simply puts a margin around an area to which I can add other content). This version of the code builds and runs fine on iOS and Android.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="App2.Page1"&gt; &lt;RelativeLayout BackgroundColor="Gray"&gt; &lt;RelativeLayout BackgroundColor="Maroon" RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=0.9,Constant=0}" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=0.9,Constant=0}" RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=0.05,Constant=0}" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=0.05,Constant=0}"&gt; &lt;BoxView Color="Yellow" RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=0.25,Constant=0}" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=0.25,Constant=0}" RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=0.25,Constant=0}" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=0.25,Constant=0}"/&gt; &lt;/RelativeLayout&gt; &lt;/RelativeLayout&gt; &lt;/ContentPage&gt; </code></pre> <p>What I would like to do it use the same layout on multiple pages, so I want to put the <code>RelativeLayout</code> constraints into a <code>Style</code>. This second piece of code does not parse or run, but I hope it shows what I am trying to achieve. If I can get the right syntax for this, the idea is that the <code>Style</code> can then be moved out into a shared file, so I can easily re-use it across multiple instances of <code>ContentPage</code>.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="App2.Page2"&gt; &lt;ContentPage.Resources&gt; &lt;ResourceDictionary&gt; &lt;Style x:Key="LayoutStyle" TargetType="RelativeLayout"&gt; &lt;Setter Property="BackgroundColor" Value="Maroon"/&gt; &lt;Setter Property="HeightConstraint"&gt; &lt;Setter.Value&gt;"Type=RelativeToParent,Property=Height,Factor=0.9,Constant=0"&lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="WidthConstraint"&gt; &lt;Setter.Value&gt;"Type=RelativeToParent,Property=Width,Factor=0.9,Constant=0"&lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="YConstraint"&gt; &lt;Setter.Value&gt;"Type=RelativeToParent,Property=Height,Factor=0.05,Constant=0&lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;Setter Property="XConstraint"&gt; &lt;Setter.Value&gt;"Type=RelativeToParent,Property=Width,Factor=0.05,Constant=0&lt;/Setter.Value&gt; &lt;/Setter&gt; &lt;/Style&gt; &lt;/ResourceDictionary&gt; &lt;/ContentPage.Resources&gt; &lt;RelativeLayout BackgroundColor="Gray"&gt; &lt;RelativeLayout Style="LayoutStyle"&gt; &lt;BoxView Color="Yellow" RelativeLayout.HeightConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=0.25,Constant=0}" RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=0.25,Constant=0}" RelativeLayout.YConstraint="{ConstraintExpression Type=RelativeToParent,Property=Height,Factor=0.25,Constant=0}" RelativeLayout.XConstraint="{ConstraintExpression Type=RelativeToParent,Property=Width,Factor=0.25,Constant=0}"/&gt; &lt;/RelativeLayout&gt; &lt;/RelativeLayout&gt; &lt;/ContentPage&gt; </code></pre> <p>Please can anyone help me out with the syntax for doing this?</p> <p>This is a link to a complete example (which obviously requires Xamarin to be installed and needs the nuget packages to be restored): <a href="https://drive.google.com/file/d/0Bz__vXtiMe03bTFTb3owaWtfV00/view?usp=sharing">XAML Layout Example</a></p>
0debug
Create TypeFaceSpan from TypeFace below SDK version 28 : <p>I found a way to <code>create</code> <code>TypeFaceSpan</code> from <code>TypeFace</code> like this :</p> <pre><code>fun getTypeFaceSpan(typeFace:TypeFace) = TypeFaceSpan(typeFace) </code></pre> <p><strong>But</strong> this API is <strong>allowed</strong> only in <strong>API level >= 28</strong> . Any <strong>Compat</strong> libray to achieve this <strong>below 28</strong>? </p>
0debug
Can' solve the error in raspberry pi : i'm new to raspberry pi and wrote a simple led blink program: import RPi.GPIO as GPIO import time GPIO.setwarnings(False) GPIO,setmode(GPIO.BOARD) GPIO.setup(3,GPIO.OUT) while True: GPIO,output(3,1) time.sleep(1) GPIO.output(3,0) time.sleep(1) but when i run it i get this: Traceback (most recent call last): File "/home/pi/ledblink.py", line 6, in <module> GPIO,setmode(GPIO.BCM) NameError: name 'setmode' is not defined can anyone help please?
0debug
static int init(AVCodecParserContext *s) { H264Context *h = s->priv_data; h->thread_context[0] = h; return 0; }
1threat
static inline void RENAME(yuv2yuvX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, long dstW, long chrDstW) { #ifdef HAVE_MMX if(c->flags & SWS_ACCURATE_RND){ if(uDest){ YSCALEYUV2YV12X_ACCURATE( 0, CHR_MMX_FILTER_OFFSET, uDest, chrDstW) YSCALEYUV2YV12X_ACCURATE(4096, CHR_MMX_FILTER_OFFSET, vDest, chrDstW) } YSCALEYUV2YV12X_ACCURATE(0, LUM_MMX_FILTER_OFFSET, dest, dstW) }else{ if(uDest){ YSCALEYUV2YV12X( 0, CHR_MMX_FILTER_OFFSET, uDest, chrDstW) YSCALEYUV2YV12X(4096, CHR_MMX_FILTER_OFFSET, vDest, chrDstW) } YSCALEYUV2YV12X(0, LUM_MMX_FILTER_OFFSET, dest, dstW) } #else #ifdef HAVE_ALTIVEC yuv2yuvX_altivec_real(lumFilter, lumSrc, lumFilterSize, chrFilter, chrSrc, chrFilterSize, dest, uDest, vDest, dstW, chrDstW); #else yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize, chrFilter, chrSrc, chrFilterSize, dest, uDest, vDest, dstW, chrDstW); #endif #endif }
1threat
static MpegTSService *mpegts_add_service(MpegTSWrite *ts, int sid, const char *provider_name, const char *name) { MpegTSService *service; service = av_mallocz(sizeof(MpegTSService)); if (!service) return NULL; service->pmt.pid = ts->pmt_start_pid + ts->nb_services; service->sid = sid; service->provider_name = av_strdup(provider_name); service->name = av_strdup(name); service->pcr_pid = 0x1fff; dynarray_add(&ts->services, &ts->nb_services, service); return service; }
1threat
Oracle data types variations : <p>I'm a new beginner to Oracle ,I'm so confused about the data types .</p> <hr> <p>I don't know the difference between :</p> <ul> <li><code>INT</code>,<code>INTEGER</code>,<code>NUMBER</code></li> <li><code>CHAR</code>,<code>CHAR VARYING</code> ,<code>CHARACTER</code>,<code>CHARACTER VARYING</code></li> </ul>
0debug
bad request response to fetch REST API : I have built an API and app that uses that API. When I POST method via Postman it works fine but when I try fetch via app I get bad request 400 status response. What am I doing wrong? here is my js code: const myForm = document.getElementById('loginForm'); myForm.addEventListener('submit', function(e) { e.preventDefault(); const url = 'https://thawing-peak-69345.herokuapp.com/api/auth'; const myHeaders = new Headers(); myHeaders.append('Accept', 'application/json, text/html, */* '); myHeaders.append( 'Content-Type', 'application/json, charset=utf-8') const formData = { email: this.email.value, password: this.password.value }; console.log(formData); const fetchOptions = { method: 'POST', mode: 'no-cors', cache: 'no-cache', headers: myHeaders, body: JSON.stringify(formData) }; fetch(url, fetchOptions) .then(res => res.json()) .then(res => console.log(res)) .catch(err => console.log(err)) }) [request photo[\]\[1\][1] and response [enter image description here][2] headers request: [enter image description here][3] headers response: [enter image description here][4] [1]: https://i.stack.imgur.com/LKso7.png [2]: https://i.stack.imgur.com/vQVnm.png [3]: https://i.stack.imgur.com/yDCsk.png [4]: https://i.stack.imgur.com/1RS0j.png
0debug
How to serialize into Json C# DateTime value? : <p>I have an object <strong>model</strong> that contains <strong>DateTime</strong> property. This object is being serialized into Json format by calling</p> <blockquote> <p>return Json(model);</p> </blockquote> <p>as a result, I am getting this string </p> <blockquote> <p>"/Date(1474398517910)/"</p> </blockquote> <p>instead of DateTime. That's because Json doesnt support DateTime format, instead it uses a string.</p> <p><strong>Question - how to make this string to look like real date, something like</strong> </p> <blockquote> <p>"2016-10-22 12:20 PM"</p> </blockquote> <p>Thanks?</p>
0debug
how to view structure of blade template use PHPStorm? : `.php` could view structure of html but `.blade.php` couldn't in PHPStorm.how to use blade and view structure of html at the same time?
0debug
Extract text from specific HTML tag : <p>I'm coding little script and I've faced this problem</p> <p>now I have this HTML code</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;div class="domains"&gt; &lt;ul&gt; &lt;li class="noMessages"&gt; &lt;a href="select-admin-domain.do?domain=ex1.com"&gt;ex1.com&lt;/a&gt; &lt;/li&gt; &lt;li class="noMessages"&gt; &lt;a href="select-admin-domain.do?domain=ex2.com"&gt;ex2.com&lt;/a&gt; &lt;/li&gt; &lt;li class="cpCurrentDomain noMessages"&gt; &lt;a href="select-admin-domain.do?domain=ex3.com"&gt;ex3.com&lt;/a&gt; &lt;/li&gt; &lt;li class="noMessages"&gt; &lt;a href="select-admin-domain.do?domain=ex4.com"&gt;ex4.com&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;</code></pre> </div> </div> now i want to extract the text from all this html tag using PHP</p> <pre><code>&lt;a href="select-admin-domain.do?domain=ex1.com"&gt;ex1.com&lt;/a&gt; &lt;a href="select-admin-domain.do?domain=ex2.com"&gt;ex2.com&lt;/a&gt; &lt;a href="select-admin-domain.do?domain=ex3.com"&gt;ex3.com&lt;/a&gt; &lt;a href="select-admin-domain.do?domain=ex4.com"&gt;ex4.com&lt;/a&gt; </code></pre> <p>so the output become ex1.com ex2.com etc..</p> <p>i've make this code</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;?php function GetStr($string,$start,$end){ $str = explode($start, $string); $str = explode($end, $str[1]); echo $str[0]; } $ss= getStr($htmlcode,'&lt;a href="select-admin-domain.do?domain=','"&gt;'); echo $ss;</code></pre> </div> </div> </p> <p>it works good but it only gives me the first output ex1.com and I want to echo all of them not just 1</p>
0debug
Xcode 9 - failed to emit precompiled header : <p>I have a project in Objective-C as well as in swift by taking <code>MyProjectName-Bridging-Header.h</code> and i also configured the Objective-C Bridging Header. Also i have added 'MyprojectName-Swift.h' in .pch file.</p> <p>This works fine on xcode 8.2 but when i build my project from xcode 9 i am getting the below error. </p> <blockquote> <p>failed to emit precompiled header '/Library/Developer/Xcode/DerivedData/MyprojectName-lajanjvhqjnfjksdsndsfkads/Build/Intermediates.noindex/PrecompiledHeaders/MyprojectName-Bridging-Header-swift_44AHJm3Z96qu-clang_2BIMGQVXGEZ09.pch' for bridging header '/Documents/MyProjectLocaiton/FoneApp-Bridging-Header.h'</p> </blockquote> <p>Please help me out from this. Thanks!</p>
0debug
Angular 2 creating reactive forms with nested components : <p>My requirement is that I need to create a form with nested components. I am creating components for each form field means for textbox there will be one component, for radio button there will be another component like wise.<br> <code>&lt;form [formGroup]="myForm"&gt;<br> &lt;textbox-component&gt;&lt;/textbox-component&gt;<br> &lt;radioButton-component&gt;&lt;/radioButton-component&gt;<br> &lt;/form&gt;</code></p> <p>And I want to use Reactive forms for creating this form as I want my html to be untouched and have my form validations through typescript only. </p> <p>But I cant find any solution how can we have reactive forms nested with components.</p>
0debug
static enum AVPixelFormat webp_get_format(AVCodecContext *avctx, const enum AVPixelFormat *formats) { WebPContext *s = avctx->priv_data; if (s->has_alpha) return AV_PIX_FMT_YUVA420P; else return AV_PIX_FMT_YUV420P; }
1threat
How to import gRPC empty and Google api annotations proto : <p>I am trying to use Google Cloud Endpoints to make a gRPC based api that can <a href="https://cloud.google.com/endpoints/docs/transcoding" rel="noreferrer">transcode incoming REST requests</a>. I am following <a href="https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/endpoints/bookstore-grpc/http_bookstore.proto" rel="noreferrer">their example code</a> but I can not any documentation on how to properly import and compile with the annotation.proto or the empty.proto.</p> <p>Thank you!</p>
0debug
void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size) { MemoryRegion *mr = g_malloc(sizeof(*mr)); isa_mmio_setup(mr, size); memory_region_add_subregion(get_system_memory(), base, mr); }
1threat
How to create a self contained .Net core application? : <p>I created an asp.net core on .Net core and planned to publish it on a Windows server. I don't want to install anything on the server so I want the application be self contained. </p> <p>I selected the menu "Build-> Publish MyApp" and then created File system based method. It generated the following files in the folder and I copied it to the server. However, how to run it on the server which doesn't have .Net core installed?</p> <pre><code>Name ---- refs runtimes appsettings.json MyService.deps.json MyService.dll MyService.pdb MyService.runtimeconfig.json Microsoft.ApplicationInsights.AspNetCore.dll Microsoft.ApplicationInsights.dll Microsoft.AspNetCore.Antiforgery.dll Microsoft.AspNetCore.Authorization.dll Microsoft.AspNetCore.Cors.dll Microsoft.AspNetCore.Cryptography.Internal.dll Microsoft.AspNetCore.DataProtection.Abstractions.dll Microsoft.AspNetCore.DataProtection.dll Microsoft.AspNetCore.Diagnostics.Abstractions.dll Microsoft.AspNetCore.Hosting.Abstractions.dll Microsoft.AspNetCore.Hosting.dll Microsoft.AspNetCore.Hosting.Server.Abstractions.dll Microsoft.AspNetCore.Html.Abstractions.dll Microsoft.AspNetCore.Http.Abstractions.dll Microsoft.AspNetCore.Http.dll Microsoft.AspNetCore.Http.Extensions.dll Microsoft.AspNetCore.Http.Features.dll Microsoft.AspNetCore.HttpOverrides.dll Microsoft.AspNetCore.JsonPatch.dll Microsoft.AspNetCore.Localization.dll Microsoft.AspNetCore.Mvc.Abstractions.dll Microsoft.AspNetCore.Mvc.ApiExplorer.dll Microsoft.AspNetCore.Mvc.Core.dll Microsoft.AspNetCore.Mvc.Cors.dll Microsoft.AspNetCore.Mvc.DataAnnotations.dll Microsoft.AspNetCore.Mvc.dll Microsoft.AspNetCore.Mvc.Formatters.Json.dll Microsoft.AspNetCore.Mvc.Localization.dll Microsoft.AspNetCore.Mvc.Razor.dll Microsoft.AspNetCore.Mvc.Razor.Host.dll Microsoft.AspNetCore.Mvc.TagHelpers.dll Microsoft.AspNetCore.Mvc.ViewFeatures.dll Microsoft.AspNetCore.Razor.dll Microsoft.AspNetCore.Razor.Runtime.dll Microsoft.AspNetCore.Routing.Abstractions.dll Microsoft.AspNetCore.Routing.dll Microsoft.AspNetCore.Server.IISIntegration.dll Microsoft.AspNetCore.Server.Kestrel.dll Microsoft.AspNetCore.WebUtilities.dll Microsoft.DotNet.InternalAbstractions.dll Microsoft.EntityFrameworkCore.dll Microsoft.EntityFrameworkCore.Relational.dll Microsoft.EntityFrameworkCore.SqlServer.dll Microsoft.Extensions.Caching.Abstractions.dll Microsoft.Extensions.Caching.Memory.dll Microsoft.Extensions.Configuration.Abstractions.dll Microsoft.Extensions.Configuration.Binder.dll Microsoft.Extensions.Configuration.dll Microsoft.Extensions.Configuration.EnvironmentVariables.dll Microsoft.Extensions.Configuration.FileExtensions.dll Microsoft.Extensions.Configuration.Json.dll Microsoft.Extensions.DependencyInjection.Abstractions.dll Microsoft.Extensions.DependencyInjection.dll Microsoft.Extensions.DependencyModel.dll Microsoft.Extensions.DiagnosticAdapter.dll Microsoft.Extensions.FileProviders.Abstractions.dll Microsoft.Extensions.FileProviders.Composite.dll Microsoft.Extensions.FileProviders.Physical.dll Microsoft.Extensions.FileSystemGlobbing.dll Microsoft.Extensions.Globalization.CultureInfoCache.dll Microsoft.Extensions.Localization.Abstractions.dll Microsoft.Extensions.Localization.dll Microsoft.Extensions.Logging.Abstractions.dll Microsoft.Extensions.Logging.Console.dll Microsoft.Extensions.Logging.Debug.dll Microsoft.Extensions.Logging.dll Microsoft.Extensions.Logging.Filter.dll Microsoft.Extensions.Logging.TraceSource.dll Microsoft.Extensions.ObjectPool.dll Microsoft.Extensions.Options.ConfigurationExtensions.dll Microsoft.Extensions.Options.dll Microsoft.Extensions.PlatformAbstractions.dll Microsoft.Extensions.Primitives.dll Microsoft.Extensions.WebEncoders.dll Microsoft.Net.Http.Headers.dll Newtonsoft.Json.dll NLog.config NLog.dll NLog.Extensions.Logging.dll Remotion.Linq.dll System.Collections.NonGeneric.dll System.Collections.Specialized.dll System.ComponentModel.Primitives.dll System.ComponentModel.TypeConverter.dll System.Data.Common.dll System.Diagnostics.Contracts.dll System.Interactive.Async.dll System.Net.WebSockets.dll System.Runtime.Serialization.Primitives.dll System.Text.Encodings.Web.dll web.config </code></pre>
0debug
VBA EXCEL LAST ROW INDEX ON ANOTHER WORKBOOK : This is part of a code i wrote under VBA Excel but it doesnt work what im trying to do is create a loop on a sheet of another workbook but the last row index line of code seems not be working I hope to find a solution with your interactions [PLEASE CLICK HERE TO FIND THE CODE][1] [1]: https://i.stack.imgur.com/F5jcy.png
0debug
How to get the local timezone from the system using nodejs : <p>Is there a way to obtain the local timezone from the system (eg:- ubuntu) using nodejs? </p> <p>I used moment.js to extract the date and time values. But couldn't find a way to extract the timezone as well. </p>
0debug
Why the input "abc!!!" but the output is not "abc+++"? : <p>I researching about input/output file.Below code relate some functions such as: fgetc(),fgets(),fputs(). i don't know why it does not work exactly as i want.Thank you so much ! Below is my code:</p> <pre><code>#include &lt;stdio.h&gt; int main() { FILE *fp; //FILE type pointer int c; //using to get each character from file char buffer [256]; //array as buffer to archive string fp = fopen("file.txt", "r"); /*open a file with only read mode*/ if( fp == NULL ) { perror("Error in opening file"); return(-1); } while(!feof(fp)) /*check if has not yet reached to end of file*/ { c = getc (fp); //get a character from fp if( c == '!' ) { ungetc ('+', fp); //replace '!' by '+' } else { ungetc(c, fp); //no change } fgets(buffer,255,fp);//push string of fp to buffer fputs(buffer, stdout); //outputting string from buffer to stdout } return(0); } </code></pre> <hr>
0debug
How would I get the amount of business days in a month with LocalDate - Java : How would I go about getting the number of business days in a month with LocalDate? I've never used java.time before so I don't know all of its workings. I've been looking on this site to no avail along with searching for an answer. I also do not want to use any external libraries.
0debug
static void ram_save_cleanup(void *opaque) { RAMState **rsp = opaque; RAMBlock *block; memory_global_dirty_log_stop(); QLIST_FOREACH_RCU(block, &ram_list.blocks, next) { g_free(block->bmap); block->bmap = NULL; g_free(block->unsentmap); block->unsentmap = NULL; } XBZRLE_cache_lock(); if (XBZRLE.cache) { cache_fini(XBZRLE.cache); g_free(XBZRLE.encoded_buf); g_free(XBZRLE.current_buf); g_free(XBZRLE.zero_target_page); XBZRLE.cache = NULL; XBZRLE.encoded_buf = NULL; XBZRLE.current_buf = NULL; XBZRLE.zero_target_page = NULL; } XBZRLE_cache_unlock(); compress_threads_save_cleanup(); ram_state_cleanup(rsp); }
1threat
int av_append_packet(AVIOContext *s, AVPacket *pkt, int size) { int ret; int old_size; if (!pkt->size) return av_get_packet(s, pkt, size); old_size = pkt->size; ret = av_grow_packet(pkt, size); if (ret < 0) return ret; ret = avio_read(s, pkt->data + old_size, size); av_shrink_packet(pkt, old_size + FFMAX(ret, 0)); return ret; }
1threat
How to link HTML CSS and PHP together? : <p>I created a new PHP project using Netbeans and i have some trouble referencing the very same css file to all my links in the project.</p> <p>This is what I have: <a href="https://i.stack.imgur.com/32huH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/32huH.png" alt="enter image description here"></a></p> <p>If you know why this is happening please let me know.</p>
0debug
Java: Cannot find symbol but typing is correct : <p>I made a class <code>Operator</code> and a method called <code>compare</code>. However, when call this method in my program, I always got error message </p> <p><code>InfixToPostfix.java:17: error: cannot find symbol System.out.println(compare(op,op1)); ^ symbol: method compare(Operator,Operator) location: class InfixToPostfix </code></p> <p>I think I did not make any spell mistakes.</p> <pre><code>public class Operator extends Token { protected String val; //Modified by Qinjianhong Yang, 11/18/16 public boolean isOperator() { return true; } public boolean isOperand() { return false; } // helper method, returns (assigns) precedence for operators protected int getPrec() { //modified by Qinjianhong Yang, 11/17/2016 if(this.val.equals("+") || this.val.equals("-")){ return 1; } else return 2; } // handy for comparing 2 operators public static int compare( Operator a, Operator b ) { if( a.getPrec() == b.getPrec() ) return 0; else if( a.getPrec() &lt; b.getPrec() ) return -1; else return 1; } public String getVal() { return this.val; } public Operator( String v ) { this.val = v; } } </code></pre> <p>I call this function like this:</p> <pre><code> Operator op = new Operator("+"); Operator op1 = new Operator("*"); System.out.println(compare(op,op1)); </code></pre>
0debug
static void qmp_output_type_str(Visitor *v, const char *name, char **obj, Error **errp) { QmpOutputVisitor *qov = to_qov(v); if (*obj) { qmp_output_add(qov, name, qstring_from_str(*obj)); } else { qmp_output_add(qov, name, qstring_from_str("")); } }
1threat
static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) { AVStream *st; MOVStreamContext *sc; int ret; st = avformat_new_stream(c->fc, NULL); if (!st) return AVERROR(ENOMEM); st->id = c->fc->nb_streams; sc = av_mallocz(sizeof(MOVStreamContext)); if (!sc) return AVERROR(ENOMEM); st->priv_data = sc; st->codec->codec_type = AVMEDIA_TYPE_DATA; sc->ffindex = st->index; c->trak_index = st->index; if ((ret = mov_read_default(c, pb, atom)) < 0) return ret; c->trak_index = -1; if (sc->chunk_count && (!sc->stts_count || !sc->stsc_count || (!sc->sample_size && !sc->sample_count))) { av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n", st->index); return 0; } fix_timescale(c, sc); avpriv_set_pts_info(st, 64, 1, sc->time_scale); mov_build_index(c, st); if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) { MOVDref *dref = &sc->drefs[sc->dref_id - 1]; if (mov_open_dref(c, &sc->pb, c->fc->filename, dref, &c->fc->interrupt_callback) < 0) av_log(c->fc, AV_LOG_ERROR, "stream %d, error opening alias: path='%s', dir='%s', " "filename='%s', volume='%s', nlvl_from=%d, nlvl_to=%d\n", st->index, dref->path, dref->dir, dref->filename, dref->volume, dref->nlvl_from, dref->nlvl_to); } else { sc->pb = c->fc->pb; sc->pb_is_copied = 1; } if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (!st->sample_aspect_ratio.num && st->codec->width && st->codec->height && sc->height && sc->width && (st->codec->width != sc->width || st->codec->height != sc->height)) { st->sample_aspect_ratio = av_d2q(((double)st->codec->height * sc->width) / ((double)st->codec->width * sc->height), INT_MAX); } #if FF_API_R_FRAME_RATE if (sc->stts_count == 1 || (sc->stts_count == 2 && sc->stts_data[1].count == 1)) av_reduce(&st->r_frame_rate.num, &st->r_frame_rate.den, sc->time_scale, sc->stts_data[0].duration, INT_MAX); #endif } if (!st->codec->extradata_size && st->codec->codec_id == AV_CODEC_ID_H264 && TAG_IS_AVCI(st->codec->codec_tag)) { ret = ff_generate_avci_extradata(st); if (ret < 0) return ret; } switch (st->codec->codec_id) { #if CONFIG_H261_DECODER case AV_CODEC_ID_H261: #endif #if CONFIG_H263_DECODER case AV_CODEC_ID_H263: #endif #if CONFIG_MPEG4_DECODER case AV_CODEC_ID_MPEG4: #endif st->codec->width = 0; st->codec->height= 0; break; } if (st->codec->codec_id == AV_CODEC_ID_MP3 && sc->stts_count > 3 && sc->stts_count*10 > st->nb_frames && sc->time_scale == st->codec->sample_rate) { st->need_parsing = AVSTREAM_PARSE_FULL; } av_freep(&sc->chunk_offsets); av_freep(&sc->stsc_data); av_freep(&sc->sample_sizes); av_freep(&sc->keyframes); av_freep(&sc->stts_data); av_freep(&sc->stps_data); av_freep(&sc->elst_data); av_freep(&sc->rap_group); return 0; }
1threat
Error in bind_rows_(x, .id) : Argument 1 must have names using map_df in purrr : <p>I'm using the spotifyr package to scrape spotify audio features for every song of specific albums in my dataset. My issue is that my dataset consists of some artists that are not on spotify -- so they shouldn't be returning any values. </p> <p>My issue is that when I get to an artist that is not on spotify, I get this error:</p> <pre><code>Error in bind_rows_(x, .id) : Argument 1 must have names </code></pre> <p>I've tried wrapping the function in tryCatch to get <code>NA</code> for each column of the problematic row, but it doesn't seem to work.</p> <p>Here's an example of my code (FYI, you need to get API access from spotify's website to run the spotifyr code)</p> <pre><code>library(readr) library(spotifyr) library(dplyr) library(purrr) Sys.setenv(SPOTIFY_CLIENT_ID = "xxx") #xxx will be from spotify's website Sys.setenv(SPOTIFY_CLIENT_SECRET = "xxx") access_token &lt;- get_spotify_access_token() artist &lt;- c("Eminem", "Chris Stapleton", "Brockhampton", "Big Sean, Metro Boomin") album &lt;- c("Revival", "From A Room: Volume 2", "SATURATION III", "Double or Nothing") mydata &lt;- data_frame(artist, album) get_album_data &lt;- function(x) { get_artist_audio_features(mydata$artist[x], return_closest_artist = TRUE) %&gt;% filter(album_name == mydata$album[x])} try_get_album_data &lt;- function(x) { tryCatch(get_album_data(x), error = function(e) {NA})} map_df(seq(1, 4), try_get_album_data) </code></pre>
0debug
JS Cannot read property "length" of undefined : <p>I'm trying to create an object using a given string where each word has a property stating its length. </p> <pre><code>var strings = {}; function findLongestWord(str) { var splitStr = str.split(" "); for (var i = 0; i &lt;= str.length; i++){ strings[splitStr[i]] = splitStr[i].length; } return strings; } findLongestWord("The quick brown fox jumped over the lazy dog"); </code></pre> <p>I end up getting:</p> <pre><code>"TypeError": Cannot read property "length" of undefined. </code></pre> <p>If I were to replace splitStr[i].length with splitStr[0].length, the code runs properly, but of course giving me the same number for each word in the object.</p> <p>Any help is appreciated, thanks.</p>
0debug
Compilation on Linux - In function '_start': (.text+0x20): undefined reference to 'main' : <p>I want to compile a series of cpp files on Linux. Using CentOS 7, in the Konsole, I type "g++ -std=c++11 main.cpp canvas.cpp patch.cpp utils.cpp", and I get an error: </p> <pre><code>/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../lib64/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' collect2: error: ld returned 1 exit status </code></pre> <p>Could anyone tell me how to solve this?</p>
0debug
What does authSource means in mongo database url? : <p>i am trying to connect to my mongo database with following connection string</p> <pre><code>var Mongo_url = 'mongodb://MyUSer:tech@localhost:27017/chatme?authSource=admin'; </code></pre> <p>I am getting error as </p> <pre><code> assertionError: null == { [MongoError: Authentication failed.] name: 'MongoError', message: 'Authentication failed.', ok: 0, code: 18, </code></pre> <p>Could anyone please clear this "authSource=admin" thing to me.</p>
0debug
Best practice for passing enum params in Web API : <p>I have a RESTful Web API project, and I have 2 different Enum scenarios that I'm unsure of re best practice.</p> <p><strong>Scenario 1 : Straightforward Enum Param</strong></p> <p>My API method requires a parameter called <code>ruleType</code>, with valid values being <code>EmailAddress</code> and <code>IPAddress</code>. My enum within the Web API project looks like this:</p> <pre><code>public enum RuleType { None = 0, EmailAddress = 1, IPAddress = 2 } </code></pre> <p>My question for this scenario is, should I use <code>?ruleType=EmailAddress</code> in my request to the API (which automatically binds that value to my <code>RuleType</code> property within the API method)? If so, how best to validate that the <code>RuleType</code> param sent, is a valid RuleType Enum value?</p> <p><strong>Scenario 2 : Multiple Enum Values for a Single Param</strong></p> <p>My API method has an optional <code>fields</code> param, which is allows you to specify any additional data that should be returned. E.g. <code>&amp;fields=ruleOwner,rule</code>. This would return those 2 extra bits of data in the response.</p> <p>I have an enum in the Web API project which relates to each possible <code>field</code> that may be requested, and at present, I am splitting the comma separated fields param, then looping through each string representation of that enum, parsing it to the equivalent enum, resulting in a list of Enum values which I can then use within my API to retrieve the relevant data.</p> <p>This is the Enum:</p> <pre><code>public enum OptionalField { None = 0, RuleOwner = 1, Rule = 2, etc. } </code></pre> <p>What would be best practice here? I was looking into bitwise enums, so a single value is sent in the API request which resulted in any combination of <code>fields</code> but didn't know if this would work well with a Web API, or if there's generally a better way to go about this?</p>
0debug
static void test_acpi_dsdt_table(test_data *data) { AcpiSdtTable dsdt_table; uint32_t addr = le32_to_cpu(data->fadt_table.dsdt); test_dst_table(&dsdt_table, addr); ACPI_ASSERT_CMP(dsdt_table.header.signature, "DSDT"); g_array_append_val(data->tables, dsdt_table); }
1threat
How do i convert a binary int into a string? : <p>I'm looking to convert an integer representation of binary into a string. i'm not allowed to use bitwise operations. when i converted the decimal integer value into that integer binary representation, i could've put the digits in a string and reverse, but i'm searching for a more elegant way.</p> <p>Any ideas? </p>
0debug
static void vmxnet3_pci_realize(PCIDevice *pci_dev, Error **errp) { DeviceState *dev = DEVICE(pci_dev); VMXNET3State *s = VMXNET3(pci_dev); int ret; VMW_CBPRN("Starting init..."); memory_region_init_io(&s->bar0, OBJECT(s), &b0_ops, s, "vmxnet3-b0", VMXNET3_PT_REG_SIZE); pci_register_bar(pci_dev, VMXNET3_BAR0_IDX, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar0); memory_region_init_io(&s->bar1, OBJECT(s), &b1_ops, s, "vmxnet3-b1", VMXNET3_VD_REG_SIZE); pci_register_bar(pci_dev, VMXNET3_BAR1_IDX, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar1); memory_region_init(&s->msix_bar, OBJECT(s), "vmxnet3-msix-bar", VMXNET3_MSIX_BAR_SIZE); pci_register_bar(pci_dev, VMXNET3_MSIX_BAR_IDX, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->msix_bar); vmxnet3_reset_interrupt_states(s); pci_dev->config[PCI_INTERRUPT_PIN] = 0x01; ret = msi_init(pci_dev, VMXNET3_MSI_OFFSET(s), VMXNET3_MAX_NMSIX_INTRS, VMXNET3_USE_64BIT, VMXNET3_PER_VECTOR_MASK, NULL); assert(!ret || ret == -ENOTSUP); if (!vmxnet3_init_msix(s)) { VMW_WRPRN("Failed to initialize MSI-X, configuration is inconsistent."); } vmxnet3_net_init(s); if (pci_is_express(pci_dev)) { if (pci_bus_is_express(pci_dev->bus)) { pcie_endpoint_cap_init(pci_dev, VMXNET3_EXP_EP_OFFSET); } pcie_dev_ser_num_init(pci_dev, VMXNET3_DSN_OFFSET, vmxnet3_device_serial_num(s)); } register_savevm_live(dev, "vmxnet3-msix", -1, 1, &savevm_vmxnet3_msix, s); }
1threat
This program crashes : I made up some program that view the 7*7 table of powered by.... It's work, but from some reason the program crash at the end of the program. My compiler is GCC and I'm using C99. #include <stdlib.h> #include <stdio.h> #include <time.h> #include <math.h> #include <string.h> #define LENGTH 7 void printsTable(int arr[LENGTH][],int len); int main() { int table[LENGTH][LENGTH] = {0}; int i = 0, j = 0; for(j = 1; j <= LENGTH; j++) { for(i = 1; i <= LENGTH; i++) { table[j][i] = pow(j,i); } } printsTable(table,LENGTH); return 0; } void printsTable(int arr[][LENGTH],int len) { int i = 0, j = 0; for(i = 1; i <= LENGTH; i++) { for(j = 1; j <= LENGTH; j++) { printf("%d\t", arr[i][j]); } printf("\n"); } } thanks :)
0debug
Creating multiple checkbox that needs to be send to database as 1 or 0 : Creating question multiple checkbox and I need to send two possible cases 1 or 0 to the database but instead it always sends the last one I click as 1 all the others 0. So for ex. if if click check the first one and the last I want to send to the database both 1 and the other two unchecked 0. My controller public function create($request){ foreach ($request['options'] as $key => $option){ Answer::create([ 'question_id' => $this->get(), 'text' => $option, 'correct' => $request['correct'] == $key ? 1 : 0 ]); } } And my view @for($i = 1; $i<=4; $i++) <div class="form-group {{ $errors->has('options.'.$i) ? ' has-error': '' }}" id="option{{ $i }}"> <div class="checkbox col-xs-2 control-label" style="margin-top: -2px"> <label> <input id="cc" type="checkbox" name="correct" value="{{$i}}" {{ $i==1 ? 'checked' : '' }} > <!-- {!! Form::hidden('correct',0) !!} {!! Form::checkbox('correct',1,false) !!} --> </label> </div> <div class="col-xs-8"> <input type="text" name="options[{{ $i }}]" value="{{ old('options.'.$i) }}" class="form-control" placeholder="@lang('general.option') {{ $i }}"> @if($errors->has('options.'.$i)) <div class="col-xs-12"></div> <span class="help-block"> <strong>{{ $errors->first('options.'.$i) }}</strong> </span> @endif </div>
0debug
static int mlib_YUV2ABGR420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ if(c->srcFormat == PIX_FMT_YUV422P){ srcStride[1] *= 2; srcStride[2] *= 2; } assert(srcStride[1] == srcStride[2]); mlib_VideoColorYUV2ABGR420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW, srcSliceH, dstStride[0], srcStride[0], srcStride[1]); return srcSliceH; }
1threat
i cant remove underline : <p>bold-normal,italic-normal working but underline-none not working? why?How fix first example with change styles parameters.</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;style type="text/css"&gt; vurgulu { text-decoration: underline; font-weight: bold; font-style: italic; font-size:40; } vurgusuz{ text-decoration: none; font-weight: normal; font-style: normal; font-size:40; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; Why output different? why first ex. zalimi underline?&lt;br&gt; &lt;vurgulu&gt;Zulmü alkışlayamam, &lt;vurgusuz&gt;zalimi&lt;/vurgusuz&gt; asla sevemem;&lt;/vurgulu&gt; &lt;br&gt; &lt;vurgulu&gt;Zulmü alkışlayamam, &lt;/vurgulu&gt;&lt;vurgusuz&gt;zalimi&lt;/vurgusuz&gt;&lt;vurgulu&gt; asla sevemem;&lt;/vurgulu&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
0debug
v-model doesn't support input type="file" : <p>I can not use <code>v-model</code> with file input, Vue says I must use <code>v-on:change</code>. Ok so I can use <code>v-on:change</code>, but how can I bind the "content" of the input file to a <code>data</code> property?</p> <p>Let's say I want to bind it in a component to <code>this.file</code>:</p> <pre><code>export default { data() { file: null }, // ... } </code></pre> <p>Here is the HTML part:</p> <pre><code>&lt;input id="image" v-on:change="???" type="file"&gt; &lt;!-- ^- don't know how to bind without v-model --&gt; </code></pre> <p>How should I do the binding?</p>
0debug
jquery click funtion order : I would like to know how can I change the background-image of another div element, when I click on it. I would like to see images one after another in order but what I get is the last one. Here is some code: $(document).ready(function () { // console.log('ready!'); $('.right').click(function () { $('.zur-gda-img').css('background','url(images/sail-boat.jpg)'); }).click(function() { $('.zur-gda-img').css('background','url(images/sad_ostateczny.jpg)'); }) }).click(function() { $('.zur-gda-img').css('background','url(images/twierdza_wisloujscie.jpg)'); });
0debug
static void vfio_err_notifier_handler(void *opaque) { VFIOPCIDevice *vdev = opaque; if (!event_notifier_test_and_clear(&vdev->err_notifier)) { return; } error_report("%s(%04x:%02x:%02x.%x) Unrecoverable error detected. " "Please collect any data possible and then kill the guest", __func__, vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function); vm_stop(RUN_STATE_INTERNAL_ERROR); }
1threat
How can I INSERT the value of TotalPrice by calculating automatically by (quantity*price) from Items table and Order table : CREATE TABLE Items( ID INT IDENTITY(1,1) PRIMARY KEY, Name VARCHAR(50), Price FLOAT ) CREATE TABLE Customers ( Id INT IDENTITY(1,1) PRIMARY KEY, Name VARCHAR(50), [Address] VARCHAR(200), Contact VARCHAR(50), ) CREATE TABLE Orders ( Id INT IDENTITY(1,1) PRIMARY KEY, CustomerId INT FOREIGN KEY REFERENCES Customers(Id), ItemId INT FOREIGN KEY REFERENCES Items(Id), Quantity INT, TotalPrice FLOAT )
0debug
Flexbox: Two elements on top of each other in flex-direction: row : <p>I am trying to achieve the following:</p> <p><img src="https://i.stack.imgur.com/5qoEy.jpg" alt=""></p> <hr> <p>My first attempt was to use a helper div (green):</p> <p><img src="https://i.stack.imgur.com/BTKTg.jpg" alt=""></p> <p><a href="https://jsfiddle.net/89z21rq3/7/" rel="noreferrer">JSFiddle</a></p> <p>What I could do here, is using JavaScript to move the puple and orange elements out of the helper on mobile screens. <strong>But there has to be a plain css way.</strong></p> <hr> <p>My second attempt was to remove the helper and build the Mobile Layout:</p> <p><img src="https://i.stack.imgur.com/U4iwQ.jpg" alt=""></p> <p><a href="https://jsfiddle.net/umq3L2wL/1/" rel="noreferrer">JSFiddle</a></p> <hr> <p>Is there a way to place two elements on top of each other in <code>flex-direction: row</code>? (<a href="https://jsfiddle.net/umq3L2wL/1/" rel="noreferrer">second attempt</a>)</p>
0debug
how to find edge from data in excel : If I have this data : 'data for id_books that user_id borrowed user_id id_book book 1 55 physic 2 55 physic 2 55 physic 3 55 physic 4 55 physic this is the output is show me the users that borrowed the same book from library : ' nodes(user_id): edges(relation between user_id) source,target 1 1,2 2 1,3 3 1,4 4 2,3 2,4 2,3 2,4 ' is that correct to show me 1,2 just once?
0debug
static int flic_decode_frame_15_16BPP(AVCodecContext *avctx, void *data, int *got_frame, const uint8_t *buf, int buf_size) { FlicDecodeContext *s = avctx->priv_data; GetByteContext g2; int pixel_ptr; unsigned char palette_idx1; unsigned int frame_size; int num_chunks; unsigned int chunk_size; int chunk_type; int i, j, ret; int lines; int compressed_lines; signed short line_packets; int y_ptr; int byte_run; int pixel_skip; int pixel_countdown; unsigned char *pixels; int pixel; unsigned int pixel_limit; bytestream2_init(&g2, buf, buf_size); if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) return ret; pixels = s->frame->data[0]; pixel_limit = s->avctx->height * s->frame->linesize[0]; frame_size = bytestream2_get_le32(&g2); bytestream2_skip(&g2, 2); num_chunks = bytestream2_get_le16(&g2); bytestream2_skip(&g2, 8); if (frame_size > buf_size) frame_size = buf_size; frame_size -= 16; while ((frame_size > 0) && (num_chunks > 0) && bytestream2_get_bytes_left(&g2) >= 4) { int stream_ptr_after_chunk; chunk_size = bytestream2_get_le32(&g2); if (chunk_size > frame_size) { av_log(avctx, AV_LOG_WARNING, "Invalid chunk_size = %u > frame_size = %u\n", chunk_size, frame_size); chunk_size = frame_size; } stream_ptr_after_chunk = bytestream2_tell(&g2) - 4 + chunk_size; chunk_type = bytestream2_get_le16(&g2); switch (chunk_type) { case FLI_256_COLOR: case FLI_COLOR: ff_dlog(avctx, "Unexpected Palette chunk %d in non-palettized FLC\n", chunk_type); bytestream2_skip(&g2, chunk_size - 6); break; case FLI_DELTA: case FLI_DTA_LC: y_ptr = 0; compressed_lines = bytestream2_get_le16(&g2); while (compressed_lines > 0) { if (bytestream2_tell(&g2) + 2 > stream_ptr_after_chunk) break; line_packets = bytestream2_get_le16(&g2); if (line_packets < 0) { line_packets = -line_packets; y_ptr += line_packets * s->frame->linesize[0]; } else { compressed_lines--; pixel_ptr = y_ptr; CHECK_PIXEL_PTR(0); pixel_countdown = s->avctx->width; for (i = 0; i < line_packets; i++) { if (bytestream2_tell(&g2) + 2 > stream_ptr_after_chunk) break; pixel_skip = bytestream2_get_byte(&g2); pixel_ptr += (pixel_skip*2); pixel_countdown -= pixel_skip; byte_run = sign_extend(bytestream2_get_byte(&g2), 8); if (byte_run < 0) { byte_run = -byte_run; pixel = bytestream2_get_le16(&g2); CHECK_PIXEL_PTR(2 * byte_run); for (j = 0; j < byte_run; j++, pixel_countdown -= 2) { *((signed short*)(&pixels[pixel_ptr])) = pixel; pixel_ptr += 2; } } else { if (bytestream2_tell(&g2) + 2*byte_run > stream_ptr_after_chunk) break; CHECK_PIXEL_PTR(2 * byte_run); for (j = 0; j < byte_run; j++, pixel_countdown--) { *((signed short*)(&pixels[pixel_ptr])) = bytestream2_get_le16(&g2); pixel_ptr += 2; } } } y_ptr += s->frame->linesize[0]; } } break; case FLI_LC: av_log(avctx, AV_LOG_ERROR, "Unexpected FLI_LC chunk in non-palettized FLC\n"); bytestream2_skip(&g2, chunk_size - 6); break; case FLI_BLACK: memset(pixels, 0x0000, s->frame->linesize[0] * s->avctx->height); break; case FLI_BRUN: y_ptr = 0; for (lines = 0; lines < s->avctx->height; lines++) { pixel_ptr = y_ptr; bytestream2_skip(&g2, 1); pixel_countdown = (s->avctx->width * 2); while (pixel_countdown > 0) { if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk) break; byte_run = sign_extend(bytestream2_get_byte(&g2), 8); if (byte_run > 0) { palette_idx1 = bytestream2_get_byte(&g2); CHECK_PIXEL_PTR(byte_run); for (j = 0; j < byte_run; j++) { pixels[pixel_ptr++] = palette_idx1; pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) (linea%d)\n", pixel_countdown, lines); } } else { byte_run = -byte_run; if (bytestream2_tell(&g2) + byte_run > stream_ptr_after_chunk) break; CHECK_PIXEL_PTR(byte_run); for (j = 0; j < byte_run; j++) { palette_idx1 = bytestream2_get_byte(&g2); pixels[pixel_ptr++] = palette_idx1; pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n", pixel_countdown, lines); } } } #if HAVE_BIGENDIAN pixel_ptr = y_ptr; pixel_countdown = s->avctx->width; while (pixel_countdown > 0) { *((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[pixel_ptr]); pixel_ptr += 2; } #endif y_ptr += s->frame->linesize[0]; } break; case FLI_DTA_BRUN: y_ptr = 0; for (lines = 0; lines < s->avctx->height; lines++) { pixel_ptr = y_ptr; bytestream2_skip(&g2, 1); pixel_countdown = s->avctx->width; while (pixel_countdown > 0) { if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk) break; byte_run = sign_extend(bytestream2_get_byte(&g2), 8); if (byte_run > 0) { pixel = bytestream2_get_le16(&g2); CHECK_PIXEL_PTR(2 * byte_run); for (j = 0; j < byte_run; j++) { *((signed short*)(&pixels[pixel_ptr])) = pixel; pixel_ptr += 2; pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", pixel_countdown); } } else { byte_run = -byte_run; if (bytestream2_tell(&g2) + 2 * byte_run > stream_ptr_after_chunk) break; CHECK_PIXEL_PTR(2 * byte_run); for (j = 0; j < byte_run; j++) { *((signed short*)(&pixels[pixel_ptr])) = bytestream2_get_le16(&g2); pixel_ptr += 2; pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d)\n", pixel_countdown); } } } y_ptr += s->frame->linesize[0]; } break; case FLI_COPY: case FLI_DTA_COPY: if (chunk_size - 6 > (unsigned int)(FFALIGN(s->avctx->width, 2) * s->avctx->height)*2) { av_log(avctx, AV_LOG_ERROR, "In chunk FLI_COPY : source data (%d bytes) " \ "bigger than image, skipping chunk\n", chunk_size - 6); bytestream2_skip(&g2, chunk_size - 6); } else { for (y_ptr = 0; y_ptr < s->frame->linesize[0] * s->avctx->height; y_ptr += s->frame->linesize[0]) { pixel_countdown = s->avctx->width; pixel_ptr = 0; while (pixel_countdown > 0) { *((signed short*)(&pixels[y_ptr + pixel_ptr])) = bytestream2_get_le16(&g2); pixel_ptr += 2; pixel_countdown--; } if (s->avctx->width & 1) bytestream2_skip(&g2, 2); } } break; case FLI_MINI: bytestream2_skip(&g2, chunk_size - 6); break; default: av_log(avctx, AV_LOG_ERROR, "Unrecognized chunk type: %d\n", chunk_type); break; } if (stream_ptr_after_chunk - bytestream2_tell(&g2) >= 0) { bytestream2_skip(&g2, stream_ptr_after_chunk - bytestream2_tell(&g2)); } else { av_log(avctx, AV_LOG_ERROR, "Chunk overread\n"); break; } frame_size -= chunk_size; num_chunks--; } if ((bytestream2_get_bytes_left(&g2) != 0) && (bytestream2_get_bytes_left(&g2) != 1)) av_log(avctx, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \ "and final chunk ptr = %d\n", buf_size, bytestream2_tell(&g2)); if ((ret = av_frame_ref(data, s->frame)) < 0) return ret; *got_frame = 1; return buf_size; }
1threat
FormData append item in array : <pre><code> public List&lt;Region&gt; Regions { get; set; } </code></pre> <p>in model called News.An Region Model is</p> <pre><code>public class Region { public int Id { get; set; } public string Name { get; set; } public static Region Parse(DataRow row) { return new Region { Id = Database.GetInteger(row["Id"]), Name = Database.GetString(row["Region"]), }; } } </code></pre> <p>in Javascript I am using AJAX post method with formdata. I want to set this region.</p> <pre><code>var regionList = []; if (selected === "region") { if (region.length &lt;= 0) { toastr.warning('Lütfen en az bir bölge seçin !!!'); return; } for (var i = 0; i &lt; region.length; i++) { var item = { Id: region[i] } regionList.push(item); } console.log(regionList); formData.append("Regions", regionList); } </code></pre> <p>Code above in JS i wrote like this to set it</p> <pre><code> public ActionResult AddByRegion(News item) { int refPortal = SessionRepository.GetPortalId(); if(refPortal!=1) return View("List", NewsRepository.ListAll(SessionRepository.GetPortalId())); if (item == null || string.IsNullOrEmpty(item.Title) || string.IsNullOrEmpty(item.Content) ) return Content(Serialization.JsonSerialize(new { Status = 400 })); return Content(Serialization.JsonSerialize(new { Status = 200, Result = NewsRepository.AddByRegion(item) })); } </code></pre> <p>and code above i will get in controller. But it returns always 0 record although at least i choosed two region.</p> <pre><code> $.ajax({ type: 'POST', url: '@Url.Action("AddByRegion", "News")', data: formData, contentType: false, processData: false, success: function(data) { var result = JSON.parse(data); if (result.Result === "SUCCEED") { toastr.success('@Resources.Resource.Success_MediaAdd'); window.location.reload(); return; } else { toastr.error('@Resources.Resource.Error_Unexpected'); return; } }, error: function(error) { toastr.error('@Resources.Resource.Error_Unexpected'); return; }, beforeSend: function() { waitingDialog.show('Wait...'); }, complete: function() { waitingDialog.hide(); } }); </code></pre> <p>My Ajax method is above. Where am I making mistake ?</p> <p>Thanks in advance.</p>
0debug
comparing two big lists(More than 1 Lack) in java : I want to compare two big string lists faster in java which are not of equal size. I want to know is there any better way to improve performance. I see performance issue in List<String> list1 = 1 Lack records and List<String> list2 = 100 lack records; #method1 used removeAll list1.removeAll(list2); method2 used java8 streams List<String> unavailable = list1.stream() .filter(e -> (list2.stream() .filter(d -> d.equals(e)) .count())<1) .collect(Collectors.toList());
0debug
static void pci_init_wmask(PCIDevice *dev) { int i; int config_size = pci_config_size(dev); dev->wmask[PCI_CACHE_LINE_SIZE] = 0xff; dev->wmask[PCI_INTERRUPT_LINE] = 0xff; pci_set_word(dev->wmask + PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); for (i = PCI_CONFIG_HEADER_SIZE; i < config_size; ++i) dev->wmask[i] = 0xff; }
1threat
Looking for a light-weight cross-platform C threading library : <p>I wanted to use OpenMP for this, but it is not appropriate for my purposes: creating my own thread pool.</p> <p>So, this needs to be C89 code with, of course, platform specific code for windows and unices.</p> <p>I need this for a C only library, so no C++, boost C++11, etc.</p> <p>Thanks!</p>
0debug
ASP/C#/SQL - Checkbox List - Store multiple values in database where checked : I have a checkboxlist. <asp:CheckBoxList ID="cbBowelSounds" runat="server"> <asp:ListItem Text="&nbsp;&nbsp;<span style=font-weight:normal;>1 Quadrant</span>" Value="1 Quadrant" /> <asp:ListItem Text="&nbsp;&nbsp;<span style=font-weight:normal;>2 Quadrant</span>" Value="2 Quadrant" /> <asp:ListItem Text="&nbsp;&nbsp;<span style=font-weight:normal;>Hypo</span>" Value="Hypo" /> <asp:ListItem Text="&nbsp;&nbsp;<span style=font-weight:normal;>Hyper</span>" Value="Hyper" /> <asp:ListItem Text="&nbsp;&nbsp;<span style=font-weight:normal;>Normal</span>" Value="Normal" /> </asp:CheckBoxList> You can select multiple values. I want to store those values in a SQL database. At first I thought I would create 5 columns in the sql table and I would add each selected value to the correct column. That didnt work. Then I found this snippet. var s = cbBowelSounds.SelectedValue; string[] values = s.Split(','); foreach (ListItem item in cbBowelSounds.Items) item.Selected = values.Contains(item.Value); That was great... until the database reported this for the answer. System.String[] So, what can I do here? whether it's one column with multiple values or 5 columns where the first listitem writes to column 1, etc., It doesn't matter me. I just need the values selected to be sent to the DB. Thank you
0debug
can someone help me I can't get rid of that typeerror:'tuple' object is not callable : <p><a href="http://i.stack.imgur.com/o7muZ.png" rel="nofollow">screenshot</a></p> <p>I don't know how to have the right thing, like whats descriped in the picture thank you</p>
0debug
static int target_restore_sigframe(CPUARMState *env, struct target_rt_sigframe *sf) { sigset_t set; int i; struct target_aux_context *aux = (struct target_aux_context *)sf->uc.tuc_mcontext.__reserved; uint32_t magic, size, fpsr, fpcr; uint64_t pstate; target_to_host_sigset(&set, &sf->uc.tuc_sigmask); sigprocmask(SIG_SETMASK, &set, NULL); for (i = 0; i < 31; i++) { __get_user(env->xregs[i], &sf->uc.tuc_mcontext.regs[i]); } __get_user(env->xregs[31], &sf->uc.tuc_mcontext.sp); __get_user(env->pc, &sf->uc.tuc_mcontext.pc); __get_user(pstate, &sf->uc.tuc_mcontext.pstate); pstate_write(env, pstate); __get_user(magic, &aux->fpsimd.head.magic); __get_user(size, &aux->fpsimd.head.size); if (magic != TARGET_FPSIMD_MAGIC || size != sizeof(struct target_fpsimd_context)) { return 1; } for (i = 0; i < 32; i++) { #ifdef TARGET_WORDS_BIGENDIAN __get_user(env->vfp.regs[i * 2], &aux->fpsimd.vregs[i * 2 + 1]); __get_user(env->vfp.regs[i * 2 + 1], &aux->fpsimd.vregs[i * 2]); #else __get_user(env->vfp.regs[i * 2], &aux->fpsimd.vregs[i * 2]); __get_user(env->vfp.regs[i * 2 + 1], &aux->fpsimd.vregs[i * 2 + 1]); #endif } __get_user(fpsr, &aux->fpsimd.fpsr); vfp_set_fpsr(env, fpsr); __get_user(fpcr, &aux->fpsimd.fpcr); vfp_set_fpcr(env, fpcr); return 0; }
1threat
Is there a definitive *nix command line tool for inspecting protocol buffers? : <p>I'm looking for a command-line utility that will, at a minimum, render binary protobuf data in human-readable form. Filtering and selection options (along the lines of <code>cut</code> for text) would be nice, but the primary object is to make the data visible for debugging purposes.</p> <p>If there is no definitive tool for the job, links to relevant packages are fine.</p>
0debug
static int yop_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { YopDecContext *s = avctx->priv_data; int tag, firstcolor, is_odd_frame; int ret, i, x, y; uint32_t *palette; if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); ret = ff_get_buffer(avctx, &s->frame); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } s->dstbuf = s->frame.data[0]; s->dstptr = s->frame.data[0]; s->srcptr = avpkt->data + 4; s->low_nibble = NULL; is_odd_frame = avpkt->data[0]; firstcolor = s->first_color[is_odd_frame]; palette = (uint32_t *)s->frame.data[1]; for (i = 0; i < s->num_pal_colors; i++, s->srcptr += 3) palette[i + firstcolor] = (s->srcptr[0] << 18) | (s->srcptr[1] << 10) | (s->srcptr[2] << 2); s->frame.palette_has_changed = 1; for (y = 0; y < avctx->height; y += 2) { for (x = 0; x < avctx->width; x += 2) { if (s->srcptr - avpkt->data >= avpkt->size) { av_log(avctx, AV_LOG_ERROR, "Packet too small.\n"); return AVERROR_INVALIDDATA; } tag = yop_get_next_nibble(s); if (tag != 0xf) { yop_paint_block(s, tag); } else { tag = yop_get_next_nibble(s); ret = yop_copy_previous_block(s, tag); if (ret < 0) { avctx->release_buffer(avctx, &s->frame); return ret; } } s->dstptr += 2; } s->dstptr += 2*s->frame.linesize[0] - x; } *got_frame = 1; *(AVFrame *) data = s->frame; return avpkt->size; }
1threat
Can this design be made with just CSS? : <p><a href="https://i.stack.imgur.com/7DTnG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7DTnG.png" alt="enter image description here"></a> <a href="https://i.imgur.com/D69glPV.png" rel="nofollow noreferrer">https://i.imgur.com/D69glPV.png</a> - I'm trying to create this design with CSS/HTML. My initial thought, was to create the white "wave" container that wraps the icons with SVG shapes, but I was wondering if you could actually make it with just CSS? How would you guys approach this? :)</p>
0debug
void qmp_blockdev_open_tray(const char *device, bool has_force, bool force, Error **errp) { if (!has_force) { force = false; } do_open_tray(device, force, errp); }
1threat
static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { IscsiLun *iscsilun = bs->opaque; struct iscsi_context *iscsi = NULL; struct iscsi_url *iscsi_url = NULL; struct scsi_task *task = NULL; struct scsi_inquiry_standard *inq = NULL; struct scsi_inquiry_supported_pages *inq_vpd; char *initiator_name = NULL; QemuOpts *opts; Error *local_err = NULL; const char *filename; int i, ret = 0; if ((BDRV_SECTOR_SIZE % 512) != 0) { error_setg(errp, "iSCSI: Invalid BDRV_SECTOR_SIZE. " "BDRV_SECTOR_SIZE(%lld) is not a multiple " "of 512", BDRV_SECTOR_SIZE); return -EINVAL; } opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { error_propagate(errp, local_err); ret = -EINVAL; goto out; } filename = qemu_opt_get(opts, "filename"); iscsi_url = iscsi_parse_full_url(iscsi, filename); if (iscsi_url == NULL) { error_setg(errp, "Failed to parse URL : %s", filename); ret = -EINVAL; goto out; } memset(iscsilun, 0, sizeof(IscsiLun)); initiator_name = parse_initiator_name(iscsi_url->target); iscsi = iscsi_create_context(initiator_name); if (iscsi == NULL) { error_setg(errp, "iSCSI: Failed to create iSCSI context."); ret = -ENOMEM; goto out; } if (iscsi_set_targetname(iscsi, iscsi_url->target)) { error_setg(errp, "iSCSI: Failed to set target name."); ret = -EINVAL; goto out; } if (iscsi_url->user != NULL) { ret = iscsi_set_initiator_username_pwd(iscsi, iscsi_url->user, iscsi_url->passwd); if (ret != 0) { error_setg(errp, "Failed to set initiator username and password"); ret = -EINVAL; goto out; } } parse_chap(iscsi, iscsi_url->target, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); ret = -EINVAL; goto out; } if (iscsi_set_session_type(iscsi, ISCSI_SESSION_NORMAL) != 0) { error_setg(errp, "iSCSI: Failed to set session type to normal."); ret = -EINVAL; goto out; } iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); parse_header_digest(iscsi, iscsi_url->target, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); ret = -EINVAL; goto out; } if (iscsi_full_connect_sync(iscsi, iscsi_url->portal, iscsi_url->lun) != 0) { error_setg(errp, "iSCSI: Failed to connect to LUN : %s", iscsi_get_error(iscsi)); ret = -EINVAL; goto out; } iscsilun->iscsi = iscsi; iscsilun->aio_context = bdrv_get_aio_context(bs); iscsilun->lun = iscsi_url->lun; iscsilun->has_write_same = true; task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 0, 0, (void **) &inq, errp); if (task == NULL) { ret = -EINVAL; goto out; } iscsilun->type = inq->periperal_device_type; scsi_free_scsi_task(task); task = NULL; if (iscsilun->type == TYPE_DISK && (flags & BDRV_O_RDWR) && iscsi_is_write_protected(iscsilun)) { error_setg(errp, "Cannot open a write protected LUN as read-write"); ret = -EACCES; goto out; } iscsi_readcapacity_sync(iscsilun, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); ret = -EINVAL; goto out; } bs->total_sectors = sector_lun2qemu(iscsilun->num_blocks, iscsilun); bs->request_alignment = iscsilun->block_size; if (iscsilun->type != TYPE_DISK && iscsilun->type != TYPE_ROM) { bs->sg = 1; } task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 1, SCSI_INQUIRY_PAGECODE_SUPPORTED_VPD_PAGES, (void **) &inq_vpd, errp); if (task == NULL) { ret = -EINVAL; goto out; } for (i = 0; i < inq_vpd->num_pages; i++) { struct scsi_task *inq_task; struct scsi_inquiry_logical_block_provisioning *inq_lbp; struct scsi_inquiry_block_limits *inq_bl; switch (inq_vpd->pages[i]) { case SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING: inq_task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 1, SCSI_INQUIRY_PAGECODE_LOGICAL_BLOCK_PROVISIONING, (void **) &inq_lbp, errp); if (inq_task == NULL) { ret = -EINVAL; goto out; } memcpy(&iscsilun->lbp, inq_lbp, sizeof(struct scsi_inquiry_logical_block_provisioning)); scsi_free_scsi_task(inq_task); break; case SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS: inq_task = iscsi_do_inquiry(iscsilun->iscsi, iscsilun->lun, 1, SCSI_INQUIRY_PAGECODE_BLOCK_LIMITS, (void **) &inq_bl, errp); if (inq_task == NULL) { ret = -EINVAL; goto out; } memcpy(&iscsilun->bl, inq_bl, sizeof(struct scsi_inquiry_block_limits)); scsi_free_scsi_task(inq_task); break; default: break; } } scsi_free_scsi_task(task); task = NULL; iscsi_attach_aio_context(bs, iscsilun->aio_context); if (iscsilun->bl.opt_unmap_gran * iscsilun->block_size >= 4 * 1024 && iscsilun->bl.opt_unmap_gran * iscsilun->block_size <= 16 * 1024 * 1024) { iscsilun->cluster_sectors = (iscsilun->bl.opt_unmap_gran * iscsilun->block_size) >> BDRV_SECTOR_BITS; if (iscsilun->lbprz && !(bs->open_flags & BDRV_O_NOCACHE)) { iscsilun->allocationmap = iscsi_allocationmap_init(iscsilun); if (iscsilun->allocationmap == NULL) { ret = -ENOMEM; } } } out: qemu_opts_del(opts); g_free(initiator_name); if (iscsi_url != NULL) { iscsi_destroy_url(iscsi_url); } if (task != NULL) { scsi_free_scsi_task(task); } if (ret) { if (iscsi != NULL) { iscsi_destroy_context(iscsi); } memset(iscsilun, 0, sizeof(IscsiLun)); } return ret; }
1threat
static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb, AVStream *st, RMStream *ast, int read_all) { char buf[256]; uint32_t version; int ret; version = avio_rb16(pb); if (version == 3) { int header_size = avio_rb16(pb); int64_t startpos = avio_tell(pb); avio_skip(pb, 14); rm_read_metadata(s, 0); if ((startpos + header_size) >= avio_tell(pb) + 2) { avio_r8(pb); get_str8(pb, buf, sizeof(buf)); } if ((startpos + header_size) > avio_tell(pb)) avio_skip(pb, header_size + startpos - avio_tell(pb)); st->codec->sample_rate = 8000; st->codec->channels = 1; st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_id = CODEC_ID_RA_144; ast->deint_id = DEINT_ID_INT0; } else { int flavor, sub_packet_h, coded_framesize, sub_packet_size; int codecdata_length; avio_skip(pb, 2); avio_rb32(pb); avio_rb32(pb); avio_rb16(pb); avio_rb32(pb); flavor= avio_rb16(pb); ast->coded_framesize = coded_framesize = avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); avio_rb32(pb); ast->sub_packet_h = sub_packet_h = avio_rb16(pb); st->codec->block_align= avio_rb16(pb); ast->sub_packet_size = sub_packet_size = avio_rb16(pb); avio_rb16(pb); if (version == 5) { avio_rb16(pb); avio_rb16(pb); avio_rb16(pb); } st->codec->sample_rate = avio_rb16(pb); avio_rb32(pb); st->codec->channels = avio_rb16(pb); if (version == 5) { ast->deint_id = avio_rl32(pb); avio_read(pb, buf, 4); buf[4] = 0; } else { get_str8(pb, buf, sizeof(buf)); ast->deint_id = AV_RL32(buf); get_str8(pb, buf, sizeof(buf)); } st->codec->codec_type = AVMEDIA_TYPE_AUDIO; st->codec->codec_tag = AV_RL32(buf); st->codec->codec_id = ff_codec_get_id(ff_rm_codec_tags, st->codec->codec_tag); switch (ast->deint_id) { case DEINT_ID_GENR: case DEINT_ID_INT0: case DEINT_ID_INT4: case DEINT_ID_SIPR: case DEINT_ID_VBRS: case DEINT_ID_VBRF: break; default: av_log(NULL,0,"Unknown interleaver %X\n", ast->deint_id); return AVERROR_INVALIDDATA; } switch (st->codec->codec_id) { case CODEC_ID_AC3: st->need_parsing = AVSTREAM_PARSE_FULL; break; case CODEC_ID_RA_288: st->codec->extradata_size= 0; ast->audio_framesize = st->codec->block_align; st->codec->block_align = coded_framesize; if(ast->audio_framesize >= UINT_MAX / sub_packet_h){ av_log(s, AV_LOG_ERROR, "ast->audio_framesize * sub_packet_h too large\n"); return -1; } av_new_packet(&ast->pkt, ast->audio_framesize * sub_packet_h); break; case CODEC_ID_COOK: case CODEC_ID_ATRAC3: case CODEC_ID_SIPR: avio_rb16(pb); avio_r8(pb); if (version == 5) avio_r8(pb); codecdata_length = avio_rb32(pb); if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){ av_log(s, AV_LOG_ERROR, "codecdata_length too large\n"); return -1; } ast->audio_framesize = st->codec->block_align; if (st->codec->codec_id == CODEC_ID_SIPR) { if (flavor > 3) { av_log(s, AV_LOG_ERROR, "bad SIPR file flavor %d\n", flavor); return -1; } st->codec->block_align = ff_sipr_subpk_size[flavor]; } else { if(sub_packet_size <= 0){ av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n"); return -1; } st->codec->block_align = ast->sub_packet_size; } if ((ret = rm_read_extradata(pb, st->codec, codecdata_length)) < 0) return ret; if(ast->audio_framesize >= UINT_MAX / sub_packet_h){ av_log(s, AV_LOG_ERROR, "rm->audio_framesize * sub_packet_h too large\n"); return -1; } av_new_packet(&ast->pkt, ast->audio_framesize * sub_packet_h); break; case CODEC_ID_AAC: avio_rb16(pb); avio_r8(pb); if (version == 5) avio_r8(pb); codecdata_length = avio_rb32(pb); if(codecdata_length + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)codecdata_length){ av_log(s, AV_LOG_ERROR, "codecdata_length too large\n"); return -1; } if (codecdata_length >= 1) { avio_r8(pb); if ((ret = rm_read_extradata(pb, st->codec, codecdata_length - 1)) < 0) return ret; } break; default: av_strlcpy(st->codec->codec_name, buf, sizeof(st->codec->codec_name)); } if (read_all) { avio_r8(pb); avio_r8(pb); avio_r8(pb); rm_read_metadata(s, 0); } } return 0; }
1threat
aio_read_f(int argc, char **argv) { int nr_iov, c; struct aio_ctx *ctx = calloc(1, sizeof(struct aio_ctx)); BlockDriverAIOCB *acb; while ((c = getopt(argc, argv, "CP:qv")) != EOF) { switch (c) { case 'C': ctx->Cflag = 1; break; case 'P': ctx->Pflag = 1; ctx->pattern = parse_pattern(optarg); if (ctx->pattern < 0) return 0; break; case 'q': ctx->qflag = 1; break; case 'v': ctx->vflag = 1; break; default: free(ctx); return command_usage(&aio_read_cmd); } } if (optind > argc - 2) { free(ctx); return command_usage(&aio_read_cmd); } ctx->offset = cvtnum(argv[optind]); if (ctx->offset < 0) { printf("non-numeric length argument -- %s\n", argv[optind]); free(ctx); return 0; } optind++; if (ctx->offset & 0x1ff) { printf("offset %" PRId64 " is not sector aligned\n", ctx->offset); free(ctx); return 0; } nr_iov = argc - optind; ctx->buf = create_iovec(&ctx->qiov, &argv[optind], nr_iov, 0xab); gettimeofday(&ctx->t1, NULL); acb = bdrv_aio_readv(bs, ctx->offset >> 9, &ctx->qiov, ctx->qiov.size >> 9, aio_read_done, ctx); if (!acb) { free(ctx->buf); free(ctx); return -EIO; } return 0; }
1threat
List-initialization of an array without temporaries - not working in GCC : <p>Consider the following contrived example</p> <pre><code>struct A { A(int) {} A(const A&amp;) = delete; ~A() {} }; struct B { A a[2] = {{1}, {2}}; }; int main() { B b; } </code></pre> <p>It compiles fine in <strong>clang</strong> (any version) but not in <strong>GCC</strong> (any version, any standard >= C++11)</p> <pre><code>&lt;source&gt;: In constructor 'constexpr B::B()': &lt;source&gt;:7:8: error: use of deleted function 'A::A(const A&amp;)' struct B { ^ &lt;source&gt;:3:5: note: declared here A(const A&amp;) = delete; ^ &lt;source&gt;: In function 'int main()': &lt;source&gt;:12:7: note: synthesized method 'constexpr B::B()' first required here B b; ^ </code></pre> <p><a href="https://gcc.godbolt.org/z/DneRbb" rel="noreferrer">LIVE DEMO</a></p> <p>When A's destructor is commented out, it compiles fine also in GCC.</p> <p><strong>Question is</strong> - who is right, clang or GCC, and why?</p> <p>Initially I thought GCC is wrong, but then I saw <a href="https://timsong-cpp.github.io/cppwp/n3337/dcl.init.list#5" rel="noreferrer">[dcl.init.list]/5</a> which states that temporaries are created. Though I'm not sure if that applies here or if there's another rule that overrides this.</p>
0debug
static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index) { AVPacket out_pkt = { 0 }, flush_pkt = { 0 }; AVStream *st = s->streams[stream_index]; uint8_t *data = pkt ? pkt->data : NULL; int size = pkt ? pkt->size : 0; int ret = 0, got_output = 0; if (!pkt) { av_init_packet(&flush_pkt); pkt = &flush_pkt; got_output = 1; } while (size > 0 || (pkt == &flush_pkt && got_output)) { int len; av_init_packet(&out_pkt); len = av_parser_parse2(st->parser, st->codec, &out_pkt.data, &out_pkt.size, data, size, pkt->pts, pkt->dts, pkt->pos); pkt->pts = pkt->dts = AV_NOPTS_VALUE; data += len; size -= len; got_output = !!out_pkt.size; if (!out_pkt.size) continue; if (pkt->side_data) { out_pkt.side_data = pkt->side_data; out_pkt.side_data_elems = pkt->side_data_elems; pkt->side_data = NULL; pkt->side_data_elems = 0; } out_pkt.duration = 0; if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) { if (st->codec->sample_rate > 0) { out_pkt.duration = av_rescale_q_rnd(st->parser->duration, (AVRational) { 1, st->codec->sample_rate }, st->time_base, AV_ROUND_DOWN); } } out_pkt.stream_index = st->index; out_pkt.pts = st->parser->pts; out_pkt.dts = st->parser->dts; out_pkt.pos = st->parser->pos; if (st->parser->key_frame == 1 || (st->parser->key_frame == -1 && st->parser->pict_type == AV_PICTURE_TYPE_I)) out_pkt.flags |= AV_PKT_FLAG_KEY; compute_pkt_fields(s, st, st->parser, &out_pkt); if ((s->iformat->flags & AVFMT_GENERIC_INDEX) && out_pkt.flags & AV_PKT_FLAG_KEY) { ff_reduce_index(s, st->index); av_add_index_entry(st, st->parser->frame_offset, out_pkt.dts, 0, 0, AVINDEX_KEYFRAME); } if (out_pkt.data == pkt->data && out_pkt.size == pkt->size) { out_pkt.buf = pkt->buf; pkt->buf = NULL; } if ((ret = av_dup_packet(&out_pkt)) < 0) goto fail; if (!add_to_pktbuf(&s->internal->parse_queue, &out_pkt, &s->internal->parse_queue_end)) { av_packet_unref(&out_pkt); ret = AVERROR(ENOMEM); goto fail; } } if (pkt == &flush_pkt) { av_parser_close(st->parser); st->parser = NULL; } fail: av_packet_unref(pkt); return ret; }
1threat
How to update S3 bucket with expire date using AWS CLI : <p>I would like to update the S3 bucket with the new content(create a folder within a bucket). What is the <code>--expires</code> date format. I didn't find any examples using <code>AWS CLI</code> on google. Can someone please help me on this thing? </p> <p>Something like this:</p> <pre><code>aws s3 sync $backup_home s3://backup/$app-backup/$app-$DATE --expires '$DATE' </code></pre>
0debug
How do I get the private key for a GoDaddy certificate so I can install it on Ubuntu 14+? : <p>The cert I have from StartSSL comes with a key file. But from GoDaddy, I get only the 2 .crt files. GoDaddy's instructions are for CentOS and explicitly do not work for Ubuntu.</p> <p>How do I export the private key ... or get it from somewhere ... so I can use it with Apache SSL? The question that is ALMOST the same as mine assumes use of a Mac Keychain application. I don't run a Mac and I'm trying to do everything on the Ubuntu command line. I know there's a way to do this ... can anyone help me find it?</p> <p>Thanks!</p>
0debug
sql server query with joins : want to write a one single query that return table names,no of rows,table size,date table created and modified,table created by? i have 4 tables in my database.please help me out --my database CREATE TABLE Branch( Br_ID int IDENTITY (1,1)PRIMARY KEY, Name varchar(255), Desp varchar (255) ); CREATE TABLE Region( R_ID int IDENTITY(1,1) PRIMARY KEY, Name varchar(255), Desp varchar(255) ); CREATE TABLE Customer( Cust_ID int IDENTITY(1,1) PRIMARY KEY, Name varchar(255), Desp varchar(255) ); CREATE TABLE Customer_Branch( Br_ID int FOREIGN KEY REFERENCES Branch(Br_ID)not null, Cust_ID int FOREIGN KEY REFERENCES Customer(Cust_ID) not null, PRIMARY KEY (Br_ID,Cust_ID) ); INSERT INTO Branch (Name,Desp) VALUES ('xyz','headoffice');
0debug
C: Evaluation of pointer arihmetic: When is an operation done? : <pre><code>void add( int a, int b) { a += b; } void sub( int *a, int* b) { *a -= *b; } void mul( int a, int *b) { a *= *b; } void div( int *a, int b) { *a /= b; } int a = 2, b = 3; sub( &amp;a, &amp;a ); add( a, b ); div( &amp;a, b ); mul( b, &amp;a ); div( &amp;b, b ); add( b, a ); printf( "%d\n", a ); printf( "%d\n", b ); </code></pre> <p>Why isn't a = 1 and b = 2, instead a = 0 and b = 1. Can anyone explain to me what *, &amp;, so what pointer, in this code is the reason for doing an operation?</p>
0debug
static int compat_decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, const AVPacket *pkt) { AVCodecInternal *avci = avctx->internal; int ret; av_assert0(avci->compat_decode_consumed == 0); *got_frame = 0; avci->compat_decode = 1; if (avci->compat_decode_partial_size > 0 && avci->compat_decode_partial_size != pkt->size) { av_log(avctx, AV_LOG_ERROR, "Got unexpected packet size after a partial decode\n"); ret = AVERROR(EINVAL); goto finish; } if (!avci->compat_decode_partial_size) { ret = avcodec_send_packet(avctx, pkt); if (ret == AVERROR_EOF) ret = 0; else if (ret == AVERROR(EAGAIN)) { ret = AVERROR_BUG; goto finish; } else if (ret < 0) goto finish; } while (ret >= 0) { ret = avcodec_receive_frame(avctx, frame); if (ret < 0) { if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) ret = 0; goto finish; } if (frame != avci->compat_decode_frame) { if (!avctx->refcounted_frames) { ret = unrefcount_frame(avci, frame); if (ret < 0) goto finish; } *got_frame = 1; frame = avci->compat_decode_frame; } else { if (!avci->compat_decode_warned) { av_log(avctx, AV_LOG_WARNING, "The deprecated avcodec_decode_* " "API cannot return all the frames for this decoder. " "Some frames will be dropped. Update your code to the " "new decoding API to fix this.\n"); avci->compat_decode_warned = 1; } } if (avci->draining || (!avctx->codec->bsfs && avci->compat_decode_consumed < pkt->size)) break; } finish: if (ret == 0) { if (avctx->codec->bsfs) ret = pkt->size; else ret = FFMIN(avci->compat_decode_consumed, pkt->size); } avci->compat_decode_consumed = 0; avci->compat_decode_partial_size = (ret >= 0) ? pkt->size - ret : 0; return ret; }
1threat
Dynamic href tag React in JSX : <pre><code>// This Javascript &lt;a&gt; tag generates correctly React.createElement('a', {href:"mailto:"+this.props.email}, this.props.email) </code></pre> <p>However, I'm struggling to recreate it in JSX</p> <pre><code>&lt;a href="mailto: {this.props.email}"&gt;{this.props.email}&lt;/a&gt; // =&gt; &lt;a href="mailto: {this.props.email}"&gt;&lt;/a&gt; </code></pre> <p>The href tag thinks the <code>{this.props.email}</code> is a string instead of dynamically inputting the value of <code>{this.props.email}</code>. Any ideas on where I went amiss?</p>
0debug
static int mov_write_wave_tag(AVIOContext *pb, MOVTrack *track) { int64_t pos = avio_tell(pb); avio_wb32(pb, 0); ffio_wfourcc(pb, "wave"); if (track->enc->codec_id != AV_CODEC_ID_QDM2) { avio_wb32(pb, 12); ffio_wfourcc(pb, "frma"); avio_wl32(pb, track->tag); } if (track->enc->codec_id == AV_CODEC_ID_AAC) { avio_wb32(pb, 12); ffio_wfourcc(pb, "mp4a"); avio_wb32(pb, 0); mov_write_esds_tag(pb, track); } else if (mov_pcm_le_gt16(track->enc->codec_id)) { mov_write_enda_tag(pb); } else if (track->enc->codec_id == AV_CODEC_ID_AMR_NB) { mov_write_amr_tag(pb, track); } else if (track->enc->codec_id == AV_CODEC_ID_AC3) { mov_write_ac3_tag(pb, track); } else if (track->enc->codec_id == AV_CODEC_ID_ALAC || track->enc->codec_id == AV_CODEC_ID_QDM2) { mov_write_extradata_tag(pb, track); } else if (track->enc->codec_id == AV_CODEC_ID_ADPCM_MS || track->enc->codec_id == AV_CODEC_ID_ADPCM_IMA_WAV) { mov_write_ms_tag(pb, track); } avio_wb32(pb, 8); avio_wb32(pb, 0); return update_size(pb, pos); }
1threat
how to fix it python flask we application error for internal server? : <p>I code in python using flask frame work to built an application But it showing internal server error while redirecting to the next page. the log in page contain the path which going to redirect to the next page.so how to fix that problem. This is code for the app.py file.</p> <pre><code>from flask import Flask, request, render_template from flaskext.mysql import MySQL app = Flask(__name__) mysql = MySQL() app = Flask(__name__) app.config['MYSQL_DATABASE_USER'] = 'root' app.config['MYSQL_DATABASE_PASSWORD'] = '' app.config['MYSQL_DATABASE_DB'] = 'invertoryDb' app.config['MYSQL_DATABASE_HOST'] = 'localhost' MYSQL_DATABASE_SOCKET = '/tmp/mysql.sock' mysql.init_app(app) @app.route('/') def my_form(): return render_template('loginPage.html') @app.route('/login', methods=['POST']) def Authenticate(): username = request.form['username'] password = request.form['password'] cursor = mysql.connect().cursor() cursor.execute("SELECT * FROM user WHERE username='"+username+"' and password='"+password+"'") data = cursor.fetchone() if data is None: return "usernme and password is wrong" else: return "logged in succesfully" if __name__ == '__main__': app.run() </code></pre> <p>this is the code for html file.</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Login page&lt;/title&gt; &lt;style type="text/css"&gt; * { box-sizing: border-box; } *:focus { outline: none; } body { font-family: Arial; background-color: #3498DB; padding: 50px; } .login { margin: 20px auto; width: 300px; } .login-screen { background-color: #FFF; padding: 20px; border-radius: 5px } .app-title { text-align: center; color: #777; } .login-form { text-align: center; } .control-group { margin-bottom: 10px; } input { text-align: center; background-color: #ECF0F1; border: 2px solid transparent; border-radius: 3px; font-size: 16px; font-weight: 200; padding: 10px 0; width: 250px; transition: border .5s; } input:focus { border: 2px solid #3498DB; box-shadow: none; } .btn { border: 2px solid transparent; background: #3498DB; color: #ffffff; font-size: 16px; line-height: 25px; padding: 10px 0; text-decoration: none; text-shadow: none; border-radius: 3px; box-shadow: none; transition: 0.25s; display: block; width: 250px; margin: 0 auto; } .btn:hover { background-color: #2980B9; } .login-link { font-size: 12px; color: #444; display: block; margin-top: 12px; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="/login" method="POST"&gt; &lt;div class="login"&gt; &lt;div class="login-screen"&gt; &lt;div class="app-title"&gt; &lt;h1&gt;Login&lt;/h1&gt; &lt;/div&gt; &lt;div class="login-form"&gt; &lt;div class="control-group"&gt; &lt;input type="text" class="login-field" value="" placeholder="username" name="username"&gt; &lt;label class="login-field-icon fui-user" for="login-name"&gt;&lt;/label&gt;&lt;/div&gt; &lt;div class="control-group"&gt; &lt;input type="password" class="login-field" value="" placeholder="password" name="password"&gt; &lt;label class="login-field-icon fui-lock" for="login-pass"&gt;&lt;/label&gt;&lt;/div&gt; &lt;input type="submit" value="Log in" class="btn btn-primary btn-large btn-block"&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and this is the run console for the application.(error list)</p> <pre><code>127.0.0.1 - - [03/Feb/2020 11:58:41] "GET / HTTP/1.1" 200 - 127.0.0.1 - - [03/Feb/2020 11:58:41] "GET / HTTP/1.1" 200 - [2020-02-03 11:58:54,752] ERROR in app: Exception on /login [POST] Traceback (most recent call last): File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 2446, in wsgi_app response = self.full_dispatch_request() File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 1951, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 1820, in ha ndle_user_exception reraise(exc_type, exc_value, tb) File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\_compat.py", line 39, in reraise raise value File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 1949, in full_dispatch_request rv = self.dispatch_request() File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 1935, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "C:\Users\OWNER\PycharmProjects\untitled\app.py", line 27, in Authenticate cursor = mysql.connect().cursor() File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flaskext\mysql.py", line 54, in connect if self.app.config['MYSQL_DATABASE_SOCKET']: KeyError: 'MYSQL_DATABASE_SOCKET' 127.0.0.1 - - [03/Feb/2020 11:58:54] "POST /login HTTP/1.1" 500 - </code></pre>
0debug
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
Qeustion about the consumption of memory in OpenCV : Cross post [here](http://answers.opencv.org/question/178949/problem-about-the-consumption-of-memory/) *** I have such simple code: //OpenCV 3.3.1 project #include<opencv.hpp> #include<iostream> using namespace std; using namespace cv; Mat removeBlackEdge(Mat img) { if (img.channels() != 1) cvtColor(img, img, COLOR_BGR2GRAY); Mat bin, whiteEdge; threshold(img, bin, 0, 255, THRESH_BINARY_INV + THRESH_OTSU); rectangle(bin, Rect(0, 0, bin.cols, bin.rows), Scalar(255)); whiteEdge = bin.clone(); floodFill(bin, Point(0, 0), Scalar(0)); dilate(whiteEdge - bin, whiteEdge, Mat()); return whiteEdge + img; } int main() { //13.0M Mat emptyImg = imread("test.png", 0); //14.7M emptyImg = removeBlackEdge(emptyImg); //33.0M waitKey(); return 0; } And this is my [test.png](http://answers.opencv.org/upfiles/15113815462075951.jpg). As the Windows show, it's size is about `1.14M`. Of course I know it will be larger when it is read in memory. But I fill cannot accept the huge consumption of memory. If I use F10, I can know the `project.exe` take up `13.0M`. I have nothing to say about it When I run `Mat emptyImg = imread("test.png", 0);`, the consumption of memory is `14.7M`. It is normal also. But why when I run `emptyImg = removeBlackEdge(emptyImg);`, the consumption of memory is up to `33.0M`?? It mean function `removeBlackEdge` cost my extra `18.3M` memory. Can anybody tell me some thing? I cannot totally accept such huge consumption of memory. Is there I miss something? I use new `emptyImg` to replace the old `emptyImg`. I think I don't need extra memory to cost? **Ps:** If I want implement to do same thing by my `removeBlackEdge`( delete that black edge in the image), how to adjust it to cost minimum consumption of memory?
0debug
void bdrv_set_dirty_tracking(BlockDriverState *bs, int enable) { int64_t bitmap_size; if (enable) { if (bs->dirty_tracking == 0) { int64_t i; uint8_t test; bitmap_size = (bdrv_getlength(bs) >> BDRV_SECTOR_BITS); bitmap_size /= BDRV_SECTORS_PER_DIRTY_CHUNK; bitmap_size++; bs->dirty_bitmap = qemu_mallocz(bitmap_size); bs->dirty_tracking = enable; for(i = 0; i < bitmap_size; i++) test = bs->dirty_bitmap[i]; } } else { if (bs->dirty_tracking != 0) { qemu_free(bs->dirty_bitmap); bs->dirty_tracking = enable; } } }
1threat
insert a node at nth position in c ; whats wrong in this : Node* InsertNth(Node *head, int data, int position) { int i; struct Node *h=head; struct Node *p=(struct Node *)malloc(sizeof(struct Node)); p->data=data; for(i=0;i<position ;i++){ h=h->next; } p->next=h; h=p; if(position==0){ return h; } else return head; }
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
Determine array type based on signature : Based on the signature, determine if the array is most likely perfect sized or oversized. I know perfect sized arrays are used when the size of the array is known, otherwise an oversized array is used, but I don’t know how to determine the array type based on a signature. For example: public static void myMethod(int[] ray, int size) Or: public static myMethod(int[] ray, boolean value)
0debug
Get first and second element satisfying a CSS path : <p>Let's say I have a CSS path: <code>.event__participant.event__participant--away</code> How can I get the first element satisfying that path? Or second element? Or X element? I'm using selenium and I don't want to be getting all 100+ of them. <code>:nth-type-of</code> doesn't work and I can't use <code>nth-child</code> because it has more children than just <code>.event__participant--away</code>.</p>
0debug
int kvm_on_sigbus(int code, void *addr) { #if defined(KVM_CAP_MCE) if ((first_cpu->mcg_cap & MCG_SER_P) && addr && code == BUS_MCEERR_AO) { uint64_t status; void *vaddr; ram_addr_t ram_addr; target_phys_addr_t paddr; vaddr = addr; if (qemu_ram_addr_from_host(vaddr, &ram_addr) || !kvm_physical_memory_addr_from_ram(first_cpu->kvm_state, ram_addr, &paddr)) { fprintf(stderr, "Hardware memory error for memory used by " "QEMU itself instead of guest system!: %p\n", addr); return 0; } status = MCI_STATUS_VAL | MCI_STATUS_UC | MCI_STATUS_EN | MCI_STATUS_MISCV | MCI_STATUS_ADDRV | MCI_STATUS_S | 0xc0; kvm_inject_x86_mce(first_cpu, 9, status, MCG_STATUS_MCIP | MCG_STATUS_RIPV, paddr, (MCM_ADDR_PHYS << 6) | 0xc, ABORT_ON_ERROR); kvm_mce_broadcast_rest(first_cpu); } else #endif { if (code == BUS_MCEERR_AO) { return 0; } else if (code == BUS_MCEERR_AR) { hardware_memory_error(); } else { return 1; } } return 0; }
1threat
XML Comparison which having attributes in SQL server : I'm having two XML strings in two seperate tables. **ROOT** **Node ID=** 1 **name** vignesh **/name** **street** 1211 **/street** **/Node** **Node ID=** 2 **name** ram **/name** **street** 333 **/street** **/Node** **/ROOT** ---------- **ROOT** **Node ID=** 1 **name** newbie **/name** **street** 121223 **/street** **/Node** **Node ID=** 2 **name** pro **/name** **street** 445**/street** **/Node** **/ROOT** ---------- Please help me to find the comparison between these two XMLs in **SQL** Server and give result as Old value and New value for both ID1 and ID2(Node).
0debug
missing composer.json file while installing composer for laravel : I am new to laravel. i am trying to install composer for laravel but getting this error: Composer could not find a composer.json file in C:\xampp\htdocs To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section Please anyone help me. Thanks.
0debug
How to ask user to input an integer number only : I want to ask the user to input only intiger, which will be stored in a variable,, and when user inputs a string, then ask again to input a number, not string. Thanks
0debug
Desecion trees ended up with same given tree after gain/split computation? : I was given a decision tree with sample data in class to solve. After computing the gaining/splitting tree with the sample data provided, I ended up with the same tree that was in the question. What does that mean? Can someone explain what happened there?
0debug
static int bitplane_decoding(uint8_t* data, int *raw_flag, VC1Context *v) { GetBitContext *gb = &v->s.gb; int imode, x, y, code, offset; uint8_t invert, *planep = data; int width, height, stride; width = v->s.mb_width; height = v->s.mb_height >> v->field_mode; stride = v->s.mb_stride; invert = get_bits1(gb); imode = get_vlc2(gb, ff_vc1_imode_vlc.table, VC1_IMODE_VLC_BITS, 1); *raw_flag = 0; switch (imode) { case IMODE_RAW: *raw_flag = 1; return invert; case IMODE_DIFF2: case IMODE_NORM2: if ((height * width) & 1) { *planep++ = get_bits1(gb); offset = 1; } else offset = 0; for (y = offset; y < height * width; y += 2) { code = get_vlc2(gb, ff_vc1_norm2_vlc.table, VC1_NORM2_VLC_BITS, 1); *planep++ = code & 1; offset++; if (offset == width) { offset = 0; planep += stride - width; } *planep++ = code >> 1; offset++; if (offset == width) { offset = 0; planep += stride - width; } } break; case IMODE_DIFF6: case IMODE_NORM6: if (!(height % 3) && (width % 3)) { for (y = 0; y < height; y += 3) { for (x = width & 1; x < width; x += 2) { code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2); if (code < 0) { av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); return -1; } planep[x + 0] = (code >> 0) & 1; planep[x + 1] = (code >> 1) & 1; planep[x + 0 + stride] = (code >> 2) & 1; planep[x + 1 + stride] = (code >> 3) & 1; planep[x + 0 + stride * 2] = (code >> 4) & 1; planep[x + 1 + stride * 2] = (code >> 5) & 1; } planep += stride * 3; } if (width & 1) decode_colskip(data, 1, height, stride, &v->s.gb); } else { planep += (height & 1) * stride; for (y = height & 1; y < height; y += 2) { for (x = width % 3; x < width; x += 3) { code = get_vlc2(gb, ff_vc1_norm6_vlc.table, VC1_NORM6_VLC_BITS, 2); if (code < 0) { av_log(v->s.avctx, AV_LOG_DEBUG, "invalid NORM-6 VLC\n"); return -1; } planep[x + 0] = (code >> 0) & 1; planep[x + 1] = (code >> 1) & 1; planep[x + 2] = (code >> 2) & 1; planep[x + 0 + stride] = (code >> 3) & 1; planep[x + 1 + stride] = (code >> 4) & 1; planep[x + 2 + stride] = (code >> 5) & 1; } planep += stride * 2; } x = width % 3; if (x) decode_colskip(data, x, height, stride, &v->s.gb); if (height & 1) decode_rowskip(data + x, width - x, 1, stride, &v->s.gb); } break; case IMODE_ROWSKIP: decode_rowskip(data, width, height, stride, &v->s.gb); break; case IMODE_COLSKIP: decode_colskip(data, width, height, stride, &v->s.gb); break; default: break; } if (imode == IMODE_DIFF2 || imode == IMODE_DIFF6) { planep = data; planep[0] ^= invert; for (x = 1; x < width; x++) planep[x] ^= planep[x-1]; for (y = 1; y < height; y++) { planep += stride; planep[0] ^= planep[-stride]; for (x = 1; x < width; x++) { if (planep[x-1] != planep[x-stride]) planep[x] ^= invert; else planep[x] ^= planep[x-1]; } } } else if (invert) { planep = data; for (x = 0; x < stride * height; x++) planep[x] = !planep[x]; } return (imode << 1) + invert; }
1threat
How do I write logs from within Startup.cs : <p>In order to debug a .net core app which is failing on startup, I would like to write logs from within the startup.cs file. I have logging setup within the file that can be used in rest of the app outside the startup.cs file, but not sure how to write logs from within the startup.cs file itself.</p>
0debug
void gic_set_priority(GICState *s, int cpu, int irq, uint8_t val) { if (irq < GIC_INTERNAL) { s->priority1[irq][cpu] = val; } else { s->priority2[(irq) - GIC_INTERNAL] = val; } }
1threat
how to scroll PDF which is inside iframe in selenium java : here is the tag of document place under <iframe height="900" width="100%" src="/attachments/download/Attachment.pdf" title="document"/>
0debug
Creating Piano with C# part 2 : <p>In relation to my previous question I posted, I am creating a c# piano which will display a keyboard which when clicking on a music key will display a music note shape and output a music sound. However, I encountered another problem. When I click on a music key it outputs the required image, but when I click again on another again with a different duration the same image stays and does not change. Can anyone help me with this please ?</p> <pre><code>using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Media; using System.IO; using System.Reflection; using System.Diagnostics; namespace NewPiano { public partial class Form1 : Form { public Form1() { InitializeComponent(); } SoundPlayer sp = new SoundPlayer(); long count; private Control mn; Stopwatch watch = new Stopwatch(); private void Form1_Load(object sender, System.EventArgs e) { MusKey mk; BlackMusKey bmk; int[] whitePitch = { 1, 3, 5, 6, 8, 10, 12, 13, 15, 17, 18, 20, 22, 24 }; int[] blackPitch = new int[] { 2, 4, 7, 9, 11, 14, 16, 19, 21, 23 }; int[] xPos = new int[] { 10, 30, 70, 90, 110, 150, 170, 210, 230, 250 }; for (int k = 0; k &lt; 7; k++) { int iNote = whitePitch[k]; int xpos = k * 40; mk = new MusKey(iNote, xpos + 150, 120); mk.MouseDown += new System.Windows.Forms.MouseEventHandler(this.button1_MouseDown); mk.MouseUp += new System.Windows.Forms.MouseEventHandler(this.button1_MouseUp); this.panel1.Controls.Add(mk); } int xOffs = 20; for (int k = 0; k &lt; 5; k++) { int iNote = blackPitch[k]; int xpos = xPos[k] * 2; bmk = new BlackMusKey(iNote, xpos + 150, 120); bmk.MouseDown += new System.Windows.Forms.MouseEventHandler(this.button1_MouseDown); bmk.MouseUp += new System.Windows.Forms.MouseEventHandler(this.button1_MouseUp); this.panel1.Controls.Add(bmk); this.panel1.Controls[this.panel1.Controls.Count - 1].BringToFront(); } } private void button1_MouseDown(object sender, MouseEventArgs e) { watch.Reset(); foreach (MusKey mk in panel1.Controls.OfType&lt;MusKey&gt;()) { if (sender == mk) { if (e.Button == MouseButtons.Left) { watch.Start(); count = 0; sp.SoundLocation = @"C:/Users/Kim/Desktop/Notes-Sound files/mapped/" + mk.musicNote + ".wav"; //change this to the location of your "mapped" folder sp.Load(); sp.Play(); } } } } private void button1_MouseUp(object sender, MouseEventArgs e) { foreach (MusKey mk in panel1.Controls.OfType&lt;MusKey&gt;()) { if (sender == mk) { if (e.Button == MouseButtons.Left) { watch.Stop(); count = watch.ElapsedMilliseconds; } sp.Stop(); int duration = 0; string bNoteShape = null; int pitch = 0; if (count &gt;=2024) { bNoteShape = "SemiBreve"; duration = (16 + 20) / 2; pitch = 1; } else if ((count &gt;= 1024) &amp;&amp; (count &lt; 2024)) { bNoteShape = "DotMinim"; duration = (11 + 15) / 2; //average pitch = 2; } else if ((count &gt;= 768) &amp;&amp; (count &lt; 1024)) { bNoteShape = "minim"; duration = (6 + 10) / 2; //average pitch = 3; } else if ((count &gt;= 512) &amp;&amp; (count &lt; 768)) { bNoteShape = "Crotchet"; duration = (3 + 5) / 2; //average pitch = 4; } else if ((count &gt;= 256 &amp;&amp; count &lt; 512)) { bNoteShape = "Quaver"; duration = 2; //average pitch = 5; } else if ((count == 0 || count &lt; 256)) { bNoteShape = "SemiQuaver"; duration = 1; pitch = 6; } MusicNote mn = new MusicNote(count, pitch, bNoteShape, duration); panel1.Controls.Add(mn.drawNote()); watch.Restart(); } } } private void panel1_Paint(object sender, PaintEventArgs e) { System.Drawing.Graphics graphicsObj; graphicsObj = this.panel1.CreateGraphics(); Pen myPen = new Pen(System.Drawing.Color.Black, 1); for (int k = 0; k &lt; 5; k++) { int ypos = (k * 15) + 20; graphicsObj.DrawLine(myPen, 20, ypos, 550, ypos); } } } } </code></pre> <p>Music Note Class:</p> <pre><code>using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; using System.Reflection; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace NewPiano { class MusicNote { public long noteID; public int pitch = 0; public string shape = ""; public int duration = 0; public MusicNote() { } public MusicNote(long count, int mpitch, string shape, int duration) { this.noteID = count; this.shape = shape; this.duration = duration; this.pitch = mpitch; } public PictureBox drawNote() { PictureBox noteDrawing = new PictureBox(); noteDrawing.Size = new System.Drawing.Size(40, 40); noteDrawing.Location = new System.Drawing.Point(10, 10); noteDrawing.ImageLocation = @"C:/Users/Kim/Desktop/Notes-Images/" + shape + ".bmp"; return noteDrawing; } /*public void PlayAllNotesOnClick() { System.Media.SoundPlayer player = new System.Media.SoundPlayer(); player.SoundLocation = "C:/Users/Kim/Desktop/Notes-Sound files/mapped/" + this.pitch + ".wav"; player.Play(); System.Threading.Thread.Sleep(duration + 100); player.Stop(); } */ public void onDrag(int pitch) { if (pitch &gt; 150 &amp;&amp; pitch &lt; 155) { this.pitch = 1; } if (pitch &gt; 100 &amp;&amp; pitch &lt; 154) { this.pitch = 2; } if (pitch &gt; 75 &amp;&amp; pitch &lt; 99) { this.pitch = 5; } if (pitch &gt; 50 &amp;&amp; pitch &lt; 74) { this.pitch = 6; } //this.pitch = pitch; } } } </code></pre>
0debug
static void to_json(const QObject *obj, QString *str, int pretty, int indent) { switch (qobject_type(obj)) { case QTYPE_QINT: { QInt *val = qobject_to_qint(obj); char buffer[1024]; snprintf(buffer, sizeof(buffer), "%" PRId64, qint_get_int(val)); qstring_append(str, buffer); break; } case QTYPE_QSTRING: { QString *val = qobject_to_qstring(obj); const char *ptr; ptr = qstring_get_str(val); qstring_append(str, "\""); while (*ptr) { if ((ptr[0] & 0xE0) == 0xE0 && (ptr[1] & 0x80) && (ptr[2] & 0x80)) { uint16_t wchar; char escape[7]; wchar = (ptr[0] & 0x0F) << 12; wchar |= (ptr[1] & 0x3F) << 6; wchar |= (ptr[2] & 0x3F); ptr += 2; snprintf(escape, sizeof(escape), "\\u%04X", wchar); qstring_append(str, escape); } else if ((ptr[0] & 0xE0) == 0xC0 && (ptr[1] & 0x80)) { uint16_t wchar; char escape[7]; wchar = (ptr[0] & 0x1F) << 6; wchar |= (ptr[1] & 0x3F); ptr++; snprintf(escape, sizeof(escape), "\\u%04X", wchar); qstring_append(str, escape); } else switch (ptr[0]) { case '\"': qstring_append(str, "\\\""); break; case '\\': qstring_append(str, "\\\\"); break; case '\b': qstring_append(str, "\\b"); break; case '\f': qstring_append(str, "\\f"); break; case '\n': qstring_append(str, "\\n"); break; case '\r': qstring_append(str, "\\r"); break; case '\t': qstring_append(str, "\\t"); break; default: { if (ptr[0] <= 0x1F) { char escape[7]; snprintf(escape, sizeof(escape), "\\u%04X", ptr[0]); qstring_append(str, escape); } else { char buf[2] = { ptr[0], 0 }; qstring_append(str, buf); } break; } } ptr++; } qstring_append(str, "\""); break; } case QTYPE_QDICT: { ToJsonIterState s; QDict *val = qobject_to_qdict(obj); s.count = 0; s.str = str; s.indent = indent + 1; s.pretty = pretty; qstring_append(str, "{"); qdict_iter(val, to_json_dict_iter, &s); if (pretty) { int j; qstring_append(str, "\n"); for (j = 0 ; j < indent ; j++) qstring_append(str, " "); } qstring_append(str, "}"); break; } case QTYPE_QLIST: { ToJsonIterState s; QList *val = qobject_to_qlist(obj); s.count = 0; s.str = str; s.indent = indent + 1; s.pretty = pretty; qstring_append(str, "["); qlist_iter(val, (void *)to_json_list_iter, &s); if (pretty) { int j; qstring_append(str, "\n"); for (j = 0 ; j < indent ; j++) qstring_append(str, " "); } qstring_append(str, "]"); break; } case QTYPE_QFLOAT: { QFloat *val = qobject_to_qfloat(obj); char buffer[1024]; int len; len = snprintf(buffer, sizeof(buffer), "%f", qfloat_get_double(val)); while (len > 0 && buffer[len - 1] == '0') { len--; } if (len && buffer[len - 1] == '.') { buffer[len - 1] = 0; } else { buffer[len] = 0; } qstring_append(str, buffer); break; } case QTYPE_QBOOL: { QBool *val = qobject_to_qbool(obj); if (qbool_get_int(val)) { qstring_append(str, "true"); } else { qstring_append(str, "false"); } break; } case QTYPE_QERROR: case QTYPE_NONE: break; } }
1threat
static int pcm_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { const uint8_t *src = avpkt->data; int buf_size = avpkt->size; PCMDecode *s = avctx->priv_data; int sample_size, c, n, ret, samples_per_block; uint8_t *samples; int32_t *dst_int32_t; sample_size = av_get_bits_per_sample(avctx->codec_id) / 8; samples_per_block = 1; if (AV_CODEC_ID_PCM_DVD == avctx->codec_id) { if (avctx->bits_per_coded_sample != 20 && avctx->bits_per_coded_sample != 24) { av_log(avctx, AV_LOG_ERROR, "PCM DVD unsupported sample depth\n"); return AVERROR(EINVAL); } samples_per_block = 2; sample_size = avctx->bits_per_coded_sample * 2 / 8; } else if (avctx->codec_id == AV_CODEC_ID_PCM_LXF) { samples_per_block = 2; sample_size = 5; } if (sample_size == 0) { av_log(avctx, AV_LOG_ERROR, "Invalid sample_size\n"); return AVERROR(EINVAL); } n = avctx->channels * sample_size; if (n && buf_size % n) { if (buf_size < n) { av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n"); return -1; } else buf_size -= buf_size % n; } n = buf_size / sample_size; s->frame.nb_samples = n * samples_per_block / avctx->channels; if ((ret = avctx->get_buffer(avctx, &s->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } samples = s->frame.data[0]; switch (avctx->codec->id) { case AV_CODEC_ID_PCM_U32LE: DECODE(32, le32, src, samples, n, 0, 0x80000000) break; case AV_CODEC_ID_PCM_U32BE: DECODE(32, be32, src, samples, n, 0, 0x80000000) break; case AV_CODEC_ID_PCM_S24LE: DECODE(32, le24, src, samples, n, 8, 0) break; case AV_CODEC_ID_PCM_S24BE: DECODE(32, be24, src, samples, n, 8, 0) break; case AV_CODEC_ID_PCM_U24LE: DECODE(32, le24, src, samples, n, 8, 0x800000) break; case AV_CODEC_ID_PCM_U24BE: DECODE(32, be24, src, samples, n, 8, 0x800000) break; case AV_CODEC_ID_PCM_S24DAUD: for (; n > 0; n--) { uint32_t v = bytestream_get_be24(&src); v >>= 4; AV_WN16A(samples, ff_reverse[(v >> 8) & 0xff] + (ff_reverse[v & 0xff] << 8)); samples += 2; } break; case AV_CODEC_ID_PCM_S16LE_PLANAR: { n /= avctx->channels; for (c = 0; c < avctx->channels; c++) { samples = s->frame.extended_data[c]; #if HAVE_BIGENDIAN DECODE(16, le16, src, samples, n, 0, 0) #else memcpy(samples, src, n * 2); #endif src += n * 2; } break; } case AV_CODEC_ID_PCM_U16LE: DECODE(16, le16, src, samples, n, 0, 0x8000) break; case AV_CODEC_ID_PCM_U16BE: DECODE(16, be16, src, samples, n, 0, 0x8000) break; case AV_CODEC_ID_PCM_S8: for (; n > 0; n--) *samples++ = *src++ + 128; break; #if HAVE_BIGENDIAN case AV_CODEC_ID_PCM_F64LE: DECODE(64, le64, src, samples, n, 0, 0) break; case AV_CODEC_ID_PCM_S32LE: case AV_CODEC_ID_PCM_F32LE: DECODE(32, le32, src, samples, n, 0, 0) break; case AV_CODEC_ID_PCM_S16LE: DECODE(16, le16, src, samples, n, 0, 0) break; case AV_CODEC_ID_PCM_F64BE: case AV_CODEC_ID_PCM_F32BE: case AV_CODEC_ID_PCM_S32BE: case AV_CODEC_ID_PCM_S16BE: #else case AV_CODEC_ID_PCM_F64BE: DECODE(64, be64, src, samples, n, 0, 0) break; case AV_CODEC_ID_PCM_F32BE: case AV_CODEC_ID_PCM_S32BE: DECODE(32, be32, src, samples, n, 0, 0) break; case AV_CODEC_ID_PCM_S16BE: DECODE(16, be16, src, samples, n, 0, 0) break; case AV_CODEC_ID_PCM_F64LE: case AV_CODEC_ID_PCM_F32LE: case AV_CODEC_ID_PCM_S32LE: case AV_CODEC_ID_PCM_S16LE: #endif case AV_CODEC_ID_PCM_U8: memcpy(samples, src, n * sample_size); break; case AV_CODEC_ID_PCM_ZORK: for (; n > 0; n--) { int v = *src++; if (v < 128) v = 128 - v; *samples++ = v; } break; case AV_CODEC_ID_PCM_ALAW: case AV_CODEC_ID_PCM_MULAW: for (; n > 0; n--) { AV_WN16A(samples, s->table[*src++]); samples += 2; } break; case AV_CODEC_ID_PCM_DVD: { const uint8_t *src8; dst_int32_t = (int32_t *)s->frame.data[0]; n /= avctx->channels; switch (avctx->bits_per_coded_sample) { case 20: while (n--) { c = avctx->channels; src8 = src + 4 * c; while (c--) { *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8 & 0xf0) << 8); *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++ & 0x0f) << 12); } src = src8; } break; case 24: while (n--) { c = avctx->channels; src8 = src + 4 * c; while (c--) { *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8); *dst_int32_t++ = (bytestream_get_be16(&src) << 16) + ((*src8++) << 8); } src = src8; } break; } break; } case AV_CODEC_ID_PCM_LXF: { int i; n /= avctx->channels; for (c = 0; c < avctx->channels; c++) { dst_int32_t = (int32_t *)s->frame.extended_data[c]; for (i = 0; i < n; i++) { *dst_int32_t++ = (src[2] << 28) | (src[1] << 20) | (src[0] << 12) | ((src[2] & 0x0F) << 8) | src[1]; *dst_int32_t++ = (src[4] << 24) | (src[3] << 16) | ((src[2] & 0xF0) << 8) | (src[4] << 4) | (src[3] >> 4); src += 5; } } break; } default: return -1; } *got_frame_ptr = 1; *(AVFrame *)data = s->frame; return buf_size; }
1threat
Pointer offset causes overflow : <p>The following results don't make any sense to me. It looks like a negative offset is cast to unsigned before addition or subtraction are performed.</p> <pre><code>double[] x = new double[1000]; int i = 1; // for the overflow it makes no difference if it is long, int or short int j = -1; unsafe { fixed (double* px = x) { double* opx = px+500; // = 0x33E64B8 //unchecked //{ double* opx1 = opx+i; // = 0x33E64C0 double* opx2 = opx-i; // = 0x33E64B0 double* opx3 = opx+j; // = 0x33E64B0 if unchecked; throws overflow exception if checked double* opx4 = opx-j; // = 0x33E64C0 if unchecked; throws overflow exception if checked //} } } </code></pre> <p>Although it might seem strange to use negative offsets, there are use cases for it. In my case it was reflecting boundary conditions in a two-dimensional array.</p> <p>Of course, the overflow doesn't hurt too much because I can either use unchecked or move the sign of the value to the operation by inverting and applying it to the modulus of the operand.</p> <p>But this behaviour seems undocumented. According to <a href="https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/unsafe-code-pointers/arithmetic-operations-on-pointers" rel="noreferrer">MSDN</a> I don't expect negative offsets to be problematic:</p> <blockquote> <p>You can add a value n of type int, uint, long, or ulong to a pointer, p,of any type except void*. The result p+n is the pointer resulting from adding n * sizeof(p) to the address of p. Similarly, p-n is the pointer resulting from subtracting n * sizeof(p) from the address of p. </p> </blockquote>
0debug
static void scsi_hd_realize(SCSIDevice *dev, Error **errp) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); blkconf_blocksizes(&s->qdev.conf); s->qdev.blocksize = s->qdev.conf.logical_block_size; s->qdev.type = TYPE_DISK; if (!s->product) { s->product = g_strdup("QEMU HARDDISK"); } scsi_realize(&s->qdev, errp); }
1threat
Compile error when using std::cout between if/elseif statements : <p>I was wondering why I get a compile error when I try to use std::cout in between, say, an if statement and else if statement. For example:</p> <pre><code>if (condition) {body} std::cout &lt;&lt; "hello world" &lt;&lt; std::endl; else if (condition) {body} </code></pre> <p>Gives the error </p> <pre><code>error: 'else' without a previous 'if' </code></pre>
0debug
[] = (), () = (), and {} = () 'assignments' : <p>I was surprised to find the following, in Python 3, the first two raise nothing:</p> <pre><code>&gt;&gt;&gt; [] = () &gt;&gt;&gt; () = () &gt;&gt;&gt; {} = () File "&lt;stdin&gt;", line 1 SyntaxError: can't assign to literal </code></pre> <p>In Python 2.7, only the first one raises nothing:</p> <pre><code>&gt;&gt;&gt; [] = () &gt;&gt;&gt; () = () File "&lt;stdin&gt;", line 1 SyntaxError: can't assign to () &gt;&gt;&gt; {} = () File "&lt;stdin&gt;", line 1 SyntaxError: can't assign to literal </code></pre> <p>What is going on here? Why are any of then not raising errors? And why was the <code>() = ()</code> presumably added to be valid in Python 3?</p> <p>*Note, you can replace the right hand side with any empty iterable (e.g. <code>[] = set()</code>), I just choose an empty tuple for the illustration</p>
0debug
Use & to create a pointer to member : I'm trying to create a function that takes in a string, the reverses it, which is all being done in main. Here's what I have so far. #include <cstring> #include <iostream> #include <string> std::string str = "zombie"; void Reverse( std::string a) { char* a1 = a.c_str; char* a2; for (int i = (strlen(a1) -1); a1[i]!=0; i--) { a2 += a1[i]; } str = a2; } int main() { Reverse(str); std::cout << str << std::endl; } But i keep getting this error. I can't utilize pointers in this question. Any suggestions?
0debug
static inline void RENAME(yuv2rgb565_2)(SwsContext *c, const uint16_t *buf0, const uint16_t *buf1, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, const uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y) { x86_reg uv_off = c->uv_off << 1; __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB(%%REGBP, %5, %6) "pxor %%mm7, %%mm7 \n\t" #ifdef DITHER1XBPP "paddusb "BLUE_DITHER"(%5), %%mm2 \n\t" "paddusb "GREEN_DITHER"(%5), %%mm4 \n\t" "paddusb "RED_DITHER"(%5), %%mm5 \n\t" #endif WRITERGB16(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither), "m"(uv_off) ); }
1threat
Spring WebFlux, how can I debug my WebClient POST exchange? : <p>I am having trouble understanding what I've done wrong in constructing my WebClient request. I would like to understand what the actual HTTP request looks like. (e.g., dumping the raw request to console)</p> <pre><code>POST /rest/json/send HTTP/1.1 Host: emailapi.dynect.net Cache-Control: no-cache Postman-Token: 93e70432-2566-7627-6e08-e2bcf8d1ffcd Content-Type: application/x-www-form-urlencoded apikey=ABC123XYZ&amp;from=example%40example.com&amp;to=customer1%40domain.com&amp;to=customer2%40domain.com&amp;to=customer3%40domain.com&amp;subject=New+Sale+Coming+Friday&amp;bodytext=You+will+love+this+sale. </code></pre> <p>I am using Spring5's reactive tools to build an API. I have a utility class that will send an email using Dyn's email api. I would like to use The new WebClient class to accomplish this (<strong>org.springframework.web.reactive.function.client.WebClient</strong>)</p> <p>The following command has been taken from : <a href="https://help.dyn.com/email-rest-methods-api/sending-api/#postsend" rel="noreferrer">https://help.dyn.com/email-rest-methods-api/sending-api/#postsend</a></p> <pre><code>curl --request POST "https://emailapi.dynect.net/rest/json/send" --data "apikey=ABC123XYZ&amp;from=example@example.com&amp;to=customer1@domain.com&amp;to=customer2@domain.com&amp;to=customer3@domain.com&amp;subject=New Sale Coming Friday&amp;bodytext=You will love this sale." </code></pre> <p>When I make the call in curl with real values, the email sends correctly, so I feel like I am generating my request incorrectly.</p> <p>My Send Command</p> <pre><code>public Mono&lt;String&gt; send( DynEmailOptions options ) { WebClient webClient = WebClient.create(); HttpHeaders headers = new HttpHeaders(); // this line causes unsupported content type exception :( // headers.setContentType( MediaType.APPLICATION_FORM_URLENCODED ); Mono&lt;String&gt; result = webClient.post() .uri( "https://emailapi.dynect.net/rest/json/send" ) .headers( headers ) .accept( MediaType.APPLICATION_JSON ) .body( BodyInserters.fromObject( options ) ) .exchange() .flatMap( clientResponse -&gt; clientResponse.bodyToMono( String.class ) ); return result; } </code></pre> <p>My DynEmailOptions Class</p> <pre><code>import java.util.Collections; import java.util.Set; public class DynEmailOptions { public String getApikey() { return apiKey_; } public Set&lt;String&gt; getTo() { return Collections.unmodifiableSet( to_ ); } public String getFrom() { return from_; } public String getSubject() { return subject_; } public String getBodytext() { return bodytext_; } protected DynEmailOptions( String apiKey, Set&lt;String&gt; to, String from, String subject, String bodytext ) { apiKey_ = apiKey; to_ = to; from_ = from; subject_ = subject; bodytext_ = bodytext; } private Set&lt;String&gt; to_; private String from_; private String subject_; private String bodytext_; private String apiKey_; } </code></pre>
0debug
static void report_unavailable_features(FeatureWord w, uint32_t mask) { FeatureWordInfo *f = &feature_word_info[w]; int i; for (i = 0; i < 32; ++i) { if (1 << i & mask) { const char *reg = get_register_name_32(f->cpuid_reg); assert(reg); fprintf(stderr, "warning: %s doesn't support requested feature: " "CPUID.%02XH:%s%s%s [bit %d]\n", kvm_enabled() ? "host" : "TCG", f->cpuid_eax, reg, f->feat_names[i] ? "." : "", f->feat_names[i] ? f->feat_names[i] : "", i); } } }
1threat
void ff_flac_compute_autocorr(const int32_t *data, int len, int lag, double *autoc) { int i, j; double tmp[len + lag + 1]; double *data1= tmp + lag; apply_welch_window(data, len, data1); for(j=0; j<lag; j++) data1[j-lag]= 0.0; data1[len] = 0.0; for(j=0; j<lag; j+=2){ double sum0 = 1.0, sum1 = 1.0; for(i=0; i<len; i++){ sum0 += data1[i] * data1[i-j]; sum1 += data1[i] * data1[i-j-1]; } autoc[j ] = sum0; autoc[j+1] = sum1; } if(j==lag){ double sum = 1.0; for(i=0; i<len; i+=2){ sum += data1[i ] * data1[i-j ] + data1[i+1] * data1[i-j+1]; } autoc[j] = sum; } }
1threat