problem
stringlengths
26
131k
labels
class label
2 classes
Amazon s3 static web hosting caching : <p>I'm using Amazon S3 webhosting for my static html,js,css (etc..) files. After replacing my index.html file, I still get the old version when consuming via the browser. I would like to set a default ttl <strong>to the bucket</strong> (and not to specific objects in it). I found this link: <a href="http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesDefaultTTL" rel="noreferrer">http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesDefaultTTL</a></p> <p>but can't find the "Object Caching" setting in the dashboard. can someone point out where it is? </p>
0debug
Getting Dynamic Constants in laravel : I am having one table named as <b>Settings</b> and fields are <b>id</b>,<b>constant_name</b>,<b>constant_value</b>,<b>Timestampsfield</b> and values are<br> constant_name &nbsp; constant_value<br> <b>sitename</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b>My sitename</b> <br> How can i retrive and print in my site
0debug
How to customize default auth login form in Django? : <p>How do you customize the default login form in Django?</p> <pre><code># demo_project/urls.py from django.contrib import admin from django.urls import include, path urlpatterns = [ path('', include('pages.urls')), path('users/', include('users.urls')), # new path('users/', include('django.contrib.auth.urls')), # new path('admin/', admin.site.urls), ] &lt;!-- templates/registration/login.html --&gt; &lt;h2&gt;Login&lt;/h2&gt; &lt;form method="post"&gt; {% csrf_token %} {{ form.as_p }} &lt;button type="submit"&gt;Login&lt;/button&gt; &lt;/form&gt; </code></pre> <p>Above code works but I need to customize that {{form.as_p}} Where is that form or can it be override? Thanks for the help.</p>
0debug
Laravel unit tests - changing a config value depending on test method : <p>I have an application with a system to verify accounts (register -> get email with link to activate -> account verified). That verification flow is optional and can be switched off with a configuration value:</p> <pre><code>// config/auth.php return [ // ... 'enable_verification' =&gt; true ]; </code></pre> <p>I want to test the registration controller: </p> <ul> <li>it should redirect to home page in both cases</li> <li>when verification is ON, home page should show message 'email sent'</li> <li>when verification is OFF, home page should show message 'account created'</li> <li>etc.</li> </ul> <p>My test methods:</p> <pre><code>public function test_UserProperlyCreated_WithVerificationDisabled() { $this-&gt;app['config']-&gt;set('auth.verification.enabled', false); $this -&gt;visit(route('frontend.auth.register.form')) -&gt;type('Test', 'name') -&gt;type('test@example.com', 'email') -&gt;type('123123', 'password') -&gt;type('123123', 'password_confirmation') -&gt;press('Register'); $this -&gt;seePageIs('/') -&gt;see(trans('auth.registration.complete')); } public function test_UserProperlyCreated_WithVerificationEnabled() { $this-&gt;app['config']-&gt;set('auth.verification.enabled', true); $this -&gt;visit(route('frontend.auth.register.form')) -&gt;type('Test', 'name') -&gt;type('test@example.com', 'email') -&gt;type('123123', 'password') -&gt;type('123123', 'password_confirmation') -&gt;press('Register'); $this -&gt;seePageIs('/') -&gt;see(trans('auth.registration.needs_verification')); } </code></pre> <p>When debugging, I noticed that the configuration value when inside the controller method is always set to the value in the config file, no matter what I set with my <code>$this-&gt;app['config']-&gt;set...</code></p> <p>I have other tests on the user repository itself to check that it works both when validation is ON or OFF. And there the tests behave as expected.</p> <p><strong>Any idea why it fails for controllers and how to fix that?</strong></p>
0debug
void OPPROTO op_addco (void) { do_addco(); RETURN(); }
1threat
How to find consecutive letters in a string in Python 3? : guys. I want to count the number of consecutive letters that arrive in a string. For example, my string input is EOOOEOEE I would only like to find the number of consecutive O's in the string. The Output should be: 1 Since, there is only one set of O's that come consecutively. Any suggestion would be very helpful.
0debug
static void s390_cpu_full_reset(CPUState *s) { S390CPU *cpu = S390_CPU(s); S390CPUClass *scc = S390_CPU_GET_CLASS(cpu); CPUS390XState *env = &cpu->env; int i; scc->parent_reset(s); cpu->env.sigp_order = 0; s390_cpu_set_state(CPU_STATE_STOPPED, cpu); memset(env, 0, offsetof(CPUS390XState, end_reset_fields)); env->cregs[0] = CR0_RESET; env->cregs[14] = CR14_RESET; env->gbea = 1; env->pfault_token = -1UL; env->ext_index = -1; for (i = 0; i < ARRAY_SIZE(env->io_index); i++) { env->io_index[i] = -1; } env->mchk_index = -1; set_float_detect_tininess(float_tininess_before_rounding, &env->fpu_status); if (kvm_enabled()) { kvm_s390_reset_vcpu(cpu); } }
1threat
How can I use java Integer.Intparse()? : I was trying to change like String A00001 to int 1 in this code.but Eclipse told me that --- Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "00001 " at java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at LibraryManager.BookAdd.getInsertOrderedList(BookAdd.java:105) while(rs1.next()){ allid[i]=rs1.getString("id"); String mystr=allid[i].substring(1); try{ System.out.println(mystr);//this print 00001 intofid[i]=Integer.parseInt(mystr); }catch(Exception e){ e.printStackTrace(); } i++; } <!-- end snippet --> how could I resolved this??
0debug
How to convert string to mm/dd/yyyy format in vb.net : How do i change string like "15:33:56 Thursday 17th, November 2016" to mm/dd/yyyy date format vb.net. Have already tried to use the inbuilt vb.net date function cdate
0debug
How to call Destructor : <p>I know destructor are called by Garbage Collector when object is no longer used. But I want to know </p> <blockquote> <p>How to call destructor through c# code?</p> </blockquote> <p><strong>If possible please give some basic example for understanding.</strong></p>
0debug
Why can't i just define a non-const gloabal variable in header? and if i use namespaces why do i have to declare it 'extern'? : 1) I know a non-const variable is external linkage by default (it's like it's been declared as external more or less) but i dont understand why cant i define a global variable such as `int glbl_a` in header //test.h int glbl_a=0; //wrong -> "multiple definition of `glbl_a`" static int st_glbl_a=1; //ok to initialize it in header! extern int ext_glbl_a; //ok to declare it and define it in test.cpp --------- //test.cpp #include "test.h" using namespace std; //st_glbl_a=22; i could use st_glbl_a but it wouldn't affect st_glbl_a in main cause of 'static' int ext_glbl_a=2; //definition of external gloabal non-const variable ----------------- //main.cpp #include <iostream> #include "test.h" using namespace std; extern int glbl_a; //declaration of glbl_a external int main(){ cout<<glbl_a; } the working version for this program is the one in which i define `int glbl_a=0;` in test.cpp only and declare `extern int glbl_a;` in main before using it in output (definition in test.h is just commented, that is there's nothing about `glbl_a`). 2)the working version doesn't work anymore if i group all definitions/declaretions into a namespace spread onto test.cpp and test.h (`MyNamespace`) cause of `int glbl_a` in test.cpp: //test.h namespace MyNamespace{ //extern int glbl_a; } --------- //test.cpp #include "test.h" using namespace std; namespace MyNamespace{ int glbl_a=0; } ----------------- //main.cpp #include <iostream> #include "test.h" using namespace std; int main(){ cout<<MyNamespace::glbl_a; //wrong -> "'glbl_a' is not a member of 'MyNaspace'" } it would work only if i de-comment declaration in test.h, but why?
0debug
if..else..if..else code not working properly(coding in C) : <p>I have a question.I think I may have a mistake in my code because my code program(Dev C++) seems not to recognize the "else if" statement.</p> <p>Here is the code:</p> <pre><code>#include &lt;stdio.h&gt; int main() { int a = 80; if(a == 10); printf("value of a is 10\n"); else if(a == 20); printf("value of a is 20\n"); else if(a == 30); printf("value of a is 30\n"); else printf("none of the values match"); printf("the real value of a is: &amp;d", a); system("PAUSE"); return 0; } </code></pre>
0debug
How to insert data from other tables when the destination table has primary keys : I need help creating a table the can track a 2% yearly price increase over the years 2010-2016.[My create statement is as follows][1] [1]: http://i.stack.imgur.com/M5hCu.png I have 24 products and the starting price in my Products table that need insert into my new table. In theory I should have 192 records. I need help populating the year column so that it can cycle though 2010-2016 for each product. I also need help referencing the pervious year price for the next years calculation.
0debug
static int nprobe(AVFormatContext *s, uint8_t *enc_header, const uint8_t *n_val) { OMAContext *oc = s->priv_data; uint32_t pos, taglen, datalen; struct AVDES av_des; if (!enc_header || !n_val) return -1; pos = OMA_ENC_HEADER_SIZE + oc->k_size; if (!memcmp(&enc_header[pos], "EKB ", 4)) pos += 32; if (AV_RB32(&enc_header[pos]) != oc->rid) av_log(s, AV_LOG_DEBUG, "Mismatching RID\n"); taglen = AV_RB32(&enc_header[pos+32]); datalen = AV_RB32(&enc_header[pos+36]) >> 4; pos += 44 + taglen; av_des_init(&av_des, n_val, 192, 1); while (datalen-- > 0) { av_des_crypt(&av_des, oc->r_val, &enc_header[pos], 2, NULL, 1); kset(s, oc->r_val, NULL, 16); if (!rprobe(s, enc_header, oc->r_val)) return 0; pos += 16; } return -1; }
1threat
What is the difference between using a class and not using a class in Python : <p>So I'm working on a personal Python project as of right now and I would research a certain question I had. However, lots of the code samples looked like this:</p> <pre><code>x = 0 class foo(object): def bar(self): global x x += 1 self.y = x if __name__ == '__main__': newClass = foo() newClass.bar() print(newClass.y) </code></pre> <p>Just a loose example. Is there any advantage of doing that over this:</p> <pre><code>x = 0 y = 0 def bar(): global x global y x += 1 y = x bar() print(y) </code></pre> <p>Is the class quicker and more efficient or is it just a matter of personal preference? I tend to use the one shown above, without the class, but should I use the class instead?</p>
0debug
Extend slice length on the left : <p>I just started going through gotour, and encountered a question regarding slice defaults chapter.</p> <pre><code>package main import "fmt" func main() { s := []int{2, 3, 5, 7, 11, 13} s = s[1:4] fmt.Println(s) // [3 5 7] fmt.Println(len(s)) // 3 s = s[:4] fmt.Println(s) // [3 5 7 11] fmt.Println(len(s)) // 4 } </code></pre> <p>I can extend the length of slice on the right by picking an index greater than or equal to previous slice length. e.g. <code>s[:4]</code> so I can reach entry <code>11</code>. But when I use<code>s[-1:]</code> to extend on the left and reach entry <code>2</code>, compiler gives me error <code>invalid slice index -1 (index must be non-negative)</code>. Is it possible to extend the slice length on the left to reach entry <code>2</code> after <code>s=s[1:4]</code> executed?</p>
0debug
Multiple data-toggle not working correctly : I have the following page: http://mindspyder.com/newline/my-account.html And the following code on that page: <!-- begin snippet: js hide: false --> <!-- language: lang-html --> <!-- Nav tabs --> <ul class="nav nav-tabs" role="tablist"> <li class="nav-item"> <a class="btn btn-primary btn-sm" href="#" role="button"><i class="fa fa-search-plus"></i> View</a> </li> <li class="nav-item"> <span data-toggle="modal" data-target="#myModal"><a class="btn btn-primary btn-sm" href="#delete" role="tab" data-toggle="tab"><i class="fa fa-times"></i> Delete</a></span></li> <li class="nav-item"> <a class="btn btn-primary btn-sm" href="#download" role="tab" data-toggle="tab">Settings</a> </li> </ul> <!-- /Nav tabs --> <!-- Tab panes --> <div class="tab-content"> <div role="tabpanel" class="tab-pane active" id="review"></div> <div role="tabpanel" class="tab-pane" id="edit"></div> <div role="tabpanel" class="tab-pane" id="delete">hello</div> <div role="tabpanel" class="tab-pane" id="download"> <p> <form> <p> <label> <input type="checkbox" name="CheckboxGroup1" value="Invoice" id="CheckboxGroup1_0"> Invoice</label> <br> <label> <input type="checkbox" name="CheckboxGroup1" value="Establishment Kit" id="CheckboxGroup1_1"> Establishment Kit</label> <br> <label> <input type="checkbox" name="CheckboxGroup1" value="Declaration of Custody Trust" id="CheckboxGroup1_2"> Declaration of Custody Trust</label> <br> <label> <input type="checkbox" name="CheckboxGroup1" value="Trustee Minutes" id="CheckboxGroup1_3"> Trustee Minutes</label> <br> <label> <input type="checkbox" name="CheckboxGroup1" value="Compliance Letter" id="CheckboxGroup1_4"> Compliance Letter</label> <br> </p> </form> </p> <p> <button type="button" class="btn btn-success btn-sm">Download Selected <i class="fa fa-arrow-down"></i></button> </p> </div> </div> <!-- /Tab panes --> <!-- end snippet --> Now, if you go to the page and click the blue Delete button, everything works perfectly. Now if you click Cancel, and click on one of the other tabs, it still works as it should. The problem is you click Delete again, it doesn't switch back to the Delete tab when opening the modal, but leaves it on the previous tab. What am I doing wrong?
0debug
How to divide many columns? : <p>I have a data frame that look like </p> <pre><code>V1 V2 V3 V4 V5 V6 V7 V8 0 Tri1 D D D D D D D D D D D D 0 Tri2 D D D D D D D D D D D D 0 Tri3 D D D D D D D D D D D D 0 Tri4 D D D D D D D D D D D D 0 Tri5 D D D D D D D D D D D D </code></pre> <p>And I want to divide column V3-V8</p> <pre><code>V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12V13V14 0 Tri1 D D D D D D D D D D D D 0 Tri2 D D D D D D D D D D D D 0 Tri3 D D D D D D D D D D D D 0 Tri4 D D D D D D D D D D D D 0 Tri5 D D D D D D D D D D D D </code></pre> <p>How may I do it?</p>
0debug
bool migration_is_blocked(Error **errp) { if (qemu_savevm_state_blocked(errp)) { return true; } if (migration_blockers) { *errp = error_copy(migration_blockers->data); return true; } return false; }
1threat
static void vnc_listen_read(void *opaque, bool websocket) { VncDisplay *vs = opaque; struct sockaddr_in addr; socklen_t addrlen = sizeof(addr); int csock; graphic_hw_update(vs->dcl.con); #ifdef CONFIG_VNC_WS if (websocket) { csock = qemu_accept(vs->lwebsock, (struct sockaddr *)&addr, &addrlen); } else #endif { csock = qemu_accept(vs->lsock, (struct sockaddr *)&addr, &addrlen); } if (csock != -1) { socket_set_nodelay(csock); vnc_connect(vs, csock, false, websocket); } }
1threat
Not sure how to flip these lines to form a diamond in python 3 : The idea of this code is to enter a height and form a diamond with asterisks(stars). eg. If the input for the height was 6, I'd want the code to produce: ************ ***** ***** **** **** *** *** ** ** * * ** ** *** *** **** **** ***** ***** ************ I've gotten the top half so far and am wondering if it is possible to 'flip' lines horizontally to get the bottom half. height = int(input('Enter triangle height: ')) star = height while star >= 1: a = int(star)*'*' b = int(2*height-2*star)*' ' c = (height-star)*'' d = star*'*' print(a, b,c,d,sep='') star = star - 1 star = height while star >= 2: a = int(star) b = int(2*height-2*star) c = int((height-star)) d = int(star) print(a*'*', b*' ',c*'',d*'*',sep='') star = star - 1`
0debug
static void gen_dmtc0 (DisasContext *ctx, int reg, int sel) { const char *rn = "invalid"; switch (reg) { case 0: switch (sel) { case 0: gen_op_mtc0_index(); rn = "Index"; break; case 1: rn = "MVPControl"; case 2: rn = "MVPConf0"; case 3: rn = "MVPConf1"; default: goto die; } break; case 1: switch (sel) { case 0: rn = "Random"; break; case 1: rn = "VPEControl"; case 2: rn = "VPEConf0"; case 3: rn = "VPEConf1"; case 4: rn = "YQMask"; case 5: rn = "VPESchedule"; case 6: rn = "VPEScheFBack"; case 7: rn = "VPEOpt"; default: goto die; } break; case 2: switch (sel) { case 0: gen_op_dmtc0_entrylo0(); rn = "EntryLo0"; break; case 1: rn = "TCStatus"; case 2: rn = "TCBind"; case 3: rn = "TCRestart"; case 4: rn = "TCHalt"; case 5: rn = "TCContext"; case 6: rn = "TCSchedule"; case 7: rn = "TCScheFBack"; default: goto die; } break; case 3: switch (sel) { case 0: gen_op_dmtc0_entrylo1(); rn = "EntryLo1"; break; default: goto die; } break; case 4: switch (sel) { case 0: gen_op_dmtc0_context(); rn = "Context"; break; case 1: rn = "ContextConfig"; default: goto die; } break; case 5: switch (sel) { case 0: gen_op_mtc0_pagemask(); rn = "PageMask"; break; case 1: gen_op_mtc0_pagegrain(); rn = "PageGrain"; break; default: goto die; } break; case 6: switch (sel) { case 0: gen_op_mtc0_wired(); rn = "Wired"; break; case 1: rn = "SRSConf0"; case 2: rn = "SRSConf1"; case 3: rn = "SRSConf2"; case 4: rn = "SRSConf3"; case 5: rn = "SRSConf4"; default: goto die; } break; case 7: switch (sel) { case 0: gen_op_mtc0_hwrena(); rn = "HWREna"; break; default: goto die; } break; case 8: rn = "BadVaddr"; break; case 9: switch (sel) { case 0: gen_op_mtc0_count(); rn = "Count"; break; default: goto die; } ctx->bstate = BS_STOP; break; case 10: switch (sel) { case 0: gen_op_mtc0_entryhi(); rn = "EntryHi"; break; default: goto die; } break; case 11: switch (sel) { case 0: gen_op_mtc0_compare(); rn = "Compare"; break; default: goto die; } ctx->bstate = BS_STOP; break; case 12: switch (sel) { case 0: gen_op_mtc0_status(); rn = "Status"; break; case 1: gen_op_mtc0_intctl(); rn = "IntCtl"; break; case 2: gen_op_mtc0_srsctl(); rn = "SRSCtl"; break; case 3: gen_op_mtc0_srsmap(); rn = "SRSMap"; break; default: goto die; } ctx->bstate = BS_STOP; break; case 13: switch (sel) { case 0: gen_op_mtc0_cause(); rn = "Cause"; break; default: goto die; } ctx->bstate = BS_STOP; break; case 14: switch (sel) { case 0: gen_op_dmtc0_epc(); rn = "EPC"; break; default: goto die; } break; case 15: switch (sel) { case 0: rn = "PRid"; break; case 1: gen_op_dmtc0_ebase(); rn = "EBase"; break; default: goto die; } break; case 16: switch (sel) { case 0: gen_op_mtc0_config0(); rn = "Config"; break; case 1: rn = "Config1"; break; case 2: gen_op_mtc0_config2(); rn = "Config2"; break; case 3: rn = "Config3"; break; default: rn = "Invalid config selector"; goto die; } ctx->bstate = BS_STOP; break; case 17: switch (sel) { case 0: rn = "LLAddr"; break; default: goto die; } break; case 18: switch (sel) { case 0: gen_op_dmtc0_watchlo0(); rn = "WatchLo"; break; case 1: rn = "WatchLo1"; case 2: rn = "WatchLo2"; case 3: rn = "WatchLo3"; case 4: rn = "WatchLo4"; case 5: rn = "WatchLo5"; case 6: rn = "WatchLo6"; case 7: rn = "WatchLo7"; default: goto die; } break; case 19: switch (sel) { case 0: gen_op_mtc0_watchhi0(); rn = "WatchHi"; break; case 1: rn = "WatchHi1"; case 2: rn = "WatchHi2"; case 3: rn = "WatchHi3"; case 4: rn = "WatchHi4"; case 5: rn = "WatchHi5"; case 6: rn = "WatchHi6"; case 7: rn = "WatchHi7"; default: goto die; } break; case 20: switch (sel) { case 0: gen_op_dmtc0_xcontext(); rn = "XContext"; break; default: goto die; } break; case 21: switch (sel) { case 0: gen_op_mtc0_framemask(); rn = "Framemask"; break; default: goto die; } break; case 22: rn = "Diagnostic"; break; case 23: switch (sel) { case 0: gen_op_mtc0_debug(); rn = "Debug"; break; case 1: rn = "TraceControl"; case 2: rn = "TraceControl2"; case 3: rn = "UserTraceData"; case 4: rn = "TraceBPC"; default: goto die; } ctx->bstate = BS_STOP; break; case 24: switch (sel) { case 0: gen_op_dmtc0_depc(); rn = "DEPC"; break; default: goto die; } break; case 25: switch (sel) { case 0: gen_op_mtc0_performance0(); rn = "Performance0"; break; case 1: rn = "Performance1"; case 2: rn = "Performance2"; case 3: rn = "Performance3"; case 4: rn = "Performance4"; case 5: rn = "Performance5"; case 6: rn = "Performance6"; case 7: rn = "Performance7"; default: goto die; } break; case 26: rn = "ECC"; break; case 27: switch (sel) { case 0 ... 3: rn = "CacheErr"; break; default: goto die; } break; case 28: switch (sel) { case 0: case 2: case 4: case 6: gen_op_mtc0_taglo(); rn = "TagLo"; break; case 1: case 3: case 5: case 7: gen_op_mtc0_datalo(); rn = "DataLo"; break; default: goto die; } break; case 29: switch (sel) { case 0: case 2: case 4: case 6: gen_op_mtc0_taghi(); rn = "TagHi"; break; case 1: case 3: case 5: case 7: gen_op_mtc0_datahi(); rn = "DataHi"; break; default: rn = "invalid sel"; goto die; } break; case 30: switch (sel) { case 0: gen_op_dmtc0_errorepc(); rn = "ErrorEPC"; break; default: goto die; } break; case 31: switch (sel) { case 0: gen_op_mtc0_desave(); rn = "DESAVE"; break; default: goto die; } ctx->bstate = BS_STOP; break; default: goto die; } #if defined MIPS_DEBUG_DISAS if (loglevel & CPU_LOG_TB_IN_ASM) { fprintf(logfile, "dmtc0 %s (reg %d sel %d)\n", rn, reg, sel); } #endif return; die: #if defined MIPS_DEBUG_DISAS if (loglevel & CPU_LOG_TB_IN_ASM) { fprintf(logfile, "dmtc0 %s (reg %d sel %d)\n", rn, reg, sel); } #endif generate_exception(ctx, EXCP_RI); }
1threat
static av_cold int pam_encode_init(AVCodecContext *avctx) { avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; avctx->coded_frame->key_frame = 1; return 0; }
1threat
Eclipse jre 1.5 > 1.8 : <p>Can anybody convert these lines from jre 1.5 to 1.8?</p> <p>Even tho if i put my eclipse project version to 1.5 my jar breaks.</p> <pre><code> Map&lt;String, byte[]&gt; resources = new HashMap&lt;&gt;(); Enumeration&lt;JarEntry&gt; enumeration = jar.entries(); Class&lt;?&gt; clazz = loader.loadClass("com.kit.Application"); Method main = clazz.getMethod("main", String[].class); if (main != null) { main.invoke(null, (Object) new String[]{}); Class&lt;?&gt; applicationClass = applicationObject.getClass(); Method setDockIconImage = applicationClass.getDeclaredMethod("setDockIconImage", new Class[]{Image.class}); setDockIconImage.invoke(applicationObject, (Object) ICON_IMAGE);` </code></pre>
0debug
I'm android Problems to convert a full name of a android.widget.EditText@410e5a58 edittextview : <p>I'm android Problems to convert a full name of a android.widget.EditText@410e5a58 edittextview is the string representation of your EditText object (ie , calling the toString your EditText object will return this string) I know it's simple but , as I followed here Tips site and not getting hit.</p> <p>coding page1 send to page2</p> <pre><code>TextView codigo1 = (TextView)findViewById(R.id.textView1); TextView codigo2 = (TextView)findViewById(R.id.textView2); Intent intent = new Intent(this, MainActivity.class); intent.putExtra("codigo1",""+codigo1 ); intent.putExtra("codigo2",""+codigo2 ); startActivity(intent); </code></pre> <p>XML page1</p> <pre><code>&lt;EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputType="number" &gt; &lt;TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Código Monitorado:" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; </code></pre> <p>coding page2 recive </p> <pre><code> setContentView(R.layout.main); String codigo1 = getIntent().getStringExtra("codigo1"); String codigo2 = getIntent().getStringExtra("codigo2"); TextView codMonitorTV = (TextView)findViewById(R.id.textViewCod1); TextView codMonitoradoTV = (TextView)findViewById(R.id.textViewCod2); codMonitorTV.setText(codigomonitor); codMonitoradoTV.setText(codigomonitorado); </code></pre> <p>XML page2</p> <pre><code>&lt;TextView android:id="@+id/textViewCodMonitor" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_toRightOf="@+id/retrieve_location_button" android:textAppearance="?android:attr/textAppearanceSmall" /&gt; &lt;TextView android:id="@+id/textViewCodMonitorado" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/textViewCodMonitor" android:layout_toRightOf="@+id/retrieve_location_button" android:textAppearance="?android:attr/textAppearanceSmall" /&gt; </code></pre> <p>I type in 1234 and get android.widget.EditText@410e5a58</p>
0debug
static int film_read_packet(AVFormatContext *s, AVPacket *pkt) { FilmDemuxContext *film = s->priv_data; AVIOContext *pb = s->pb; film_sample *sample; int ret = 0; int i; int left, right; if (film->current_sample >= film->sample_count) return AVERROR(EIO); sample = &film->sample_table[film->current_sample]; avio_seek(pb, sample->sample_offset, SEEK_SET); if ((sample->stream == film->video_stream_index) && (film->video_type == AV_CODEC_ID_CINEPAK)) { pkt->pos= avio_tell(pb); if (av_new_packet(pkt, sample->sample_size)) return AVERROR(ENOMEM); avio_read(pb, pkt->data, sample->sample_size); } else if ((sample->stream == film->audio_stream_index) && (film->audio_channels == 2) && (film->audio_type != AV_CODEC_ID_ADPCM_ADX)) { if (av_new_packet(pkt, sample->sample_size)) return AVERROR(ENOMEM); if (sample->sample_size > film->stereo_buffer_size) { av_free(film->stereo_buffer); film->stereo_buffer_size = sample->sample_size; film->stereo_buffer = av_malloc(film->stereo_buffer_size); if (!film->stereo_buffer) { film->stereo_buffer_size = 0; return AVERROR(ENOMEM); } } pkt->pos= avio_tell(pb); ret = avio_read(pb, film->stereo_buffer, sample->sample_size); if (ret != sample->sample_size) ret = AVERROR(EIO); left = 0; right = sample->sample_size / 2; for (i = 0; i < sample->sample_size; ) { if (film->audio_bits == 8) { pkt->data[i++] = film->stereo_buffer[left++]; pkt->data[i++] = film->stereo_buffer[right++]; } else { pkt->data[i++] = film->stereo_buffer[left++]; pkt->data[i++] = film->stereo_buffer[left++]; pkt->data[i++] = film->stereo_buffer[right++]; pkt->data[i++] = film->stereo_buffer[right++]; } } } else { ret= av_get_packet(pb, pkt, sample->sample_size); if (ret != sample->sample_size) ret = AVERROR(EIO); } pkt->stream_index = sample->stream; pkt->pts = sample->pts; film->current_sample++; return ret; }
1threat
Where do I find the source for the "script" command in linux : <p>Where do I find the source for the "script" command. I would like to change it from relative time between lines to relative time from start of script?</p> <p>ie, man script SCRIPT(1) BSD General Commands Manual SCRIPT(1) NAME script - make typescript of terminal session SYNOPSIS script [-a] [-c COMMAND] [-f] [-q] [-t] [file]</p>
0debug
Vue combine event handlers : <p>I have the following Vue event handlers with contenteditable:</p> <pre><code>&lt;div contentEditable="true" v-on:keyup="changed($event, current, 0)" v-on:paste="changed($event, current, 0)" v-on:blur="changed($event, current, 0)" v-on:delete="changed($event, current, 0)" v-on:focused="changed($event, current, 0)"&gt;&lt;/div&gt; </code></pre> <p>However, I have many places where I call the same code and the code is getting long and verbose. Is there a way to combine event handlers? Something like:</p> <p><code>v-on:keyup:paste:blur:delete:focused</code> ?</p>
0debug
R: Remove a row from all data.frames in global environment : <p>I have over 200 data.frames in my global environment. I would like to remove the first row from each data.frame, but I am not sure how. </p> <p>Any help will be appreciated please let me know if further information is needed.</p>
0debug
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
I need help in ggplot. : > smokeyes_male LungCap.cc. Age..years. Height.inches. Smoke Gender Caesarean 211 6.575 10 63.2 yes male yes 220 7.000 10 62.8 yes male yes 252 9.350 11 71.2 yes male no 258 7.925 11 67.1 yes male no 280 10.275 11 72.2 yes male no 285 8.925 11 65.6 yes male yes 305 6.450 12 61.0 yes male yes 345 8.000 12 64.5 yes male no 370 9.750 13 72.8 yes male no 371 8.025 13 66.2 yes male no I need to plot a relationship between lung capacity and age with respect to the height of the person or whether the person is Caesarean or not. Please help.. i get the following error: > library(ggplot2) > smoker_male_graph=ggplot(smokeyes_male,aes(x=smokeyes_male$age,y=smokeyes_male$LungCap.cc.)) + geom_point() > smoker_male_graph + facet_wrap(~smokeyes_male$Height.inches.) Error: Aesthetics must be either length 1 or the same as the data (33): x, y
0debug
How can I read a webpage in R and made a data table out of it : <p>Here is the website and there are 5 properties </p> <p><a href="http://cpdocket.cp.cuyahogacounty.us/SheriffSearch/results.aspx?q=searchType%3dZipCode%26searchString%3d44106%26foreclosureType%3d%26dateFrom%3d10%2f6%2f2016+12%3a00%3a00+AM%26dateTo%3d4%2f6%2f2017+11%3a59%3a59+PM" rel="nofollow">http://cpdocket.cp.cuyahogacounty.us/SheriffSearch/results.aspx?q=searchType%3dZipCode%26searchString%3d44106%26foreclosureType%3d%26dateFrom%3d10%2f6%2f2016+12%3a00%3a00+AM%26dateTo%3d4%2f6%2f2017+11%3a59%3a59+PM</a></p> <p>How I can read this website into R and make a table like this out of it</p> <pre><code>Address Prorated_Tax 1462 EAST 115TH STREET $0.00 10531 37 LEE AVE $0.00 10526 ORVILLE AVENUE $0.00 1116 ASHBURY AVENUE $0.00 2780 EAST OVERLOOK $0.00 </code></pre> <p>or Can I do it in Python? </p>
0debug
static int sls_flag_use_localtime_filename(AVFormatContext *oc, HLSContext *c, VariantStream *vs) { if (c->flags & HLS_SECOND_LEVEL_SEGMENT_INDEX) { char * filename = av_strdup(oc->filename); if (!filename) return AVERROR(ENOMEM); if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename), #if FF_API_HLS_WRAP filename, 'd', c->wrap ? vs->sequence % c->wrap : vs->sequence) < 1) { #else filename, 'd', vs->sequence) < 1) { #endif av_log(c, AV_LOG_ERROR, "Invalid second level segment filename template '%s', " "you can try to remove second_level_segment_index flag\n", filename); av_free(filename); return AVERROR(EINVAL); } av_free(filename); } if (c->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE | HLS_SECOND_LEVEL_SEGMENT_DURATION)) { av_strlcpy(vs->current_segment_final_filename_fmt, oc->filename, sizeof(vs->current_segment_final_filename_fmt)); if (c->flags & HLS_SECOND_LEVEL_SEGMENT_SIZE) { char * filename = av_strdup(oc->filename); if (!filename) return AVERROR(ENOMEM); if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename), filename, 's', 0) < 1) { av_log(c, AV_LOG_ERROR, "Invalid second level segment filename template '%s', " "you can try to remove second_level_segment_size flag\n", filename); av_free(filename); return AVERROR(EINVAL); } av_free(filename); } if (c->flags & HLS_SECOND_LEVEL_SEGMENT_DURATION) { char * filename = av_strdup(oc->filename); if (!filename) return AVERROR(ENOMEM); if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename), filename, 't', 0) < 1) { av_log(c, AV_LOG_ERROR, "Invalid second level segment filename template '%s', " "you can try to remove second_level_segment_time flag\n", filename); av_free(filename); return AVERROR(EINVAL); } av_free(filename); } } return 0; }
1threat
How can I "wrap" or break this line of Code? : I know people have probably asked this a thousand times before, but every time I try Netbeans tells me I am wrong. So can you guys help please? This is Java btw.` highestPoint = (initialVelocity * math.sin(launchAngle) * t - 1/2g math.sqrt(t)); ` I want to break it around even in the middle and center it with around the initalVelocity underneath Thank you
0debug
static void free_test_data(test_data *data) { AcpiSdtTable *temp; int i; g_free(data->rsdt_tables_addr); for (i = 0; i < data->tables->len; ++i) { temp = &g_array_index(data->tables, AcpiSdtTable, i); g_free(temp->aml); if (temp->aml_file && !temp->tmp_files_retain && g_strstr_len(temp->aml_file, -1, "aml-")) { unlink(temp->aml_file); } g_free(temp->aml_file); g_free(temp->asl); if (temp->asl_file && !temp->tmp_files_retain) { unlink(temp->asl_file); } g_free(temp->asl_file); } g_array_free(data->tables, false); }
1threat
static void scsi_do_read(SCSIDiskReq *r, int ret) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); SCSIDiskClass *sdc = (SCSIDiskClass *) object_get_class(OBJECT(s)); assert (r->req.aiocb == NULL); if (r->req.io_canceled) { scsi_req_cancel_complete(&r->req); goto done; } if (ret < 0) { if (scsi_handle_rw_error(r, -ret, false)) { goto done; } } scsi_req_ref(&r->req); if (r->req.sg) { dma_acct_start(s->qdev.conf.blk, &r->acct, r->req.sg, BLOCK_ACCT_READ); r->req.resid -= r->req.sg->size; r->req.aiocb = dma_blk_io(blk_get_aio_context(s->qdev.conf.blk), r->req.sg, r->sector << BDRV_SECTOR_BITS, sdc->dma_readv, r, scsi_dma_complete, r, DMA_DIRECTION_FROM_DEVICE); } else { scsi_init_iovec(r, SCSI_DMA_BUF_SIZE); block_acct_start(blk_get_stats(s->qdev.conf.blk), &r->acct, r->qiov.size, BLOCK_ACCT_READ); r->req.aiocb = sdc->dma_readv(r->sector, &r->qiov, scsi_read_complete, r, r); } done: scsi_req_unref(&r->req); }
1threat
php merge Boolean variable : I have some Boolean variables and I want merge those (Calculation) I used `implode()` but always return true! <?php $myarray = array(true,false,false,true,false); implode(''&&'', $myarray); ?> How to do it !
0debug
static av_cold int sunrast_encode_init(AVCodecContext *avctx) { SUNRASTContext *s = avctx->priv_data; switch (avctx->coder_type) { case FF_CODER_TYPE_RLE: s->type = RT_BYTE_ENCODED; break; case FF_CODER_TYPE_RAW: s->type = RT_STANDARD; break; default: av_log(avctx, AV_LOG_ERROR, "invalid coder_type\n"); return AVERROR(EINVAL); } avctx->coded_frame = av_frame_alloc(); if (!avctx->coded_frame) return AVERROR(ENOMEM); avctx->coded_frame->key_frame = 1; avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I; s->maptype = RMT_NONE; s->maplength = 0; switch (avctx->pix_fmt) { case AV_PIX_FMT_MONOWHITE: s->depth = 1; break; case AV_PIX_FMT_PAL8 : s->maptype = RMT_EQUAL_RGB; s->maplength = 3 * 256; case AV_PIX_FMT_GRAY8: s->depth = 8; break; case AV_PIX_FMT_BGR24: s->depth = 24; break; default: return AVERROR_BUG; } s->length = avctx->height * (FFALIGN(avctx->width * s->depth, 16) >> 3); s->size = 32 + s->maplength + s->length * (s->type == RT_BYTE_ENCODED ? 2 : 1); return 0; }
1threat
Where do I start with first c# project using amazon and netflix? : <p>I need to learn c# for work and I thought the best way for me to get started would be with a passion project. </p> <p>I love movies and tv and was thinking about creating a c# database app that would take data from my netflix and amazon accounts and show me exactly what I've already watched.</p> <p>Is this possible? If so, where do I start?</p>
0debug
Golang : Could not understang how below code is executing : Below is the code i have a query upon: I have a single dimentional array a I could not understand when i printing a[0][0] then why it is returning ascii value of the character a package main import ( "fmt" ) func main() { a := [3]string{"a","b","c"} fmt.Println(a[0][0]) } Output :97
0debug
React router redirect after action redux : <p>I'm using react-redux and standard react-routing. I need redirect after definite action.</p> <p>For example: I have registration a few steps. And after action:</p> <pre><code>function registerStep1Success(object) { return { type: REGISTER_STEP1_SUCCESS, status: object.status }; } </code></pre> <p>I want him redirect to page with registrationStep2. How to do it?</p> <p>p.s. In history browser '/registrationStep2' has never been. This page appears only after successful result registrationStep1 page.</p>
0debug
static inline uint16_t mipsdsp_lshift16(uint16_t a, uint8_t s, CPUMIPSState *env) { uint8_t sign; uint16_t discard; if (s == 0) { return a; } else { sign = (a >> 15) & 0x01; if (sign != 0) { discard = (((0x01 << (16 - s)) - 1) << s) | ((a >> (14 - (s - 1))) & ((0x01 << s) - 1)); } else { discard = a >> (14 - (s - 1)); } if ((discard != 0x0000) && (discard != 0xFFFF)) { set_DSPControl_overflow_flag(1, 22, env); } return a << s; } }
1threat
Hello i cannot make update on PHP (Mysqli) : php but it is not correct and what can i do? insert is working. Everything is working but not update. I dont know why, i think i had made everything correct. if you can help me it would be great. Thank you! i cannot make update on PHP (Mysqli) <?php include("conn.php"); echo "<meta charset='utf-8'>"; ?> <?php $id = $_GET['edi']; $showrecs = "SELECT ID, English, Georgian FROM register WHERE ID='$id'"; $result = $conn->query($showrecs); if(isset($_POST['update'])){ $Updatee = "UPDATE register SET English='".$_POST['English']."', Georgian='".$_POST['Georgian']."' WHERE ID='$id'"; $res=mysqli_query($conn, $Updatee); if($res==1){ echo "&#4332;&#4304;&#4320;&#4315;&#4304;&#4322;&#4308;&#4305;&#4312;&#4311; &#4306;&#4304;&#4316;&#4334;&#4317;&#4320;&#4330;&#4312;&#4308;&#4314;&#4307;&#4304; &#4320;&#4308;&#4307;&#4304;&#4325;&#4322;&#4312;&#4320;&#4308;&#4305;&#4304;."; echo "<br>"; echo "<a href='view.php'>&#4329;&#4304;&#4316;&#4304;&#4332;&#4308;&#4320;&#4308;&#4305;&#4312;&#4321; &#4316;&#4304;&#4334;&#4309;&#4304;</a>"; } if($res==0){ echo "&#4304;&#4320;&#4304;&#4324;&#4308;&#4320;&#4312;&#4330; &#4304;&#4320; &#4315;&#4317;&#4334;&#4307;&#4304;"; } exit(); } elseif ($result->num_rows > 0) { // while($row = $result->fetch_assoc()) { echo "<form method=POST>"; echo "<tr>"; echo "<td>" . "<input type='text' name='id' value=" . $row['ID'] ." disabled>". "</td>"; echo "<td>" . "<input type='text' name='Engish' value=" . $row['Engish'] .">". " </td>"; echo "<td>" . "<input type='text' name='Georgian' value=" . $row['Georgian'] .">". " </td>"; echo "<td>" . "<input type='submit' name='update' value='&#4328;&#4308;&#4330;&#4309;&#4314;&#4304;'>" . " </td>"; echo "</form>"; ?> <?php echo "</br>"; echo "</br>"; } } else { echo "Error;"; } $conn->close(); ?>
0debug
PHP : preg_replace_callback() not working if occurrence starts with a number : I'm using **preg_replace_callback()** with a regex to pick up some heading content and create an ID based on the content but it seems that it's not working if the occurrence begins with a number and I don't understand where I'm wrong. Here is the code I'm using : function betterId($match){ $escape = str_split(strip_tags($match[2]), 20); $id = strlen($escape[0]) >=5 ? function_to_makeItClear($escape[0]) : str_shuffle('AnyWordsHere'); return '<h'.$match[1].' id="'.$id.'">'.$match[2].'</h'.$match[1].'>'; } return preg_replace_callback('#<h([1-6]).*?>(.*?)<\/h[1-6]>#si', 'betterId', $texte); Here is the text I want to transform <p>Paragraph one is okay </p> <h2>This will work without problem</h2> <p>Paragraph two is okay </p> <h2>This heading too</h2> <p>Paragraph one is okay </p> <h2>This item list will work too</h2> <p>Paragraph two is okay </p> <h3>1. <a href="https://www.example1.com/">This wont work</a></h3> <p>Paragraph one is okay </p> <h3>2. <a href="https://www.example2.com/">Not working</a></h3> <p>Paragraph two is okay </p> <h3>3. Neither this one</h3> <h3>But this works again</h3> I would like to have something like this : <p>Paragraph one is okay </p> <h2 id="this-will-work">This will work without problem</h2> <p>Paragraph two is okay </p> <h2 id="this-heading-too">This heading too</h2> <p>Paragraph one is okay </p> <h2 id="this-item-list">This item list will work too</h2> <p>Paragraph two is okay </p> <h3 id="this-wont-work">1. <a href="https://www.example1.com/">This wont work</a></h3> <p>Paragraph one is okay </p> <h3 id="not-working">2. <a href="https://www.example2.com/">Not working</a></h3> <p>Paragraph two is okay </p> <h3 id="neither-this-one">3. Neither this one</h3> <h3 id="but-this-works">But this works again</h3> Any help will be greatly appreciated
0debug
int kvmppc_put_books_sregs(PowerPCCPU *cpu) { CPUPPCState *env = &cpu->env; struct kvm_sregs sregs; int i; sregs.pvr = env->spr[SPR_PVR]; sregs.u.s.sdr1 = env->spr[SPR_SDR1]; #ifdef TARGET_PPC64 for (i = 0; i < ARRAY_SIZE(env->slb); i++) { sregs.u.s.ppc64.slb[i].slbe = env->slb[i].esid; if (env->slb[i].esid & SLB_ESID_V) { sregs.u.s.ppc64.slb[i].slbe |= i; } sregs.u.s.ppc64.slb[i].slbv = env->slb[i].vsid; } #endif for (i = 0; i < 16; i++) { sregs.u.s.ppc32.sr[i] = env->sr[i]; } for (i = 0; i < 8; i++) { sregs.u.s.ppc32.dbat[i] = ((uint64_t)env->DBAT[0][i] << 32) | env->DBAT[1][i]; sregs.u.s.ppc32.ibat[i] = ((uint64_t)env->IBAT[0][i] << 32) | env->IBAT[1][i]; } return kvm_vcpu_ioctl(CPU(cpu), KVM_SET_SREGS, &sregs); }
1threat
alert('Hello ' + user_input);
1threat
static void intel_hda_response(HDACodecDevice *dev, bool solicited, uint32_t response) { HDACodecBus *bus = HDA_BUS(dev->qdev.parent_bus); IntelHDAState *d = container_of(bus, IntelHDAState, codecs); hwaddr addr; uint32_t wp, ex; if (d->ics & ICH6_IRS_BUSY) { dprint(d, 2, "%s: [irr] response 0x%x, cad 0x%x\n", __FUNCTION__, response, dev->cad); d->irr = response; d->ics &= ~(ICH6_IRS_BUSY | 0xf0); d->ics |= (ICH6_IRS_VALID | (dev->cad << 4)); return; } if (!(d->rirb_ctl & ICH6_RBCTL_DMA_EN)) { dprint(d, 1, "%s: rirb dma disabled, drop codec response\n", __FUNCTION__); return; } ex = (solicited ? 0 : (1 << 4)) | dev->cad; wp = (d->rirb_wp + 1) & 0xff; addr = intel_hda_addr(d->rirb_lbase, d->rirb_ubase); stl_le_pci_dma(&d->pci, addr + 8*wp, response); stl_le_pci_dma(&d->pci, addr + 8*wp + 4, ex); d->rirb_wp = wp; dprint(d, 2, "%s: [wp 0x%x] response 0x%x, extra 0x%x\n", __FUNCTION__, wp, response, ex); d->rirb_count++; if (d->rirb_count == d->rirb_cnt) { dprint(d, 2, "%s: rirb count reached (%d)\n", __FUNCTION__, d->rirb_count); if (d->rirb_ctl & ICH6_RBCTL_IRQ_EN) { d->rirb_sts |= ICH6_RBSTS_IRQ; intel_hda_update_irq(d); } } else if ((d->corb_rp & 0xff) == d->corb_wp) { dprint(d, 2, "%s: corb ring empty (%d/%d)\n", __FUNCTION__, d->rirb_count, d->rirb_cnt); if (d->rirb_ctl & ICH6_RBCTL_IRQ_EN) { d->rirb_sts |= ICH6_RBSTS_IRQ; intel_hda_update_irq(d); } } }
1threat
How do I find out and change the value of <input type = "text"> in asp.net? : <p>I want to find the value of and want to mask the first 4th of the text field to another character when the length of the text field is 4 or greater. </p> <p>but I don't know well asp.net skill. help me plz.</p> <p>here is some html in body tag</p> <pre class="lang-html prettyprint-override"><code>&lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;div&gt; &lt;input type="text" runat="server" id="input1" name="input1" value="TestText" /&gt; &lt;input type="button" runat="server" class="btnCnvt" name="btnCnvt" id="btnCnvt" value="convert" onclick="GetValue()" /&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; </code></pre> <p>here is javascript :(</p> <pre><code>&lt;script type="text/javascript"&gt; function GetValue() { // Don't Work!!!(not fount 'value' attribute) var str = document.getElementById("input1").value; } &lt;/script&gt; </code></pre>
0debug
Ajax.load wont work when pressing a button : <p>I am trying to run ajax.load method when pressing a button. The idea is very simple: change the body of a to something else, by using the ajax.load method. However, i havent been succesful yet, and after researching for a couple of hours, i still havent found the solution. Nothing happens when i press the button.</p> <p>i have tried to copy/paste one of w3schools examples into my own project, just to see if it works on my computer. The result was that it didn't work on my computer, even after changing the files in the example to my own files. this makes me think that there is a problem with how ajax has been put into the project. but i am not sure. The example is here: <a href="https://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_ajax_load" rel="nofollow noreferrer">https://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_ajax_load</a> </p> <p>my test-website is running on a tomcat server and is written in intelliJ. Here is the code:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;AjaxTest&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;script&gt; $("#button").click(function () { $("#maincontainer").load("ajaxTestAlternativeText.txt") }) &lt;/script&gt; &lt;div id="maincontainer"&gt; this text needs to change &lt;/div&gt; &lt;button id="button" type="button"&gt; tryk her :)&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>in the code above, i change the body to a .txt file. I have also tried with changing to a .html file, but that didn't work either.</p>
0debug
How to run Tensorboard from python scipt in virtualenv? : <p>Tensorboard should be started from commnad line like that:</p> <pre><code>tensorboard --logdir=path </code></pre> <p>I need to run it from code. Until now I use this:</p> <pre><code>import os os.system('tensorboard --logdir=' + path) </code></pre> <p>However tensorboard do not start because is not included in the system path. I use PyCharm with virtualenv on windows. I don't want to change system paths so the only option is to run it from virtualenv. How to do this? </p>
0debug
Yarn warning on docker build : <p>Upon running <code>yarn install</code> inside my docker container it gives a warning about being without connection. <a href="https://hub.docker.com/r/tavern/rpg-web/~/dockerfile/" rel="noreferrer">https://hub.docker.com/r/tavern/rpg-web/~/dockerfile/</a></p> <p><code> warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries. </code></p> <p>What could be causing this?</p>
0debug
Android: ANR Input dispatching timed out : <p>I am getting following error logs on some phone which as follow:</p> <p>Reason: Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 20. Wait queue head age: 5509.1ms.)</p> <p>I am using Retrofit 2 for networking calls in which I use async method, Using database as realm where I used async transaction for writing stuff. Using Glide for image loading.</p> <p>On using Strict Mode I found out I get penalty log for shared preferences nothing else. Any other pointers to see and debug issue</p>
0debug
static void curl_setup_preadv(BlockDriverState *bs, CURLAIOCB *acb) { CURLState *state; int running; BDRVCURLState *s = bs->opaque; uint64_t start = acb->offset; uint64_t end; qemu_mutex_lock(&s->mutex); if (curl_find_buf(s, start, acb->bytes, acb)) { goto out; } for (;;) { state = curl_find_state(s); if (state) { break; } qemu_mutex_unlock(&s->mutex); aio_poll(bdrv_get_aio_context(bs), true); qemu_mutex_lock(&s->mutex); } if (curl_init_state(s, state) < 0) { curl_clean_state(state); acb->ret = -EIO; goto out; } acb->start = 0; acb->end = MIN(acb->bytes, s->len - start); state->buf_off = 0; g_free(state->orig_buf); state->buf_start = start; state->buf_len = MIN(acb->end + s->readahead_size, s->len - start); end = start + state->buf_len - 1; state->orig_buf = g_try_malloc(state->buf_len); if (state->buf_len && state->orig_buf == NULL) { curl_clean_state(state); acb->ret = -ENOMEM; goto out; } state->acb[0] = acb; snprintf(state->range, 127, "%" PRIu64 "-%" PRIu64, start, end); DPRINTF("CURL (AIO): Reading %" PRIu64 " at %" PRIu64 " (%s)\n", acb->bytes, start, state->range); curl_easy_setopt(state->curl, CURLOPT_RANGE, state->range); curl_multi_add_handle(s->multi, state->curl); curl_multi_socket_action(s->multi, CURL_SOCKET_TIMEOUT, 0, &running); out: qemu_mutex_unlock(&s->mutex); }
1threat
Function to count small letters and Capital in a string , spaces? : I created a function that you type a string and it will bring back the amount of small letters and the amount of capital letters in that string the program works for 1 word but as soon I add two letters the 'space' between two words messes things up. spaces counts too. What is your thoughts? ``` def myfunc(s): s = str(s) upperl = 0 lowerl = 0 for i in s: if i == i.lower(): lowerl += 1 if i == i.upper(): upperl += 1 if i == ' ': continue return upperl,lowerl x = myfunc('hello G') print (x) ``` ``` def myfunc(s): s = str(s) upperl = 0 lowerl = 0 for i in s: if i == i.lower(): lowerl += 1 if i == i.upper(): upperl += 1 if i == ' ': continue return upperl,lowerl x = myfunc('hello G') print (x) ``` from the word 'hello G' we expect upperletter,lowerletters I expect 1,5 but that space between two words make it: 2,6
0debug
Java , binary search in file : I want to write a program that makes binary search in a file. I have a treeset adt that has strings int and i want to make research in file for each string this way : First i want to read the middle page of the file and do research in it . if the string is found then the position of the string is returned. if not then i have to read the page from the left or right half of the file depends on the alphabetical order of the strings. My code for the class of the binary search is this : public class PageBinarySearch { final int NOT_FOUND = -1; final int BOUND_LIMIT = -1; final int EVRTHG_OK = 0; final int ON = 1; final int OFF = 0; private DataInputStream inFile; private String[] readBuffer; //This buffer is used to read a specified page from //the disk. private String[] auxBuffer; //Auxiliary buffer is used for searching in the la- //st page. This buffer has less than PAGE_SIZE ele- //ments. private int lastPage, leftElemNum, lastPageNo; private int diskAccessMeter; //This variable is used to count disk accesses. private int firstNum; /********************************************************************************/ //Constructor of the class public PageBinarySearch(String filename, String key, int PageSize, int numPage, int numOfWords) throws IOException{ System.out.println(); System.out.println("Binary Search on disk pages"); System.out.println("*************************************************"); System.out.println(); //Initializing the elements of the class. readBuffer = new String[PageSize]; lastPage = numPage*PageSize; leftElemNum = numOfWords-(lastPage); auxBuffer = new String[leftElemNum]; lastPageNo = numPage; diskAccessMeter = 0; this.setFirstNum(filename); basicPageBinarySearchMethod(filename, 0, lastPageNo, key,PageSize,numPage,numOfWords); System.out.println("Disk accesses:"+this.getDiskAccessMeter()); } /********************************************************************************/ //Recursive binary search on disk pages. public void basicPageBinarySearchMethod(String filename, int start, int end, String key, int PageSize, int numPage, int numOfWords) throws IOException{ inFile = new DataInputStream(new FileInputStream(filename)); int bound = boundHandler(start, key); if (bound != EVRTHG_OK){return;} int midPage = start + (end-start)/2; int midPageIndex = ((midPage) * (PageSize)); int midPageEnd = midPageIndex + PageSize; //System.out.println("----------------------------------------"); System.out.println("Page:"+(midPage+1)); System.out.println(" Index:"+midPageIndex+" End:"+midPageEnd); //Accessing midPage's index. accessPageIndex(midPageIndex - 1); fillBasicBuffer(PageSize); System.out.println(); if (key.compareTo(readBuffer[0])<0){ //Case that the key is in the left part. end = midPage - 1; inFile.close(); //We close the stream because in the next recursion //we want to access new midPage. basicPageBinarySearchMethod(filename, start, end, key, PageSize, numPage, numOfWords); } else if (key.compareTo(readBuffer[255])>0){ //Case that the key is in the left part. start = midPage+1; inFile.close(); basicPageBinarySearchMethod(filename, start, end, key, PageSize, numPage, numOfWords); } else{ //Case that: //a) key is bigger than the integer, which is in the midPage- //Index position of the file, and //b) key is less than the integer, which is in the midPageEnd //position of the file. LookingOnPage(midPage, key); } } /********************************************************************************/ public int boundHandler(int start, String key) throws IOException{ if (start == this.getLastPageNo()){ //In this case the program has to start searching in the last page, //which has less than PAGE_SIZE elements. So we call the alternative //function "LookingOnLastPage". System.out.println("Start == End"); accessPageIndex(this.getLastPage()); LookingOnLastPage(key); return BOUND_LIMIT; } //if (key < this.getFirstNum()){ //System.out.println("Key does not exist."); //return BOUND_LIMIT; //} return EVRTHG_OK; } /********************************************************************************/ //This function is running a binary search in the specified disk page, which //is saved in the readBuffer. public void LookingOnPage(int pageNo, String key) throws IOException{ int i, result; System.out.println("Looking for key:"+key+" on page:"+(pageNo+1)); result = myBinarySearch(key, readBuffer); if (result != -1){ System.out.println("Key found on page:"+(pageNo+1)); inFile.close(); return; } else{ System.out.println("Key is not found"); inFile.close(); return; } } /********************************************************************************/ //This function is running a binary search in the last disk page, which //is saved in the auxBuffer. public void LookingOnLastPage(String key) throws IOException{ int i, result; this.setDiskAccessMeter(this.getDiskAccessMeter()+1); System.out.println("Looking for key:"+key+" on last page:" +(this.getLastPageNo()+1)); for (i=0; i<this.getLeftElemNum(); i++){ auxBuffer[i] = inFile.readUTF(); } result = myBinarySearch(key, auxBuffer); if (result != -1){ System.out.println("Key found on last page"); inFile.close(); return; } else{ System.out.println("Key is not found"); inFile.close(); return; } } /********************************************************************************/ public void accessPageIndex(int intNum) throws IOException { //This function is skipping intNum integers in the file, to access page's //index. int i; System.out.println(" Accessing page's index..."); inFile.skipBytes(intNum*4); //inFile.readInt(); } /********************************************************************************/ public void fillBasicBuffer(int PageSize) throws IOException{ //Loading readBuffer. int i; this.setDiskAccessMeter(this.getDiskAccessMeter()+1); for (i=0; i<PageSize; i++){ readBuffer[i] = inFile.readUTF(); } } /********************************************************************************/ //This function implements binary search on a given buffer. public int myBinarySearch(String key, String[] auxBuffer) { int lo = 0; int hi = auxBuffer.length - 1; while (lo <= hi) { // Key is in a[lo..hi] or not present. int mid = lo + (hi - lo) / 2; if (key.compareTo(auxBuffer[mid])<0) hi = mid - 1; else if (key.compareTo(auxBuffer[mid])>0) lo = mid + 1; else return mid; } return NOT_FOUND; } /********************************************************************************/ public int getLastPage() { return lastPage; } public void setLastPage(int lastPage) { this.lastPage = lastPage; } public int getLeftElemNum() { return leftElemNum; } public void setLeftElemNum(int leftElemNum) { this.leftElemNum = leftElemNum; } public int getLastPageNo() { return lastPageNo; } public void setLastPageNo(int lastPageNo) { this.lastPageNo = lastPageNo; } public int getDiskAccessMeter() { return diskAccessMeter; } public void setDiskAccessMeter(int diskAccessMeter) { this.diskAccessMeter = diskAccessMeter; } public int getFirstNum() { return firstNum; } public void setFirstNum(String filename) throws IOException { inFile = new DataInputStream(new FileInputStream(filename)); this.firstNum = inFile.readInt(); inFile.close(); } } and my main is : public class MyMain { private static final int DataPageSize = 128; // Default Data Page size public static void main(String[] args) throws IOException { TreeSet<DictPage> listOfWords = new TreeSet<DictPage>(new MyDictPageComp()); LinkedList<Page> Eurethrio = new LinkedList<Page>(); File file = new File("C:\\Kennedy.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file))); //This will reference one line at a time... String line = null; int line_count=0; //Metavliti gia na metrame grammes .. int byte_count; //Metavliti gia na metrame bytes... int total_byte_count=0; //Metavliti gia synoliko arithmo bytes ... int fromIndex; int middleP; int kat = 0; while( (line = br.readLine())!= null ){ line_count++; fromIndex=0; String [] tokens = line.split(",\\s+|\\s*\\\"\\s*|\\s+|\\.\\s*|\\s*\\:\\s*"); String line_rest=line; for (int i=1; i <= tokens.length; i++) { byte_count = line_rest.indexOf(tokens[i-1]); fromIndex = fromIndex + byte_count + 1 + tokens[i-1].length(); if (fromIndex < line.length()) line_rest = line.substring(fromIndex); listOfWords.add(new DictPage(tokens[i-1],kat)); kat++; Eurethrio.add(new Page("Kennedy",fromIndex)); } total_byte_count += fromIndex; Eurethrio.add(new Page("Kennedy", total_byte_count)); } //for(DictPage p : listOfWords){ //System.out.println(p.getWord() + " " + p.getPage()); //} //for (int i = 0;i<Eurethrio.size();i++){ //System.out.println(""+Eurethrio.get(i).getFile()+" "+Eurethrio.get(i).getBytes()); //} ByteArrayOutputStream bos = new ByteArrayOutputStream(128) ; DataOutputStream out = new DataOutputStream(bos); String s ; int integ; byte[] buf ; int nPag=1; //Aritmos selidwn int numOfWords=0; for (DictPage p : listOfWords){ s = p.getWord(); integ = p.getPage(); numOfWords++; byte dst[] = new byte[20]; byte[] src = s.getBytes(); //metatrepei se bytes to string System.arraycopy(src, 0, dst, 1, src.length); //to antigrafei ston buffer dst out.write(dst, 0, 20); // to grafei sto arxeio out.writeInt(integ); // grafei ton akeraio sto file out.close(); buf = bos.toByteArray(); // Creates a newly allocated byte array. System.out.println("\nbuf size: " + buf.length + " bytes"); //dhmiourgia selidas (h opoia einai enas byte array) if(buf.length> nPag*DataPageSize){ nPag++; } byte[] DataPage = new byte[nPag*DataPageSize]; System.arraycopy( buf, 0, DataPage, 0, buf.length); // antigrafw buf sth selida System.out.println("TARRARA"+DataPage.length); bos.close();//kleinw buf // write to the file RandomAccessFile MyFile = new RandomAccessFile ("newbabis", "rw"); MyFile.seek(0); MyFile.write(DataPage); } System.out.println("Number of Pages :"+nPag); if (nPag%2 == 0){ middleP = nPag/2; } else{ middleP = (nPag+1)/2; } System.out.println("Middle page is no:"+middleP); PageBinarySearch BinarySearch; String key; for(DictPage p : listOfWords){ key = p.getWord(); BinarySearch = new PageBinarySearch("C:\\Kennedy.txt", key , DataPageSize, nPag, numOfWords); } } } My program is not working well and i can't find what I am doing wrong .
0debug
Disable Active Storage in Rails 5.2 : <p>Upgrading Rails to 5.2, and I found out that I must commit the storage.yml into version control. I don't plan to use ActiveStorage. Is there a way to disable it?</p>
0debug
how to pass suspend function as parameter to another function? Kotlin Coroutines : <p>I want to send suspending function as a parameter, but it shows " Modifier 'suspend' is not applicable to 'value parameter" . how to do it?</p> <pre><code>fun MyModel.onBG(suspend bar: () -&gt; Unit) { launch { withContext(Dispatchers.IO) { bar() } } } </code></pre>
0debug
Python "triplet" dictionary? : <p>If we have <code>(a1, b1)</code> and <code>(a2, b2)</code> it's easy to use a dictionary to store the correspondences:</p> <pre><code>dict[a1] = b1 dict[a2] = b2 </code></pre> <p>And we can get <code>(a1, b1)</code> and <code>(a2, b2)</code> back no problem.</p> <p>But, if we have <code>(a1, b1, c1)</code> and <code>(a2, b2, c2)</code>, is it possible to get something like:</p> <pre><code>dict[a1] = (b1, c1) dict[b1] = (a1, c1) </code></pre> <p>Where we can use either <code>a1</code> or <code>b1</code> to get the triplet <code>(a1, b1, c2)</code> back? Does that make sense? I'm not quite sure which datatype to use for this problem. The above would work but there would be duplicate data. </p> <p>Basically, if I have a triplet, which data type could I use such that I can use either the first or second value to get the triplet back?</p>
0debug
how to pass php value to script variable : i have a php variable value and we have to pass it to a script variable automatically on a button click ---------- <button><? echo $part1;?></button><? }?><br> <video style="border:1px solid" id="myVideo" width="320" height="176" controls> <source src="uploads/videos/<?php echo $vid;?>" type="video/mp4"> </video> <script> var video = document.getElementById('myVideo'); var videoStartTime = 0; var durationTime = 0; video.addEventListener('loadedmetadata', function() { videoStartTime = 2; durationTime = 4; this.currentTime = videoStartTime; }, false); video.addEventListener('timeupdate', function() { if(this.currentTime > videoStartTime + durationTime){ this.pause(); } }); </script>
0debug
VSCode Implement Method Shortcut : <p>I'm using VSCode, Exist, a way to implement the methods that are within an interface in typescript using some shortcut keys or set for it.</p> <p>I searched on the website of Microsoft, and the web, but I have not found anything.</p>
0debug
static uint64_t cirrus_linear_read(void *opaque, target_phys_addr_t addr, unsigned size) { CirrusVGAState *s = opaque; uint32_t ret; addr &= s->cirrus_addr_mask; if (((s->vga.sr[0x17] & 0x44) == 0x44) && ((addr & s->linear_mmio_mask) == s->linear_mmio_mask)) { ret = cirrus_mmio_blt_read(s, addr & 0xff); } else if (0) { ret = 0xff; } else { if ((s->vga.gr[0x0B] & 0x14) == 0x14) { addr <<= 4; } else if (s->vga.gr[0x0B] & 0x02) { addr <<= 3; } addr &= s->cirrus_addr_mask; ret = *(s->vga.vram_ptr + addr); } return ret; }
1threat
Type 'void' is not assignable to type '((event: MouseEvent<HTMLInputElement>) => void) | undefined' : <pre><code> import * as React from "react"; import "./App.css"; import PageTwo from "./components/PageTwo"; export interface IPropsk { data?: Array&lt;Items&gt;; fetchData?(value: string): void; } export interface IState { isLoaded: boolean; hits: Array&lt;Items&gt;; value: string; } class App extends React.Component&lt;IPropsk, IState&gt; { constructor(props: IPropsk) { super(props); this.state = { isLoaded: false, hits: [], value: "" this.handleChange = this.handleChange.bind(this); } fetchData = val =&gt; { alert(val); }; handleChange(event) { this.setState({ value: event.target.value }); } render() { return ( &lt;div&gt; &lt;div&gt; &lt;input type="text" value={this.state.value} onChange= {this.handleChange} &lt;input type="button" onClick={this.fetchData("dfd")} value="Search" /&gt; &lt;/div&gt; &lt;/div&gt; ); } } export default App; </code></pre> <p>In the above code example I tried to call a method(<strong>fetchData</strong> ) by clicking button with a paremeter.But I gives a error from following line</p> <pre><code> &lt;input type="button" onClick={this.fetchData("dfd")} value="Search" /&gt; </code></pre> <p>The error is</p> <p></p> <p><em>type 'void' is not assignable to type '((event: MouseEvent) => void) | undefined'.</em></p>
0debug
C# .NET MVC 5 Advanced ajaxform with 2 models : I'm looking for any ideas/ tutorials or maybe the name of that metod. I'd like to create something like this on the photo. **Let's me explain:** Technology: - C# .Net MVC5 We have 2 tables. - Order (Order_Id, OrderName), - Item (Item_Id, ItemName), Functionalities: - user is able to add item to **Item table** by that form. - user after button had been clicked is able to choose item from **Item table** and add it to **Order table**. - everything should be related [![img_form][1]][1] [1]: https://i.stack.imgur.com/2cyoK.jpg P.S: What is that when sb is writing for example "Door" in textbox an under the textbox appears some data from DB which we are able to click and then the form is filled with that data?
0debug
When trying to print UINT_MAX I get -1 : <p>When trying to print 'UINT_MAX' all I get it -1, why is this? It's the only thing I have in my 'main()', a printf statement that prints 'UINT_MAX'</p>
0debug
int ff_insert_pad(unsigned idx, unsigned *count, size_t padidx_off, AVFilterPad **pads, AVFilterLink ***links, AVFilterPad *newpad) { AVFilterLink **newlinks; AVFilterPad *newpads; unsigned i; idx = FFMIN(idx, *count); newpads = av_realloc_array(*pads, *count + 1, sizeof(AVFilterPad)); newlinks = av_realloc_array(*links, *count + 1, sizeof(AVFilterLink*)); if (newpads) *pads = newpads; if (newlinks) *links = newlinks; if (!newpads || !newlinks) return AVERROR(ENOMEM); memmove(*pads + idx + 1, *pads + idx, sizeof(AVFilterPad) * (*count - idx)); memmove(*links + idx + 1, *links + idx, sizeof(AVFilterLink*) * (*count - idx)); memcpy(*pads + idx, newpad, sizeof(AVFilterPad)); (*links)[idx] = NULL; (*count)++; for (i = idx + 1; i < *count; i++) if (*links[i]) (*(unsigned *)((uint8_t *) *links[i] + padidx_off))++; return 0; }
1threat
How to retry Ansible task that may fail? : <p>In my Ansible play I am restarting database then trying to do some operations on it. Restart command returns as soon as restart is started, not when db is up. Next command tries to connect to the database. That command my fail when db is not up.</p> <p>I want to retry my second command a few times. If last retry fails, I want to fail my play. </p> <p>When I do retries as follows</p> <pre><code> retries: 3 delay: 5 </code></pre> <p>Then retries are not executed at all, because first command execution fails whole play. I could add <code>ignore_errors: yes</code> but that way play will pass even if all retries failed. Is there a easy way to retry failures until I have success, but fail when no success from last retry?</p>
0debug
Module using another function of the same module : <p>I have something like this:</p> <ul> <li>MyModule <ul> <li><code>index.js</code></li> <li><code>myFunction1.js</code></li> <li><code>myFunction2.js</code></li> </ul></li> </ul> <p>In <code>index.js</code> file i'm exporting all modules function (<code>myFunction1</code> and <code>myFunction2</code>). But, in <code>myFunction2</code> I use <code>myFunction1</code>.</p> <p>If I import the index (all the module) and call it like <code>MyModule.myFunction1</code> inside <code>myFunction2</code>, I get an error (function does not exists).</p> <p>If I import <code>myFunction1.js</code> and call it like <code>myFunction1()</code>, I can't make an Stub of it when I'm going to test it.</p> <p>Any aproach to do something like this?</p>
0debug
static int lag_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; unsigned int buf_size = avpkt->size; LagarithContext *l = avctx->priv_data; ThreadFrame frame = { .f = data }; AVFrame *const p = data; uint8_t frametype = 0; uint32_t offset_gu = 0, offset_bv = 0, offset_ry = 9; uint32_t offs[4]; uint8_t *srcs[4], *dst; int i, j, planes = 3; int ret; p->key_frame = 1; frametype = buf[0]; offset_gu = AV_RL32(buf + 1); offset_bv = AV_RL32(buf + 5); switch (frametype) { case FRAME_SOLID_RGBA: avctx->pix_fmt = AV_PIX_FMT_RGB32; case FRAME_SOLID_GRAY: if (frametype == FRAME_SOLID_GRAY) if (avctx->bits_per_coded_sample == 24) { avctx->pix_fmt = AV_PIX_FMT_RGB24; } else { avctx->pix_fmt = AV_PIX_FMT_0RGB32; planes = 4; } if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0) return ret; dst = p->data[0]; if (frametype == FRAME_SOLID_RGBA) { for (j = 0; j < avctx->height; j++) { for (i = 0; i < avctx->width; i++) AV_WN32(dst + i * 4, offset_gu); dst += p->linesize[0]; } } else { for (j = 0; j < avctx->height; j++) { memset(dst, buf[1], avctx->width * planes); dst += p->linesize[0]; } } break; case FRAME_SOLID_COLOR: if (avctx->bits_per_coded_sample == 24) { avctx->pix_fmt = AV_PIX_FMT_RGB24; } else { avctx->pix_fmt = AV_PIX_FMT_RGB32; offset_gu |= 0xFFU << 24; } if ((ret = ff_thread_get_buffer(avctx, &frame,0)) < 0) return ret; dst = p->data[0]; for (j = 0; j < avctx->height; j++) { for (i = 0; i < avctx->width; i++) if (avctx->bits_per_coded_sample == 24) { AV_WB24(dst + i * 3, offset_gu); } else { AV_WN32(dst + i * 4, offset_gu); } dst += p->linesize[0]; } break; case FRAME_ARITH_RGBA: avctx->pix_fmt = AV_PIX_FMT_RGB32; planes = 4; offset_ry += 4; offs[3] = AV_RL32(buf + 9); case FRAME_ARITH_RGB24: case FRAME_U_RGB24: if (frametype == FRAME_ARITH_RGB24 || frametype == FRAME_U_RGB24) avctx->pix_fmt = AV_PIX_FMT_RGB24; if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0) return ret; offs[0] = offset_bv; offs[1] = offset_gu; offs[2] = offset_ry; l->rgb_stride = FFALIGN(avctx->width, 16); av_fast_malloc(&l->rgb_planes, &l->rgb_planes_allocated, l->rgb_stride * avctx->height * planes + 1); if (!l->rgb_planes) { av_log(avctx, AV_LOG_ERROR, "cannot allocate temporary buffer\n"); return AVERROR(ENOMEM); } for (i = 0; i < planes; i++) srcs[i] = l->rgb_planes + (i + 1) * l->rgb_stride * avctx->height - l->rgb_stride; for (i = 0; i < planes; i++) if (buf_size <= offs[i]) { av_log(avctx, AV_LOG_ERROR, "Invalid frame offsets\n"); return AVERROR_INVALIDDATA; } for (i = 0; i < planes; i++) lag_decode_arith_plane(l, srcs[i], avctx->width, avctx->height, -l->rgb_stride, buf + offs[i], buf_size - offs[i]); dst = p->data[0]; for (i = 0; i < planes; i++) srcs[i] = l->rgb_planes + i * l->rgb_stride * avctx->height; for (j = 0; j < avctx->height; j++) { for (i = 0; i < avctx->width; i++) { uint8_t r, g, b, a; r = srcs[0][i]; g = srcs[1][i]; b = srcs[2][i]; r += g; b += g; if (frametype == FRAME_ARITH_RGBA) { a = srcs[3][i]; AV_WN32(dst + i * 4, MKBETAG(a, r, g, b)); } else { dst[i * 3 + 0] = r; dst[i * 3 + 1] = g; dst[i * 3 + 2] = b; } } dst += p->linesize[0]; for (i = 0; i < planes; i++) srcs[i] += l->rgb_stride; } break; case FRAME_ARITH_YUY2: avctx->pix_fmt = AV_PIX_FMT_YUV422P; if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0) return ret; if (offset_ry >= buf_size || offset_gu >= buf_size || offset_bv >= buf_size) { av_log(avctx, AV_LOG_ERROR, "Invalid frame offsets\n"); return AVERROR_INVALIDDATA; } lag_decode_arith_plane(l, p->data[0], avctx->width, avctx->height, p->linesize[0], buf + offset_ry, buf_size - offset_ry); lag_decode_arith_plane(l, p->data[1], avctx->width / 2, avctx->height, p->linesize[1], buf + offset_gu, buf_size - offset_gu); lag_decode_arith_plane(l, p->data[2], avctx->width / 2, avctx->height, p->linesize[2], buf + offset_bv, buf_size - offset_bv); break; case FRAME_ARITH_YV12: avctx->pix_fmt = AV_PIX_FMT_YUV420P; if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0) return ret; if (buf_size <= offset_ry || buf_size <= offset_gu || buf_size <= offset_bv) { return AVERROR_INVALIDDATA; } if (offset_ry >= buf_size || offset_gu >= buf_size || offset_bv >= buf_size) { av_log(avctx, AV_LOG_ERROR, "Invalid frame offsets\n"); return AVERROR_INVALIDDATA; } lag_decode_arith_plane(l, p->data[0], avctx->width, avctx->height, p->linesize[0], buf + offset_ry, buf_size - offset_ry); lag_decode_arith_plane(l, p->data[2], avctx->width / 2, avctx->height / 2, p->linesize[2], buf + offset_gu, buf_size - offset_gu); lag_decode_arith_plane(l, p->data[1], avctx->width / 2, avctx->height / 2, p->linesize[1], buf + offset_bv, buf_size - offset_bv); break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported Lagarith frame type: %#"PRIx8"\n", frametype); return AVERROR_PATCHWELCOME; } *got_frame = 1; return buf_size; }
1threat
Anaconda3 - AttributeError: 'dict' object has no attribute 'rsplit' : <p>I am running Anaconda3 locally via web browser. Everytime I go to the "Conda" section to see the packages that are installed (at <a href="http://localhost:8888/tree#conda" rel="noreferrer">http://localhost:8888/tree#conda</a>) I get <code>An error occurred while retrieving installed packages. Internal Server Error</code>.</p> <p>Checking the logs, this is what is currently happening. Any ideas?</p> <pre><code>[E 13:53:08.195 NotebookApp] 500 GET /conda/environments/root?_=1484574786374 (127.0.0.1) 760.41ms referer=http://localhost:8888/tree? [E 13:53:14.557 NotebookApp] Unhandled error in API request Traceback (most recent call last): File "/root/anaconda3/lib/python3.5/site- packages/notebook/base/handlers.py", line 503, in wrapper result = yield gen.maybe_future(method(self, *args, **kwargs)) File "/root/anaconda3/lib/python3.5/site-packages/nb_conda/handlers.py", line 62, in get self.finish(json.dumps(self.env_manager.env_packages(env))) File "/root/anaconda3/lib/python3.5/site-packages/nb_conda/envmanager.py", line 124, in env_packages "packages": [pkg_info(package) for package in data] File "/root/anaconda3/lib/python3.5/site-packages/nb_conda/envmanager.py", line 124, in &lt;listcomp&gt; "packages": [pkg_info(package) for package in data] File "/root/anaconda3/lib/python3.5/site-packages/nb_conda/envmanager.py", line 16, in pkg_info name, version, build = s.rsplit('-', 2) AttributeError: 'dict' object has no attribute 'rsplit' [E 13:53:14.558 NotebookApp] { "Accept-Language": "en-US,en;q=0.8,es;q=0.6", "Connection": "keep-alive", "X-Requested-With": "XMLHttpRequest", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36", "Accept-Encoding": "gzip, deflate, sdch, br", "Cookie": "_xsrf=2|0e84028c|becasdfafdssffjkafdsjkf473451bfcb|1484574343; username-localhost-8888=\"2|1:0|10:1484574347|23:username-localhost-8888|44:ODBlMWE5Mjk1MjRiNDNmNDhkZTVkNTU5MGI3NTNmNDQ=|83dad5a9e1aa2da460539882d41f5b3a7ac93163dab3b324526b730be88d7d69\"", "Referer": "http://localhost:8888/tree?", "Host": "localhost:8888", "Accept": "application/json, text/javascript, */*; q=0.01" } [E 13:53:14.559 NotebookApp] 500 GET /conda/environments/root?_=1484574792779 (127.0.0.1) 750.79ms referer=http://localhost:8888/tree? </code></pre>
0debug
How to convert Decimal() to a number in Python? : <p>I have a JSON output that is <code>Decimal('142.68500203')</code>.</p> <p>I can use str() to get a string which is <code>"142.68500203"</code>. But I want to get a number output which is <code>142.68500203</code>.</p> <p>How to make the conversion in Python?</p>
0debug
print everything in div tag selenium python3 : Hello I am newbie at learning selenium. I am trying to scrape a website which has some info under its div tag like this ``` <div> id="searchResults" class="multiple-view-elements" <span>name</name> <span>info</name> <span>info</name> ---- <span>name</name> ...... ``` my code ``` print ('-------------------------------------------------------------') resp=driver.find_elements_by_id('searchResults').text print (resp) driver.quit() ``` it gives me this error AttributeError: 'list' object has no attribute 'text' what i am doing wrong?
0debug
How to get variable's value outside promise? : <p>I'm trying to set a value to a variable outside a promise. But when I check the value it prints <code>undefined</code>, I defined the variable outside the promise so I don't understand why its <code>undefined</code></p> <p>Here is my code, hope you can help me with that:</p> <pre><code>UserSchema.statics.findByToken = function (token) { var User = this; var decoded; try{ decoded = jwt.verify(token, 'secret'); } catch (err){ if(err.name === 'TokenExpiredError'){ var refreshToken; User.findOne({ 'tokens.token': token, 'tokens.access': 'auth' }).then( (user) =&gt; { User.findOne({ 'tokens.token': token, 'tokens.access': 'auth' }).then( (user) =&gt; { var access = 'auth'; token = jwt.sign({_id: user._id.toHexString(), access}, 'secret', { expiresIn: 30 }).toString(); refreshToken = token; // set value to refreshToken user.tokens.push({access, token}); user.save().then( () =&gt; { token = refreshToken; }); }); }); console.log(refreshToken); // refresh is undefined return Promise.reject({errName: 'TokenExpiredError', token: refreshToken}); } return Promise.reject(); } return User.findOne({ _id: decoded._id, 'tokens.token': token, 'tokens.access': 'auth' }) } </code></pre>
0debug
Bigrams as map keys in C++ : <p>Alright, so I'm wondering how I would go about creating a map key from a two word string (a bigram). For example, the line "This is only a test." would contain the bigrams "this is", "is only", "only a", and "a test."</p> <p>I'm thinking of using make_pair, but something tells me this could cause these bigrams to be created out of order. Would this be the case? If not, would this pairing approach be on the right track?</p>
0debug
Nmap scan to get 2 random addresses with open port 80 in a prefix : How can I use nmap to get 2 random addresses with open port 80 in a prefix. Nmap takes time for port scanning, Is there way to speed up the scanning?
0debug
static void init_vlcs(ASV1Context *a){ static int done = 0; if (!done) { done = 1; init_vlc(&ccp_vlc, VLC_BITS, 17, &ccp_tab[0][1], 2, 1, &ccp_tab[0][0], 2, 1); init_vlc(&dc_ccp_vlc, VLC_BITS, 8, &dc_ccp_tab[0][1], 2, 1, &dc_ccp_tab[0][0], 2, 1); init_vlc(&ac_ccp_vlc, VLC_BITS, 16, &ac_ccp_tab[0][1], 2, 1, &ac_ccp_tab[0][0], 2, 1); init_vlc(&level_vlc, VLC_BITS, 7, &level_tab[0][1], 2, 1, &level_tab[0][0], 2, 1); init_vlc(&asv2_level_vlc, ASV2_LEVEL_VLC_BITS, 63, &asv2_level_tab[0][1], 2, 1, &asv2_level_tab[0][0], 2, 1); } }
1threat
static void test_visitor_out_native_list_str(TestOutputVisitorData *data, const void *unused) { test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_STRING); }
1threat
I am writing a Movie Session Program. : I get the error: "Bad Operand Types for Binary Operator ">" first type: Time second type: Time" This is the method where it gives me the error: @Override public int compareTo(MovieSession currentMovieSession) { if (this.sessionTime < currentMovieSession.sessionTime) { return -1; } else if (this.sessionTime > currentMovieSession.sessionTime) { return 1; } if(this.sessionTime == currentMovieSession.sessionTime) { return this.movieName > currentMovieSession.movieName ? 1 : -1; } }
0debug
int main_loop(void) { #ifndef _WIN32 struct pollfd ufds[MAX_IO_HANDLERS + 1], *pf; IOHandlerRecord *ioh, *ioh_next; uint8_t buf[4096]; int n, max_size; #endif int ret, timeout; CPUState *env = global_env; for(;;) { if (vm_running) { ret = cpu_exec(env); if (shutdown_requested) { ret = EXCP_INTERRUPT; break; } if (reset_requested) { reset_requested = 0; qemu_system_reset(); ret = EXCP_INTERRUPT; } if (ret == EXCP_DEBUG) { vm_stop(EXCP_DEBUG); } if (ret == EXCP_HLT) timeout = 10; else timeout = 0; } else { timeout = 10; } #ifdef _WIN32 if (timeout > 0) Sleep(timeout); #else pf = ufds; for(ioh = first_io_handler; ioh != NULL; ioh = ioh->next) { if (!ioh->fd_can_read) { max_size = 0; pf->fd = ioh->fd; pf->events = POLLIN; ioh->ufd = pf; pf++; } else { max_size = ioh->fd_can_read(ioh->opaque); if (max_size > 0) { if (max_size > sizeof(buf)) max_size = sizeof(buf); pf->fd = ioh->fd; pf->events = POLLIN; ioh->ufd = pf; pf++; } else { ioh->ufd = NULL; } } ioh->max_size = max_size; } ret = poll(ufds, pf - ufds, timeout); if (ret > 0) { for(ioh = first_io_handler; ioh != NULL; ioh = ioh_next) { ioh_next = ioh->next; pf = ioh->ufd; if (pf) { if (pf->revents & POLLIN) { if (ioh->max_size == 0) { ioh->fd_read(ioh->opaque, NULL, 0); } else { n = read(ioh->fd, buf, ioh->max_size); if (n >= 0) { ioh->fd_read(ioh->opaque, buf, n); } else if (errno != EAGAIN) { ioh->fd_read(ioh->opaque, NULL, -errno); } } } } } } #if defined(CONFIG_SLIRP) if (slirp_inited) { fd_set rfds, wfds, xfds; int nfds; struct timeval tv; nfds = -1; FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&xfds); slirp_select_fill(&nfds, &rfds, &wfds, &xfds); tv.tv_sec = 0; tv.tv_usec = 0; ret = select(nfds + 1, &rfds, &wfds, &xfds, &tv); if (ret >= 0) { slirp_select_poll(&rfds, &wfds, &xfds); } } #endif #endif if (vm_running) { qemu_run_timers(&active_timers[QEMU_TIMER_VIRTUAL], qemu_get_clock(vm_clock)); if (audio_enabled) { SB16_run(); } DMA_run(); } qemu_run_timers(&active_timers[QEMU_TIMER_REALTIME], qemu_get_clock(rt_clock)); } cpu_disable_ticks(); return ret; }
1threat
c++ dynamic array of pointers : <p>I'm trying to understand how to create a dynamic array of pointers in C++. I understand that <code>new</code> returns a pointer to the allocated block of memory and <code>int*[10]</code> is an array of pointers to <code>int</code>. But why to you assign it to a <code>int**</code>? I'm struggling to understand that.</p> <pre><code>int **arr = new int*[10]; </code></pre>
0debug
Which code is better to find the first recurring alphabet in a string? : <p>The first code is:</p> <pre><code> string = "DBCABA" #computing the first recurring alphabet def compute_reccuring(): for a in string: var = string.count(a) if var &gt; 1: final = str(a) print(str(final) + " is repeated first") break </code></pre> <p>The second code is:</p> <pre><code>def recurring(): counts = {} for a in string: if a in counts: print(a) else: counts[a] = 1 </code></pre> <p>Both of these codes work but I don't know which one is better in performance.</p>
0debug
static int start_frame_overlay(AVFilterLink *inlink, AVFilterBufferRef *inpicref) { AVFilterContext *ctx = inlink->dst; OverlayContext *over = ctx->priv; inlink->cur_buf = NULL; over->overpicref = inpicref; over->overpicref->pts = av_rescale_q(inpicref->pts, ctx->inputs[OVERLAY]->time_base, ctx->outputs[0]->time_base); return 0; }
1threat
What does declare in `export declare type Xyz` mean vs `export type Xyz` : <p>In a definition file it is valid to write both:</p> <pre><code>export declare type Abc = string; export type Bcd = string; </code></pre> <p>The <code>declare</code> keyword here serves no purpose, correct?</p>
0debug
Lazarus - No Form Window, Dialogue Grey'd Out : <p>I've got a wee bit of experience with Pascal, as I've used it to create mods via TES5Edit for Skyrim, and I've hit a wee snag with modding Dark Souls, and I figured flexin' me Pascalerrific muscles would be a good exercise.</p> <p>But, uh, it's all buggered right from the get go. Lazarus supposedly has this "Form Window" feature, where ya can just click one of the icons and then click on the IDE, and bam. Automated GUI creation.</p> <p>I ain't got that. The window isn't up, and the option to open it is grey'd out. 'Eres an image to demonstrate:</p> <p><a href="http://i.stack.imgur.com/rBvYu.png" rel="nofollow">'Ere 'tis, lads.</a></p> <p>Bit sad that, right from the get go, I'm flummoxed. LEND ME YO' EARS, MA HOMIES! A BROTHA NEEDS AID!</p> <p><em>Achem</em> So, uh, what do I do to enable it? Google gives absolutely nothing in regards to using Lazarus in pretty much any way, so that bridge wasn't even built 'afore it was burnt.</p>
0debug
static int do_virtio_net_can_receive(VirtIONet *n, int bufsize) { if (!virtio_queue_ready(n->rx_vq) || !(n->vdev.status & VIRTIO_CONFIG_S_DRIVER_OK)) return 0; if (virtio_queue_empty(n->rx_vq) || (n->mergeable_rx_bufs && !virtqueue_avail_bytes(n->rx_vq, bufsize, 0))) { virtio_queue_set_notification(n->rx_vq, 1); return 0; } virtio_queue_set_notification(n->rx_vq, 0); return 1; }
1threat
How to get data of an specefic row or column in sql : <p>Example</p> <pre><code>id name surname 0 Alex A 1 Mark B 2 Bill C </code></pre> <p>Let's suppose that I want to get the name and surname where id equals 1 in Java, how can I get the values of each column</p>
0debug
void address_space_init(AddressSpace *as, MemoryRegion *root) { memory_region_transaction_begin(); as->root = root; as->current_map = g_new(FlatView, 1); flatview_init(as->current_map); QTAILQ_INSERT_TAIL(&address_spaces, as, address_spaces_link); as->name = NULL; memory_region_transaction_commit(); address_space_init_dispatch(as); }
1threat
Create Shapes on a website given an input in Javascript : <p>Suppose I have an array in Javascript with integer values: <code>[10, 20, 30, 40, 50]</code>. My goal is to have rectangles side by side that have a width of 10 pixels and a height of the pixels specified in the array. In this case, I would have a rectangle 10 pixels by 10 pixels. Right of the 10x10 rectangle is a rectangle 10x20 and then 10x30 and so on and so forth. What would I code in the HTML, CSS, and JS file to make this. Right now, the only idea I can think of is an HTML table with shapes in it. The picture below is an example of the output I would like:</p> <p><a href="https://i.stack.imgur.com/p2iLD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p2iLD.png" alt="enter image description here"></a></p>
0debug
Are C++17 Parallel Algorithms implemented already? : <p>I was trying to play around with the new parallel library features proposed in the C++17 standard, but I couldn't get it to work. I tried compiling with the up-to-date versions of <code>g++ 8.1.1</code> and <code>clang++-6.0</code> and <code>-std=c++17</code>, but neither seemed to support <code>#include &lt;execution&gt;</code>, <code>std::execution::par</code> or anything similar. </p> <p>When looking at the <a href="https://en.cppreference.com/w/cpp/experimental/parallelism" rel="noreferrer">cppreference</a> for parallel algorithms there is a long list of algorithms, claiming </p> <blockquote> <p>Technical specification provides parallelized versions of the following 69 algorithms from <code>algorithm</code>, <code>numeric</code> and <code>memory</code>: <em>( ... long list ...)</em></p> </blockquote> <p>which sounds like the algorithms are ready <em>'on paper'</em>, but not ready to use yet?</p> <p>In <a href="https://stackoverflow.com/questions/42567998/how-do-i-use-the-new-c17-execution-policies">this SO question</a> from over a year ago the answers claim these features hadn't been implemented yet. But by now I would have expected to see some kind of implementation. Is there anything we can use already?</p>
0debug
Search into database based on user input : <p>I am a newbie in PHP. I am working on searching function, but it does not work well and I could not find why. The problem is; the <strong>$query has been sent and accepted well</strong> however it <strong>could not find the $query in the database</strong> even though the <strong>$query existed</strong>. I think, the <strong>$sql command might be wrong somewhere</strong>, but <strong>could not find it</strong> anyway. Thank you.</p> <p>Here is my code: asset_search.php</p> <pre><code>&lt;?php //Search data in database $query = $_GET['query']; $min_length = 3; if(strlen($query) &gt;= $min_length) { //$query = htmlspecialchars($query); //$query = mysql_real_escape_string($query); $query = strtoupper($query); $sql = "SELECT * FROM asset WHERE ('asset_name' LIKE '%".$query."%')"; $result = mysqli_query($conn, $sql); $row_cnt = mysqli_num_rows($result); $count = 0; if($row_cnt &gt; 0) { echo "&lt;table style='padding: 5px; font-size: 15px;'&gt;"; echo "&lt;tr&gt;&lt;th style='width: 30px; border: 1px solid black; align:'center''&gt;No&lt;/th&gt;"; echo "&lt;th style='width: 200px; border: 1px solid black; align:'center''&gt;Status&lt;/th&gt;"; echo "&lt;th style='width: 200px; border: 1px solid black; align:'center''&gt;Asset Sub-identifier&lt;/th&gt;"; echo "&lt;th style='width: 200px; border: 1px solid black; align:'center''&gt;Asset Name&lt;/th&gt;"; echo "&lt;th style='width: 200px; border: 1px solid black; align:'center''&gt;Asset Type&lt;/th&gt;"; echo "&lt;th style='width: 200px; border: 1px solid black; align:'center''&gt;Brand&lt;/th&gt;"; echo "&lt;th style='width: 200px; border: 1px solid black; align:'center''&gt;Service Tag/ Product Tag/ Product S/N&lt;/th&gt;"; echo "&lt;th style='width: 200px; border: 1px solid black; align:'center''&gt;CSM Tag&lt;/th&gt;"; echo "&lt;th style='width: 200px; border: 1px solid black; align:'center''&gt;Action&lt;/th&gt;&lt;/tr&gt;"; while($row = mysqli_fetch_assoc($result)) { echo "&lt;tr&gt;&lt;td align='center'&gt;" . ++$count . "&lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $row["asset_status"] . "&lt;/td&gt;"; echo "&lt;td align='center'&gt;&lt;a href='asset_viewfull.php?asset_id=" . $row["asset_id"] . "'&gt;&lt;ins&gt;" . $row["asset_subidentifier"] . "&lt;/a&gt;&lt;/ins&gt;&lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $row["asset_name"] . "&lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $row["asset_type"] . "&lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $row["asset_brand"] . "&lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $row["asset_sertag"] . "&lt;/td&gt;"; echo "&lt;td align='center'&gt;" . $row["asset_csmtag"] . "&lt;/td&gt;"; if($row["asset_status"] == "DISPOSE") { echo "&lt;td align='center'&gt;&lt;a href='asset_delete.php?asset_id=" . $row["asset_id"] . "'&gt;Delete&lt;/a&gt;"; echo " "; echo "&lt;a href='asset_print.php?asset_id=" . $row["asset_id"] . "'&gt;Print&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;"; }else { echo "&lt;td align='center'&gt;&lt;a href='asset_editform.php?asset_id=" . $row["asset_id"] . "'&gt;Edit&lt;/a&gt;"; echo " "; echo "&lt;a href='asset_delete.php?asset_id=" . $row["asset_id"] . "'&gt;Delete&lt;/a&gt;"; echo " "; echo "&lt;a href='asset_disposeform.php?asset_id=" . $row["asset_id"] . "'&gt;Dispose&lt;/a&gt;"; echo " "; echo "&lt;a href='asset_print.php?asset_id=" . $row["asset_id"] . "'&gt;Print&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;"; } } }else { echo "&lt;tr&gt; There is no asset in the database &lt;/tr&gt;"; } echo "&lt;/table&gt;"; } else { echo "&lt;script languange = 'Javascript'&gt; alert('Minimum length is' .$min_length);&lt;/script&gt;"; } //Close connection mysqli_close($conn); $count = 0; </code></pre> <p>?></p>
0debug
How to find last git commit before a merge : <p>After I have done a merge to my master branch from a working branch with git, I sometimes want to find to find the last commit on master before the merge happened. How do I do this?</p>
0debug
How does append() work in this code snippet? Confused with a particular variable : <p>Can someone explain this code to me? More specifically, the part about lead.append([sum1 - sum2 , 1]) and print(ans[1],ans[0]). </p> <p>I do not understand the "1" in "lead.append([sum1 - sum2 , 1])"</p> <p>I, also, do not understand the "1" and "0" in print(ans[1],ans[0]). </p> <pre class="lang-py prettyprint-override"><code>lead = [] sum1 , sum2 = 0 , 0 for i in range(int(input())): a1 , a2 = map(int, input().split()) sum1 += a1 sum2 += a2 if sum1&gt;sum2: lead.append([sum1 - sum2 , 1]) else: lead.append([sum2 - sum1 , 2]) ans = max(lead) print(ans[1],ans[0]) </code></pre> <p>Thanks.</p>
0debug
Go:get fragment values in url : sample code <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> func main() { fmt.Print("starting box web server...") http.HandleFunc("/", landing) http.HandleFunc("/handle", handler) http.ListenAndServe(connector_port, nil) } func landing(w http.ResponseWriter, r *http.Request) { fmt.Println("redirecting to login for authentication...") http.Redirect(w, r, "http://*****urlfortoken", http.StatusFound) } func handler(w http.ResponseWriter, r *http.Request) { bodyresnew_folder, _ := ioutil.ReadAll(r.Body) fmt.Println("response Body:", string(bodyresnew_folder)) fmt.Println("1", r.GetBody) fmt.Println("2", r.URL.String()) fmt.Println("3", r.URL.Fragment) fmt.Println("4", r.URL.Query().Get("access_token")) fmt.Println("inside handle function,", r.Form.Get("access_token")) fmt.Println("finished processing all files please close this server manually") } <!-- end snippet --> i tried above code to get fragment in Url but was unsuccessfull. Url causing execution of handler function is ** http://localhost:8080/handle#access_token=*1234$111&token_type=bearer&expires_in=3600&scope=onedrive.readwrite&user_id=hashed** now in this url i want to get the value of fragment access_token in handler function which is basically an http handler
0debug
Do function parameters take up local memory space? : <p>In the following example, am I taking up any local memory space in the function "add"? And if not, where are the parameter variables stored in memory?</p> <pre><code>void add(int *a, int *b, int *result){ *result = *a + *b; } int main(){ int a = 1, b = 2, result; add(&amp;a, &amp;b, &amp;result); printf("Result = %d\n", result); return 0; } </code></pre>
0debug
jQuery click() - not working more than once : Beginner stuff :) I want to add auto-scrolling to header images here: https://listify-demos.astoundify.com/classic/listing/the-drake-hotel/ So `document.querySelector('.slick-next').click();` can do the click and I'm trying to get it working in a loop. Running the following in JS console: function myscroller() { document.querySelector('.slick-next').click(); } for (var i = 1; i < 10; ++i) { myscroller(); } I thought it's supposed to click the next button 10 times, but it clicks it only once. What's that I'm missing?
0debug
void ff_cavs_init_top_lines(AVSContext *h) { h->top_qp = av_malloc( h->mb_width); h->top_mv[0] = av_malloc((h->mb_width*2+1)*sizeof(cavs_vector)); h->top_mv[1] = av_malloc((h->mb_width*2+1)*sizeof(cavs_vector)); h->top_pred_Y = av_malloc( h->mb_width*2*sizeof(*h->top_pred_Y)); h->top_border_y = av_malloc((h->mb_width+1)*16); h->top_border_u = av_malloc( h->mb_width * 10); h->top_border_v = av_malloc( h->mb_width * 10); h->col_mv = av_malloc( h->mb_width*h->mb_height*4*sizeof(cavs_vector)); h->col_type_base = av_malloc(h->mb_width*h->mb_height); h->block = av_mallocz(64*sizeof(int16_t)); }
1threat
int bdrv_snapshot_create(BlockDriverState *bs, QEMUSnapshotInfo *sn_info) { BlockDriver *drv = bs->drv; if (!drv) return -ENOMEDIUM; if (drv->bdrv_snapshot_create) return drv->bdrv_snapshot_create(bs, sn_info); if (bs->file) return bdrv_snapshot_create(bs->file, sn_info); return -ENOTSUP; }
1threat
the result of my code is 0 and i don't know why, can someone help me? : Can somebody help me please. The question is to print out the smallest prime number but bigger than other not prime number. after hours of work, my code print out 0 no matter what i type in, can anyone tell me where i go wrong? sorry for bad english, i have try to translate my code into english for you. Hope it help (i post this yesterday but because of my lack of communication ability, no one seem to firgue out the problem, i have tried harder, hoping today will be different) for example: 4 7 8 9 then the result is 9 because 9 is the smallest prime number and bigger then the biggest non-prime number ( which is 8) here is my code: #include <iostream> #include <cmath> #include <complex> using namespace std; void TypeIn(int a[] ,int &n) { cout<< "\nType in n: "; cin >> n; for(int i=0; i<n; i++) { cout << "a[" << i << "]= "; cin >> a[i]; } } int CheckPrimeNum(int Number) { int Count=0; int Divisor =1; while (Number >= Divisor) { if(Number % Divisor == 0) { Count++; } Divisor++; } return Count; } int BiggestNotPrime(int a[], int n) { int BiggestNotPrime =0; for( int i=0; i<n; i++) { if( CheckPrimeNum(a[i]) !=2) { BiggestNotPrime = a[i]; break; } } if(BiggestNotPrime ==0) { return 0; } else { for( int i=0; i<n; i++) { if(CheckPrimeNum(a[i])!=2 && a[i] > BiggestNotPrime) BiggestNotPrime =a[i]; } return BiggestNotPrime; } } int main() { int n; int a[100]; TypeIn(a,n); int SmallestPrimeLocation =0; for(int i=0; i<n; i++) { if(CheckPrimeNum(a[i])==2 && a[i]> BiggestNotPrime(a,n)) SmallestPrimeLocation =i; break; } if(SmallestPrimeLocation ==0) { cout << 0; } else { for(int i=SmallestPrimeLocation; i<n; i++) { if(a[i]>BiggestNotPrime(a,n) && a[i] < a[SmallestPrimeLocation] && CheckPrimeNum(a[i])==2) { SmallestPrimeLocation=i; } } cout << a[SmallestPrimeLocation]; } return 0; }
0debug
Geometric Distribution - Expected number of rolls of a die before a value occurs : <p>Say I want to calculate the expected number of rolls of a die before a particular value is rolled, let's say a 5. I know this involves geometric distribution. Is there an R function that can calculate this?</p>
0debug
Sql Server conditional within a condition : I want to say 'Where the first 2 letters are not 10 and for those that do start with 10 only exclude the ones from 2018 onward' where (left(c.DealCode, 2) <> '10' and estyear > 2018) Does not work.. What am I missing ?
0debug
ivshmem_client_parse_args(IvshmemClientArgs *args, int argc, char *argv[]) { int c; while ((c = getopt(argc, argv, "h" "v" "S:" )) != -1) { switch (c) { case 'h': ivshmem_client_usage(argv[0], 0); break; case 'v': args->verbose = 1; break; case 'S': args->unix_sock_path = strdup(optarg); break; default: ivshmem_client_usage(argv[0], 1); break; } } }
1threat