problem
stringlengths
26
131k
labels
class label
2 classes
How can I mock Webpack's require.context in Jest? : <p>Suppose I have the following module:</p> <pre><code>var modulesReq = require.context('.', false, /\.js$/); modulesReq.keys().forEach(function(module) { modulesReq(module); }); </code></pre> <p>Jest complains because it doesn't know about <code>require.context</code>:</p> <pre><code> FAIL /foo/bar.spec.js (0s) ● Runtime Error - TypeError: require.context is not a function </code></pre> <p>How can I mock it? I tried using <a href="http://facebook.github.io/jest/docs/api.html#setuptestframeworkscriptfile-string"><code>setupTestFrameworkScriptFile</code></a> Jest configuration but the tests can't see any changes that I've made in <code>require</code>.</p>
0debug
Html head meta tags explanation required? : <p>I have seen the following meta tags in many places can anyone explain that are these necessary and how? What do they exactly mean?</p> <pre><code>&lt;meta name="hdl" content=""&gt; &lt;meta name="lp" content=""&gt; &lt;meta name="byl" content=""&gt; &lt;meta name="utime" content=""&gt; &lt;meta name="ptime" content=""&gt; &lt;meta name="pdate" content=""&gt; &lt;meta name="dat" content=""&gt; &lt;meta name="CG" content=""&gt; &lt;meta name="SCG" content=""&gt; &lt;meta name="PT" content=""&gt; &lt;meta name="PST" content=""&gt; &lt;meta name="CN" content=""&gt; &lt;meta name="CT" content=""&gt; &lt;meta name="genre" itemprop="genre" content=""&gt; &lt;meta name="url" itemprop="url" content=""&gt; </code></pre>
0debug
Question about declaration and initialization : <p>I have a question about initialization. When we initialize an array with { }, we must do it right after declaration to show compiler which type to use. Why does compiler allow diamond operator do it with 2 statements?</p> <pre><code>Integer[] array = {2,4,5}; //Integer[] array; array = {2,4,5}; - error List&lt;Integer&gt; list = new ArrayList&lt;&gt;(); //List&lt;Integer&gt; list; list = new ArrayList&lt;&gt;(); - no error </code></pre>
0debug
uniq -u -i -d command implement in linux : I tried something but Resus mainly not know how to read the file line by line to compare lines between them, I get the error segmentation fault ( core dumped ). This is my function for uniq -u command void uniq_u() { // strcpy(file_name1,params[2]); FILE *file = fopen ( file_name1, "r" ); if ( file != NULL ) { fgets(prev, sizeof prev,file); while ( fgets ( line, sizeof line, file ) != NULL ) /* read a line */ { if(!strcmp(line, prev)) printf("%s", prev); else strcpy(prev,line); } fclose ( file ); } } Thanks!
0debug
How to initialize a bool pointer in C? : <p>I'm coding something small to understand how pointers work and have reached an issue. I have a boolean pointed to by "valid" in a file called "main.c":</p> <pre><code>bool *valid; </code></pre> <p>The pointer's address is passed to a method in a second file called "test.c": </p> <pre><code>method(&amp;valid); </code></pre> <p>Inside the "test.c" method I set valid to true:</p> <pre><code>*valid = true; </code></pre> <p>After the method call in "main.c" I dereference valid in two if statements to see if it's true or false: </p> <pre><code>if (*valid) { printf("valid is true.\n"); } if (!(*valid)) { printf("valid is false.\n"); } </code></pre> <p>Both statements print, but only "valid is true" should. What could be the issue here?</p>
0debug
Ansible: no hosts matched : <p>I'm trying to execute my first remote shell script on Ansible. I've first generated and copied the SSH keys. Here is my yml file:</p> <pre><code>--- - name: Ansible remote shell hosts: 192.168.10.1 user: myuser1 become: true become_user: jboss tasks: - name: Hello server shell: /home/jboss/script.sh </code></pre> <p>When launching the playbook however, the outcome is "no hosts matched":</p> <pre><code>ansible-playbook setup.yml PLAY [Ansible remote shell ******************************************** skipping: no hosts matched PLAY RECAP ******************************************************************** </code></pre> <p>I've tried also using the host name (instead of the IP address), however nothing changed. Any help ?</p>
0debug
device support files for iOS 11.4 (15F79) : <p>After updated my iPhone to 11.4, I found out that current version (Version 9.3 (9E145)) of Xcode do not have device support files for iOS 11.4 (15F79). Is there anything I can or should do to remedy this issue?</p>
0debug
React-native-camera error when compiling android : <p>I tried to upgrade my react native project to the newest version (0.59.2). Unfortunately, now when trying to run react-native run-android im getting this error:</p> <pre><code>Could not determine the dependencies of task ':app:preDebugBuild'. &gt; Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'. &gt; Could not resolve project :react-native-camera. Required by: project :app &gt; Cannot choose between the following variants of project :react-native-camera: - generalDebugRuntimeElements - mlkitDebugRuntimeElements All of them match the consumer attributes: - Variant 'generalDebugRuntimeElements': - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'. - Found com.android.build.api.attributes.VariantAttr 'generalDebug' but wasn't required. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'. - Found react-native-camera 'general' but wasn't required. - Variant 'mlkitDebugRuntimeElements': - Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'. - Found com.android.build.api.attributes.VariantAttr 'mlkitDebug' but wasn't required. - Required com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' and found compatible value 'Aar'. - Required org.gradle.usage 'java-runtime' and found compatible value 'java-runtime'. - Found react-native-camera 'mlkit' but wasn't required. </code></pre> <p>I have already tried to create a new project however this results in the same error. Reinstalling the node modules didn't help either. On iOS it works fine.</p>
0debug
Floating Point Exception for seemingly no reason : <p>My code is throwing me a floating point exception here, but I can't figure out why.</p> <pre><code>int i = this -&gt; numerator; while(i &gt; 1){ if ((this -&gt; numerator % i == 0) &amp;&amp; (this -&gt; denominator % i == 0)) { this -&gt; numerator = this -&gt; numerator / i; this -&gt; denominator = this -&gt; denominator / i; } i = i - 1; } </code></pre> <p>The goal is to simplify a fraction. As you can see, things only get mod by i and i > 1. Same goes for division. Strangely it will keep throwing the error even if I comment out the code within the while loop, but the code works fine if I get rid of the while loop completely. The same thing happened when I tried to use a for loop instead. What am I missing?</p>
0debug
markdown not using emmet : <p>I have included the following in my vs-code user settings:</p> <pre><code>"emmet.includeLanguages": { "vue-html": "html", "markdown": "html" }, "emmet.triggerExpansionOnTab": true, </code></pre> <p>And would have expected to see <strong>emmet</strong> working for markdown files as an outcome but I get no suggestions and even if I explicitly press <code>⌃Space</code> it just comes up with "No Suggestions". </p> <p>What else is needed to get emmet in Markdown files?</p>
0debug
Should paging be zero indexed within an API? : <p>When implementing a Rest API, with parameters for paging, should paging be zero indexed or start at 1. The parameters would be Page, and PageSize. </p> <p>For me, it makes sense to start at 1, since we are talking about pages</p>
0debug
Why does adding a new value to a linked list overwrite the existing content? : <p>I'm trying to add randomly generated values into a linked list using a for loop. When I try to print the list out, it has the correct number of entries, but they all match the values of the last item that was entered. </p> <p>Here is the code.</p> <pre><code>#include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;time.h&gt; typedef struct student { int num; char* name; } student; typedef struct container { student* data; struct container* next; } container ; container* front; container* back; container* createContainer(student* data) { container* tmp = malloc(sizeof(container)); tmp-&gt;data = data; tmp-&gt;next = NULL; return tmp; } int add(student* to_add) { printf("%d %s\n", to_add-&gt;num, to_add-&gt;name); back-&gt;next = createContainer(to_add); back = back-&gt;next; return 1; } void printList(container* front) { container* tmp = front; int i; i=0; while (tmp != NULL) { i++; printf("%d:\t%d\t\t%s\n", i, tmp-&gt;data-&gt;num, tmp-&gt;data-&gt;name); tmp = tmp-&gt;next; } } int main(void) { srand(time(NULL)); student st = {rand(), "test"}; front = createContainer(&amp;st); back = front; printList(front); int i; for (i=0; i&lt;12; i++) { st.num = rand(); st.name = "test"; add(&amp;st); } printList(front); // print the third value stored in the list. container* tmp = front-&gt;next-&gt;next; printf("%d\t\t%s\n", tmp-&gt;data-&gt;num, tmp-&gt;data-&gt;name); return EXIT_SUCCESS; } </code></pre> <p>Here is what it outputs:</p> <pre><code>1: 25312 test 17285 test 3447 test 8299 test 14310 test 22628 test 31306 test 8682 test 31936 test 18951 test 4107 test 7910 test 20556 test 1: 20556 test 2: 20556 test 3: 20556 test 4: 20556 test 5: 20556 test 6: 20556 test 7: 20556 test 8: 20556 test 9: 20556 test 10: 20556 test 11: 20556 test 12: 20556 test 13: 20556 test 20556 test </code></pre> <p>The first line shows that the first value is added correctly. The non-numbered lines are what the values in the list should be, and the numbered lines show the values actually stored in the list. The last line is just printing the third value stored in the list, just to show that it is (hopefully) not a problem with the print function. </p>
0debug
Angular subject subscription is not working : <p>I have a service -> </p> <pre><code>subject = new Subject&lt;any&gt;(); constructor (){ this.subject.next('hello'); } getsubject():Observable&lt;any&gt;{ return this.subject.asObservable(); } </code></pre> <p>and component -></p> <pre><code>name:string; subscription : Subscription; constructor(private serv:SService) { this.subscription=this.serv.getsubject().subscribe(message=&gt;{console.log('hello');}); } </code></pre> <p>as you can see, i'm passing hello message from service to subscribers, but in component subscriber is not getting that value, even it's not logging any word.</p> <p>plunker <a href="https://plnkr.co/edit/yD2YrBIYqzaVzsRxhOVg?p=preview" rel="noreferrer">example</a></p>
0debug
Omitting <?> unintuitively breaks this code : <p>I have created a MWE where changing a single line by adding <code>&lt;?&gt;</code> solves a compiler error.</p> <p>The following code does not compile:</p> <pre><code>import java.util.List; public class MainClass { public void traverse() { List&lt;MyEntity&gt; list = null /* ... */; for (MyEntity myEntity : list) { for (String label : myEntity.getLabels()) { // &lt;-- Offending Line /* ... */ } } } interface MyEntity&lt;T&gt; { T get(); List&lt;String&gt; getLabels(); } } </code></pre> <p>The compiler error is:</p> <pre><code>Error:(9, 51) java: incompatible types: java.lang.Object cannot be converted to java.lang.String </code></pre> <p>Changing the definition in the offending line from <code>MyEntity myEntity</code> to <code>MyEntity&lt;?&gt; myEntity</code> solves the issue. I wonder why is the return type of this for-each treated as an <code>Object</code> and not as a <code>String</code>, unless I add the wildcard to the parent class? Note that <code>getLabels()</code> itself does not contain generics.</p> <p>According to <a href="http://docs.oracle.com/javase/specs/jls/se8/html/jls-14.html#jls-14.14.2">Chapter 14.14.2. of the Java Language Specification</a>, a for-each is compiled to a loop using an iterator. Interestingly, expanding the for-each to such an iterator manually <strong>works</strong>:</p> <pre><code>Iterator&lt;String&gt; iterator = myEntity.getLabels().iterator(); while (iterator.hasNext()) { String label = iterator.next(); /* ... */ } </code></pre> <p>Can anyone explain why?</p>
0debug
static CharDriverState *net_vhost_parse_chardev( const NetdevVhostUserOptions *opts, Error **errp) { CharDriverState *chr = qemu_chr_find(opts->chardev); VhostUserChardevProps props; if (chr == NULL) { error_setg(errp, "chardev \"%s\" not found", opts->chardev); return NULL; } memset(&props, 0, sizeof(props)); if (qemu_opt_foreach(chr->opts, net_vhost_chardev_opts, &props, errp)) { return NULL; } if (!props.is_socket || !props.is_unix) { error_setg(errp, "chardev \"%s\" is not a unix socket", opts->chardev); return NULL; } qemu_chr_fe_claim_no_fail(chr); return chr; }
1threat
CentOS installed php72 but command line php isn not working : <p>I'm reading the following tutorial on installing PHP 7.2 on CentOS 7 <a href="https://www.cyberciti.biz/faq/how-to-install-php-7-2-on-centos-7-rhel-7/" rel="noreferrer">https://www.cyberciti.biz/faq/how-to-install-php-7-2-on-centos-7-rhel-7/</a></p> <p>It basically says;</p> <pre><code>sudo yum install epel-release sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm sudo yum install yum-utils sudo yum-config-manager --enable remi-php72 sudo yum update sudo yum install php72 </code></pre> <p>Then it says to verify the installation using the standard</p> <pre><code>php --version </code></pre> <p>Which returns the following;</p> <pre><code>-bash: php: command not found </code></pre> <p>BUT, if i type the following;</p> <pre><code>php72 --version </code></pre> <p>It works just fine and returns the version.</p> <p>The problem is that everything relies on the command php and not php72</p> <p>Any idea on what i should be doing?</p>
0debug
The order of template specializations in C++ : <p>Can the order in which template specializations appear in the code alter the meaning of the program? If so, then why?</p> <p>Example:</p> <p>Somewhere inside a source code</p> <pre><code>// specialization A ... // specialization B ... </code></pre> <p>vs.</p> <pre><code>// specialization B ... // specialization A ... </code></pre> <p>Will this always produce the same result?</p>
0debug
How to decrease the speed of the below program? : I am trying to solve the below question. You are given an array of n numbers and q queries. For each query you have to print the floor of the expected value(mean) of the subarray from L to R. First line contains two integers N and Q denoting number of array elements and number of queries. Next line contains N space seperated integers denoting array elements. Next Q lines contain two integers L and R(indices of the array). print a single integer denoting the answer. I have replaced print with stdout.write() and input with stdin.readline ```` from sys import stdin, stdout x,y=map(int,stdin.readline().split()) array=[int(x) for x in stdin.readline().split()] result=[] sum=0 for i in range(y): l,r=map(int,stdin.readline().split()) for i in range(l-1,r): sum = sum + array[i] result.append(sum//(r-l+1)) sum=0 for i in result: stdout.write(str(i)+"\n") ```` The time taken by my program is about 8 secs to solve that challenge whereas the required limit is 1.5secs.
0debug
Visual Basic variables : I am currently struggling with this function in Visual Studio: Private Sub dlsuc() Dim file_ As String = My.Computer.FileSystem.SpecialDirectories.Temp & "\v.txt" Dim file As String = IO.File.ReadAllLines(file_) End Sub I can't get this to work, I get something like these error messages: > Error 1 Value of type '1-dimensional array of String' cannot be converted to 'String'. </blockquote> I would really appreciate if someone could help me with this.
0debug
navbar links , such as about and contac, don't work : Can anyone tell me please how I can fix my navbar link problem in the code below? I tried almost everything. and read all related stackoverflow article and sort of things but cant figure it out! [nothing happens when i click on about or contact][1] [1]: https://i.stack.imgur.com/D8Sot.png ----- i REALLY appreciate if someone has a clue or any idea that could be helpfull for me! thanks in advance <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Welcome</title> <!-- Bootstrap core CSS --> {% load staticfiles %} <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css"> <link href="{% static 'personal/css/bootstrap.min.css' %}" rel="stylesheet" /> <link href="{% static 'personal/css/navbar-static-top.css' %}" rel="stylesheet"> <link href="{% static 'personal/css/custom.css' %}" rel="stylesheet"> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <!-- NAVBAR ================================================== --> <div class="container"> <nav class="navbar navbar-default navbar-static-top"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="{% url 'home' %}"><img src="{% static 'personal/img/mvp_landing_logo.png' %}" /></a> </div> <div id="navbar" class="navbar-collapse collapse"> <ul class="nav navbar-nav"> <li><a href="{% url 'home' %}">Home</a></li> <li><a href="{% url 'about' %}">About</a></li> <li><a href="http://www.jssor.com/tutorial/index.html">Tutorial</a></li> <li><a href="{% url 'contact' %}">Contact</a></li> </ul> </div><!--/.nav-collapse --> </div> </nav> </div> <!-- Use a container to wrap the slider, the purpose is to enable slider to always fit width of the wrapper while window resize --> <div class="container"> <!-- Jssor Slider Begin --> <!-- To move inline styles to css file/block, please specify a class name for each element. --> <!-- ================================================== --> <script src="{% static 'personal/js/jquery-1.9.1.min.js' %}"></script> <script src="{% static 'personal/js/jssor.slider.mini.js' %}"></script> <script> jssor_slider1_starter = function (containerId) { //Reference http://www.jssor.com/development/slider-with-slideshow-no-jquery.html //Reference http://www.jssor.com/development/tool-slideshow-transition-viewer.html var _SlideshowTransitions = [ //Fade { $Duration: 3200, $Opacity: 2 } ]; var options = { $SlideDuration: 800, //[Optional] Specifies default duration (swipe) for slide in milliseconds, default value is 500 $DragOrientation: 3, //[Optional] Orientation to drag slide, 0 no drag, 1 horizental, 2 vertical, 3 either, default value is 1 (Note that the $DragOrientation should be the same as $PlayOrientation when $DisplayPieces is greater than 1, or parking position is not 0) $AutoPlay: true, //[Optional] Whether to auto play, to enable slideshow, this option must be set to true, default value is false $AutoPlayInterval: 1500, //[Optional] Interval (in milliseconds) to go for next slide since the previous stopped if the slider is auto playing, default value is 3000 $SlideshowOptions: { //[Optional] Options to specify and enable slideshow or not $Class: $JssorSlideshowRunner$, //[Required] Class to create instance of slideshow $Transitions: _SlideshowTransitions, //[Required] An array of slideshow transitions to play slideshow $TransitionsOrder: 1, //[Optional] The way to choose transition to play slide, 1 Sequence, 0 Random $ShowLink: true //[Optional] Whether to bring slide link on top of the slider when slideshow is running, default value is false } }; var jssor_slider1 = new $JssorSlider$(containerId, options); } </script> <div id="slider1_container" style="visibility: hidden; position: relative; margin: 0 auto; width: 1140px; height: 442px; overflow: hidden;"> <!-- Loading Screen --> <div u="loading" style="position: absolute; top: 0px; left: 0px;"> <div style="filter: alpha(opacity=70); opacity:0.7; position: absolute; display: block; background-color: #000; top: 0px; left: 0px;width: 100%; height:100%;"> </div> <div style="position: absolute; display: block; background: url(/static/personal/img/loading.gif) no-repeat center center; top: 0px; left: 0px;width: 100%;height:100%;"> </div> </div> <!-- Slides Container --> <div u="slides" style="position: absolute; left: 0px; top: 0px; width: 1140px; height: 442px; overflow: hidden;"> <div> <img u="image" src="{% static 'personal/img/01.jpg' %}" /> <div> </div> <img u="image" src="{% static 'personal/img/02.jpg' %}" /> </div> <div> <img u="image" src="{% static 'personal/img/03.jpg' %}" /> </div> <div> <img u="image" src="{% static 'personal/img/04.jpg' %}" /> </div> </div> <a style="display: none" href="http://www.jssor.com">content slider</a> <!-- Trigger --> <script> jssor_slider1_starter('slider1_container'); </script> <!--#region Bullet Navigator Skin Begin --> <!-- Help: http://www.jssor.com/tutorial/set-bullet-navigator.html --> <style> /* jssor slider bullet navigator skin 05 css */ /* .jssorb05 div (normal) .jssorb05 div:hover (normal mouseover) .jssorb05 .av (active) .jssorb05 .av:hover (active mouseover) .jssorb05 .dn (mousedown) */ .jssorb05 { position: absolute; } .jssorb05 div, .jssorb05 div:hover, .jssorb05 .av { position: absolute; /* size of bullet elment */ width: 16px; height: 16px; background: url(static/personal/img/b05.png) no-repeat; overflow: hidden; cursor: pointer; } .jssorb05 div { background-position: -7px -7px; } .jssorb05 div:hover, .jssorb05 .av:hover { background-position: -37px -7px; } .jssorb05 .av { background-position: -67px -7px; } .jssorb05 .dn, .jssorb05 .dn:hover { background-position: -97px -7px; } </style> <!-- bullet navigator container --> <div u="navigator" class="jssorb05" style="bottom: 16px; right: 6px;"> <!-- bullet navigator item prototype --> <div u="prototype"></div> </div> <!--#endregion Bullet Navigator Skin End --> <!--#region Arrow Navigator Skin Begin --> <!-- Help: http://www.jssor.com/tutorial/set-arrow-navigator.html --> <style> /* jssor slider arrow navigator skin 11 css */ /* .jssora11l (normal) .jssora11r (normal) .jssora11l:hover (normal mouseover) .jssora11r:hover (normal mouseover) .jssora11l.jssora11ldn (mousedown) .jssora11r.jssora11rdn (mousedown) */ .jssora11l, .jssora11r { display: block; position: absolute; /* size of arrow element */ width: 37px; height: 37px; cursor: pointer; background: url(static/personal/img/a11.png) no-repeat; overflow: hidden; } .jssora11l { background-position: -11px -41px; } .jssora11r { background-position: -71px -41px; } .jssora11l:hover { background-position: -131px -41px; } .jssora11r:hover { background-position: -191px -41px; } .jssora11l.jssora11ldn { background-position: -251px -41px; } .jssora11r.jssora11rdn { background-position: -311px -41px; } </style> <!-- Arrow Left --> <span u="arrowleft" class="jssora11l" style="top: 123px; left: 8px;"> </span> <!-- Arrow Right --> <span u="arrowright" class="jssora11r" style="top: 123px; right: 8px;"> </span> <!--#endregion Arrow Navigator Skin End --> <a style="display: none" href="http://www.jssor.com">Bootstrap Carousel</a> </div> <!-- Jssor Slider End --> </div> <!-- Marketing messaging and featurettes ================================================== --> <!-- Wrap the rest of the page in another container to center all the content. --> <div class="container marketing"> <hr class="featurette-divider"> <div class="row featurette"> <div class="col-md-7"> <h2 class="featurette-heading">This page runs <a href="http://getbootstrap.com" target="_blank" rel="nofollow">Bootstrap</a> with Jssor Slider.</h2> <p class="lead">Use Jssor Slider as a compoment of Bootstrap is extremly easy. Given a slider you worked out, to integrate it with Bootstrap, you can just copy javascript and html code and paste it into your page. This page is a simple demo, please view source of this page or download <a href="http://www.jssor.com/download-bootstrap-carousel-slider-example.html">Bootstrap Carousel Slider Example</a>.</p> </div> <div class="col-md-5"> <img class="featurette-image img-responsive" data-src="holder.js/500x500/auto" alt="Generic placeholder image"> </div> </div> <hr class="featurette-divider"> <div class="row featurette"> <div class="col-md-5"> <img class="featurette-image img-responsive" data-src="holder.js/500x500/auto" alt="Generic placeholder image"> </div> <div class="col-md-7"> <h2 class="featurette-heading">Javascript Code</h2> <div class="lead" style="background-color:#f0f0f0; border: 1px dashed #000; white-space: nowrap;"> <pre style="margin:0px;"> &lt;script type="text/javascript" src="../js/jssor.slider.mini.js"&gt;&lt;/script&gt; &lt;script&gt; jQuery(document).ready(function ($) { var options = { .. }; var jssor_slider1 = new $JssorSlider$("slider1_container", options); ... }); &lt;/script&gt;</pre> </div> </div> </div> <hr class="featurette-divider"> <div class="row featurette"> <div class="col-md-7"> <h2 class="featurette-heading">HTML Code</h2> <div class="lead" style="background-color:#f0f0f0; border: 1px dashed #000; white-space: nowrap;"> <pre style="margin:0px;"> &lt;div class="container"&gt; &lt;!-- Jssor Slider Begin --&gt; &lt;div id="slider1_container" style="visibility: hidden; position: relative; margin: 0 auto; width: 980px; height: 380px; overflow: hidden;"&gt; ... &lt;/div&gt; &lt;!-- Jssor Slider End --&gt; &lt;/div&gt;</pre> </div> </div> <div class="col-md-5"> <img class="featurette-image img-responsive" data-src="holder.js/500x500/auto" alt="Generic placeholder image"> </div> </div> <hr class="featurette-divider"> <!-- /END THE FEATURETTES --> <!-- FOOTER --> <footer> <p class="pull-right"><a href="#">Back to top</a></p> <p>&copy; Jssor Slider 2009 - 2016. &middot; <a href="#">Privacy</a> &middot; </p> </footer> </div><!-- /.container --> <!-- Bootstrap core JavaScript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="{% static 'personal/js/jquery-1.9.1.min.js' %}"></script> <script src="{% static 'personal/js/bootstrap.min.js' %}"></script> <script src="{% static 'personal/js/docs.min.js' %}"></script> <!-- IE10 viewport hack for Surface/desktop Windows 8 bug --> <script src="{% static 'personal/js/ie10-viewport-bug-workaround.js' %}"></script> <!-- jssor slider scripts--> <!-- use jssor.slider.debug.js for debug --> <script src="{% static 'personal/js/jssor.slider.mini.js' %}"></script> <script> jQuery(document).ready(function ($) { var options = { $AutoPlay: true, //[Optional] Whether to auto play, to enable slideshow, this option must be set to true, default value is false $AutoPlaySteps: 1, //[Optional] Steps to go for each navigation request (this options applys only when slideshow disabled), the default value is 1 $Idle: 2000, //[Optional] Interval (in milliseconds) to go for next slide since the previous stopped if the slider is auto playing, default value is 3000 $PauseOnHover: 1, //[Optional] Whether to pause when mouse over if a slider is auto playing, 0 no pause, 1 pause for desktop, 2 pause for touch device, 3 pause for desktop and touch device, 4 freeze for desktop, 8 freeze for touch device, 12 freeze for desktop and touch device, default value is 1 $ArrowKeyNavigation: true, //[Optional] Allows keyboard (arrow key) navigation or not, default value is false $SlideEasing: $JssorEasing$.$EaseOutQuint, //[Optional] Specifies easing for right to left animation, default value is $JssorEasing$.$EaseOutQuad $SlideDuration: 800, //[Optional] Specifies default duration (swipe) for slide in milliseconds, default value is 500 $MinDragOffsetToSlide: 20, //[Optional] Minimum drag offset to trigger slide , default value is 20 //$SlideWidth: 600, //[Optional] Width of every slide in pixels, default value is width of 'slides' container //$SlideHeight: 300, //[Optional] Height of every slide in pixels, default value is height of 'slides' container $SlideSpacing: 0, //[Optional] Space between each slide in pixels, default value is 0 $Cols: 1, //[Optional] Number of pieces to display (the slideshow would be disabled if the value is set to greater than 1), the default value is 1 $ParkingPosition: 0, //[Optional] The offset position to park slide (this options applys only when slideshow disabled), default value is 0. $UISearchMode: 1, //[Optional] The way (0 parellel, 1 recursive, default value is 1) to search UI components (slides container, loading screen, navigator container, arrow navigator container, thumbnail navigator container etc). $PlayOrientation: 1, //[Optional] Orientation to play slide (for auto play, navigation), 1 horizental, 2 vertical, 5 horizental reverse, 6 vertical reverse, default value is 1 $DragOrientation: 1, //[Optional] Orientation to drag slide, 0 no drag, 1 horizental, 2 vertical, 3 either, default value is 1 (Note that the $DragOrientation should be the same as $PlayOrientation when $Cols is greater than 1, or parking position is not 0) $ArrowNavigatorOptions: { //[Optional] Options to specify and enable arrow navigator or not $Class: $JssorArrowNavigator$, //[Requried] Class to create arrow navigator instance $ChanceToShow: 2, //[Required] 0 Never, 1 Mouse Over, 2 Always $AutoCenter: 2, //[Optional] Auto center arrows in parent container, 0 No, 1 Horizontal, 2 Vertical, 3 Both, default value is 0 $Steps: 1, //[Optional] Steps to go for each navigation request, default value is 1 $Scale: false //Scales bullets navigator or not while slider scale }, $BulletNavigatorOptions: { //[Optional] Options to specify and enable navigator or not $Class: $JssorBulletNavigator$, //[Required] Class to create navigator instance $ChanceToShow: 2, //[Required] 0 Never, 1 Mouse Over, 2 Always $AutoCenter: 1, //[Optional] Auto center navigator in parent container, 0 None, 1 Horizontal, 2 Vertical, 3 Both, default value is 0 $Steps: 1, //[Optional] Steps to go for each navigation request, default value is 1 $Rows: 1, //[Optional] Specify lanes to arrange items, default value is 1 $SpacingX: 12, //[Optional] Horizontal space between each item in pixel, default value is 0 $SpacingY: 4, //[Optional] Vertical space between each item in pixel, default value is 0 $Orientation: 1, //[Optional] The orientation of the navigator, 1 horizontal, 2 vertical, default value is 1 $Scale: false //Scales bullets navigator or not while slider scale } }; var jssor_slider1 = new $JssorSlider$("slider1_container", options); //responsive code begin //you can remove responsive code if you don't want the slider scales while window resizing function ScaleSlider() { var parentWidth = jssor_slider1.$Elmt.parentNode.clientWidth; if (parentWidth) { jssor_slider1.$ScaleWidth(parentWidth - 30); } else window.setTimeout(ScaleSlider, 30); } ScaleSlider(); $(window).bind("load", ScaleSlider); $(window).bind("resize", ScaleSlider); $(window).bind("orientationchange", ScaleSlider); //responsive code end }); </script> </body> </html> <!-- end snippet -->
0debug
static int qemu_rdma_registration_stop(QEMUFile *f, void *opaque, uint64_t flags) { Error *local_err = NULL, **errp = &local_err; QEMUFileRDMA *rfile = opaque; RDMAContext *rdma = rfile->rdma; RDMAControlHeader head = { .len = 0, .repeat = 1 }; int ret = 0; CHECK_ERROR_STATE(); qemu_fflush(f); ret = qemu_rdma_drain_cq(f, rdma); if (ret < 0) { goto err; } if (flags == RAM_CONTROL_SETUP) { RDMAControlHeader resp = {.type = RDMA_CONTROL_RAM_BLOCKS_RESULT }; RDMALocalBlocks *local = &rdma->local_ram_blocks; int reg_result_idx, i, j, nb_remote_blocks; head.type = RDMA_CONTROL_RAM_BLOCKS_REQUEST; DPRINTF("Sending registration setup for ram blocks...\n"); ret = qemu_rdma_exchange_send(rdma, &head, NULL, &resp, &reg_result_idx, rdma->pin_all ? qemu_rdma_reg_whole_ram_blocks : NULL); if (ret < 0) { ERROR(errp, "receiving remote info!"); return ret; } nb_remote_blocks = resp.len / sizeof(RDMARemoteBlock); if (local->nb_blocks != nb_remote_blocks) { ERROR(errp, "ram blocks mismatch #1! " "Your QEMU command line parameters are probably " "not identical on both the source and destination."); return -EINVAL; } qemu_rdma_move_header(rdma, reg_result_idx, &resp); memcpy(rdma->block, rdma->wr_data[reg_result_idx].control_curr, resp.len); for (i = 0; i < nb_remote_blocks; i++) { network_to_remote_block(&rdma->block[i]); for (j = 0; j < local->nb_blocks; j++) { if (rdma->block[i].offset != local->block[j].offset) { continue; } if (rdma->block[i].length != local->block[j].length) { ERROR(errp, "ram blocks mismatch #2! " "Your QEMU command line parameters are probably " "not identical on both the source and destination."); return -EINVAL; } local->block[j].remote_host_addr = rdma->block[i].remote_host_addr; local->block[j].remote_rkey = rdma->block[i].remote_rkey; break; } if (j >= local->nb_blocks) { ERROR(errp, "ram blocks mismatch #3! " "Your QEMU command line parameters are probably " "not identical on both the source and destination."); return -EINVAL; } } } DDDPRINTF("Sending registration finish %" PRIu64 "...\n", flags); head.type = RDMA_CONTROL_REGISTER_FINISHED; ret = qemu_rdma_exchange_send(rdma, &head, NULL, NULL, NULL, NULL); if (ret < 0) { goto err; } return 0; err: rdma->error_state = ret; return ret; }
1threat
Is Configuration interface in hibernate ? : When i am searching for core interfaces in Hibernate i found that Configuration as a interface. If it is an interface how can we create object for that directly like below. Configuration cfg = new Configuration().configure();
0debug
Can my java client print out the echo statements from my php server? : <p>Could I somehow capture the echos and use them in my java client? I'm trying to obtain a jwt from the server so my client can use it and send a message to the server.</p>
0debug
static int mov_write_packet(AVFormatContext *s, int stream_index, const uint8_t *buf, int size, int64_t pts) { MOVContext *mov = s->priv_data; ByteIOContext *pb = &s->pb; AVCodecContext *enc = &s->streams[stream_index]->codec; MOVTrack* trk = &mov->tracks[stream_index]; int cl, id; unsigned int samplesInChunk = 0; if (url_is_streamed(&s->pb)) return 0; if (!size) return 0; if (enc->codec_type == CODEC_TYPE_VIDEO ) { samplesInChunk = 1; } else if (enc->codec_type == CODEC_TYPE_AUDIO ) { if( enc->codec_id == CODEC_ID_AMR_NB) { static uint16_t packed_size[16] = {13, 14, 16, 18, 20, 21, 27, 32, 6, 0, 0, 0, 0, 0, 0, 0}; int len = 0; while (len < size && samplesInChunk < 100) { len += packed_size[(buf[len] >> 3) & 0x0F]; samplesInChunk++; } } else if(enc->codec_id == CODEC_ID_PCM_ALAW) { samplesInChunk = size/enc->channels; } else { samplesInChunk = 1; } } if ((enc->codec_id == CODEC_ID_MPEG4 || enc->codec_id == CODEC_ID_AAC) && trk->vosLen == 0) { assert(enc->extradata_size); trk->vosLen = enc->extradata_size; trk->vosData = av_malloc(trk->vosLen); memcpy(trk->vosData, enc->extradata, trk->vosLen); } cl = trk->entry / MOV_INDEX_CLUSTER_SIZE; id = trk->entry % MOV_INDEX_CLUSTER_SIZE; if (trk->ents_allocated <= trk->entry) { trk->cluster = av_realloc(trk->cluster, (cl+1)*sizeof(void*)); if (!trk->cluster) return -1; trk->cluster[cl] = av_malloc(MOV_INDEX_CLUSTER_SIZE*sizeof(MOVIentry)); if (!trk->cluster[cl]) return -1; trk->ents_allocated += MOV_INDEX_CLUSTER_SIZE; } if (mov->mdat_written == 0) { mov_write_mdat_tag(pb, mov); mov->mdat_written = 1; mov->time = Timestamp(); } trk->cluster[cl][id].pos = url_ftell(pb) - mov->movi_list; trk->cluster[cl][id].samplesInChunk = samplesInChunk; trk->cluster[cl][id].size = size; trk->cluster[cl][id].entries = samplesInChunk; if(enc->codec_type == CODEC_TYPE_VIDEO) { trk->cluster[cl][id].key_frame = enc->coded_frame->key_frame; if(enc->coded_frame->pict_type == FF_I_TYPE) trk->hasKeyframes = 1; } trk->enc = enc; trk->entry++; trk->sampleCount += samplesInChunk; trk->mdat_size += size; put_buffer(pb, buf, size); put_flush_packet(pb); return 0; }
1threat
How to perform student t test contain mulitple observation in R : Here is my data, 900000 obs of 9 variables in R. I've tried apply function but unable to give parameters in apply function. Data looks like this, please help. ID A1 A2 A3 A4 A5 B1 B2 B3 B4 1 10 12 11 13 15 50 55 56 57 2 20 22 23 21 20 60 76 78 71 3 10 12 13 15 14 50 55 52 53 ... 90000 11 12 13 15 12 21 22 23 24 I need to perform 900000 times two sample student t test from those 9 variables divide into 2 groups (group A and B). Can anyone post a code here?Thanks.
0debug
Pandas - add value at specific iloc into new dataframe column : <p>I have a large dataframe containing lots of columns.</p> <p>For each row/index in the dataframe I do some operations, read in some ancilliary ata, etc and get a new value. Is there a way to add that new value into a new column at the correct row/index?</p> <p>I can use .assign to add a new column but as I'm looping over the rows and only generating the data to add for one value at a time (generating it is quite involved). When it's generated I'd like to immediately add it to the dataframe rather than waiting until I've generated the entire series.</p> <p>This doesn't work and gives a key error:</p> <pre><code>df['new_column_name'].iloc[this_row]=value </code></pre> <p>Do I need to initialise the column first or something?</p>
0debug
How do I tell IntelliJ about groovy installed with brew on OSX : <p>I'm running: </p> <ul> <li>IntelliJ Ultimate 2016.3</li> <li>Homebrew 1.1.2</li> <li>OS X 10.11.5 El Capitan </li> </ul> <p>I ran <code>brew install groovy</code> which resulted in groovy being installed in <code>/usr/local/Cellar/groovy/2.4.7/</code>. Brew also added a symlink: <code>/usr/local/bin/groovy -&gt; ../Cellar/groovy/2.4.7/bin/groovy</code></p> <p>When I open the groovy project in IntelliJ, it gives me an option to Configure a Groovy SDK. I haven't set this up yet, so I get a "Create" button, which launches finder. From what I can tell there's nothing that I can select to make IntelliJ happy. I've tried <code>/user/local/bin/groovy</code>, <code>/user/local/Cellar/groovy</code>, <code>/user/local/Cellar/groovy/2.4.7</code>, <code>/user/local/Cellar/groovy/2.4.7/bin</code> etc. No mater which I choose, IntelliJ doesn't accept the library and continues to tell me "Error: library is not specified". </p> <p>Does anyone know how I'm supposed to go about telling IntelliJ where groovy is? </p>
0debug
How to destroy Python objects and free up memory : <p>I am trying to iterate over 100,000 images and capture some image features and store the resulting dataFrame on disk as a pickle file. </p> <p>Unfortunately due to RAM constraints, i am forced to split the images into chunks of 20,000 and perform operations on them before saving the results onto disk.</p> <p>The code written below is supposed to save the dataframe of results for 20,000 images before starting the loop to process the next 20,000 images. </p> <p>However - This does not seem to be solving my problem as the memory is not getting released from RAM at the end of the first for loop</p> <p>So somewhere while processing the 50,000th record, the program crashes due to Out of Memory Error.</p> <p>I tried deleting the objects after saving them to disk and invoking the garbage collector, however the RAM usage does not seem to be going down.</p> <p>What am i missing? </p> <pre><code>#file_list_1 contains 100,000 images file_list_chunks = list(divide_chunks(file_list_1,20000)) for count,f in enumerate(file_list_chunks): # make the Pool of workers pool = ThreadPool(64) results = pool.map(get_image_features,f) # close the pool and wait for the work to finish list_a, list_b = zip(*results) df = pd.DataFrame({'filename':list_a,'image_features':list_b}) df.to_pickle("PATH_TO_FILE"+str(count)+".pickle") del list_a del list_b del df gc.collect() pool.close() pool.join() print("pool closed") </code></pre>
0debug
Hash iteration keys : I have this hash: games = {"Mario" => "SNES", "Ico" => "PS2", "Tetris" => "Gameboy"} I want to make a method that will convert the keys to integers and then add all of the keys in the hash together and return a single integer I looked up some methods on rubydocs and came across the string method .ord which converts letters to their numerical values. I know I will want to split('') the keys I'm just not sure how to get it all to work.
0debug
AVBufferRef *av_buffer_alloc(int size) { AVBufferRef *ret = NULL; uint8_t *data = NULL; data = av_malloc(size); if (!data) return NULL; if(CONFIG_MEMORY_POISONING) memset(data, 0x2a, size); ret = av_buffer_create(data, size, av_buffer_default_free, NULL, 0); if (!ret) av_freep(&data); return ret; }
1threat
Python creating video from images using opencv : <p>I was trying to create a video to show the dynamic variation of the data, like just continuously showing the images one by one quickly, so I used images (the images just called 1,2,3,4,.....) and wrote the following code:</p> <pre><code>import cv2 import numpy as np img=[] for i in range(0,5): img.append(cv2.imread(str(i)+'.png')) height,width,layers=img[1].shape video=cv2.VideoWriter('video.avi',-1,1,(width,height)) for j in range(0,5): video.write(img) cv2.destroyAllWindows() video.release() </code></pre> <p>and a error was raised:</p> <pre><code>TypeError: image is not a numpy array, neither a scalar </code></pre> <p>I think I used the list in a wrong way but I'm not sure. So where did I do wrong?</p>
0debug
unexpected tidentifier expecting keyword_end : <p>I've got a problem in Ruby, "unexpected tidentifier expecting keyword_end", how Can I solve it?</p> <pre><code>def riko(user) if user.name.eql? 'Mia Khalifa Fan' @client.send_msg 'Hola Mia &lt;3 ¿Cómo te trato este dia, cosa guapa y sensual?', else if user.mame.eql? 'Skul Goy' @client.send_msg 'Muerete. ' else @client.send_msg "Hola #{user.name} o/ \ :v / " end end </code></pre>
0debug
In Python,how can I add to a dictionare from raw_input,for both key and value? M : <pre><code>students = {} name = input("Give me the student name(key): ") grade = input("What is their Grade(value): ") </code></pre> <p>'(put in to dictionary key=name and value = grade print all students and their grades from dictionary"</p>
0debug
static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, int buf_size) { int i; int cur = 0; int skip = 0; int len, toks; TM2Codes codes; len = AV_RB32(buf); buf += 4; cur += 4; skip = len * 4 + 4; if(len == 0) return 4; if (len >= INT_MAX/4-1 || len < 0 || len > buf_size) { av_log(ctx->avctx, AV_LOG_ERROR, "Error, invalid stream size.\n"); } toks = AV_RB32(buf); buf += 4; cur += 4; if(toks & 1) { len = AV_RB32(buf); buf += 4; cur += 4; if(len == TM2_ESCAPE) { len = AV_RB32(buf); buf += 4; cur += 4; } if(len > 0) { init_get_bits(&ctx->gb, buf, (skip - cur) * 8); if(tm2_read_deltas(ctx, stream_id) == -1) buf += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2; cur += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2; } } if(AV_RB32(buf) == TM2_ESCAPE) { buf += 4; cur += 4; } buf += 4; cur += 4; buf += 4; cur += 4; init_get_bits(&ctx->gb, buf, (skip - cur) * 8); if(tm2_build_huff_table(ctx, &codes) == -1) buf += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2; cur += ((get_bits_count(&ctx->gb) + 31) >> 5) << 2; toks >>= 1; if((toks < 0) || (toks > 0xFFFFFF)){ av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks); tm2_free_codes(&codes); } ctx->tokens[stream_id] = av_realloc(ctx->tokens[stream_id], toks * sizeof(int)); ctx->tok_lens[stream_id] = toks; len = AV_RB32(buf); buf += 4; cur += 4; if(len > 0) { init_get_bits(&ctx->gb, buf, (skip - cur) * 8); for(i = 0; i < toks; i++) { if (get_bits_left(&ctx->gb) <= 0) { av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect number of tokens: %i\n", toks); } ctx->tokens[stream_id][i] = tm2_get_token(&ctx->gb, &codes); } } else { for(i = 0; i < toks; i++) ctx->tokens[stream_id][i] = codes.recode[0]; } tm2_free_codes(&codes); return skip; }
1threat
static uint32_t rtas_set_isolation_state(uint32_t idx, uint32_t state) { sPAPRDRConnector *drc = spapr_drc_by_index(idx); sPAPRDRConnectorClass *drck; if (!drc) { return RTAS_OUT_PARAM_ERROR; } drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc); return drck->set_isolation_state(drc, state); }
1threat
How to center only one element in a row of 2 elements in flutter : <p>In my layout I have two Widgets in a row, one text and the an icon. </p> <p>As shown below, assume that * refers to the icon, and using "-" to represent the row:</p> <pre><code>---------------------------- Text * ---------------------------- </code></pre> <p>How do I make my text centered in the entire row, and the icon to the right end ?</p>
0debug
Extracting parts of a string with regular expression : <p>I've a bunch of strings that contains a pattern, which I want to extract. It looks like the following:</p> <pre><code> str &lt;- "Regular Expression Language (AbcDfE-BB)" </code></pre> <p>So I would like two new columns, one with the "AbcDfE" part, and the other with the after - part, in this case "BB".</p>
0debug
Difficulty in creating program for admission in schools. : I had just made a project program that functions as an easy way to apply for admission in school. So far, everything went kinda okay but I am not getting the proper output. Please look into the material posted below and help me. def search(t2): t2=(('xxx',1),('yyy',2),('zzz',3)) s=input('Enter student ID=') for i in range(len(t2)): for ch in t2: if ch==s: print'Student =>',t2[i],'of Id number',t2[i+1] break else: print'Invalid Entry, try again' def details(t1): n=raw_input('Enter applicant name=') t2=(('xxx',1),('yyy',2),('zzz',3)) for i in range(len(t1)): if len(t1)<5: t2=t2+(n,i) break elif len(t1)==5: print'Sorry, class full' else: print'Sorry, class full' print'Student added successfully to class' def delete(t2): l=list(t2) j=input('Enter the student ID=') for i in range(len(t2)): for ch in l: if j==ch: del l[i] del l[i+1] break else: print'Student not found. Please try again' print tuple(l) n=input('Enter the number of students=') t1=tuple() t2=(('xxx',1),('yyy',2),('zzz',3)) name=raw_input('Enter the student name=') idn=input('Enter the Id no.=') for i in range(n): t1=t1+(name,) t1=t1+(idn,) while True: print'\n\n\t\t----Admission Menu----' print'\t\t1->Apply for admission' print'\t\t2->Search for a student' print'\t\t3->Remove a student' print'\t\t4->Exit' ch=input('Enter your choice=') if ch==1: details(t1) elif ch==2: search(t1) elif ch==3: delete(t1) elif ch==4: print'Thank You for visiting --School Name--' exit() else: print'Wrong choice, please select a valid choice and try again'
0debug
static int vt82c686b_pm_initfn(PCIDevice *dev) { VT686PMState *s = DO_UPCAST(VT686PMState, dev, dev); uint8_t *pci_conf; pci_conf = s->dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_VIA); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_VIA_ACPI); pci_config_set_class(pci_conf, PCI_CLASS_BRIDGE_OTHER); pci_config_set_revision(pci_conf, 0x40); pci_set_word(pci_conf + PCI_COMMAND, 0); pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_FAST_BACK | PCI_STATUS_DEVSEL_MEDIUM); pci_set_long(pci_conf + 0x48, 0x00000001); s->smb_io_base =((s->smb_io_base & 0xfff0) + 0x0); pci_conf[0x90] = s->smb_io_base | 1; pci_conf[0x91] = s->smb_io_base >> 8; pci_conf[0xd2] = 0x90; register_ioport_write(s->smb_io_base, 0xf, 1, smb_ioport_writeb, &s->smb); register_ioport_read(s->smb_io_base, 0xf, 1, smb_ioport_readb, &s->smb); apm_init(&s->apm, NULL, s); acpi_pm_tmr_init(&s->tmr, pm_tmr_timer); acpi_pm1_cnt_init(&s->pm1_cnt, NULL); pm_smbus_init(&s->dev.qdev, &s->smb); return 0; }
1threat
Java declaring private member variables : <p>I was studying in a book and here is the example:</p> <pre><code>public class SimpleGeometricObject { private String color = "white"; ... </code></pre> <p>I've always been taught that we can't give a value to a member variable if its not in a constructor or in a setter. This example from the book, is it a good example? Can we do that? Is that a style problem?</p> <p>Thanks</p>
0debug
monitor_qapi_event_queue(QAPIEvent event, QDict *qdict, Error **errp) { MonitorQAPIEventConf *evconf; MonitorQAPIEventState *evstate; assert(event < QAPI_EVENT__MAX); evconf = &monitor_qapi_event_conf[event]; trace_monitor_protocol_event_queue(event, qdict, evconf->rate); qemu_mutex_lock(&monitor_lock); if (!evconf->rate) { monitor_qapi_event_emit(event, qdict); } else { QDict *data = qobject_to_qdict(qdict_get(qdict, "data")); MonitorQAPIEventState key = { .event = event, .data = data }; evstate = g_hash_table_lookup(monitor_qapi_event_state, &key); assert(!evstate || timer_pending(evstate->timer)); if (evstate) { QDECREF(evstate->qdict); evstate->qdict = qdict; QINCREF(evstate->qdict); } else { int64_t now = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); monitor_qapi_event_emit(event, qdict); evstate = g_new(MonitorQAPIEventState, 1); evstate->event = event; evstate->data = data; QINCREF(evstate->data); evstate->qdict = NULL; evstate->timer = timer_new_ns(QEMU_CLOCK_REALTIME, monitor_qapi_event_handler, evstate); g_hash_table_add(monitor_qapi_event_state, evstate); timer_mod_ns(evstate->timer, now + evconf->rate); } } qemu_mutex_unlock(&monitor_lock); }
1threat
av_cold void ff_rv40dsp_init(RV34DSPContext *c, DSPContext* dsp) { ff_rv34dsp_init(c, dsp); c->put_pixels_tab[0][ 0] = dsp->put_h264_qpel_pixels_tab[0][0]; c->put_pixels_tab[0][ 1] = put_rv40_qpel16_mc10_c; c->put_pixels_tab[0][ 2] = dsp->put_h264_qpel_pixels_tab[0][2]; c->put_pixels_tab[0][ 3] = put_rv40_qpel16_mc30_c; c->put_pixels_tab[0][ 4] = put_rv40_qpel16_mc01_c; c->put_pixels_tab[0][ 5] = put_rv40_qpel16_mc11_c; c->put_pixels_tab[0][ 6] = put_rv40_qpel16_mc21_c; c->put_pixels_tab[0][ 7] = put_rv40_qpel16_mc31_c; c->put_pixels_tab[0][ 8] = dsp->put_h264_qpel_pixels_tab[0][8]; c->put_pixels_tab[0][ 9] = put_rv40_qpel16_mc12_c; c->put_pixels_tab[0][10] = put_rv40_qpel16_mc22_c; c->put_pixels_tab[0][11] = put_rv40_qpel16_mc32_c; c->put_pixels_tab[0][12] = put_rv40_qpel16_mc03_c; c->put_pixels_tab[0][13] = put_rv40_qpel16_mc13_c; c->put_pixels_tab[0][14] = put_rv40_qpel16_mc23_c; c->put_pixels_tab[0][15] = ff_put_rv40_qpel16_mc33_c; c->avg_pixels_tab[0][ 0] = dsp->avg_h264_qpel_pixels_tab[0][0]; c->avg_pixels_tab[0][ 1] = avg_rv40_qpel16_mc10_c; c->avg_pixels_tab[0][ 2] = dsp->avg_h264_qpel_pixels_tab[0][2]; c->avg_pixels_tab[0][ 3] = avg_rv40_qpel16_mc30_c; c->avg_pixels_tab[0][ 4] = avg_rv40_qpel16_mc01_c; c->avg_pixels_tab[0][ 5] = avg_rv40_qpel16_mc11_c; c->avg_pixels_tab[0][ 6] = avg_rv40_qpel16_mc21_c; c->avg_pixels_tab[0][ 7] = avg_rv40_qpel16_mc31_c; c->avg_pixels_tab[0][ 8] = dsp->avg_h264_qpel_pixels_tab[0][8]; c->avg_pixels_tab[0][ 9] = avg_rv40_qpel16_mc12_c; c->avg_pixels_tab[0][10] = avg_rv40_qpel16_mc22_c; c->avg_pixels_tab[0][11] = avg_rv40_qpel16_mc32_c; c->avg_pixels_tab[0][12] = avg_rv40_qpel16_mc03_c; c->avg_pixels_tab[0][13] = avg_rv40_qpel16_mc13_c; c->avg_pixels_tab[0][14] = avg_rv40_qpel16_mc23_c; c->avg_pixels_tab[0][15] = ff_avg_rv40_qpel16_mc33_c; c->put_pixels_tab[1][ 0] = dsp->put_h264_qpel_pixels_tab[1][0]; c->put_pixels_tab[1][ 1] = put_rv40_qpel8_mc10_c; c->put_pixels_tab[1][ 2] = dsp->put_h264_qpel_pixels_tab[1][2]; c->put_pixels_tab[1][ 3] = put_rv40_qpel8_mc30_c; c->put_pixels_tab[1][ 4] = put_rv40_qpel8_mc01_c; c->put_pixels_tab[1][ 5] = put_rv40_qpel8_mc11_c; c->put_pixels_tab[1][ 6] = put_rv40_qpel8_mc21_c; c->put_pixels_tab[1][ 7] = put_rv40_qpel8_mc31_c; c->put_pixels_tab[1][ 8] = dsp->put_h264_qpel_pixels_tab[1][8]; c->put_pixels_tab[1][ 9] = put_rv40_qpel8_mc12_c; c->put_pixels_tab[1][10] = put_rv40_qpel8_mc22_c; c->put_pixels_tab[1][11] = put_rv40_qpel8_mc32_c; c->put_pixels_tab[1][12] = put_rv40_qpel8_mc03_c; c->put_pixels_tab[1][13] = put_rv40_qpel8_mc13_c; c->put_pixels_tab[1][14] = put_rv40_qpel8_mc23_c; c->put_pixels_tab[1][15] = ff_put_rv40_qpel8_mc33_c; c->avg_pixels_tab[1][ 0] = dsp->avg_h264_qpel_pixels_tab[1][0]; c->avg_pixels_tab[1][ 1] = avg_rv40_qpel8_mc10_c; c->avg_pixels_tab[1][ 2] = dsp->avg_h264_qpel_pixels_tab[1][2]; c->avg_pixels_tab[1][ 3] = avg_rv40_qpel8_mc30_c; c->avg_pixels_tab[1][ 4] = avg_rv40_qpel8_mc01_c; c->avg_pixels_tab[1][ 5] = avg_rv40_qpel8_mc11_c; c->avg_pixels_tab[1][ 6] = avg_rv40_qpel8_mc21_c; c->avg_pixels_tab[1][ 7] = avg_rv40_qpel8_mc31_c; c->avg_pixels_tab[1][ 8] = dsp->avg_h264_qpel_pixels_tab[1][8]; c->avg_pixels_tab[1][ 9] = avg_rv40_qpel8_mc12_c; c->avg_pixels_tab[1][10] = avg_rv40_qpel8_mc22_c; c->avg_pixels_tab[1][11] = avg_rv40_qpel8_mc32_c; c->avg_pixels_tab[1][12] = avg_rv40_qpel8_mc03_c; c->avg_pixels_tab[1][13] = avg_rv40_qpel8_mc13_c; c->avg_pixels_tab[1][14] = avg_rv40_qpel8_mc23_c; c->avg_pixels_tab[1][15] = ff_avg_rv40_qpel8_mc33_c; c->put_chroma_pixels_tab[0] = put_rv40_chroma_mc8_c; c->put_chroma_pixels_tab[1] = put_rv40_chroma_mc4_c; c->avg_chroma_pixels_tab[0] = avg_rv40_chroma_mc8_c; c->avg_chroma_pixels_tab[1] = avg_rv40_chroma_mc4_c; c->rv40_weight_pixels_tab[0][0] = rv40_weight_func_rnd_16; c->rv40_weight_pixels_tab[0][1] = rv40_weight_func_rnd_8; c->rv40_weight_pixels_tab[1][0] = rv40_weight_func_nornd_16; c->rv40_weight_pixels_tab[1][1] = rv40_weight_func_nornd_8; c->rv40_weak_loop_filter[0] = rv40_h_weak_loop_filter; c->rv40_weak_loop_filter[1] = rv40_v_weak_loop_filter; c->rv40_strong_loop_filter[0] = rv40_h_strong_loop_filter; c->rv40_strong_loop_filter[1] = rv40_v_strong_loop_filter; c->rv40_loop_filter_strength[0] = rv40_h_loop_filter_strength; c->rv40_loop_filter_strength[1] = rv40_v_loop_filter_strength; if (ARCH_X86) ff_rv40dsp_init_x86(c, dsp); if (HAVE_NEON) ff_rv40dsp_init_neon(c, dsp); }
1threat
Why the if statment will not run? : So I am trying to make a chess game (The board is 64 buttons) and I need to check if the button that was first pressed is a certain button but for some reason the code in the if will not run. public void button_click(object sender, EventArgs e) { if (partOfTurn == false) { //code previousButton = (Button)sender; partOfTurn = true; } else if (partOfTurn == true) { //code click(); partOfTurn = false; } void click() { if (turn == true) { if (previousButton.BackgroundImage == Properties.Resources.White_Pown) { //unreachable code } } } }
0debug
static void setup_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUPPCState *env) { struct target_sigframe *frame; struct target_sigcontext *sc; target_ulong frame_addr, newsp; int err = 0; int signal; frame_addr = get_sigframe(ka, env, sizeof(*frame)); if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 1)) goto sigsegv; sc = &frame->sctx; signal = current_exec_domain_sig(sig); __put_user(ka->_sa_handler, &sc->handler); __put_user(set->sig[0], &sc->oldmask); #if defined(TARGET_PPC64) __put_user(set->sig[0] >> 32, &sc->_unused[3]); #else __put_user(set->sig[1], &sc->_unused[3]); #endif __put_user(h2g(&frame->mctx), &sc->regs); __put_user(sig, &sc->signal); err |= save_user_regs(env, &frame->mctx, TARGET_NR_sigreturn); env->lr = (target_ulong) h2g(frame->mctx.tramp); env->fpscr = 0; newsp = frame_addr - SIGNAL_FRAMESIZE; err |= put_user(env->gpr[1], newsp, target_ulong); if (err) goto sigsegv; env->gpr[1] = newsp; env->gpr[3] = signal; env->gpr[4] = frame_addr + offsetof(struct target_sigframe, sctx); env->nip = (target_ulong) ka->_sa_handler; env->msr &= ~MSR_LE; unlock_user_struct(frame, frame_addr, 1); return; sigsegv: unlock_user_struct(frame, frame_addr, 1); qemu_log("segfaulting from setup_frame\n"); force_sig(TARGET_SIGSEGV); }
1threat
Incompatible types : String cannot be converted to int error in java : <p>I've checked my codes many times but not seeing any error in lines. But It shows <code>incompatible types: string cannot be converted to int</code> in the package name. I've tried copying all codes in new package also but still seeing the same error. What was the exact problem. Here is my error screenshot <a href="http://i.stack.imgur.com/Rdxnu.png" rel="nofollow">Error</a></p>
0debug
Working and building a project with multiple developer with specified permission for each one? : We are two developer(me and my friend) and working on a MVC ASP.Net project in Visual Studio 2017 with TFS Online(visualstudio.com).<br> All of us have full access to all files for developing and building to view and test.<br> We want to outsource part of our project to another developers and we don't want to access full permission of project files to new developers.<br> If we didn't access full permission to all files to new developers, they can't build project to view and test.<br> Is there a way to access just some files of a project to another developers but they could build project to view and test?
0debug
I want to add Label , where should i write the code to add label? : I want to add Label , where should i write the code to add label ?**strong text** import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. var x = 20.0 var y = 100.0 let width = 100.0 let offsetX = 80.0 let offsetY = 80.0 for i in 1 ... 9 { let button = UIButton(frame: CGRect(x: x, y: y, width: width, height: width)) button.tag = i button.setTitle("\(i)", for: UIControlState.normal) button.setTitleColor(UIColor.green, for: UIControlState.normal) button.addTarget(self, action: #selector(self.buttonPressed(button:)), for: UIControlEvents.touchUpInside) self.view.addSubview(button) x = x + offsetX if i%3 == 0 { y = y + offsetY x = 20.0 } } } @objc func buttonPressed (button:UIButton) { print("Button Pressed: \(button.tag)") } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } I want to add Label , where should i write the code to add label ?
0debug
static int alloc_frame_buffer(AVCodecContext *avctx, Picture *pic, MotionEstContext *me, ScratchpadContext *sc, int chroma_x_shift, int chroma_y_shift, int linesize, int uvlinesize) { int edges_needed = av_codec_is_encoder(avctx->codec); int r, ret; pic->tf.f = pic->f; if (avctx->codec_id != AV_CODEC_ID_WMV3IMAGE && avctx->codec_id != AV_CODEC_ID_VC1IMAGE && avctx->codec_id != AV_CODEC_ID_MSS2) { if (edges_needed) { pic->f->width = avctx->width + 2 * EDGE_WIDTH; pic->f->height = avctx->height + 2 * EDGE_WIDTH; } r = ff_thread_get_buffer(avctx, &pic->tf, pic->reference ? AV_GET_BUFFER_FLAG_REF : 0); } else { pic->f->width = avctx->width; pic->f->height = avctx->height; pic->f->format = avctx->pix_fmt; r = avcodec_default_get_buffer2(avctx, pic->f, 0); } if (r < 0 || !pic->f->buf[0]) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed (%d %p)\n", r, pic->f->data[0]); return -1; } if (edges_needed) { int i; for (i = 0; pic->f->data[i]; i++) { int offset = (EDGE_WIDTH >> (i ? chroma_y_shift : 0)) * pic->f->linesize[i] + (EDGE_WIDTH >> (i ? chroma_x_shift : 0)); pic->f->data[i] += offset; } pic->f->width = avctx->width; pic->f->height = avctx->height; } if (avctx->hwaccel) { assert(!pic->hwaccel_picture_private); if (avctx->hwaccel->frame_priv_data_size) { pic->hwaccel_priv_buf = av_buffer_allocz(avctx->hwaccel->frame_priv_data_size); if (!pic->hwaccel_priv_buf) { av_log(avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n"); return -1; } pic->hwaccel_picture_private = pic->hwaccel_priv_buf->data; } } if (linesize && (linesize != pic->f->linesize[0] || uvlinesize != pic->f->linesize[1])) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n"); ff_mpeg_unref_picture(avctx, pic); return -1; } if (pic->f->linesize[1] != pic->f->linesize[2]) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed (uv stride mismatch)\n"); ff_mpeg_unref_picture(avctx, pic); return -1; } if (!sc->edge_emu_buffer && (ret = ff_mpeg_framesize_alloc(avctx, me, sc, pic->f->linesize[0])) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed to allocate context scratch buffers.\n"); ff_mpeg_unref_picture(avctx, pic); return ret; } return 0; }
1threat
Indentation in VS Code : <p>I'm a long time Emacs user. I've been trying out VS Code and i like it so far. </p> <p>One thing i love about Emacs is that it always indents the code correctly when i press tab. I've looked but i can't seem to get that behavior in VS Code. I've tried looking in the settings and searching for an extension but have had no luck.</p> <p>Can anyone help me on this please? Is there an extension i can/have to install to get it to do what i want?</p> <p>I code mostly in PHP, HTML, CSS and Javascript.</p> <p>Thanks in advance.</p>
0debug
Where can I find source code for Windows commands? : <p>I've been messing around with command prompt for a few days now, but I want to have a better understanding of what's actually going on under the hood. Searching the Internet has been of no use so far, as almost all the results there will show, you the syntax of the commands, which is not I want. </p> <p>Is it possible to retrieve the source code for any of the Windows commands?</p>
0debug
static int decode_group3_2d_line(AVCodecContext *avctx, GetBitContext *gb, unsigned int width, int *runs, const int *runend, const int *ref) { int mode = 0, saved_run = 0, t; int run_off = *ref++; unsigned int offs=0, run= 0; runend--; while(offs < width){ int cmode = get_vlc2(gb, ccitt_group3_2d_vlc.table, 9, 1); if(cmode == -1){ av_log(avctx, AV_LOG_ERROR, "Incorrect mode VLC\n"); return -1; } if(!cmode){ run_off += *ref++; run = run_off - offs; offs= run_off; run_off += *ref++; if(offs > width){ av_log(avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return -1; } saved_run += run; }else if(cmode == 1){ int k; for(k = 0; k < 2; k++){ run = 0; for(;;){ t = get_vlc2(gb, ccitt_vlc[mode].table, 9, 2); if(t == -1){ av_log(avctx, AV_LOG_ERROR, "Incorrect code\n"); return -1; } run += t; if(t < 64) break; } *runs++ = run + saved_run; if(runs >= runend){ av_log(avctx, AV_LOG_ERROR, "Run overrun\n"); return -1; } saved_run = 0; offs += run; if(offs > width || run > width){ av_log(avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return -1; } mode = !mode; } }else if(cmode == 9 || cmode == 10){ av_log(avctx, AV_LOG_ERROR, "Special modes are not supported (yet)\n"); return -1; }else{ run = run_off - offs + (cmode - 5); run_off -= *--ref; offs += run; if(offs > width || run > width){ av_log(avctx, AV_LOG_ERROR, "Run went out of bounds\n"); return -1; } *runs++ = run + saved_run; if(runs >= runend){ av_log(avctx, AV_LOG_ERROR, "Run overrun\n"); return -1; } saved_run = 0; mode = !mode; } while(run_off <= offs){ run_off += *ref++; run_off += *ref++; } } *runs++ = saved_run; *runs++ = 0; return 0; }
1threat
static int avi_read_tag(AVFormatContext *s, AVStream *st, uint32_t tag, uint32_t size) { AVIOContext *pb = s->pb; char key[5] = {0}, *value; size += (size & 1); if (size == UINT_MAX) return -1; value = av_malloc(size+1); if (!value) return -1; avio_read(pb, value, size); value[size]=0; AV_WL32(key, tag); return av_dict_set(st ? &st->metadata : &s->metadata, key, value, AV_DICT_DONT_STRDUP_VAL); }
1threat
static void scsi_command_complete(void *opaque, int ret) { int status; SCSIGenericReq *r = (SCSIGenericReq *)opaque; r->req.aiocb = NULL; if (r->req.io_canceled) { goto done; } if (r->io_header.driver_status & SG_ERR_DRIVER_SENSE) { r->req.sense_len = r->io_header.sb_len_wr; } if (ret != 0) { switch (ret) { case -EDOM: status = TASK_SET_FULL; break; case -ENOMEM: status = CHECK_CONDITION; scsi_req_build_sense(&r->req, SENSE_CODE(TARGET_FAILURE)); break; default: status = CHECK_CONDITION; scsi_req_build_sense(&r->req, SENSE_CODE(IO_ERROR)); break; } } else { if (r->io_header.host_status == SG_ERR_DID_NO_CONNECT || r->io_header.host_status == SG_ERR_DID_BUS_BUSY || r->io_header.host_status == SG_ERR_DID_TIME_OUT || (r->io_header.driver_status & SG_ERR_DRIVER_TIMEOUT)) { status = BUSY; BADF("Driver Timeout\n"); } else if (r->io_header.host_status) { status = CHECK_CONDITION; scsi_req_build_sense(&r->req, SENSE_CODE(I_T_NEXUS_LOSS)); } else if (r->io_header.status) { status = r->io_header.status; } else if (r->io_header.driver_status & SG_ERR_DRIVER_SENSE) { status = CHECK_CONDITION; } else { status = GOOD; } } DPRINTF("Command complete 0x%p tag=0x%x status=%d\n", r, r->req.tag, status); scsi_req_complete(&r->req, status); done: if (!r->req.io_canceled) { scsi_req_unref(&r->req); } }
1threat
FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port, target_phys_addr_t ctl_addr, target_phys_addr_t data_addr) { DeviceState *dev; SysBusDevice *d; FWCfgState *s; dev = qdev_create(NULL, "fw_cfg"); qdev_prop_set_uint32(dev, "ctl_iobase", ctl_port); qdev_prop_set_uint32(dev, "data_iobase", data_port); qdev_init_nofail(dev); d = sysbus_from_qdev(dev); s = DO_UPCAST(FWCfgState, busdev.qdev, dev); if (ctl_addr) { sysbus_mmio_map(d, 0, ctl_addr); } if (data_addr) { sysbus_mmio_map(d, 1, data_addr); } fw_cfg_add_bytes(s, FW_CFG_SIGNATURE, (uint8_t *)"QEMU", 4); fw_cfg_add_bytes(s, FW_CFG_UUID, qemu_uuid, 16); fw_cfg_add_i16(s, FW_CFG_NOGRAPHIC, (uint16_t)(display_type == DT_NOGRAPHIC)); fw_cfg_add_i16(s, FW_CFG_NB_CPUS, (uint16_t)smp_cpus); fw_cfg_add_i16(s, FW_CFG_MAX_CPUS, (uint16_t)max_cpus); fw_cfg_add_i16(s, FW_CFG_BOOT_MENU, (uint16_t)boot_menu); fw_cfg_bootsplash(s); fw_cfg_reboot(s); s->machine_ready.notify = fw_cfg_machine_ready; qemu_add_machine_init_done_notifier(&s->machine_ready); return s; }
1threat
ASP.NET How read a multipart form data in Web API? : <p>I send a multipart form data to my Web API like this:</p> <pre><code>string example = "my string"; HttpContent stringContent = new StringContent(example); HttpContent fileStreamContent = new StreamContent(stream); using (var client = new HttpClient()) { using (var content = new MultipartFormDataContent()) { content.Add(stringContent, "example", "example"); content.Add(fileStreamContent, "stream", "stream"); var uri = "http://localhost:58690/api/method"; HttpResponseMessage response = await client.PostAsync(uri, content); </code></pre> <p>and this is the Web API:</p> <pre><code>[HttpPost] [Route("api/method")] public async Task&lt;HttpResponseMessage&gt; Method() { // take contents and do something } </code></pre> <p>How read the string and the stream from request body in my Web API?</p>
0debug
Not understanding event.target in W3 schools example : I'm not understanding this example: [code] <!DOCTYPE html> <html> <head> <style> /* The Modal (background) */ .modal { display: none; /* Hidden by default */ position: fixed; /* Stay in place */ z-index: 1; /* Sit on top */ padding-top: 100px; /* Location of the box */ left: 0; top: 0; width: 100%; /* Full width */ height: 100%; /* Full height */ overflow: auto; /* Enable scroll if needed */ background-color: rgb(0,0,0); /* Fallback color */ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ } /* Modal Content */ .modal-content { background-color: #fefefe; margin: auto; padding: 20px; border: 1px solid #888; width: 80%; } /* The Close Button */ .close { color: #aaaaaa; float: right; font-size: 28px; font-weight: bold; } .close:hover, .close:focus { color: #000; text-decoration: none; cursor: pointer; } </style> </head> <body> <h2>Modal Example</h2> <!-- Trigger/Open The Modal --> <button id="myBtn">Open Modal</button> <!-- The Modal --> <div id="myModal" class="modal"> <!-- Modal content --> <div class="modal-content"> <span class="close">&times;</span> <p>Some text in the Modal..</p> </div> </div> <script> // Get the modal var modal = document.getElementById('myModal'); // Get the button that opens the modal var btn = document.getElementById("myBtn"); // Get the <span> element that closes the modal var span = document.getElementsByClassName("close")[0]; // When the user clicks the button, open the modal btn.onclick = function() { modal.style.display = "block"; } // When the user clicks on <span> (x), close the modal span.onclick = function() { modal.style.display = "none"; } // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target == modal) { modal.style.display = "none"; } else alert("Mongoose"); } </script> </body> </html> [/code] The part that I'm not understanding is: if (event.target == modal) { modal.style.display = "none"; } I would have thought that since it's supposed to be clicking outside the modal, that it would be if (event.target !=modal) What does event.target refer to? (Please lose the stupid demand that all code formats be formatted, even if one line. It's so bureaucratic and makes the site user unfriendly.)
0debug
static av_cold int vp3_decode_init(AVCodecContext *avctx) { Vp3DecodeContext *s = avctx->priv_data; int i, inter, plane; int c_width; int c_height; int y_fragment_count, c_fragment_count; if (avctx->codec_tag == MKTAG('V','P','3','0')) s->version = 0; else s->version = 1; s->avctx = avctx; s->width = FFALIGN(avctx->width, 16); s->height = FFALIGN(avctx->height, 16); if (avctx->pix_fmt == PIX_FMT_NONE) avctx->pix_fmt = PIX_FMT_YUV420P; avctx->chroma_sample_location = AVCHROMA_LOC_CENTER; if(avctx->idct_algo==FF_IDCT_AUTO) avctx->idct_algo=FF_IDCT_VP3; ff_dsputil_init(&s->dsp, avctx); ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct); for (i = 0; i < 3; i++) s->qps[i] = -1; avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_x_shift, &s->chroma_y_shift); s->y_superblock_width = (s->width + 31) / 32; s->y_superblock_height = (s->height + 31) / 32; s->y_superblock_count = s->y_superblock_width * s->y_superblock_height; c_width = s->width >> s->chroma_x_shift; c_height = s->height >> s->chroma_y_shift; s->c_superblock_width = (c_width + 31) / 32; s->c_superblock_height = (c_height + 31) / 32; s->c_superblock_count = s->c_superblock_width * s->c_superblock_height; s->superblock_count = s->y_superblock_count + (s->c_superblock_count * 2); s->u_superblock_start = s->y_superblock_count; s->v_superblock_start = s->u_superblock_start + s->c_superblock_count; s->macroblock_width = (s->width + 15) / 16; s->macroblock_height = (s->height + 15) / 16; s->macroblock_count = s->macroblock_width * s->macroblock_height; s->fragment_width[0] = s->width / FRAGMENT_PIXELS; s->fragment_height[0] = s->height / FRAGMENT_PIXELS; s->fragment_width[1] = s->fragment_width[0] >> s->chroma_x_shift; s->fragment_height[1] = s->fragment_height[0] >> s->chroma_y_shift; y_fragment_count = s->fragment_width[0] * s->fragment_height[0]; c_fragment_count = s->fragment_width[1] * s->fragment_height[1]; s->fragment_count = y_fragment_count + 2*c_fragment_count; s->fragment_start[1] = y_fragment_count; s->fragment_start[2] = y_fragment_count + c_fragment_count; if (!s->theora_tables) { for (i = 0; i < 64; i++) { s->coded_dc_scale_factor[i] = vp31_dc_scale_factor[i]; s->coded_ac_scale_factor[i] = vp31_ac_scale_factor[i]; s->base_matrix[0][i] = vp31_intra_y_dequant[i]; s->base_matrix[1][i] = vp31_intra_c_dequant[i]; s->base_matrix[2][i] = vp31_inter_dequant[i]; s->filter_limit_values[i] = vp31_filter_limit_values[i]; } for(inter=0; inter<2; inter++){ for(plane=0; plane<3; plane++){ s->qr_count[inter][plane]= 1; s->qr_size [inter][plane][0]= 63; s->qr_base [inter][plane][0]= s->qr_base [inter][plane][1]= 2*inter + (!!plane)*!inter; } } for (i = 0; i < 16; i++) { init_vlc(&s->dc_vlc[i], 11, 32, &dc_bias[i][0][1], 4, 2, &dc_bias[i][0][0], 4, 2, 0); init_vlc(&s->ac_vlc_1[i], 11, 32, &ac_bias_0[i][0][1], 4, 2, &ac_bias_0[i][0][0], 4, 2, 0); init_vlc(&s->ac_vlc_2[i], 11, 32, &ac_bias_1[i][0][1], 4, 2, &ac_bias_1[i][0][0], 4, 2, 0); init_vlc(&s->ac_vlc_3[i], 11, 32, &ac_bias_2[i][0][1], 4, 2, &ac_bias_2[i][0][0], 4, 2, 0); init_vlc(&s->ac_vlc_4[i], 11, 32, &ac_bias_3[i][0][1], 4, 2, &ac_bias_3[i][0][0], 4, 2, 0); } } else { for (i = 0; i < 16; i++) { if (init_vlc(&s->dc_vlc[i], 11, 32, &s->huffman_table[i][0][1], 8, 4, &s->huffman_table[i][0][0], 8, 4, 0) < 0) goto vlc_fail; if (init_vlc(&s->ac_vlc_1[i], 11, 32, &s->huffman_table[i+16][0][1], 8, 4, &s->huffman_table[i+16][0][0], 8, 4, 0) < 0) goto vlc_fail; if (init_vlc(&s->ac_vlc_2[i], 11, 32, &s->huffman_table[i+16*2][0][1], 8, 4, &s->huffman_table[i+16*2][0][0], 8, 4, 0) < 0) goto vlc_fail; if (init_vlc(&s->ac_vlc_3[i], 11, 32, &s->huffman_table[i+16*3][0][1], 8, 4, &s->huffman_table[i+16*3][0][0], 8, 4, 0) < 0) goto vlc_fail; if (init_vlc(&s->ac_vlc_4[i], 11, 32, &s->huffman_table[i+16*4][0][1], 8, 4, &s->huffman_table[i+16*4][0][0], 8, 4, 0) < 0) goto vlc_fail; } } init_vlc(&s->superblock_run_length_vlc, 6, 34, &superblock_run_length_vlc_table[0][1], 4, 2, &superblock_run_length_vlc_table[0][0], 4, 2, 0); init_vlc(&s->fragment_run_length_vlc, 5, 30, &fragment_run_length_vlc_table[0][1], 4, 2, &fragment_run_length_vlc_table[0][0], 4, 2, 0); init_vlc(&s->mode_code_vlc, 3, 8, &mode_code_vlc_table[0][1], 2, 1, &mode_code_vlc_table[0][0], 2, 1, 0); init_vlc(&s->motion_vector_vlc, 6, 63, &motion_vector_vlc_table[0][1], 2, 1, &motion_vector_vlc_table[0][0], 2, 1, 0); for (i = 0; i < 3; i++) { s->current_frame.data[i] = NULL; s->last_frame.data[i] = NULL; s->golden_frame.data[i] = NULL; } return allocate_tables(avctx); vlc_fail: av_log(avctx, AV_LOG_FATAL, "Invalid huffman table\n"); return -1; }
1threat
Observables: Complete vs finally vs done : <p>When speaking about Observables (especially rxjs), what is the difference between "finally" and "done" or "complete"?</p>
0debug
Why these parameters applied? : <p>Applying class="container" to div causes a problem with width of div. The index takes properties from _grid.cscc. </p> <p>It should be 100% width.</p> <p><a href="https://i.stack.imgur.com/KGgXA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KGgXA.jpg" alt="enter image description here"></a></p> <p><a href="https://i.stack.imgur.com/6tSgW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6tSgW.png" alt="enter image description here"></a></p> <p>And it's applied on every container I make</p>
0debug
Strange error in selenium after upgrading to chromedriver 2.28 needed for chrome 57 : <p>After being forced to upgrading to chromedriver 2.28 to use selenium with chrome 57, I get the following error message:</p> <pre><code>[0313/100022.689:ERROR:child_thread_impl.cc(762)] Request for unknown Channel-associated interface: ui::mojom::GpuMain </code></pre> <p>Any ideas on what might this be about?</p> <p>Chromedriver: 2.28 Chrome: 57 Webdriver: 3.3 node: 6.10</p>
0debug
static void pc_isa_bios_init(MemoryRegion *rom_memory, MemoryRegion *flash_mem, int ram_size) { int isa_bios_size; MemoryRegion *isa_bios; uint64_t flash_size; void *flash_ptr, *isa_bios_ptr; flash_size = memory_region_size(flash_mem); isa_bios_size = flash_size; if (isa_bios_size > (128 * 1024)) { isa_bios_size = 128 * 1024; } isa_bios = g_malloc(sizeof(*isa_bios)); memory_region_init_ram(isa_bios, NULL, "isa-bios", isa_bios_size); vmstate_register_ram_global(isa_bios); memory_region_add_subregion_overlap(rom_memory, 0x100000 - isa_bios_size, isa_bios, 1); flash_ptr = memory_region_get_ram_ptr(flash_mem); isa_bios_ptr = memory_region_get_ram_ptr(isa_bios); memcpy(isa_bios_ptr, ((uint8_t*)flash_ptr) + (flash_size - isa_bios_size), isa_bios_size); memory_region_set_readonly(isa_bios, true); }
1threat
maximum number of rows in a sqlite database ? (to quering Efficiently) : I've Developed a data logger system with C , that read data from sensors and save the info taken in SQLite database. Know my purpose is to reporting data from SQLite weekly . In a period of one week about 900000 rows (each row has 4 columns) stored in SQLite table . My main Question is : Is it possible to query between this number of rows ? (900000 row) And second problem is usage of RAM and CPU when query between 900000 rows !
0debug
How to lint for Typescript compilation issues? : <p>Take the following Typescript arrow function:</p> <pre><code>/** * Returns a probably unique component name. * * @param baseName a suggested name to make unique. * @returns a probably unique name. */ export const getUniqueComponentName = ( baseName ): string =&gt; { return baseName + Math.round(Math.random() * 10000000) } </code></pre> <p>When Typescript is configured in <code>tsconfig.json</code> as such:</p> <pre><code>"noImplicitAny": true, </code></pre> <p>This correctly results in a compilation error:</p> <blockquote> <p>[ts] Parameter 'baseName' implicitly has an 'any' type.</p> </blockquote> <p>Visual Studio Code is also smart enough to inform you about this issue during development.</p> <p>My goal is to create a precommit git hook that prevents such errors from ending up in version control. I tried to do this with <code>tslint</code>, <code>husky</code> and <code>lint-staged</code> using this <code>npm script</code>:</p> <pre><code>"lint": "tslint --project tsconfig.json --config tslint.json" </code></pre> <p>However, this does not result in the compilation error showing up by tslint. It is silently ignored.</p> <p>I then tried to add a rule in tslint.json:</p> <pre><code>"typedef": [ true, "arrow-parameter" ] </code></pre> <p>While this did make tslint complain, it also started to complain in anonymous arrow functions where the <code>tsc</code> compiler does not complain. In these arrow functions it should not be necessary to add types because the types were already set previously in the parent scope (they are inferred). </p> <p>So basically, I would like for tslint to behave the same as tsc in this case. Anytime there is an error that would cause compilation to fail (such as the above arrow function), I would like to prevent the commit, but without actually compiling to Javascript. Is this possible?</p>
0debug
static int ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile, AVCodecContext *avctx) { int mbn, blk, num_blocks, num_coeffs, blk_size, scan_pos, run, val, pos, is_intra, mc_type = 0, mv_x, mv_y, col_mask; uint8_t col_flags[8]; int32_t prev_dc, trvec[64]; uint32_t cbp, sym, lo, hi, quant, buf_offs, q; IVIMbInfo *mb; RVMapDesc *rvmap = band->rv_map; void (*mc_with_delta_func)(int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type); void (*mc_no_delta_func) (int16_t *buf, const int16_t *ref_buf, uint32_t pitch, int mc_type); const uint16_t *base_tab; const uint8_t *scale_tab; prev_dc = 0; blk_size = band->blk_size; col_mask = blk_size - 1; num_blocks = (band->mb_size != blk_size) ? 4 : 1; num_coeffs = blk_size * blk_size; if (blk_size == 8) { mc_with_delta_func = ff_ivi_mc_8x8_delta; mc_no_delta_func = ff_ivi_mc_8x8_no_delta; } else { mc_with_delta_func = ff_ivi_mc_4x4_delta; mc_no_delta_func = ff_ivi_mc_4x4_no_delta; } for (mbn = 0, mb = tile->mbs; mbn < tile->num_MBs; mb++, mbn++) { is_intra = !mb->type; cbp = mb->cbp; buf_offs = mb->buf_offs; quant = av_clip(band->glob_quant + mb->q_delta, 0, 23); base_tab = is_intra ? band->intra_base : band->inter_base; scale_tab = is_intra ? band->intra_scale : band->inter_scale; if (scale_tab) quant = scale_tab[quant]; if (!is_intra) { mv_x = mb->mv_x; mv_y = mb->mv_y; if (band->is_halfpel) { mc_type = ((mv_y & 1) << 1) | (mv_x & 1); mv_x >>= 1; mv_y >>= 1; } if (mb->type) { int dmv_x, dmv_y, cx, cy; dmv_x = mb->mv_x >> band->is_halfpel; dmv_y = mb->mv_y >> band->is_halfpel; cx = mb->mv_x & band->is_halfpel; cy = mb->mv_y & band->is_halfpel; if ( mb->xpos + dmv_x < 0 || mb->xpos + dmv_x + band->mb_size + cx > band->pitch || mb->ypos + dmv_y < 0 || mb->ypos + dmv_y + band->mb_size + cy > band->aheight) { return AVERROR_INVALIDDATA; } } } for (blk = 0; blk < num_blocks; blk++) { if (blk & 1) { buf_offs += blk_size; } else if (blk == 2) { buf_offs -= blk_size; buf_offs += blk_size * band->pitch; } if (cbp & 1) { if (!band->scan) { av_log(avctx, AV_LOG_ERROR, "Scan pattern is not set.\n"); return AVERROR_INVALIDDATA; } scan_pos = -1; memset(trvec, 0, num_coeffs*sizeof(trvec[0])); memset(col_flags, 0, sizeof(col_flags)); while (scan_pos <= num_coeffs) { sym = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1); if (sym == rvmap->eob_sym) break; if (sym == rvmap->esc_sym) { run = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1) + 1; lo = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1); hi = get_vlc2(gb, band->blk_vlc.tab->table, IVI_VLC_BITS, 1); val = IVI_TOSIGNED((hi << 6) | lo); } else { if (sym >= 256U) { av_log(avctx, AV_LOG_ERROR, "Invalid sym encountered: %d.\n", sym); return -1; } run = rvmap->runtab[sym]; val = rvmap->valtab[sym]; } scan_pos += run; if (scan_pos >= (unsigned)num_coeffs) break; pos = band->scan[scan_pos]; if (!val) av_dlog(avctx, "Val = 0 encountered!\n"); q = (base_tab[pos] * quant) >> 9; if (q > 1) val = val * q + FFSIGN(val) * (((q ^ 1) - 1) >> 1); trvec[pos] = val; col_flags[pos & col_mask] |= !!val; } if (scan_pos >= num_coeffs && sym != rvmap->eob_sym) return -1; if (is_intra && band->is_2d_trans) { prev_dc += trvec[0]; trvec[0] = prev_dc; col_flags[0] |= !!prev_dc; } if(band->transform_size > band->blk_size){ av_log(NULL, AV_LOG_ERROR, "Too large transform\n"); return AVERROR_INVALIDDATA; } band->inv_transform(trvec, band->buf + buf_offs, band->pitch, col_flags); if (!is_intra) mc_with_delta_func(band->buf + buf_offs, band->ref_buf + buf_offs + mv_y * band->pitch + mv_x, band->pitch, mc_type); } else { if (is_intra) { band->dc_transform(&prev_dc, band->buf + buf_offs, band->pitch, blk_size); } else mc_no_delta_func(band->buf + buf_offs, band->ref_buf + buf_offs + mv_y * band->pitch + mv_x, band->pitch, mc_type); } cbp >>= 1; } } align_get_bits(gb); return 0; }
1threat
void monitor_readline(const char *prompt, int is_password, char *buf, int buf_size) { int i; if (is_password) { for (i = 0; i < MAX_MON; i++) if (monitor_hd[i] && monitor_hd[i]->focus == 0) qemu_chr_send_event(monitor_hd[i], CHR_EVENT_FOCUS); } readline_start(prompt, is_password, monitor_readline_cb, NULL); monitor_readline_buf = buf; monitor_readline_buf_size = buf_size; monitor_readline_started = 1; while (monitor_readline_started) { main_loop_wait(10); } }
1threat
static float get_band_cost_ZERO_mips(struct AACEncContext *s, PutBitContext *pb, const float *in, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits) { int i; float cost = 0; for (i = 0; i < size; i += 4) { cost += in[i ] * in[i ]; cost += in[i+1] * in[i+1]; cost += in[i+2] * in[i+2]; cost += in[i+3] * in[i+3]; } if (bits) *bits = 0; return cost * lambda; }
1threat
Find the next leap year in C : <p>I'm having trouble with an exercise on my homework. I have to make a function that tells me when the next leap year is given an <code>n</code> (or <code>n</code> if it's a leap year).</p> <p>I already tackled the last part, but I'm having trouble with the "next leap year" part. I assume I have to do a cycle? </p> <p>Here's what I have so far</p> <pre><code>int next_leapyear(int n) { if(((n%4==0)&amp;&amp;(n%100!=0))||(n%400==0)) return n; else while(?){ n++; } return n; } </code></pre> <p>I'm just starting to learn this language, so if you guys could keep it simple I would appreciate it</p>
0debug
How do I get the current time from the internet? : <p>I have browsed the whole site to find a solution. But none of the ones I found worked. And most of them were pretty old. So I want to get the current UTC time from the internet. Completely independent from the phone.</p> <p>Would be nice if someone could help me.</p>
0debug
Is it possible to change the return value of a method in this case? : <p>I want to change the return value of method getvalue() to string "firefighter" which i tried from main method but did not work out. looking forward to some soln. </p> <pre><code>public class Summ2 { private String getValue() { return "TUHH"; } public static void main(String[] args) { Summ2 GO = new Summ2(); assert GO.getValue() == "firefighter"; System.out.println(GO.getValue()); } } </code></pre>
0debug
Unity C# ArgumentOutOfRangeException: Argument is out of range. Parameter name: index : <p>I'm creating a game that is like snake. In my code below, each segment of the snake's body is an instance of the Character class. When I try to add a new character, I get the error: </p> <pre><code>ArgumentOutOfRangeException: Argument is out of range. Parameter name: index </code></pre> <p>Other resources online have proposed that there's a List that is empty that I'm trying to reference. But I don't see any evidence of that case in my code.</p> <p>Perhaps someone smarter than myself can find what I've done wrong?</p> <pre><code>using System.Collections; using System.Collections.Generic; using UnityEngine; /* * This class controls the entire snake. The snake has a list * of segments that are each a character. We can move along the snake * by moving the characters bottom up, so that the character replaces * the position of the character before him. */ public class PlayerController : MonoBehaviour { //how many units will he move per 'frame' public float moveUnits = 1; //how often he will move (every quarter second) public float moveTimer = 0.25f; private float timeSinceLastMoved; public KeyCode dir = KeyCode.RightArrow; //locations of boundaries public float topBoundary = 4.5f; public float bottomBoundary = -4.5f; public float leftBoundary = -8.5f; public float rightBoundary = 8.5f; //Holds all characters for the snake body public List&lt;Character&gt; chars = new List&lt;Character&gt;(); // Use this for initialization void Start () { timeSinceLastMoved = Time.time; getFirstCharacter (); } // Update is called once per frame void Update () { getInput (); if (timeSinceLastMoved + moveTimer &lt; Time.time) { move (); timeSinceLastMoved = Time.time; } } void getInput() { //if i press right go right, but i can't be going left when i want to go right if (Input.GetKeyDown (KeyCode.RightArrow) &amp;&amp; dir != KeyCode.LeftArrow) { dir = KeyCode.RightArrow; } else if (Input.GetKeyDown (KeyCode.LeftArrow) &amp;&amp; dir != KeyCode.RightArrow) { dir = KeyCode.LeftArrow; } else if (Input.GetKeyDown (KeyCode.UpArrow) &amp;&amp; dir != KeyCode.DownArrow) { dir = KeyCode.UpArrow; } else if (Input.GetKeyDown (KeyCode.DownArrow) &amp;&amp; dir != KeyCode.UpArrow) { dir = KeyCode.DownArrow; } //for testing character addition else if (Input.GetKey (KeyCode.A)) { addCharacter (); } } void move() { float x = 0; float y = 0; if (chars.Count != 0) { //moves the transform in the appropriate directions switch (dir) { case KeyCode.RightArrow: x = transform.position.x + moveUnits; y = transform.position.y; break; case KeyCode.LeftArrow: x = transform.position.x - moveUnits; y = transform.position.y; break; case KeyCode.UpArrow: x = transform.position.x; y = transform.position.y + moveUnits; break; case KeyCode.DownArrow: x = transform.position.x; y = transform.position.y - moveUnits; break; default: break; } //prevents him from moving outside the set boundaries x = Mathf.Clamp (x, leftBoundary, rightBoundary); y = Mathf.Clamp (y, bottomBoundary, topBoundary); Vector2 pos = new Vector2 (x, y); //this moves the whole snake transform.position = pos; //this moves the first snake segment chars[0].transform.position = pos; //for all characters(aka snake segments) //take the position of the segment before you for (int i = chars.Count - 1; i &gt; 0; i++) { chars [i].transform.position = chars [i - 1].transform.position; } } } void addCharacter() { //the position of the last segment Vector2 prevCharPos = chars[chars.Count-1].transform.position; Vector2 pos; float x = 0; float y = 0; switch (dir) { case KeyCode.RightArrow: x = prevCharPos.x - moveUnits; y = prevCharPos.y; break; case KeyCode.LeftArrow: x = prevCharPos.x + moveUnits; y = prevCharPos.y;; break; case KeyCode.UpArrow: x = prevCharPos.x; y = prevCharPos.y + moveUnits; break; case KeyCode.DownArrow: x = prevCharPos.x; y = prevCharPos.y - moveUnits; break; default: break; } pos = new Vector2 (x, y); //make a new character at the position behind the last segment Character newChar = Instantiate (chars[chars.Count - 1], pos, Quaternion.identity, this.transform); //add him to the list chars.Add (newChar); } void getFirstCharacter() { //find the character that already exists and add him to the list GameObject firstChar = GameObject.Find ("Character"); if (firstChar != null) { chars.Add(firstChar.GetComponent&lt;Character&gt;()); } } </code></pre> <p>}</p>
0debug
static int seg_write_header(AVFormatContext *s) { SegmentContext *seg = s->priv_data; AVFormatContext *oc = NULL; AVDictionary *options = NULL; int ret; seg->segment_count = 0; if (!seg->write_header_trailer) seg->individual_header_trailer = 0; if (!!seg->time_str + !!seg->times_str + !!seg->frames_str > 1) { av_log(s, AV_LOG_ERROR, "segment_time, segment_times, and segment_frames options " "are mutually exclusive, select just one of them\n"); return AVERROR(EINVAL); } if (seg->times_str) { if ((ret = parse_times(s, &seg->times, &seg->nb_times, seg->times_str)) < 0) return ret; } else if (seg->frames_str) { if ((ret = parse_frames(s, &seg->frames, &seg->nb_frames, seg->frames_str)) < 0) return ret; } else { if (!seg->time_str) seg->time_str = av_strdup("2"); if ((ret = av_parse_time(&seg->time, seg->time_str, 1)) < 0) { av_log(s, AV_LOG_ERROR, "Invalid time duration specification '%s' for segment_time option\n", seg->time_str); return ret; } } if (seg->format_options_str) { ret = av_dict_parse_string(&seg->format_options, seg->format_options_str, "=", ":", 0); if (ret < 0) { av_log(s, AV_LOG_ERROR, "Could not parse format options list '%s'\n", seg->format_options_str); goto fail; } } if (seg->list) { if (seg->list_type == LIST_TYPE_UNDEFINED) { if (av_match_ext(seg->list, "csv" )) seg->list_type = LIST_TYPE_CSV; else if (av_match_ext(seg->list, "ext" )) seg->list_type = LIST_TYPE_EXT; else if (av_match_ext(seg->list, "m3u8")) seg->list_type = LIST_TYPE_M3U8; else if (av_match_ext(seg->list, "ffcat,ffconcat")) seg->list_type = LIST_TYPE_FFCONCAT; else seg->list_type = LIST_TYPE_FLAT; } if ((ret = segment_list_open(s)) < 0) goto fail; } if (seg->list_type == LIST_TYPE_EXT) av_log(s, AV_LOG_WARNING, "'ext' list type option is deprecated in favor of 'csv'\n"); if ((ret = select_reference_stream(s)) < 0) goto fail; av_log(s, AV_LOG_VERBOSE, "Selected stream id:%d type:%s\n", seg->reference_stream_index, av_get_media_type_string(s->streams[seg->reference_stream_index]->codec->codec_type)); seg->oformat = av_guess_format(seg->format, s->filename, NULL); if (!seg->oformat) { ret = AVERROR_MUXER_NOT_FOUND; goto fail; } if (seg->oformat->flags & AVFMT_NOFILE) { av_log(s, AV_LOG_ERROR, "format %s not supported.\n", seg->oformat->name); ret = AVERROR(EINVAL); goto fail; } if ((ret = segment_mux_init(s)) < 0) goto fail; oc = seg->avf; if ((ret = set_segment_filename(s)) < 0) goto fail; if (seg->write_header_trailer) { if ((ret = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL)) < 0) { av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", oc->filename); goto fail; } } else { if ((ret = open_null_ctx(&oc->pb)) < 0) goto fail; } av_dict_copy(&options, seg->format_options, 0); ret = avformat_write_header(oc, &options); if (av_dict_count(options)) { av_log(s, AV_LOG_ERROR, "Some of the provided format options in '%s' are not recognized\n", seg->format_options_str); } av_dict_free(&options); if (ret < 0) { avio_close(oc->pb); goto fail; } seg->segment_frame_count = 0; if (oc->avoid_negative_ts > 0 && s->avoid_negative_ts < 0) s->avoid_negative_ts = 1; if (!seg->write_header_trailer) { close_null_ctx(oc->pb); if ((ret = avio_open2(&oc->pb, oc->filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL)) < 0) goto fail; } fail: if (ret) { if (seg->list) avio_close(seg->list_pb); if (seg->avf) avformat_free_context(seg->avf); } return ret; }
1threat
Android data binding dependency conflict with the support library : <p>I'm trying to set up data binding in my Android project like so:</p> <pre><code>dataBinding { enabled = true } </code></pre> <p>However, when I add a support library dependency, lint complains:</p> <blockquote> <p>All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.1.0, 21.0.3. Examples include 'com.android.support:animated-vector-drawable:25.1.0' and 'com.android.support:support-v4:21.0.3'</p> </blockquote> <p>When I run <code>./gradlew app:dependencies</code>, I get the following:</p> <pre><code>... +--- com.android.support:appcompat-v7:25.1.0 | +--- com.android.support:support-annotations:25.1.0 | +--- com.android.support:support-v4:25.1.0 | | +--- com.android.support:support-compat:25.1.0 (*) | | +--- com.android.support:support-media-compat:25.1.0 | | | +--- com.android.support:support-annotations:25.1.0 | | | \--- com.android.support:support-compat:25.1.0 (*) | | +--- com.android.support:support-core-utils:25.1.0 | | | +--- com.android.support:support-annotations:25.1.0 | | | \--- com.android.support:support-compat:25.1.0 (*) | | +--- com.android.support:support-core-ui:25.1.0 (*) | | \--- com.android.support:support-fragment:25.1.0 | | +--- com.android.support:support-compat:25.1.0 (*) | | +--- com.android.support:support-media-compat:25.1.0 (*) | | +--- com.android.support:support-core-ui:25.1.0 (*) | | \--- com.android.support:support-core-utils:25.1.0 (*) | +--- com.android.support:support-vector-drawable:25.1.0 | | +--- com.android.support:support-annotations:25.1.0 | | \--- com.android.support:support-compat:25.1.0 (*) | \--- com.android.support:animated-vector-drawable:25.1.0 | \--- com.android.support:support-vector-drawable:25.1.0 (*) +--- com.android.databinding:library:1.3.1 | +--- com.android.support:support-v4:21.0.3 -&gt; 25.1.0 (*) | \--- com.android.databinding:baseLibrary:2.3.0-dev -&gt; 2.3.0-beta1 ... </code></pre> <p>Any ideas on how to stop link from complaining without disabling it?</p>
0debug
Robot framework, How to automare username and password fields of EDGE browser using selenium library? : How to enter username and Password into EDGE browser pop up window using selenium library
0debug
Android How to make half of imageView transparent? : I have an `ImageView` and i want to make half of its bitmap transparent without changing size . anyone can help ?
0debug
static int ram_save_setup(QEMUFile *f, void *opaque) { RAMBlock *block; bytes_transferred = 0; reset_ram_globals(); if (migrate_use_xbzrle()) { XBZRLE.cache = cache_init(migrate_xbzrle_cache_size() / TARGET_PAGE_SIZE, TARGET_PAGE_SIZE); if (!XBZRLE.cache) { DPRINTF("Error creating cache\n"); return -1; } XBZRLE.encoded_buf = g_malloc0(TARGET_PAGE_SIZE); XBZRLE.current_buf = g_malloc(TARGET_PAGE_SIZE); acct_clear(); } QLIST_FOREACH(block, &ram_list.blocks, next) { migration_bitmap_set_dirty(block->mr, block->length); } memory_global_dirty_log_start(); memory_global_sync_dirty_bitmap(get_system_memory()); qemu_put_be64(f, ram_bytes_total() | RAM_SAVE_FLAG_MEM_SIZE); QLIST_FOREACH(block, &ram_list.blocks, next) { qemu_put_byte(f, strlen(block->idstr)); qemu_put_buffer(f, (uint8_t *)block->idstr, strlen(block->idstr)); qemu_put_be64(f, block->length); } qemu_put_be64(f, RAM_SAVE_FLAG_EOS); return 0; }
1threat
When I pass a list to another method, it returns NoneType. How can I fix this? : <p>I am trying to write a <code>main()</code> method that will call another method that reads the individual records within a .txt file; this is the <code>loadFile()</code> method. I've tested that the <code>loadFile()</code> method works and that the list it returns is ListType. However, when I call <code>loadFile()</code> within <code>main()</code> and try to act upon the list generated, I get an error like <code>TypeError: 'NoneType' object is not subscriptable</code>. Can someone help me ensure that the list I'm passing from one method to the next remains ListType? </p> <pre><code>def loadFile(fileName): openFile = open(fileName, 'r') records = openFile.readlines() recordList = [] for item in records: recordList.append(item.rstrip('\n')) print(recordList) openFile.close() def main(): nameFile = 'names.txt' names = loadFile(nameFile) print(names[12]) main() </code></pre>
0debug
Android TextView DrawableTint on pre v23 devices : <p>Is there any way we can tint the <code>Drawable</code> used in the <code>TextView</code>? <code>DrawableTint</code> works only on API level 23 and above.</p> <p>Currently I'm using a <code>Vertical Linear Layout</code> to achieve my requirement.</p> <pre><code>&lt;LinearLayout style="@style/ChoiceIllustratorIconTextContainerStyle"&gt; &lt;ImageView style="@style/ChoiceIllustratorImageStyle" android:contentDescription="@string/cd_university" android:src="@drawable/ic_account_balance_white_24dp" /&gt; &lt;TextView style="@style/ChoiceIllustratorTextStyle" android:text="@string/ci_text_university" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>And it looks like,<a href="https://i.stack.imgur.com/JBrPd.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JBrPd.png" alt="enter image description here"></a></p> <p>Android studio is suggesting me to use <code>Compound Drawble</code> with <code>TextView</code> to achieve this. And I'm able to achieve it, but I cannot find a way to <code>Tint</code> the drawable.</p> <pre><code>&lt;TextView style="@style/ChoiceIllustratorTextStyle" android:drawablePadding="4dp" android:drawableTop="@drawable/ic_account_balance_white_24dp" android:text="@string/ci_text_university" /&gt; </code></pre>
0debug
when i use this code to store image in sqlite , I get only the first image , the application not restore to me the other images By the id : when i use this code to store image and restore it from SQLite . it insert only one image (the first one ) and when i restore the image by id it also restore the first image only . activity_main.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> <EditText android:layout_width="match_parent" android:layout_height="50dp" android:textSize="24dp" android:hint="enter name" android:id="@+id/nametxt" android:layout_marginTop="350dp" /> <EditText android:layout_width="match_parent" android:layout_height="50dp" android:textSize="24dp" android:hint="enter id" android:id="@+id/idtxt" android:layout_marginTop="420dp" /> <Button android:textSize="20dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Save Image Sqlite" android:id="@+id/button" android:layout_below="@+id/imageView" android:layout_marginTop="75dp" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" /> <Button android:textSize="20dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Get Image From Sqlite" android:id="@+id/button2" android:layout_below="@+id/button" android:layout_marginTop="42dp" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" /> <ImageView android:background="@color/colorPrimaryDark" android:layout_width="120dp" android:layout_height="120dp" android:id="@+id/imageView2" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" /> <ImageView android:background="@color/colorAccent" android:layout_width="120dp" android:layout_height="120dp" android:id="@+id/imageView" android:scaleType="fitCenter" android:maxHeight="120dp" android:maxWidth="120dp" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" /> </RelativeLayout> MainActivity.java package com.example.mahmoudbelal.navigator; import android.content.Intent; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.net.Uri; import android.os.Bundle; import android.provider.MediaStore; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.Toast; import java.io.ByteArrayOutputStream; public class MainActivity extends AppCompatActivity { private static int RESULT_LOAD_IMG = 1; String imgDecodableString; static EditText name,id; static ImageView Img,Img2; Button Save,Get; SQLiteDatabase db; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); id= (EditText) findViewById(R.id.idtxt); Img = (ImageView) findViewById(R.id.imageView); Img2 = (ImageView) findViewById(R.id.imageView2); Save = (Button) findViewById(R.id.button); Get = (Button) findViewById(R.id.button2); name= (EditText) findViewById(R.id.nametxt); Img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); // Start the Intent startActivityForResult(galleryIntent, RESULT_LOAD_IMG); } }); Save.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { Img.buildDrawingCache(); Bitmap bitmap=Img.getDrawingCache(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, bos); byte[] img = bos.toByteArray(); DBAdapter D=new DBAdapter(); D.open(MainActivity.this); String myname=name.getText().toString(); String myid=id.getText().toString(); D.insert_user_data(myid,myname,img); Toast.makeText(MainActivity.this, "Inserted Data well !", Toast.LENGTH_SHORT).show(); name.setText(" "); id.setText(" "); }catch (Exception e){ Toast.makeText(MainActivity.this, ""+e.getMessage(), Toast.LENGTH_SHORT).show(); } } }); //------------------------------------------------------------------------------------//\ Get.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DBAdapter D=new DBAdapter(); D.open(MainActivity.this); String use_id=id.getText().toString(); D.Get_user_data(use_id); if (DBAdapter.ok.equals("1")){ // Img2.setImageBitmap(DBAdapter.bmp); // Toast.makeText(MainActivity.this, "name is = "+DBAdapter.s, Toast.LENGTH_SHORT).show(); name.setText(""+DBAdapter.s); }else { Toast.makeText(MainActivity.this, "Error y m3lm ", Toast.LENGTH_SHORT).show(); } } }); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); // When an Image is picked if (requestCode == RESULT_LOAD_IMG && resultCode == this.RESULT_OK && null != data) { // Get the Image from data Uri selectedImage = data.getData(); String[] filePathColumn = {MediaStore.Images.Media.DATA}; // Get the cursor Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); cursor.moveToFirst(); int columnIndex = cursor.getColumnIndex(filePathColumn[0]); imgDecodableString = cursor.getString(columnIndex); //-0------------------------------------------------------------------------------------------------------------- Uri photoUri = data.getData(); String[] proj = {MediaStore.Images.Media.DATA}; Cursor actualimagecursor = managedQuery(photoUri, proj, null, null, null); int actual_image_column_index = actualimagecursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA); actualimagecursor.moveToFirst(); //-------------------------------------------------------------------------------------------- cursor.close(); Img.setImageBitmap(BitmapFactory.decodeFile(imgDecodableString)); Toast.makeText(MainActivity.this, "Image Uploaded", Toast.LENGTH_LONG).show(); } else { Toast.makeText(MainActivity.this, "You haven't picked Image", Toast.LENGTH_LONG).show(); }} } DBAdapter.java package com.example.mahmoudbelal.navigator; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.graphics.Bitmap; import android.graphics.BitmapFactory; public class DBAdapter { // first step:create table static Bitmap bmp; static String s=""; private int version=1; private String DatabaseName="DNAA"; private String TableName="user"; static String ok; // -------------------------------------------------- // private String create_table = "CREATE TABLE IF NOT EXISTS user(id varchar,name varchar,img blob);"; // second step:helper class class DbHellper extends SQLiteOpenHelper{ public DbHellper(Context context){ super(context , DatabaseName , null , version); } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(create_table); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL("Drop table If Exists "+TableName); onCreate(db); } } private DbHellper DB_helper; private SQLiteDatabase db; public DBAdapter open(Context conn){ DB_helper = new DbHellper(conn); db = DB_helper.getWritableDatabase(); return this; // activity } private void close (){ db.close(); } int i = 0; public void insert_user_data (String id, String name, byte[] ii){ ContentValues cv = new ContentValues(); cv.put("id" , id); cv.put("name" , name); cv.put("img" , ii); db.insert(TableName, null, cv); } public void updateSection(String username , String password , int rowId){ ContentValues cv = new ContentValues(); cv.put("username" , username); cv.put("password" , password); db.update(TableName, cv, "_id =" + rowId, null); } // Login method public void Get_user_data (String id){ Cursor c = db.rawQuery("SELECT name,img FROM user where id='"+id+"'", null); if (c.moveToFirst()) { s= c.getString(0); byte[] i=c.getBlob(1); bmp= BitmapFactory.decodeByteArray(i,0,i.length); MainActivity.Img2.setImageBitmap(bmp); ok="1"; } else { ok="0"; } } // delete data public void deleteSection(int rowId){ db.delete(TableName, "_id =" + rowId, null); } public Cursor getAllSections (){ return db.query(TableName,new String []{"username","password"},null,null,null,null,null); } public Cursor getSection (String whereClause){ return db.query(TableName,new String []{"_id","name","devices"},whereClause,null,null,null,null); } }
0debug
i need to add comment/chat plugins into blogger like as https://kaviijavahouse.blogspot.com : <p>.comments .comments-content .icon.blog-author { background-repeat: no-repeat; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEgAACxIB0t1+/AAAAAd0SU1FB9sLFwMeCjjhcOMAAAD+SURBVDjLtZSvTgNBEIe/WRRnm3U8RC1neQdsm1zSBIU9VVF1FkUguQQsD9ITmD7ECZIJSE4OZo9stoVjC/zc7ky+zH9hXwVwDpTAWWLrgS3QAe8AZgaAJI5zYAmc8r0G4AHYHQKVwII8PZrZFsBFkeRCABYiMh9BRUhnSkPTNCtVXYXURi1FpBDgArj8QU1eVXUzfnjv7yP7kwu1mYrkWlU33vs1QNu2qU8pwN0UpKoqokjWwCztrMuBhEhmh8bD5UDqur75asbcX0BGUB9/HAMB+r32hznJgXy2v0sGLBcyAJ1EK3LFcbo1s91JeLwAbwGYu7TP/3ZGfnXYPgAVNngtqatUNgAAAABJRU5ErkJggg==); }</p>
0debug
int usb_device_attach(USBDevice *dev) { USBBus *bus = usb_bus_from_device(dev); if (bus->nfree == 1 && dev->port_path == NULL) { usb_create_simple(bus, "usb-hub"); } return do_attach(dev); }
1threat
Multipart request with Retrofit @PartMap Error in Kotlin (Android) : <p>If I am using this code in Java then its working fine. When I convert that code in kotlin then I got Error.</p> <h2>Logcat</h2> <blockquote> <p>08-20 23:46:51.003 3782-3782/com.qkangaroo.app W/System.err: java.lang.IllegalArgumentException: Parameter type must not include a type variable or wildcard: java.util.Map (parameter #1) 08-20 23:46:51.003 3782-3782/com.qkangaroo.app W/System.err: for method ApiInterface.updateCustomerDetail 08-20 23:46:51.003 3782-3782/com.qkangaroo.app W/System.err: at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:752) 08-20 23:46:51.004 3782-3782/com.qkangaroo.app W/System.err: at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:743) 08-20 23:46:51.004 3782-3782/com.qkangaroo.app W/System.err: at retrofit2.ServiceMethod$Builder.parameterError(ServiceMethod.java:761) 08-20 23:46:51.004 3782-3782/com.qkangaroo.app W/System.err: at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:195) 08-20 23:46:51.004 3782-3782/com.qkangaroo.app W/System.err: at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:170) 08-20 23:46:51.005 3782-3782/com.qkangaroo.app W/System.err: at retrofit2.Retrofit$1.invoke(Retrofit.java:147) 08-20 23:46:51.005 3782-3782/com.qkangaroo.app W/System.err: at $Proxy0.updateCustomerDetail(Native Method) 08-20 23:46:51.005 3782-3782/com.qkangaroo.app W/System.err: at com.qkangaroo.app.Fragments.MoreScreen.MoreFragment.updateProfile(MoreFragment.kt:261) 08-20 23:46:51.006 3782-3782/com.qkangaroo.app W/System.err: at com.qkangaroo.app.Fragments.MoreScreen.MoreFragment$clickListener$1.onClick(MoreFragment.kt:191) 08-20 23:46:51.006 3782-3782/com.qkangaroo.app W/System.err: at android.view.View.performClick(View.java:3517) 08-20 23:46:51.006 3782-3782/com.qkangaroo.app W/System.err: at android.view.View$PerformClick.run(View.java:14155) 08-20 23:46:51.006 3782-3782/com.qkangaroo.app W/System.err: at android.os.Handler.handleCallback(Handler.java:605) 08-20 23:46:51.007 3782-3782/com.qkangaroo.app W/System.err: at android.os.Handler.dispatchMessage(Handler.java:92) 08-20 23:46:51.007 3782-3782/com.qkangaroo.app W/System.err: at android.os.Looper.loop(Looper.java:154) 08-20 23:46:51.007 3782-3782/com.qkangaroo.app W/System.err: at android.app.ActivityThread.main(ActivityThread.java:4624) 08-20 23:46:51.008 3782-3782/com.qkangaroo.app W/System.err: at java.lang.reflect.Method.invokeNative(Native Method) 08-20 23:46:51.009 3782-3782/com.qkangaroo.app W/System.err: at java.lang.reflect.Method.invoke(Method.java:511) 08-20 23:46:51.009 3782-3782/com.qkangaroo.app W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809) 08-20 23:46:51.010 3782-3782/com.qkangaroo.app W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576) 08-20 23:46:51.011 3782-3782/com.qkangaroo.app W/System.err: at dalvik.system.NativeStart.main(Native Method)</p> </blockquote> <h2>fragment.kt</h2> <pre><code> var map:HashMap&lt;String,RequestBody&gt; = HashMap&lt;String, RequestBody&gt;() map.put("version",ApiClient.createRequestBody(AppConstants.API_VERSION)) map.put("auth_token", ApiClient.createRequestBody(customer.authToken!!)) map.put("customer_name",ApiClient.createRequestBody(profileName)) map.put("email", ApiClient.createRequestBody(profileEmail)) val apiInterface = ApiClient.client.create(ApiInterface::class.java) val updateCustomerCall: Call&lt;UpdateCustomer&gt; = apiInterface.updateCustomerDetail(map) updateCustomerCall.enqueue(object : Callback&lt;UpdateCustomer&gt; { override fun onResponse(call: Call&lt;UpdateCustomer&gt;?, response: Response&lt;UpdateCustomer&gt;?) { } override fun onFailure(call: Call&lt;UpdateCustomer&gt;?, t: Throwable?) { utilities!!.hideProgress(progress) } }) </code></pre> <h2>ApiClient.kt</h2> <pre><code>val MULTIPART_FORM_DATA = "multipart/form-data" fun createRequestBody(s: String): RequestBody { return RequestBody.create( MediaType.parse(MULTIPART_FORM_DATA), s) } </code></pre> <h2>ApiInterface,.kt</h2> <pre><code>@Multipart @POST("customer") fun updateCustomerDetail(@PartMap map: Map&lt;String,RequestBody &gt;): Call&lt;UpdateCustomer&gt; </code></pre> <h2>Gradle file</h2> <pre><code>implementation "com.squareup.okhttp3:okhttp:3.8.1" implementation "com.squareup.okhttp3:logging-interceptor:3.8.1" implementation ("com.squareup.retrofit2:retrofit:2.3.0"){ exclude module: 'okhttp' } implementation "com.squareup.retrofit2:converter-gson:2.3.0" </code></pre>
0debug
static void v9fs_getlock(void *opaque) { size_t offset = 7; struct stat stbuf; V9fsFidState *fidp; V9fsGetlock *glock; int32_t fid, err = 0; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; glock = g_malloc(sizeof(*glock)); pdu_unmarshal(pdu, offset, "dbqqds", &fid, &glock->type, &glock->start, &glock->length, &glock->proc_id, &glock->client_id); trace_v9fs_getlock(pdu->tag, pdu->id, fid, glock->type, glock->start, glock->length); fidp = get_fid(pdu, fid); if (fidp == NULL) { err = -ENOENT; goto out_nofid; } err = v9fs_co_fstat(pdu, fidp->fs.fd, &stbuf); if (err < 0) { goto out; } glock->type = P9_LOCK_TYPE_UNLCK; offset += pdu_marshal(pdu, offset, "bqqds", glock->type, glock->start, glock->length, glock->proc_id, &glock->client_id); err = offset; out: put_fid(pdu, fidp); out_nofid: complete_pdu(s, pdu, err); v9fs_string_free(&glock->client_id); g_free(glock); }
1threat
Does google allow businesses to use "Did you Mean" feature as an api?? I would like to use it but I am not getting anything : <p>I want to use Google API for Did you mean feature. So basically I want to write a piece of code, which sends a word to Google search and either Google finds the exact hits or gives a "DID YOU MEAN" reply which i would use. </p> <p>Is it made available? Tried finding it but couldn't find.</p>
0debug
alert('Hello ' + user_input);
1threat
I need help on script which will find particular value from one file and replace it in another file( very urgent) : I have 2 files. (file ABC and file XYZ). Few contents of ABC: X_deb: step # : 9 X_deb: in : 4'b0000 X_deb: out : 4'b1110 X_deb: load (4 , 4'b1010) X_deb: MK : 4'b1111 X_deb: step # : 10 X_deb: in : 4'b0100 X_deb: out : 4'b1001 X_deb: load (4 , 4'b1100) X_deb: step # : 11 X_deb: in : 4'b0001 X_deb: out : 4'b1100 X_deb: load (4 , 4'b1011) X_deb: MK : 4'b1110 ------------------------------ Contents of file XYZ: X_step_9 4 4'b1010 ( 4'b1110) X_step_10 4 4'b1100 (4'b1001) X_step_11 4'b1011 (4'b1100) ------------- Format syntax of file XYZ X_step_# <load value for the step from ABC file> (if MK is present for the step then mk value for the step otherwise out value for that step from ABC file. ) .. But whatever scripts I am using, it is having some issues and not able to grep MK value for the step and put it in XYZ file instead of that it is putting "out" value for all the steps. And unfortunately I deleted that script. NOTE: in ABC file, not all steps have MK value.(in above example only step 9 and 11 have MK value). Now I need to create one generic script for all the steps (in any language) which can do below things:( there are many steps, not only 9,10,11) -it will grep MK value for particular step from ABC file. -after that it will grep for that step in XYZ file (X_step_#) and replace "out" value with MK value. . For example :. Script will find MK value for step 9 from ABC and then it will search for X_step_9 in XYZ file and replace "out" value with MK value. Someone please help me on this. It is very very critical and urgent.
0debug
void HELPER(window_check)(CPUXtensaState *env, uint32_t pc, uint32_t w) { uint32_t windowbase = windowbase_bound(env->sregs[WINDOW_BASE], env); uint32_t windowstart = env->sregs[WINDOW_START]; uint32_t m, n; if ((env->sregs[PS] & (PS_WOE | PS_EXCM)) ^ PS_WOE) { return; } for (n = 1; ; ++n) { if (n > w) { return; } if (windowstart & windowstart_bit(windowbase + n, env)) { break; } } m = windowbase_bound(windowbase + n, env); rotate_window(env, n); env->sregs[PS] = (env->sregs[PS] & ~PS_OWB) | (windowbase << PS_OWB_SHIFT) | PS_EXCM; env->sregs[EPC1] = env->pc = pc; if (windowstart & windowstart_bit(m + 1, env)) { HELPER(exception)(env, EXC_WINDOW_OVERFLOW4); } else if (windowstart & windowstart_bit(m + 2, env)) { HELPER(exception)(env, EXC_WINDOW_OVERFLOW8); } else { HELPER(exception)(env, EXC_WINDOW_OVERFLOW12); } }
1threat
How to make Angular-CLI compile SCSS to CSS in assets folder : <p>I have an Angular 4 project, created with angular-cli 1.0.x. At this time, angular-cli is upgraded to 1.1.1 in my project.</p> <p>I have an assets folder and when I put a css file in it, it can be used. But when I rename the css file to scss, it is not compiled by angular-cli.</p> <p>What do I need to do to get the scss file to be compiled to css?</p> <p>This is my project's package.json:</p> <pre><code>{ "name": "my project", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "4.1.3", "@angular/common": "4.1.3", "@angular/compiler": "4.1.3", "@angular/core": "4.1.3", "@angular/forms": "4.1.3", "@angular/http": "4.1.3", "@angular/platform-browser": "4.1.3", "@angular/platform-browser-dynamic": "4.1.3", "@angular/router": "4.1.3", "@angular/upgrade": "4.1.3", "@axinpm/ang-core": "^0.2.3", "chart.js": "2.5.0", "core-js": "2.4.1", "moment": "2.18.1", "ng2-charts": "1.5.0", "ng2draggable": "^1.3.2", "ngx-bootstrap": "1.6.6", "rxjs": "5.4.0", "ts-helpers": "1.1.2", "zone.js": "0.8.11" }, "devDependencies": { "@angular/cli": "1.1.1", "@angular/compiler-cli": "4.1.3", "@types/jasmine": "2.5.47", "@types/node": "7.0.22", "codelyzer": "3.0.1", "jasmine-core": "2.6.2", "jasmine-spec-reporter": "4.1.0", "karma": "1.7.0", "karma-chrome-launcher": "2.1.1", "karma-cli": "1.0.1", "karma-jasmine": "1.1.0", "karma-jasmine-html-reporter": "0.2.2", "karma-coverage-istanbul-reporter": "1.2.1", "protractor": "5.1.2", "ts-node": "3.0.4", "tslint": "5.3.2", "typescript": "2.4.2" } } </code></pre> <p>This is my project's .angular-cli.json:</p> <pre><code>{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "project": { "version": "1.0.0-alpha.6", "name": "my project" }, "apps": [ { "root": "src", "outDir": "dist", "assets": ["assets"], "index": "index.html", "main": "main.ts", "polyfills": "polyfills.ts", "test": "test.ts", "tsconfig": "tsconfig.app.json", "testTsconfig": "tsconfig.spec.json", "prefix": "app", "styles": [ "scss/style.scss" ], "scripts": [ "../node_modules/chart.js/dist/Chart.bundle.min.js", "../node_modules/chart.js/dist/Chart.min.js" ], "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } } ], "e2e": { "protractor": { "config": "./protractor.conf.js" } }, "lint": [ { "project": "src/tsconfig.app.json" }, { "project": "src/tsconfig.spec.json" }, { "project": "e2e/tsconfig.e2e.json" } ], "test": { "karma": { "config": "./karma.conf.js" } }, "defaults": { "styleExt": "scss", "prefixInterfaces": false } } </code></pre> <p>Thanks</p>
0debug
void unregister_displaychangelistener(DisplayChangeListener *dcl) { DisplayState *ds = dcl->ds; trace_displaychangelistener_unregister(dcl, dcl->ops->dpy_name); if (dcl->con) { dcl->con->dcls--; } QLIST_REMOVE(dcl, next); gui_setup_refresh(ds); }
1threat
C# split string into 2D array : I have .txt file with 10 954 lines in the format of `6,4:10` I need to load that .txt file with `StreamReader` and split every line at `':'` into 2D array. To look like this [6,4 10] [5,2 15] [9,3 20] So i can later on count each column and place it in a particular category.
0debug
Why is the undefined function levity-polymorphic when using it with unboxed types? : <p>I just got finished reading the paper <a href="https://cs.brynmawr.edu/~rae/papers/2017/levity/levity-extended.pdf" rel="noreferrer">Levity Polymorphism</a>.</p> <p>I had a question about why <a href="https://hackage.haskell.org/package/base-4.11.1.0/docs/Prelude.html#v:undefined" rel="noreferrer"><code>undefined</code></a> can be levity-polymorphic when used as an unboxed type.</p> <p>First, let's start with some definitions of boxity from the paper:</p> <ul> <li><p><strong>boxed</strong>:</p> <ul> <li><p>A <strong>boxed</strong> value is represented by a pointer into the heap.</p></li> <li><p><code>Int</code> and <code>Bool</code> are examples of types that have <strong>boxed</strong> values.</p></li> </ul></li> <li><p><strong>unboxed</strong>:</p> <ul> <li><p>An <strong>unboxed</strong> value is represented by the value itself (<em>not</em> a pointer to the heap).</p></li> <li><p><a href="https://hackage.haskell.org/package/ghc-prim-0.5.2.0/docs/GHC-Prim.html#g:3" rel="noreferrer"><code>Int#</code></a> and <a href="https://hackage.haskell.org/package/ghc-prim-0.5.2.0/docs/GHC-Prim.html#g:2" rel="noreferrer"><code>Char#</code></a> from the <a href="https://hackage.haskell.org/package/ghc-prim-0.5.2.0/docs/GHC-Prim.html" rel="noreferrer"><code>GHC.Prim</code></a> module are examples of types with <strong>unboxed</strong> values.</p></li> <li><p>An <strong>unboxed</strong> value cannot be a thunk. Function arguments of unboxed types must be passed by value.</p></li> </ul></li> </ul> <p>The paper follows with some definitions of levity:</p> <ul> <li><p><strong>lifted</strong>:</p> <ul> <li><p>A <strong>lifted</strong> type is one that is lazy.</p></li> <li><p>A <strong>lifted</strong> type has on extra element beyond the normal ones, representing a non-terminating computation.</p></li> <li><p>For example, the type <code>Bool</code> is <strong>lifted</strong>, meaning that there are three different values for <code>Bool</code>: <code>True</code>, <code>False</code>, and <code>⊥</code> (bottom).</p></li> <li><p>All <strong>lifted</strong> types MUST be <strong>boxed</strong>.</p></li> </ul></li> <li><p><strong>unlifted</strong></p> <ul> <li><p>An <strong>unlifted</strong> type is one that is strict.</p></li> <li><p>The element <code>⊥</code> does not exist in an <strong>unlifted</strong> type.</p></li> <li><p><code>Int#</code> and <code>Char#</code> are examples of <strong>unlifted</strong> types.</p></li> </ul></li> </ul> <p>The paper goes on to explain how GHC 8 provides functionality allowing type variables to have polymorphic levity.</p> <p>This allows you to write a levity-polymorphic <a href="https://hackage.haskell.org/package/base-4.11.1.0/docs/Prelude.html#v:undefined" rel="noreferrer"><code>undefined</code></a> with the following type:</p> <pre><code>undefined :: forall (r :: RuntimeRep). forall (a :: TYPE r). a </code></pre> <p>This says that <code>undefined</code> should work for <em>any</em> <code>RuntimeRep</code>, even unlifted types.</p> <p>Here is an example of using <code>undefined</code> as an unboxed, unlifted <code>Int#</code> in GHCi:</p> <pre><code>&gt; :set -XMagicHash &gt; import GHC.Prim &gt; import GHC.Exts &gt; I# (undefined :: Int#) *** Exception: Prelude.undefined </code></pre> <hr> <p>I've always thought of <code>undefined</code> as being the same as <code>⊥</code> (bottom). However, the paper says, "The element <code>⊥</code> does not exist in an unlifted type."</p> <p>What is going on here? Is <code>undefined</code> not actually <code>⊥</code> when used as an unlifted type? Am I misunderstanding something about the paper (or boxity or levity)?</p>
0debug
I need help understanding the code for reversing an of string : I do need help understanding a code of reversing the array of string I have been looking through few codes, and just trying to understand it. it is function using pointer void ReverseString(char *pStr){ int length = 0; int i = 0; while(pStr[i]!='\0') { length++; i++; } for (int i = 0; i < length / 2; i++) { char temp = pStr[length - i - 1] ; pStr[length - i - 1] = pStr[i]; pStr[i] = temp; } } expecting to reverse a string, have a main function different
0debug
Gulp: how to delete a folder? : <p>I use del package to delete folder:</p> <pre><code>gulp.task('clean', function(){ return del('dist/**/*', {force:true}); }); </code></pre> <p>But if there are many subdirectory in dist folder and I want to delete dist folder and all its files, is there any easy way to do it?</p> <p>Ps: I don't want to do in this way: <code>dist/**/**/**/**/**/**/...</code> when there are so many subdirectories.</p>
0debug
what this function do: void (*pfunc[3])(); : I have this code line in my code. what the function do? uint32_t Var1 = 1, Var2 = 2, Var3 = 3; void (*pfunc[3])(); pfunc[0] = Var1; pfunc[1] = Var2; pfunc[2] = Var3;
0debug
int ff_init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, const void *bits, int bits_wrap, int bits_size, const void *codes, int codes_wrap, int codes_size, const void *symbols, int symbols_wrap, int symbols_size, int flags) { VLCcode *buf; int i, j, ret; vlc->bits = nb_bits; if(flags & INIT_VLC_USE_NEW_STATIC){ VLC dyn_vlc = *vlc; if (vlc->table_size) return 0; ret = ff_init_vlc_sparse(&dyn_vlc, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, symbols, symbols_wrap, symbols_size, flags & ~INIT_VLC_USE_NEW_STATIC); av_assert0(ret >= 0); av_assert0(dyn_vlc.table_size <= vlc->table_allocated); if(dyn_vlc.table_size < vlc->table_allocated) av_log(NULL, AV_LOG_ERROR, "needed %d had %d\n", dyn_vlc.table_size, vlc->table_allocated); memcpy(vlc->table, dyn_vlc.table, dyn_vlc.table_size * sizeof(*vlc->table)); vlc->table_size = dyn_vlc.table_size; ff_free_vlc(&dyn_vlc); return 0; }else { vlc->table = NULL; vlc->table_allocated = 0; vlc->table_size = 0; } av_dlog(NULL, "build table nb_codes=%d\n", nb_codes); buf = av_malloc((nb_codes+1)*sizeof(VLCcode)); av_assert0(symbols_size <= 2 || !symbols); j = 0; #define COPY(condition)\ for (i = 0; i < nb_codes; i++) {\ GET_DATA(buf[j].bits, bits, i, bits_wrap, bits_size);\ if (!(condition))\ continue;\ if (buf[j].bits > 3*nb_bits || buf[j].bits>32) {\ av_log(NULL, AV_LOG_ERROR, "Too long VLC in init_vlc\n");\ return -1;\ }\ GET_DATA(buf[j].code, codes, i, codes_wrap, codes_size);\ if (buf[j].code >= (1LL<<buf[j].bits)) {\ av_log(NULL, AV_LOG_ERROR, "Invalid code in init_vlc\n");\ return -1;\ }\ if (flags & INIT_VLC_LE)\ buf[j].code = bitswap_32(buf[j].code);\ else\ buf[j].code <<= 32 - buf[j].bits;\ if (symbols)\ GET_DATA(buf[j].symbol, symbols, i, symbols_wrap, symbols_size)\ else\ buf[j].symbol = i;\ j++;\ } COPY(buf[j].bits > nb_bits); qsort(buf, j, sizeof(VLCcode), compare_vlcspec); COPY(buf[j].bits && buf[j].bits <= nb_bits); nb_codes = j; ret = build_table(vlc, nb_bits, nb_codes, buf, flags); av_free(buf); if (ret < 0) { av_freep(&vlc->table); return -1; } return 0; }
1threat
Can i use PHPMailer 5.0 version with PHP 7.0 : <p>Currently i am using PHPmailer 5.0 version and PHP Version 5.3 but now i am moving to PHP 7.0. </p> <p>Can i use phpmailer 5.0 with php 7.0 </p> <p>I need to upgrade to php 7.0 version </p>
0debug
Java - Creating a method that will set values on a object, return the object or set using the passed param? : I am creating a method in my Java project which simply set values of an object. Common approaches are returning the object being set and the other one is setting the object which was passed in the parameter. Can you give me advantages and disadvantages of both scenario(even its memory consumption or performance or even the minor differences or when to use them), both works but maybe there are key points that I missed. Thanks! Return the object being set. public Car setCarDetails(){ Car car = new Car(); car.setName("Tesla Model S"); car.setBrand("Tesla"); car.setPrice(45000); return car; } Set using the object passed in the parameter public void setCarDetails(Car car){ car.setName("Tesla Model S"); car.setBrand("Tesla"); car.setPrice(45000); }
0debug
Connot find runtime 'node' on PATH. Vscode Python : <p>I installed visual studio code to practice python.</p> <p>After I played around with settings now I cannot debug anything. Getting the error:</p> <p><a href="https://i.stack.imgur.com/VKQz5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VKQz5.png" alt="enter image description here"></a></p> <p>I deleted everything from setting already. I also tried to reinstall vscode. </p> <p>But nothing helps. </p> <p>What else should I do?</p>
0debug
shell script count lines and sum numbers from multiple files : I want to count the number of lines, I need this result be a number, and sum the last numeric column, I had done to make this one at time, but I need to make this for a crontab, so, it has to be an script, here is my lines: It counts the number of lines: egrep -i String file_name_201611* | egrep -i "cdr,20161115" | awk -F"," '{print $4}' | sort | uniq | wc -l This sum the number of last column: egrep -i String file_name_201611* | egrep -i ".cdr,20161115"| awk -F"," '{print $8}' | paste -s -d"+" |bc
0debug
OrderedDict Isn't Ordered? : <p>I'm trying to use an <code>OrderedDict</code>, but it keeps being created out of order. For example,</p> <pre><code>from collections import OrderedDict OrderedDict(a=1,b=2,c=3) </code></pre> <p>yields </p> <pre><code>OrderedDict([('a', 1), ('c', 3), ('b', 2)]) </code></pre> <p>rather than the expected</p> <pre><code>OrderedDict([('a', 1), ('b', 2), ('c', 3)]) </code></pre> <p>How can I make sure it's created in the proper order I intend?</p>
0debug
How to fill color in a rectangle percentage wise? : <p>Hi how to paint a rectangle partially filled with color ? I need to fill this according to the percentage of value generated by program. I am using swing for my Java GUI <a href="https://i.stack.imgur.com/iyLz5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iyLz5.jpg" alt="enter image description here"></a></p>
0debug