problem
stringlengths
26
131k
labels
class label
2 classes
static bool check_solid_tile(VncState *vs, int x, int y, int w, int h, uint32_t* color, bool samecolor) { VncDisplay *vd = vs->vd; switch(vd->server->pf.bytes_per_pixel) { case 4: return check_solid_tile32(vs, x, y, w, h, color, samecolor); case 2: return check_solid_tile16(vs, x, y, w, h, color, samecolor); default: return check_solid_tile8(vs, x, y, w, h, color, samecolor); } }
1threat
static void net_init_tap_one(const NetdevTapOptions *tap, NetClientState *peer, const char *model, const char *name, const char *ifname, const char *script, const char *downscript, const char *vhostfdname, int vnet_hdr, int fd, Error **errp) { Error *err = NULL; TAPState *s = net_tap_fd_init(peer, model, name, fd, vnet_hdr); int vhostfd; tap_set_sndbuf(s->fd, tap, &err); if (err) { error_propagate(errp, err); return; } if (tap->has_fd || tap->has_fds) { snprintf(s->nc.info_str, sizeof(s->nc.info_str), "fd=%d", fd); } else if (tap->has_helper) { snprintf(s->nc.info_str, sizeof(s->nc.info_str), "helper=%s", tap->helper); } else { snprintf(s->nc.info_str, sizeof(s->nc.info_str), "ifname=%s,script=%s,downscript=%s", ifname, script, downscript); if (strcmp(downscript, "no") != 0) { snprintf(s->down_script, sizeof(s->down_script), "%s", downscript); snprintf(s->down_script_arg, sizeof(s->down_script_arg), "%s", ifname); } } if (tap->has_vhost ? tap->vhost : vhostfdname || (tap->has_vhostforce && tap->vhostforce)) { VhostNetOptions options; options.backend_type = VHOST_BACKEND_TYPE_KERNEL; options.net_backend = &s->nc; options.force = tap->has_vhostforce && tap->vhostforce; if (tap->has_vhostfd || tap->has_vhostfds) { vhostfd = monitor_fd_param(cur_mon, vhostfdname, &err); if (vhostfd == -1) { error_propagate(errp, err); return; } } else { vhostfd = open("/dev/vhost-net", O_RDWR); if (vhostfd < 0) { error_setg_errno(errp, errno, "tap: open vhost char device failed"); return; } } options.opaque = (void *)(uintptr_t)vhostfd; s->vhost_net = vhost_net_init(&options); if (!s->vhost_net) { error_setg(errp, "vhost-net requested but could not be initialized"); return; } } else if (tap->has_vhostfd || tap->has_vhostfds) { error_setg(errp, "vhostfd= is not valid without vhost"); } }
1threat
static void pfpu_start(MilkymistPFPUState *s) { int x, y; int i; for (y = 0; y <= s->regs[R_VMESHLAST]; y++) { for (x = 0; x <= s->regs[R_HMESHLAST]; x++) { D_EXEC(qemu_log("\nprocessing x=%d y=%d\n", x, y)); s->gp_regs[GPR_X] = x; s->gp_regs[GPR_Y] = y; i = 0; while (pfpu_decode_insn(s)) { if (i++ >= MICROCODE_WORDS) { error_report("milkymist_pfpu: too many instructions " "executed in microcode. No VECTOUT?"); break; } } s->regs[R_PC] = 0; } } s->regs[R_VERTICES] = x * y; trace_milkymist_pfpu_pulse_irq(); qemu_irq_pulse(s->irq); }
1threat
How to make a "Rate this app" link in React Native app? : <p>How to properly link a user to reviews page at App Store app in React Native application on iOS?</p>
0debug
Failed to load org.apache.spark.examples. I am getting this error, Please help me to run a spark job(scala) : Command: bin/run-example /home/datadotz/streaming/wc_str.scala localhost 9999 Error: Failed to load org.apache.spark.examples./home/datadotz/streami java.lang.ClassNotFoundException: org.apache.spark.examples.
0debug
Java Mission Control from JDK 1.8.0_161 frozen upon startup on Mac OS X : <p>I'm trying to launch Java Mission Control as provided in the JDK 1.8.0_161 on Mac OS X High Sierra (10.13.2, with Supplemental Update of January 2018) and the JMC application is frozen, i.e. I'm unable to browse in the JVM Browser panel.</p> <p>As I've other former JDK installed, therefore I've checked JMC with the following versions with success:</p> <ul> <li>1.8.0_121</li> <li>1.8.0_144</li> <li>1.8.0_151</li> </ul> <p>So the problem is very specific to the JDK 1.8.0_161.</p> <p>(To see your JDKs, run the command <code>/usr/libexec/java_home -V</code>)</p> <p>(To run a former JMC, i.e. <code>/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home/bin/jmc</code>)</p> <p>As a side verification, I've run the JMC of the JDK 1.8.0_161 on Windows 10 with success.</p> <p>So do you experience the same issue ?</p> <p>Is there some settings to tweak to have it working ? (E.g. would it be an issue related to Mac OS X Gatekeeper !?)</p> <p>And how to report it to Oracle properly ... I've searched their bug database without success, and when I try to submit a bug, I cannot figure which would be the right subcategory (c.f. <a href="https://bugreport.java.com/submit_intro.do" rel="noreferrer">https://bugreport.java.com/submit_intro.do</a>), as JMC is not listed in the TOOLS section ... Any advice !?</p>
0debug
754 single precision 1-bit sign 8-bit exponent 23-bit fraction, What is the binary representation of 0.25*2^(-128)? : 754 single precision 1-bit sign 8-bit exponent 23-bit fraction, What is the binary representation of 0.25*2^(-128)=2^(-130)? by using the formula: **exponent-bias=log(given number)** and also **fraction=-1+(given number)/2^(exponent-bias)** doesn't give the right answer....why? And how to solve this question?
0debug
What is the bug in this code Can anyone help me out to get the correct output : As a freelancer I picked up a Project but I got stuck with this one can anyone help me out to get this code code to get the dezired output. The Code is : n = int(input('\n Enter Your Value of N : ')) answer = [[1]] for i in range(2, n+1): t = ([i]*((2*i)-3)) answer.insert(n,t) for a in answer: a.insert(0,i) a.append(i) answerfinal = [] for a in answer: answerfinal.append("".join(str(a))) for a in answerfinal: print(a) The Dezired output is to be like This : Input : 5 Output : 555555555 544444445 543333345 543222345 543212345 543222345 543333345 544444445 555555555 Please help me out to get this code corrected as this is my work can anyone help????
0debug
void net_client_uninit(NICInfo *nd) { nd->vlan->nb_guest_devs--; nb_nics--; nd->used = 0; free((void *)nd->model); }
1threat
if we get employee list using asp.net mvc then why we use webapi to call it using jquery ajax : <p>if we get employee list using asp.net mvc using jquery ajax then why we use webapi to call it using jquery ajax to do same task.I am new to mvc and services.</p>
0debug
Java retreive and compare two dates plus time : So basically I want to ask the user for a date and time of departure then ask the user for time of arrival to compare and get duration. I was wondering what kind of method of input would be good for this input. I was thinking either a multi drop down box or some kind of scrolling bar type deal. Can any one give me and suggestion on a good input method and what it is called? Thank you
0debug
static void tswap_siginfo(target_siginfo_t *tinfo, const target_siginfo_t *info) { int sig = info->si_signo; tinfo->si_signo = tswap32(sig); tinfo->si_errno = tswap32(info->si_errno); tinfo->si_code = tswap32(info->si_code); if (sig == TARGET_SIGILL || sig == TARGET_SIGFPE || sig == TARGET_SIGSEGV || sig == TARGET_SIGBUS || sig == TARGET_SIGTRAP) { tinfo->_sifields._sigfault._addr = tswapal(info->_sifields._sigfault._addr); } else if (sig == TARGET_SIGIO) { tinfo->_sifields._sigpoll._band = tswap32(info->_sifields._sigpoll._band); tinfo->_sifields._sigpoll._fd = tswap32(info->_sifields._sigpoll._fd); } else if (sig == TARGET_SIGCHLD) { tinfo->_sifields._sigchld._pid = tswap32(info->_sifields._sigchld._pid); tinfo->_sifields._sigchld._uid = tswap32(info->_sifields._sigchld._uid); tinfo->_sifields._sigchld._status = tswap32(info->_sifields._sigchld._status); tinfo->_sifields._sigchld._utime = tswapal(info->_sifields._sigchld._utime); tinfo->_sifields._sigchld._stime = tswapal(info->_sifields._sigchld._stime); } else if (sig >= TARGET_SIGRTMIN) { tinfo->_sifields._rt._pid = tswap32(info->_sifields._rt._pid); tinfo->_sifields._rt._uid = tswap32(info->_sifields._rt._uid); tinfo->_sifields._rt._sigval.sival_ptr = tswapal(info->_sifields._rt._sigval.sival_ptr); } }
1threat
Add kink to logo - Bootstrap : I am trying to add a link back to the home page index.php from my logo, Cant figure it out. Appreciate any assistance, Thanks <div class="container-fluid" style="background-color:black;"><img class="img-responsive" src="assets/img/logo.png" data-bs-hover-animate="pulse" style="padding-top:20px;padding-bottom:20px;"></div>
0debug
static void numa_stat_memory_devices(uint64_t node_mem[]) { MemoryDeviceInfoList *info_list = NULL; MemoryDeviceInfoList **prev = &info_list; MemoryDeviceInfoList *info; qmp_pc_dimm_device_list(qdev_get_machine(), &prev); for (info = info_list; info; info = info->next) { MemoryDeviceInfo *value = info->value; if (value) { switch (value->type) { case MEMORY_DEVICE_INFO_KIND_DIMM: node_mem[value->u.dimm->node] += value->u.dimm->size; break; default: break; } } } qapi_free_MemoryDeviceInfoList(info_list); }
1threat
Python: Create automated strictly-designed multi-page .pdf report from .html : <p>What are good Python-based options to create strictly designed .pdf reports from .html?</p> <p>I've attached a draft .pdf to illustrate the following points:</p> <ul> <li>The design of the report is rather strictly designed. In other words "Looks matter".</li> <li>The report contains complex vector graphics (package: <a href="http://matplotlib.org/" rel="noreferrer">Matplotlib</a>).These may slightly differ in size .</li> <li>The report contains images.</li> <li>The report contains a large number of numbers / strings filled in dynamically.</li> <li>Optimally, the solution would use open source packages.</li> <li>We create our .html with <a href="https://www.djangoproject.com/" rel="noreferrer">Django</a>.</li> <li>The report may span multiple pages.</li> </ul> <p>It looks as if there was already a good amount of very diverse packages facilitating reporting. Just to name a few, there are <a href="https://github.com/xhtml2pdf/xhtml2pdf" rel="noreferrer">xhtml2pdf</a>, <a href="http://weasyprint.org/" rel="noreferrer">weasyprint</a>, <a href="https://djangopackages.org/packages/p/django-wkhtmltopdf/" rel="noreferrer">django-wkhtmltopdf</a>.</p> <p>In my experience, it’s easy with these tools to create a .pdf from your content. The hard part comes when the .pdf needs to fall into a highly-defined design structure as in our case. Unfortunately, I was not able to find example .pdfs for the different pdf generation packages that have a highly designed structure.</p> <p>What is your experience with this? Which options worked well for you? Are there well done complex examples that I’ve overlooked?</p> <p><a href="https://i.stack.imgur.com/GM8cl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GM8cl.png" alt="Some example of a strictly-designed &quot;Looks matter&quot; report"></a></p>
0debug
I have converted dll to exe and build then it shows error exe does not contains static main method suitable for an entry point : <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace abc { public class Class1 { public void display() { Console.WriteLine("Hallo"); } public static void main(string[] args) { Class1 obj = new Class1(); obj.display(); } } } </code></pre> <p>I have created one static method and called in main method to check how dll converted to exe work .</p>
0debug
using statment with array require Dispose : The following code using the "using" statement was meant to avoid some sort of memory leak which renders the code slow over long files: var db = new EntityContext(); var cubos = db.CubosTrabalhados; var cubo = new CuboTrabalhado(); string[] lines = File.ReadAllLines(Files.cuboHistorico, Encoding.Default); bool header = true; int i = 2; foreach (string line in lines) { if (header) header = false; else { using (var reg = line.Split(';')) { cubo.Pedido = reg[0]; cubo.DataPedido = Select.ParseDate(reg[3]); cubo.Cliente = reg[4]; cubo.UF = Select.Uf(reg[5]); cubo.Cidade = reg[6]; cubo.Regiao = reg[7]; cubo.Codigo = reg[8]; cubo.Produto = reg[9]; ... cubo.VlCom = Select.ParseFloat(reg[63]); cubo.Cnpj = reg[64]; cubo.CodProdOriginal = reg[65]; cubos.Add(cubo); db.SaveChanges(); } } } But the line with the "using" statement give the error: "'string[]': type used in a using statement must be implicitly convertible to 'System.IDisposable'" As "Split" is regular part of dot.net I have no clue whatsoever how to implement of the IDisposable interface in such a case. How does it works?
0debug
running JSON from pyton issues : Construction like this failed when running json from pyton: cut test.json "01-cd":{"command": "mkdir -p /perm/opt/ODS", "cwd": "/"} output: File "parse.py", line 8, in <module> data = json.load(jdata) File "/usr/lib64/python2.7/json/__init__.py", line 291, in load **kw) File "/usr/lib64/python2.7/json/__init__.py", line 339, in loads return _default_decoder.decode(s) File "/usr/lib64/python2.7/json/decoder.py", line 367, in decode raise ValueError(errmsg("Extra data", s, end, len(s))) ValueError: Extra data: line 1 column 24 - line 2 column 1 (char 23 - 76 pyton parse.py test.json import json import sys import subprocess from pprint import pprint jdata = open(sys.argv[1]) data = json.load(jdata) print "start" subprocess.call(data['script'], shell=True) print "end" jdata.close() TIA
0debug
static int video_thread(void *arg) { VideoState *is = arg; AVPacket pkt1, *pkt = &pkt1; int len1, got_picture; AVFrame *frame= avcodec_alloc_frame(); double pts; for(;;) { while (is->paused && !is->videoq.abort_request) { SDL_Delay(10); } if (packet_queue_get(&is->videoq, pkt, 1) < 0) break; if(pkt->data == flush_pkt.data){ avcodec_flush_buffers(is->video_st->codec); is->last_dts_for_fault_detection= is->last_pts_for_fault_detection= INT64_MIN; continue; } is->video_st->codec->reordered_opaque= pkt->pts; len1 = avcodec_decode_video2(is->video_st->codec, frame, &got_picture, pkt); if(pkt->dts != AV_NOPTS_VALUE){ is->faulty_dts += pkt->dts <= is->last_dts_for_fault_detection; is->last_dts_for_fault_detection= pkt->dts; } if(frame->reordered_opaque != AV_NOPTS_VALUE){ is->faulty_pts += frame->reordered_opaque <= is->last_pts_for_fault_detection; is->last_pts_for_fault_detection= frame->reordered_opaque; } if( ( decoder_reorder_pts==1 || decoder_reorder_pts && is->faulty_pts<is->faulty_dts || pkt->dts == AV_NOPTS_VALUE) && frame->reordered_opaque != AV_NOPTS_VALUE) pts= frame->reordered_opaque; else if(pkt->dts != AV_NOPTS_VALUE) pts= pkt->dts; else pts= 0; pts *= av_q2d(is->video_st->time_base); if (got_picture) { if (output_picture2(is, frame, pts) < 0) goto the_end; } av_free_packet(pkt); if (step) if (cur_stream) stream_pause(cur_stream); } the_end: av_free(frame); return 0; }
1threat
Detecting incorrect assertion methods : <p>During one of the recent code reviews, I've stumbled upon the problem that was not immediately easy to spot - there was <code>assertTrue()</code> used instead of <code>assertEqual()</code> that basically resulted into a test that was <em>testing nothing</em>. Here is a simplified example:</p> <pre><code>from unittest import TestCase class MyTestCase(TestCase): def test_two_things_equal(self): self.assertTrue("a", "b") </code></pre> <p>The problem here is that the test would pass; and technically, the code is valid, since <a href="https://docs.python.org/3/library/unittest.html#unittest.TestCase.assertTrue" rel="noreferrer"><code>assertTrue</code> has this optional <code>msg</code> argument</a> (that gets the <code>"b"</code> value in this case).</p> <p>Can we do better than rely on the person reviewing the code to spot this kind of problems? Is there a way to <em>auto-detect</em> it using static code analysis with <code>flake8</code> or <code>pylint</code>?</p>
0debug
IntelliJ + Spring Web MVC : <p>I have problem with IntelliJ 2016.1.3 and Spring Web MVC integration. Steps I've made:</p> <ol> <li>File -> New -> Project... -> Maven (no archetype)</li> <li>GroupId = test ArtifactId = app</li> <li>Project name = App and Finish.</li> <li>I added to pom.xml &lt; packaging > war &lt; /packaging ></li> <li><p>I added to pom.xml dependencies <br/></p> <pre> &ltdependency&gt &ltgroupId&gtorg.springframework&lt/groupId&gt &ltartifactId&gtspring-webmvc&lt/artifactId&gt &ltversion&gt4.1.6.RELEASE&lt/version&gt &lt/dependency&gt &ltdependency&gt &ltgroupId&gtjavax.servlet&lt/groupId&gt &ltartifactId&gtjstl&lt/artifactId&gt &ltversion&gt1.2&lt/version&gt &lt/dependency&gt &ltdependency&gt &ltgroupId&gtjavax.servlet&lt/groupId&gt &ltartifactId&gtjavax.servlet-api&lt/artifactId&gt &ltversion&gt3.1.0&lt/version&gt &ltscope&gtprovided&lt/scope&gt &lt/dependency&gt </pre></li> <li><p>Next I added modules into project (right click on project name -> Add Framework Support... ). I selected Spring MVC and Download (Configure... - selected all items).</p></li> <li><p>I created controller class HomeController.class</p> <pre> package test.app; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; @Controller public class HomeController { @RequestMapping(value="/") public String test() { return "test"; } } </pre></li> <li><p>I created webapp\WEB-INF and put there web.xml</p> <pre> &ltweb-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt &ltservlet&gt &ltservlet-name&gtWebServlet&lt/servlet-name&gt &ltservlet-class&gtorg.springframework.web.servlet.DispatcherServlet&lt/servlet-class&gt &ltinit-param&gt &ltparam-name&gtcontextConfigLocation&lt/param-name&gt &ltparam-value&gt/WEB-INF/dispatcher-servlet.xml&lt/param-value&gt &lt/init-param&gt &lt/servlet&gt <pre><code>&amp;ltservlet-mapping&amp;gt &amp;ltservlet-name&amp;gtWebServlet&amp;lt/servlet-name&amp;gt &amp;lturl-pattern&amp;gt/&amp;lt/url-pattern&amp;gt &amp;lt/servlet-mapping&amp;gt </code></pre> &lt/web-app&gt </pre></li> <li><p>Into webapp\WEB-INF I put dispatcher-servlet.xml</p> <pre> &lt?xml version="1.0" encoding="UTF-8"?&gt &ltbeans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd"&gt <pre><code>&amp;ltmvc:annotation-driven /&amp;gt &amp;ltcontext:component-scan base-package="test.app" /&amp;gt &amp;ltbean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&amp;gt &amp;ltproperty name="prefix" value="/WEB-INF/views/" /&amp;gt &amp;ltproperty name="suffix" value=".jsp" /&amp;gt &amp;lt/bean&amp;gt </code></pre> &lt/beans&gt </pre></li> <li><p>Finally I added test.jsp file into webapp\WEB-INF\views. In addition I had to add module dependency (F4 -> modules -> dependencies -> + -> library -> from maven -> typed javax.servlet:jstl:1.2)</p></li> <li>Next step should be run application. I had to edit configurations (down arrow next to green arrow) -> + -> TomcatServer -> Local and I got warning No artifacts marked for deployment. Unfortunatelly I can't fix this problem. I have Fix button but after I press this I get Deployment tab and don't what to do.</li> </ol> <p>Please help me with deployment configuration and tell me is my way of creating spring web application in IntelliJ good or have you got another better way. I need step by step tutorial because I watched some movies on youtube and I saw options I haven't in my Intellij or they are hidden and I can't find them. Best regards </p>
0debug
How to convert recursion to loop. Its take longer time than normal time. Its a slow process. how to make it more first using java 8 : **How to convert recursion to loop. Its take longer time than normal time. Its a slow process. how to make it more first using java 8.** public class MyClass{ public static void main(String args[]) { int[] testValues = { 3,5,10}; for (int i = 0; i < testValues.length; ++i) { System.out.println(first(testValues[i])); } } public static int first(int a) { int b; if (a <= 1) { if (a == 1) { b = convertOne(a); } else { b = convertTwo(a - 1); } } else { return next(a); } return b; } public static int convertOne(int c) { return ++c; } public static int convertTwo(int d) { int i = 1; for (i = d * 11; i > d; i--) { i--; } return i; } public static int next(int e) { int container = first(e - 1); return container + first(e - 2); } } Its a slow process. how to make it more first using java 8.
0debug
calling success, error callbacks using subscribe in angular2? : <p>Giving responce.json () is not function for my case</p> <p><strong>component.ts</strong></p> <pre><code> this.AuthService.loginAuth(this.data).subscribe(function(response) { console.log("Success Response" + response) }, function(error) { console.log("Error happened" + error) }, function() { console.log("the subscription is completed") }); </code></pre> <p><strong>AuthService.ts</strong></p> <pre><code> loginAuth(data): Observable&lt;any&gt; { return this.request('POST', 'http://192.168.2.122/bapi/public/api/auth/login', data,{ headers:this. headers }) .map(response =&gt; response) //...errors if any .catch(this.handleError); } </code></pre> <p>Giving [object,objet] If I put map function service like .map(response => response.json()) is giving error like responce.json () is not function</p> <p>Please help me</p>
0debug
I should get back distance, duration and directions as result when i pass an intent with origin and destination in android studio : <p>I am working on an android application in which during the registration of the user i will get his location and i had a starting point. </p> <ul> <li>I am thinking of sending an intent to Google maps and getting back required result from it. How can i extract the distance, duration and directions from the result of intent?</li> <li>Is there any other way better than this?</li> </ul>
0debug
static inline void unpack_coeffs(SnowContext *s, SubBand *b, SubBand * parent, int orientation){ const int w= b->width; const int h= b->height; int x,y; if(1){ int run; x_and_coeff *xc= b->x_coeff; x_and_coeff *prev_xc= NULL; x_and_coeff *prev2_xc= xc; x_and_coeff *parent_xc= parent ? parent->x_coeff : NULL; x_and_coeff *prev_parent_xc= parent_xc; run= get_symbol2(&s->c, b->state[1], 3); for(y=0; y<h; y++){ int v=0; int lt=0, t=0, rt=0; if(y && prev_xc->x == 0){ rt= prev_xc->coeff; } for(x=0; x<w; x++){ int p=0; const int l= v; lt= t; t= rt; if(y){ if(prev_xc->x <= x) prev_xc++; if(prev_xc->x == x + 1) rt= prev_xc->coeff; else rt=0; } if(parent_xc){ if(x>>1 > parent_xc->x){ parent_xc++; } if(x>>1 == parent_xc->x){ p= parent_xc->coeff; } } if(l|lt|t|rt|p){ int context= av_log2(3*(l>>1) + (lt>>1) + (t&~1) + (rt>>1) + (p>>1)); v=get_rac(&s->c, &b->state[0][context]); if(v){ v= 2*(get_symbol2(&s->c, b->state[context + 2], context-4) + 1); v+=get_rac(&s->c, &b->state[0][16 + 1 + 3 + quant3bA[l&0xFF] + 3*quant3bA[t&0xFF]]); xc->x=x; (xc++)->coeff= v; } }else{ if(!run){ run= get_symbol2(&s->c, b->state[1], 3); v= 2*(get_symbol2(&s->c, b->state[0 + 2], 0-4) + 1); v+=get_rac(&s->c, &b->state[0][16 + 1 + 3]); xc->x=x; (xc++)->coeff= v; }else{ int max_run; run--; v=0; if(y) max_run= FFMIN(run, prev_xc->x - x - 2); else max_run= FFMIN(run, w-x-1); if(parent_xc) max_run= FFMIN(max_run, 2*parent_xc->x - x - 1); x+= max_run; run-= max_run; } } } (xc++)->x= w+1; prev_xc= prev2_xc; prev2_xc= xc; if(parent_xc){ if(y&1){ while(parent_xc->x != parent->width+1) parent_xc++; parent_xc++; prev_parent_xc= parent_xc; }else{ parent_xc= prev_parent_xc; } } } (xc++)->x= w+1; } }
1threat
TLS and SSL for Java apache commons email : <p>Can we use SSL and TLS both at the same time while sending an e-mail using apache commons email library?</p>
0debug
How to impliment a sidenav Navigation drawer with a (Mini variant) : <p>Angular material 2 community I need your help how to make mini variant like google material design example in angular Material 2.</p> <p>I try to implement this but I can't make this happen </p> <p><a href="https://i.stack.imgur.com/5cFAH.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5cFAH.png" alt="enter image description here"></a></p> <h3>My code so far</h3> <pre><code> &lt;!-- ===================================================================== --&gt; &lt;!-- SIDENAV &amp;&amp; SIDENAV CONTAINER --&gt; &lt;!-- ===================================================================== --&gt; &lt;mat-sidenav-container&gt; &lt;mat-sidenav #adminNavMenu mode="side" opened="true" style="min-width:50px; background: #F3F3F3;" class="shadow_right" autosize&gt; &lt;!-- MENU LEFT --&gt; &lt;app-admin-menu-left&gt;&lt;/app-admin-menu-left&gt; &lt;/mat-sidenav&gt; &lt;mat-sidenav-container&gt; </code></pre> <h3>app-admin-menu-left.html</h3> <pre><code>&lt;mat-nav-list style="min-width:60px;"&gt; &lt;mat-list-item *ngFor="let page of Menus"&gt; &lt;a routerLink="{{page.link}}" routerLinkActive="active" [routerLinkActiveOptions]="{exact:true}" matLine&gt; &lt;mat-icon class="home_icon collapse-icon vcenter" mat-list-icon&gt;{{page.icon}}&lt;/mat-icon&gt; &lt;span *ngIf="!showFiller"&gt; {{page.name}} &lt;/span&gt; &lt;/a&gt; &lt;/mat-list-item&gt; &lt;/mat-nav-list&gt; &lt;button mat-icon-button (click)="showFiller = !showFiller" mat-raised-button&gt; &lt;mat-icon *ngIf="!showFiller"&gt;chevron_right&lt;/mat-icon&gt; &lt;mat-icon *ngIf="showFiller"&gt;chevron_left&lt;/mat-icon&gt; &lt;/button&gt; </code></pre> <h3>End gives me this unexpected result</h3> <p><a href="https://i.stack.imgur.com/vOVVn.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vOVVn.png" alt="enter image description here"></a></p> <p>After I click to view the mini bar <a href="https://i.stack.imgur.com/N8k6g.png" rel="noreferrer"><img src="https://i.stack.imgur.com/N8k6g.png" alt="enter image description here"></a></p> <blockquote> <p>As you see there is a margin 250 px on <code>mat-sidenav-content</code> but I can't access this element.</p> </blockquote> <p><a href="https://i.stack.imgur.com/BHTAQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BHTAQ.png" alt="enter image description here"></a></p> <p>Any help to solve this is gonna be useful. </p> <p>Thanx</p>
0debug
Why is Shiny a dependency of devtools? : <p>When I install devtools, I get shiny as a dependency. </p> <pre><code>&gt; install.packages("devtools") Installing package into ‘/Users/xxx/tmp/xxx/packrat/lib/x86_64-apple-darwin15.6.0/3.5.3’ (as ‘lib’ is unspecified) also installing the dependencies ‘zeallot’, ‘colorspace’, ‘utf8’, ‘vctrs’, ‘plyr’, ‘labeling’, ‘munsell’, ‘RColorBrewer’, ‘fansi’, ‘pillar’, ‘pkgconfig’, ‘httpuv’, ‘xtable’, ‘sourcetools’, ‘fastmap’, ‘gtable’, ‘reshape2’, ‘scales’, ‘tibble’, ‘viridisLite’, ‘sys’, ‘ini’, ‘backports’, ‘ps’, ‘lazyeval’, ‘shiny’, ‘ggplot2’, ‘later’, ‘askpass’, ‘clipr’, ‘clisymbols’, ‘curl’, ‘fs’, ‘gh’, ‘purrr’, ‘rprojroot’, ‘whisker’, ‘yaml’, ‘processx’, ‘R6’, ‘assertthat’, ‘rex’, ‘htmltools’, ‘htmlwidgets’, ‘magrittr’, ‘crosstalk’, ‘promises’, ‘mime’, ‘openssl’, ‘prettyunits’, ‘xopen’, ‘brew’, ‘commonmark’, ‘Rcpp’, ‘stringi’, ‘stringr’, ‘xml2’, ‘evaluate’, ‘praise’, ‘usethis’, ‘callr’, ‘cli’, ‘covr’, ‘crayon’, ‘desc’, ‘digest’, ‘DT’, ‘ellipsis’, ‘glue’, ‘git2r’, ‘httr’, ‘jsonlite’, ‘memoise’, ‘pkgbuild’, ‘pkgload’, ‘rcmdcheck’, ‘remotes’, ‘rlang’, ‘roxygen2’, ‘rstudioapi’, ‘rversions’, ‘sessioninfo’, ‘testthat’, ‘withr’ </code></pre> <p>How does this make any sense? Is this expected, and if yes, how can I prevent it from happening? I am using R 3.5.3 with 0-Cloud mirror.</p>
0debug
How can I strip the data:image part from a base64 string of any image type in Javascript : <p>I am currently doing the following to decode base64 images in Javascript:</p> <pre><code> var strImage = ""; strImage = strToReplace.replace("data:image/jpeg;base64,", ""); strImage = strToReplace.replace("data:image/png;base64,", ""); strImage = strToReplace.replace("data:image/gif;base64,", ""); strImage = strToReplace.replace("data:image/bmp;base64,", ""); </code></pre> <p>As you can see above we are accepting the four most standard image types (jpeg, png, gif, bmp);</p> <p>However, some of these images are very large and scanning through each one 4-5 times with replace seems a dreadful waste and terribly inefficient.</p> <p>Is there a way I could reliably strip the data:image part of a base64 image string in a single pass? </p> <p>Perhaps by detecting the first comma in the string?</p> <p>Thanks in advance.</p>
0debug
How to instantiate fragment class using class name instead of index : <p>I have two fragment class named <code>SessionTab</code> and <code>BillingTab</code>and i am trying to create instance of those class using</p> <pre><code>SessionTab sessionTab = (SessionTab) getSupportFragmentManager().getFragments().get(1); </code></pre> <p>but sometimes index for those classes are reversed and then it causes <code>ClassCastException</code> </p> <p>How can i get instance of those fragment class by passing class name instead of index or any way to make sure that index of those class stays the same everytime so it doesn't cause <code>ClassCastException</code></p>
0debug
How to get current route path in Flutter? : <p>While implementing <a href="https://stackoverflow.com/questions/45511549/permanent-view-with-navigation-bar-in-flutter">persistent bottom bar</a>, previous <a href="https://github.com/flutter/flutter/issues/10975" rel="noreferrer">route need to be restored</a> when a button in the <a href="https://material.io/guidelines/components/bottom-navigation.html" rel="noreferrer">bottom bar</a> was clicked. </p> <p>When a button in the bottom bar is clicked, its current route path (<a href="https://docs.flutter.io/flutter/widgets/Navigator-class.html" rel="noreferrer">/a/b/c</a>) is saved and previously saved route is restored according to the button click.</p> <p>Conceptually user will think each button as a workspace and its state is never get lost (including back stack). User can safely switch from one workspace to another.</p> <p>How to get current route path in Flutter, when the routing is <a href="https://docs.flutter.io/flutter/widgets/Navigator/popUntil.html" rel="noreferrer">rewinding to root</a>?</p>
0debug
document.getElementById('input').innerHTML = user_input;
1threat
Function components cannot have refs. Did you mean to use React.forwardRef()? : <p>Hi I am trying to choose file form my computer and display the file name on input field but I am getting this error</p> <p>Function components cannot have refs. Did you mean to use React.forwardRef()</p> <p><a href="https://stackblitz.com/edit/react-aogwkt?file=bulk.js" rel="noreferrer">https://stackblitz.com/edit/react-aogwkt?file=bulk.js</a></p> <p>here is my code</p> <pre><code>import React, { Component } from "react"; import { Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControl, IconButton, Input, InputAdornment, withStyles } from "@material-ui/core"; import Attachment from "@material-ui/icons/Attachment"; import CloudDownload from "@material-ui/icons/CloudDownload"; const BulkUpload = props =&gt; { const { classes } = props; return ( &lt;div className="App"&gt; &lt;input id="file_input_file" className="none" type="file" ref={'abc'} /&gt; &lt;Input id="adornment-attachment" type="text" fullWidth endAdornment={ &lt;InputAdornment position="end"&gt; &lt;IconButton aria-label="Toggle password visibility" onClick={e =&gt; { // this.refs['abc'].click(); }} className="login-container__passwordIcon" &gt; &lt;Attachment /&gt; &lt;/IconButton&gt; &lt;/InputAdornment&gt; } /&gt; &lt;/div&gt; ); }; export default BulkUpload; </code></pre> <p>I just wanted to show selected file name on input field</p>
0debug
static av_cold int close_decoder(AVCodecContext *avctx) { PGSSubContext *ctx = avctx->priv_data; av_freep(&ctx->picture.rle); ctx->picture.rle_buffer_size = 0; return 0; }
1threat
Check is a variable is not empty : Could someone please let me know how I check is a variable is empty? I have a variable called `new_date`. I am reading dates into this variable but sometimes there is no date read in (the date does not exist). I want to check if the variable new_date is empty and do something different if there is not date in the variable e.g. I have the code below which first checks if variable `picked` is less than variable `prev_final` and `new_date` is a date. if (picked < prev_final) & isinstance(new_date, pd.datetime) # add the value from NEW_DATE list_final.append(new_date) # and update the prev_final for the next iteration of the loop prev_final = new_date else: # same idea if conditions not met list_final.append(picked) prev_final = picked to this first line I would like to add a condition that `new_date` also must have a date (not empty). If its empty I'd like the code to use the else i.e. if new_date is empty I would like the code to drop down to where I append `picked` to the `list_final` and `prev_final` and not append `new_date`) e.g. if (picked < prev_final) & isinstance(new_date, pd.datetime) & (new_date isnot empty) But I just need to know how to check if new_date is empty. Any help would be much appreciated. Thanks
0debug
Write temporary files from Google Cloud Function : <p>Can I write to the container's local filesystem from a Google Cloud Function? AWS Lambda allows writing to /tmp:</p> <blockquote> <p><strong>Q: What if I need scratch space on disk for my AWS Lambda function?</strong><br> Each Lambda function receives 500MB of non-persistent disk space in its own /tmp directory.</p> </blockquote> <p>Is there something equivalent in GCF?</p>
0debug
What is the difference between *p,**p, ***p in pointers? : <p>I have confusion in above pointers in C Language what the difference between them and in what situation they are suitable to use.. </p>
0debug
SQL Server Config manager error: Cannot connect to WMI provider : <p>I cant open my SQL server configuration manager getting this error message:</p> <pre><code>Cannot connect to WMI provider. You do not have permission or the server is unreachable. Note that you can only manage SQL Server 2005 and later servers with SQL Server Configuration Manager. Invalid </code></pre> <p>I have searched online material and ran the mofcomp command as recommended: <code>mofcomp “C:\Program Files (x86)\Microsoft SQL Server\120\Shared\sqlmgmproviderxpsp2up.mof”</code></p> <p>I am now getting this error message:</p> <pre><code>MOF file has been successfully parsed Storing data in the repository… An error occurred while processing item 10 defined on lines 73 – 79 in file C:\Program Files (x86)\Microsoft SQL Server\120\Shared\sqlmgmproviderxpsp2up.mof: Compiler returned error 0x80070005Error Number: 0x80070005, Facility: Win32 Description: Access is denied. </code></pre> <p>Can you please help me out, been 2 weeks sited with this problem</p>
0debug
input and output for the same variable : <p>I have a variable that can be edited from parent and for child.</p> <p>parent.html:</p> <pre><code> &lt;div *ngIf="editEnabled"&gt; &lt;mat-icon (click)="disableEdit()"&gt;cancel&lt;/mat-icon&gt; &lt;/div&gt; &lt;child [(editEnabled)]="editEnabled"&gt;&lt;/child&gt; </code></pre> <p>parent.ts:</p> <pre><code>export class ParentComponent { editEnabled: boolean; disableEdit(){ this.editEnabled = false; } } </code></pre> <p>Child.html:</p> <pre><code> &lt;div *ngIf="!editEnabled"&gt; &lt;mat-icon (click)="enableEdit()"&gt;settings&lt;/mat-icon&gt; &lt;/div&gt; </code></pre> <p>child.ts</p> <pre><code>private _editEnabled: boolean; @Input() set editEnabled(value: boolean) { this._editEnabled = value; } get editEnabled(): boolean { return this._editEnabled; } enableEdit(){ this.editEnabled = true; } </code></pre> <p>But I cant comunicate editEnabled between the two components. </p> <p>Where is my mistake?</p>
0debug
static int dirac_header(AVFormatContext *s, int idx) { struct ogg *ogg = s->priv_data; struct ogg_stream *os = ogg->streams + idx; AVStream *st = s->streams[idx]; dirac_source_params source; GetBitContext gb; if (st->codec->codec_id == AV_CODEC_ID_DIRAC) return 0; init_get_bits(&gb, os->buf + os->pstart + 13, (os->psize - 13) * 8); if (avpriv_dirac_parse_sequence_header(st->codec, &gb, &source) < 0) return -1; st->codec->codec_type = AVMEDIA_TYPE_VIDEO; st->codec->codec_id = AV_CODEC_ID_DIRAC; avpriv_set_pts_info(st, 64, st->codec->framerate.den, 2*st->codec->framerate.num); return 1; }
1threat
SyntaxError: Unexpected token import typeORM entity : <p>So, I am working with typeORM and am getting an odd error when I transpile my TypeScript to JavaScript. I am receiving the following error:</p> <pre><code>(function (exports, require, module, __filename, __dirname) { import { Entity, PrimaryGeneratedColumn, ManyToOne, OneToMany, TreeChildren, TreeParent, JoinColumn, Column, Tree, TreeLevelColumn } from "typeorm"; ^^^^^^ SyntaxError: Unexpected token import at createScript (vm.js:80:10) at Object.runInThisContext (vm.js:139:10) at Module._compile (module.js:616:28) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Function.PlatformTools.load (C:\Users\*redacted*\Workspace\experimental\*redacted*\node_modules\typeorm\platform\PlatformTools.js:126:28) </code></pre> <p>My tsconfig.json: </p> <pre><code>{ "compilerOptions": { "lib": [ "es5", "es6" ], "target": "es5", "module": "commonjs", "moduleResolution": "node", "outDir": "./build", "emitDecoratorMetadata": true, "experimentalDecorators": true, "sourceMap": true }, "exclude": [ "client" ] } </code></pre> <p>My package.json:</p> <pre><code>{ "name": "*redacted*", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" &amp;&amp; exit 1", "dev": "nodemon --watch 'src/**/*.ts' --ignore 'src/**/*.spec.ts' --exec ts-node src/index.ts", "start": "tsc &amp;&amp; node ./build/index.js", "migrate": "ts-node ./node_modules/typeorm/cli.js migration:generate" }, "author": "*redacted*", "license": "ISC", "dependencies": { "bcryptjs": "^2.4.3", "body-parser": "^1.18.3", "class-validator": "^0.8.5", "express": "^4.16.3", "jwt-simple": "^0.5.1", "morgan": "^1.9.0", "pg": "^7.4.3", "reflect-metadata": "^0.1.10", "typeorm": "0.2.5" }, "devDependencies": { "@types/bcryptjs": "^2.4.1", "@types/body-parser": "^1.17.0", "@types/express": "^4.11.1", "@types/jwt-simple": "^0.5.33", "@types/node": "^8.10.15", "ts-node": "3.3.0", "typescript": "2.5.2" } } </code></pre> <p>The file throwing the error:</p> <pre><code>import { Entity, PrimaryGeneratedColumn, ManyToOne, OneToMany, TreeChildren, TreeParent, JoinColumn, Column, Tree, TreeLevelColumn } from "typeorm"; import { User } from "./User"; import { Debate } from "./Debate"; @Entity() @Tree("closure-table") export class Comment { @PrimaryGeneratedColumn("uuid") id: string; @Column() text: string; @ManyToOne(type =&gt; User) user: User; @ManyToOne(type =&gt; Debate, debate =&gt; debate.comments) debate: Debate; @TreeChildren() children: Comment[]; @TreeParent() parent: Comment; } </code></pre> <p>What I have tried:</p> <ul> <li>I have tried updating my node.js to the latest (version 8.11.2)</li> <li>I have tried changing the "lib" settings in my tsconfig.json in various combinations of "es5", "es6", and "es7"</li> <li>I have tried changing the "target" for my tsconfig.json for the targets listed in the above bullet point.</li> <li>I have tried changing the import statements in my entity files from "import (lib) from (module)" to "const (lib) require (module)"; However, this causes more issues and doesn't work well.</li> </ul> <p>I have been googling for this issue extensively and it has left me scratching my head. Any and all help would be greatly appreciated.</p>
0debug
static void gen_sub(DisasContext *dc, TCGv dest, TCGv srca, TCGv srcb) { TCGv res = tcg_temp_new(); TCGv sr_cy = tcg_temp_new(); TCGv sr_ov = tcg_temp_new(); tcg_gen_sub_tl(res, srca, srcb); tcg_gen_xor_tl(sr_cy, srca, srcb); tcg_gen_xor_tl(sr_ov, res, srcb); tcg_gen_and_tl(sr_ov, sr_ov, sr_cy); tcg_gen_setcond_tl(TCG_COND_LTU, sr_cy, srca, srcb); tcg_gen_mov_tl(dest, res); tcg_temp_free(res); tcg_gen_shri_tl(sr_ov, sr_ov, TARGET_LONG_BITS - 1); tcg_gen_deposit_tl(cpu_sr, cpu_sr, sr_cy, ctz32(SR_CY), 1); tcg_gen_deposit_tl(cpu_sr, cpu_sr, sr_ov, ctz32(SR_OV), 1); gen_ove_cyov(dc, sr_ov, sr_cy); tcg_temp_free(sr_ov); tcg_temp_free(sr_cy); }
1threat
static int v9fs_synth_symlink(FsContext *fs_ctx, const char *oldpath, V9fsPath *newpath, const char *buf, FsCred *credp) { errno = EPERM; return -1; }
1threat
How I can achieve this design using UITableView : <p><a href="https://i.stack.imgur.com/IjJyr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IjJyr.png" alt="enter image description here"></a></p> <p>Hi, </p> <p>Can anybody have any sample code to create this view using UITableView in iOS.</p> <p>Please help me out.</p>
0debug
IdentationError: unident does not match any outer identation level. (Python) : <p>I'm pretty new to coding Python and I'm learning it.</p> <p>Now I've made a piece of code but keep getting the following error:</p> <p>'IdentationError: unident does not match any outer identation level.'</p> <p>I hope you guys can help me out.</p> <pre><code>password = test123 if password == raw_input('What is the password?'): print("Acces given") else: print("Acces forbidden") </code></pre>
0debug
C code keeps running forever : I am trying to find the largest prime factor of a huge number in C ,for small numbers like 100 or even 10000 it works fine but fails (By fail i mean it keeps **running and running** for tens of minutes on my core2duo and i5) for very big `target` numbers (See code for the target number.) Is my algorithm correct? I am new to C and really struggling with big numbers. What i want is correction or guidance not a solution i can do this using python with bignum bindings and stuff (*I have not tried yet but am pretty sure*) but not in C. Or i might have done some tiny mistake that i am too tired to realize , anyways here is the code i wrote: #include <stdio.h> // To find largest prime factor of target int is_prime(unsigned long long int num); long int main(void) { unsigned long long int target = 600851475143; unsigned long long int current_factor = 1; register unsigned long long int i = 2; while (i < target) { if ( (target % i) == 0 && is_prime(i) && (i > current_factor) ) { //verify i as a prime factor and greater than last factor current_factor = i; } i++; } printf("The greates is: %llu \n",current_factor); return(0); } int is_prime (unsigned long long int num) { //if num is prime 1 else 0 unsigned long long int z = 2; while (num > z && z !=num) { if ((num % z) == 0) {return 0;} z++; } return 1; }
0debug
Which DB technology is sued to solve the following search issue? : <p>Assume I have built a video sharing site such as youtube, and I want to build a recommendation system.</p> <p>Assume I have a simple database [ video title, link/url to database ]</p> <p>Lets assume user watches a video simply tiled - 'Sachin Tendulkar'. How can I run a query to return me other videos whose search title <code>includes</code> sachin tendulkar ?</p> <p>eg: other videos could be titled -</p> <p><code>Straight drive by Sachin Tendulkar</code> or <code>Sachin Tendulkars famous reply to Bret Lee</code>.</p> <p>In other words, which query can I run to fetch all the videos whose title contains Sachin ?</p>
0debug
ram_addr_t qemu_ram_alloc(ram_addr_t size) { RAMBlock *new_block; #ifdef CONFIG_KQEMU if (kqemu_phys_ram_base) { return kqemu_ram_alloc(size); } #endif size = TARGET_PAGE_ALIGN(size); new_block = qemu_malloc(sizeof(*new_block)); new_block->host = qemu_vmalloc(size); new_block->offset = last_ram_offset; new_block->length = size; new_block->next = ram_blocks; ram_blocks = new_block; phys_ram_dirty = qemu_realloc(phys_ram_dirty, (last_ram_offset + size) >> TARGET_PAGE_BITS); memset(phys_ram_dirty + (last_ram_offset >> TARGET_PAGE_BITS), 0xff, size >> TARGET_PAGE_BITS); last_ram_offset += size; if (kvm_enabled()) kvm_setup_guest_memory(new_block->host, size); return new_block->offset; }
1threat
How to VueJS router-link active style : <p>My page currently has Navigation.vue component. I want to make the each navigation hover and active. The 'hover' works but 'active' doesn't. <br /><br /> This is how Navigation.vue file looks like :</p> <pre><code>&lt;template&gt; &lt;div&gt; &lt;nav class="navbar navbar-expand-lg fixed-top row"&gt; &lt;router-link tag="li" class="col" class-active="active" to="/" exact&gt;TIME&lt;/router-link&gt; &lt;router-link tag="li" class="col" class-active="active" to="/CNN" exact&gt;CNN&lt;/router-link&gt; &lt;router-link tag="li" class="col" class-active="active" to="/TechCrunch" exact&gt;TechCrunch&lt;/router-link&gt; &lt;router-link tag="li" class="col" class-active="active" to="/BBCSport" exact&gt;BBC Sport&lt;/router-link&gt; &lt;/nav&gt; &lt;/div&gt; &lt;/template&gt; </code></pre> <p>And the following is the style.</p> <pre><code>&lt;style&gt; nav li:hover, nav li:active{ background-color: indianred; cursor: pointer; } &lt;/style&gt; </code></pre> <p>This is how hover looks like now and expected exactly same on active. <a href="https://i.stack.imgur.com/wOVg4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/wOVg4.png" alt="This is how hover looks like now and expected exactly same on active."></a></p> <p>I would appreciate if you give me an advice for styling router-link active works. Thanks.</p>
0debug
Laravel : Redis No connection could be made : [tcp://127.0.0.1:6379] : <p>I have installed redis with laravel by adding <code>"predis/predis":"~1.0"</code>,</p> <p>Then for testing i added the following code :</p> <pre><code>public function showRedis($id = 1) { $user = Redis::get('user:profile:'.$id); Xdd($user); } </code></pre> <p>In app/config/database.php i have :</p> <pre><code>'redis' =&gt; [ 'cluster' =&gt; false, 'default' =&gt; [ 'host' =&gt; env('REDIS_HOST', 'localhost'), 'password' =&gt; env('REDIS_PASSWORD', null), 'port' =&gt; env('REDIS_PORT', 6379), 'database' =&gt; 0, ], ], </code></pre> <p>It throws the following error : <code>No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379]</code></p> <p>I using <code>virtualhost</code> for the project. Using <code>Xampp with windows</code>.</p>
0debug
I downloaded a pdf using python 2.7, but where did it saved? : I used this code: import urllib urllib.urlretrieve('https://czechgames.com/files/rules/codenames-rules-en.pdf',"my python file") but i searched the computer and found nothing! where did it saved?
0debug
Byobu mouse scrolling - [OSX + Iterm2] : <p>I am trying to enable the mouse scrolling functionality in my local (non-ssh) byobu installation. </p> <p>What I have tried doing : </p> <ol> <li><p>Pressing F7 and scrolling with the mouse results in the following <a href="https://i.stack.imgur.com/WxVe7.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/WxVe7.jpg" alt="Incorrect scrolling"></a></p></li> <li><p>Enabled the "Save lines to scrollback option" in Iterm2 <a href="https://i.stack.imgur.com/5Am0O.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5Am0O.png" alt="Save lines to scrollback option"></a> </p></li> <li><p>Changed my ~/.tmux.conf to </p> <pre><code>set -ga terminal-overrides 'xterm*:smcup@:rmcup@' set-option -g mouse on </code></pre></li> </ol> <p>Nothing seems to enable mouse scrolling. I have read pretty much all information on StackOverflow &amp; Google to no avail.</p>
0debug
Viewing current Spring (Boot) properties : <p>I run a Spring Boot application as a .jar file which partly takes its properties from application.yml residing inside the jar while the other part of properties is being provided from another application.yml residing outside the jar. Some of the properties from the outside overwrite the properties from the inside. In order to test whether the properties were overwritten properly I would like to see the currently active ones. Is that achieveable at all out of the box? Or is the only solution to extend my application by property output logic?</p>
0debug
static void test_io_channel(bool async, SocketAddressLegacy *listen_addr, SocketAddressLegacy *connect_addr, bool passFD) { QIOChannel *src, *dst; QIOChannelTest *test; if (async) { test_io_channel_setup_async(listen_addr, connect_addr, &src, &dst); g_assert(!passFD || qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN)); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN)); test = qio_channel_test_new(); qio_channel_test_run_threads(test, true, src, dst); qio_channel_test_validate(test); object_unref(OBJECT(src)); object_unref(OBJECT(dst)); test_io_channel_setup_async(listen_addr, connect_addr, &src, &dst); g_assert(!passFD || qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN)); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN)); test = qio_channel_test_new(); qio_channel_test_run_threads(test, false, src, dst); qio_channel_test_validate(test); object_unref(OBJECT(src)); object_unref(OBJECT(dst)); } else { test_io_channel_setup_sync(listen_addr, connect_addr, &src, &dst); g_assert(!passFD || qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN)); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN)); test = qio_channel_test_new(); qio_channel_test_run_threads(test, true, src, dst); qio_channel_test_validate(test); object_unref(OBJECT(src)); object_unref(OBJECT(dst)); test_io_channel_setup_sync(listen_addr, connect_addr, &src, &dst); g_assert(!passFD || qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(!passFD || qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_SHUTDOWN)); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_SHUTDOWN)); test = qio_channel_test_new(); qio_channel_test_run_threads(test, false, src, dst); qio_channel_test_validate(test); object_unref(OBJECT(src)); object_unref(OBJECT(dst)); } }
1threat
static int virtio_mmio_set_guest_notifier(DeviceState *d, int n, bool assign, bool with_irqfd) { VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d); VirtIODevice *vdev = virtio_bus_get_device(&proxy->bus); VirtioDeviceClass *vdc = VIRTIO_DEVICE_GET_CLASS(vdev); VirtQueue *vq = virtio_get_queue(vdev, n); EventNotifier *notifier = virtio_queue_get_guest_notifier(vq); if (assign) { int r = event_notifier_init(notifier, 0); if (r < 0) { return r; } virtio_queue_set_guest_notifier_fd_handler(vq, true, with_irqfd); } else { virtio_queue_set_guest_notifier_fd_handler(vq, false, with_irqfd); event_notifier_cleanup(notifier); } if (vdc->guest_notifier_mask) { vdc->guest_notifier_mask(vdev, n, !assign); } return 0; }
1threat
int av_read_pause(AVFormatContext *s) { if (s->iformat->read_pause) return s->iformat->read_pause(s); if (s->pb && s->pb->read_pause) return av_url_read_fpause(s->pb, 1); return AVERROR(ENOSYS); }
1threat
Modify @OneToMany entity in Spring Data Rest without its repository : <p>In my project I use object of type <em>A</em> which has OneToMany relation (orphanRemoval = true, cascade = CascadeType.ALL, fetch = FetchType.EAGER) to objects of type <em>B</em>. I need SpringDataRest (SDR) to store complete full <em>A</em> object with its <em>B</em> objects (children) using single one POST request. I tried several combinations in SDR, the only one which worked for me, was to create @RepositoryRestResource for object <em>A</em> and to create @RepositoryRestResource also for object <em>B</em>, but mark this (<em>B</em>) as exported=false (if I did not create repository out of object <em>B</em> at all, it would not work -> just <em>A</em> object would be stored on single POST request, but not its children (@OneToMany relation) of type <em>B</em>; the same outcome occurs if exported=false is omitted for <em>B</em> repository). Is this ok and the only way how to achieve it (single POST request with storing all objects at once)?</p> <p>The reason I'm asking, in my previous example, I have to (I would like to) control all objects "lifecycle" by using <em>A</em>'s repository. I am ok with it, because <em>A</em>-><em>B</em> relation is composition (<em>B</em> does not exists outside of <em>A</em>). But I have serious problem of editing (also removing) one certain object of type <em>B</em> by SDR using its parent repository (since object <em>B</em> doest not have its own repository exported). Maybe, this is not possible by definition. I have tried these solutions:</p> <ul> <li>PATCH for "/A/1/B/2" does not work -> method not allowed (in headers is "Allow: GET, DELETE") -> so, also PUT is out of question</li> <li>Json Patch would not work either - PATCH for "/A/1" using json patch content-type [{"op": "add", "path": "/B/2", ....}] -> "no such index in target array" - because Json Patch uses scalar "2" after "array" as a index to its array. This is not practical in Java world, when relations are kept in Set of objects - indexing has no meaning at all.</li> <li>I could export repository (exported=true) of object <em>B</em> for manipulating it "directly", but this way I would loose ability to store the whole object <em>A</em> with its <em>B</em> objects at one single POST request as I have mentioned before.</li> </ul> <p>I would like to avoid sending the whole <em>A</em> object with one single tiny modification of its <em>B</em> object for PUT, if possible. Thank you.</p>
0debug
static TCGv_i64 read_fp_dreg(DisasContext *s, int reg) { TCGv_i64 v = tcg_temp_new_i64(); tcg_gen_ld_i64(v, cpu_env, fp_reg_offset(reg, MO_64)); return v; }
1threat
void sm501_init(MemoryRegion *address_space_mem, uint32_t base, uint32_t local_mem_bytes, qemu_irq irq, CharDriverState *chr) { SM501State * s; DeviceState *dev; MemoryRegion *sm501_system_config = g_new(MemoryRegion, 1); MemoryRegion *sm501_disp_ctrl = g_new(MemoryRegion, 1); MemoryRegion *sm501_2d_engine = g_new(MemoryRegion, 1); s = (SM501State *)g_malloc0(sizeof(SM501State)); s->base = base; s->local_mem_size_index = get_local_mem_size_index(local_mem_bytes); SM501_DPRINTF("local mem size=%x. index=%d\n", get_local_mem_size(s), s->local_mem_size_index); s->system_control = 0x00100000; s->misc_control = 0x00001000; s->dc_panel_control = 0x00010000; s->dc_crt_control = 0x00010000; memory_region_init_ram(&s->local_mem_region, "sm501.local", local_mem_bytes); vmstate_register_ram_global(&s->local_mem_region); s->local_mem = memory_region_get_ram_ptr(&s->local_mem_region); memory_region_add_subregion(address_space_mem, base, &s->local_mem_region); memory_region_init_io(sm501_system_config, &sm501_system_config_ops, s, "sm501-system-config", 0x6c); memory_region_add_subregion(address_space_mem, base + MMIO_BASE_OFFSET, sm501_system_config); memory_region_init_io(sm501_disp_ctrl, &sm501_disp_ctrl_ops, s, "sm501-disp-ctrl", 0x1000); memory_region_add_subregion(address_space_mem, base + MMIO_BASE_OFFSET + SM501_DC, sm501_disp_ctrl); memory_region_init_io(sm501_2d_engine, &sm501_2d_engine_ops, s, "sm501-2d-engine", 0x54); memory_region_add_subregion(address_space_mem, base + MMIO_BASE_OFFSET + SM501_2D_ENGINE, sm501_2d_engine); dev = qdev_create(NULL, "sysbus-ohci"); qdev_prop_set_uint32(dev, "num-ports", 2); qdev_prop_set_taddr(dev, "dma-offset", base); qdev_init_nofail(dev); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base + MMIO_BASE_OFFSET + SM501_USB_HOST); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq); if (chr) { serial_mm_init(address_space_mem, base + MMIO_BASE_OFFSET + SM501_UART0, 2, NULL, 115200, chr, DEVICE_NATIVE_ENDIAN); } s->con = graphic_console_init(sm501_update_display, NULL, NULL, NULL, s); }
1threat
React w/hooks: prevent re-rendering component with a function as prop : <p>Let's say I have:</p> <pre><code>const AddItemButton = React.memo(({ onClick }) =&gt; { // Goal is to make sure this gets printed only once console.error('Button Rendered!'); return &lt;button onClick={onClick}&gt;Add Item&lt;/button&gt;; }); const App = () =&gt; { const [items, setItems] = useState([]); const addItem = () =&gt; { setItems(items.concat(Math.random())); } return ( &lt;div&gt; &lt;AddItemButton onClick={addItem} /&gt; &lt;ul&gt; {items.map(item =&gt; &lt;li key={item}&gt;{item}&lt;/li&gt;)} &lt;/ul&gt; &lt;/div&gt; ); }; </code></pre> <p>Any time I add an item, the <code>&lt;AddItemButton /&gt;</code> gets re-rendered because addItem is a new instance. I tried memoizing addItem:</p> <pre><code> const addItemMemoized = React.memo(() =&gt; addItem, [setItems]) </code></pre> <p>But this is reusing the setItems from the first render, while </p> <pre><code> const addItemMemoized = React.memo(() =&gt; addItem, [items]) </code></pre> <p>Doesn't memoize since <code>items</code> reference changes.</p> <p>I can'd do</p> <pre><code> const addItem = () =&gt; { items.push(Math.random()); setItems(items); } </code></pre> <p>Since that doesn't change the reference of <code>items</code> and nothing gets updated.</p> <p>One weird way to do it is:</p> <pre><code> const [, frobState] = useState(); const addItemMemoized = useMemo(() =&gt; () =&gt; { items.push(Math.random()); frobState(Symbol()) }, [items]); </code></pre> <p>But I'm wondering if there's a better way that doesn't require extra state references. </p>
0debug
How to properly terminate strings in C programming? : <p>I'm using scanf to scan 5 product names and store them in a string. However, when i print them, the last one is always printed as ♣. Where am i going wrong ?</p> <p>I am trying to take in the id, name and prices of 5 products and print them using structures. However the last product name is always printed as ♣. I realised that this may be due to improper terminating of the string, and tried the solutions provided to such questions. I saw another similar question on strings and tried to terminate the string properly by doing, char name[50]={'0'}; in my code. This part is within the structure part of the code.</p> <pre><code>struct product { int id; char name[50]; int price; }; void main() { struct product p [5]; int i,a; for(i=1;i&lt;=5;i++) { printf("Enter the id no., name and price of the product %d\n",i); scanf("%d%s%d",&amp;p[i].id,&amp;p[i].name,&amp;p[i].price); } printf("The id no., name and price of the product %d are\n",i); for(i=1;i&lt;=5;i++) { printf("\t%d\t%s/0\t%d\n",p[i].id,p[i].name,p[i].price); } } </code></pre> <p>The final output, that is p[5].name ,should've been what i had entered, but is, however, ♣. And if i try to terminate the code by entering: char name[50]={'\0'}; it puts up an error message over the '=' saying that it expected a ';'.</p>
0debug
Downloading videos and storing them locally swift : <p>Could someone please provide from their experience the step-by-step guide or some tips how to download the videos from some specific url, save it locally (please suggest which database to use CoreData, realm or SQLite) and then show it to the user for example in the collectionView?</p>
0debug
void store_booke_tsr (CPUState *env, target_ulong val) { LOG_TB("%s: val " TARGET_FMT_lx "\n", __func__, val); env->spr[SPR_40x_TSR] &= ~(val & 0xFC000000); if (val & 0x80000000) ppc_set_irq(env, PPC_INTERRUPT_PIT, 0); }
1threat
How do i parse json object and json array in android? : <p>I am developing an app using json api and want to implement following format api into my app. How do i implement this in my project using android studio 2.3? </p> <pre><code>{ "getdetailsasanas": [ { "asanaid": 1, "asananame": "Half easy gas release pose", "duration": 1, "imageurl": "http://www.yogapoint.com/iOS/images/half-easy-gas-release-pose.jpg", "imageversion": 2, "audiourl": "http://www.yogapoint.com/iOS/audio/half-easy-gas-release-pose.mp3", "audioversion": 1, "videourl": "NULL", "videoversion": 0, "StepsForAsana": [ { "stepnumber": 1, "stepdesc": "Step 1", "stepimg": "http://www.yogapoint.com/iOS/images/asana-step/half-easy-gas-release-pose-step1.jpg", "stepimgeversion": 0, "imgethumbversion": 1, "imgethumburl": "http://www.yogapoint.com/iOS/images/asana-step/half-easy-gas-release-pose-step1-tb.jpg" }, { "stepnumber": 2, "stepdesc": "Step 2", "stepimg": "http://www.yogapoint.com/iOS/images/asana-step/half-easy-gas-release-pose-step2.jpg", "stepimgeversion": 0, "imgethumbversion": 1, "imgethumburl": "http://www.yogapoint.com/iOS/images/asana-step/half-easy-gas-release-pose-step2-tb.jpg" } ] } ] } </code></pre>
0debug
What is the new GlobalSection in a VS2017 15.3 solution file? : <p>After upgrading to Visual Studio 2017 15.3.1 and ASP.NET Core 2.0, my solution file now has this at the end:</p> <pre><code>GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {...a GUID...} EndGlobalSection </code></pre> <p>What is this, and do I need it?</p>
0debug
hash table with chaining within the table : <p>I have this assignment to complete. (I am new to java). I started to think about it and establish a plan. I am not looking for the answers just a feedback on my approach. I am supposed to enter integers into a hash table using a chaining scheme within the hash table (different from the regular chaining scheme). My idea is to use an arraylist so I can store data + pointer in each slot of the hash table. when a collision occurs, find an empty slot, insert the new integer and set the pointer from the original hashed slot to this new position in the arraylist. This way I am building a sort of linked list within the array. does that make sense? there is a hint about keeping track of the free space with a stack... here I have to say I am not sure how to use the stack in that instance</p>
0debug
How to add new tab : It wont go to a new tab is my code wrong? please help ASAP!!!aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa function getWaterMeterList() { // alert("ON"); var BillingPeriod = $('#BillingPeriod').val(); $.ajax({ url: '/DataEntryWater/WaterMeterAlphaListReport', type: 'POST', data: { 'BillingPeriod': BillingPeriod }, dataType: 'json', success: function (a) { $(location).attr('href', a) a.preventDefault(); }, error: function (err) { } }); }
0debug
Can anyone explain compile errors in this? : <pre><code> byte b1=10,b2=20,b3; b3=b1+b2; b3=b1+1; b3=b1*2; short s1=10,s2=20,s3; s3=s1+s2; s3=s1+1; s3=s1*1; int x1=10,x2=20,x3; x3=x1+x2; x3=b1+b2; x3=b1+1; x3=b1*2; x3=s1+s2; x3=s1+1; x3=s1*1; </code></pre> <p>Help me in this question. Explain the complie errors in it...(im not asking about brackets)</p>
0debug
Regex expression to replace string with * : <p>I need to convert string like this to ABC_464_aDE.hmi_2df to ABC464aDE.* that is want to remove all _ and add * at the end after dot. And my project requirement is to do this using regex. Please help to sort this out. Thanks</p>
0debug
how to solve this batch glitch?plzz someone answer : I have a little problem in my code if i set ghot=1 and set fo1=text and try echoing echo %fo%ghot%% like this it comes like %fo1% instead of text please help
0debug
static void rearm_sensor_evts(IPMIBmcSim *ibs, uint8_t *cmd, unsigned int cmd_len, uint8_t *rsp, unsigned int *rsp_len, unsigned int max_rsp_len) { IPMISensor *sens; IPMI_CHECK_CMD_LEN(4); if ((cmd[2] >= MAX_SENSORS) || !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; return; } sens = ibs->sensors + cmd[2]; if ((cmd[3] & 0x80) == 0) { sens->states = 0; return; } }
1threat
How companies develop (android) apps? : <p>i was curious about app dev procces. How companies develop their apps? If you have idea for app than what is the best way to make it real. </p> <p>1.Idea 2.Design 2.Wireframe 3.Coding 4.Publish 5.Fixing bugs</p> <p>This what i think how it works. I would happy if can someone expend this list and make it more complex. Thank for you answers!</p>
0debug
I want to develop browser app but i am getting errors help me please : Hi I am new to android i want to develop a browser app now i am trying to develop it in this i am getting errors. i tried in another method also on that it's asking on which browser you have to open like that but for me i want to open in my app only please help me any one thanks stack over flow . #WebviewActivity.java package com.example.admin.fristapp; import android.app.Activity; import android.os.AsyncTask; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.webkit.WebResourceRequest; import android.webkit.WebView; import android.webkit.WebViewClient; public class WebviewActivity extends Activity { WebView webview1; // String url = "http://www.google.com"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_webview); webview1 = (WebView) findViewById(R.id.webview1); // webview1.loadUrl(url); //MyBrowser my ; new Background().execute(); } public class MyBrowser extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } } public class Background extends AsyncTask<String,String,String> { @Override protected void onPostExecute(String s) { super.onPostExecute(s); } @Override protected void onPreExecute() { super.onPreExecute(); } @Override protected String doInBackground(String... strings) { search(); return null; } } public void search() { webview1.setWebViewClient(new WebviewActivity.MyBrowser()); String url = "http://www.google.com"; webview1.getSettings().setJavaScriptEnabled(true); webview1.loadUrl(url); } } #logcat java.lang.Throwable: A WebView method was called on thread 'AsyncTask #4'. All WebView methods must be called on the same thread. (Expected Looper Looper (main, tid 1) {180a245b} called on null, FYI main Looper is Looper (main, tid 1) {180a245b}) at android.webkit.WebView.checkThread(WebView.java:2290)
0debug
static int dmg_read_mish_block(BDRVDMGState *s, DmgHeaderState *ds, uint8_t *buffer, uint32_t count) { uint32_t type, i; int ret; size_t new_size; uint32_t chunk_count; int64_t offset = 0; type = buff_read_uint32(buffer, offset); if (type != 0x6d697368 || count < 244) { return 0; } offset += 4; offset += 200; chunk_count = (count - 204) / 40; new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count); s->types = g_realloc(s->types, new_size / 2); s->offsets = g_realloc(s->offsets, new_size); s->lengths = g_realloc(s->lengths, new_size); s->sectors = g_realloc(s->sectors, new_size); s->sectorcounts = g_realloc(s->sectorcounts, new_size); for (i = s->n_chunks; i < s->n_chunks + chunk_count; i++) { s->types[i] = buff_read_uint32(buffer, offset); offset += 4; if (s->types[i] != 0x80000005 && s->types[i] != 1 && s->types[i] != 2) { if (s->types[i] == 0xffffffff && i > 0) { ds->last_in_offset = s->offsets[i - 1] + s->lengths[i - 1]; ds->last_out_offset = s->sectors[i - 1] + s->sectorcounts[i - 1]; } chunk_count--; i--; offset += 36; continue; } offset += 4; s->sectors[i] = buff_read_uint64(buffer, offset); s->sectors[i] += ds->last_out_offset; offset += 8; s->sectorcounts[i] = buff_read_uint64(buffer, offset); offset += 8; if (s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) { error_report("sector count %" PRIu64 " for chunk %" PRIu32 " is larger than max (%u)", s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX); ret = -EINVAL; goto fail; } s->offsets[i] = buff_read_uint64(buffer, offset); s->offsets[i] += ds->last_in_offset; offset += 8; s->lengths[i] = buff_read_uint64(buffer, offset); offset += 8; if (s->lengths[i] > DMG_LENGTHS_MAX) { error_report("length %" PRIu64 " for chunk %" PRIu32 " is larger than max (%u)", s->lengths[i], i, DMG_LENGTHS_MAX); ret = -EINVAL; goto fail; } update_max_chunk_size(s, i, &ds->max_compressed_size, &ds->max_sectors_per_chunk); } s->n_chunks += chunk_count; return 0; fail: return ret; }
1threat
static void output_packet(AVFormatContext *s, AVPacket *pkt, OutputStream *ost) { int ret = 0; if (ost->nb_bitstream_filters) { int idx; ret = av_bsf_send_packet(ost->bsf_ctx[0], pkt); if (ret < 0) goto finish; idx = 1; while (idx) { ret = av_bsf_receive_packet(ost->bsf_ctx[idx - 1], pkt); if (ret == AVERROR(EAGAIN)) { ret = 0; idx--; continue; } else if (ret < 0) goto finish; if (idx < ost->nb_bitstream_filters) { ret = av_bsf_send_packet(ost->bsf_ctx[idx], pkt); if (ret < 0) goto finish; idx++; } else write_packet(s, pkt, ost); } } else write_packet(s, pkt, ost); finish: if (ret < 0 && ret != AVERROR_EOF) { av_log(NULL, AV_LOG_FATAL, "Error applying bitstream filters to an output " "packet for stream #%d:%d.\n", ost->file_index, ost->index); exit_program(1); } }
1threat
SimpleCart, SQL and MVC : <p>I have a product table in my sql database with one of the fields named productQuantity. I am using simpleCart which saves alot of manual coding. One such feature is the simpleCart.increment which increases the quantity of the item in the cart. </p> <p>However I am now having an issue of whereby if there is 5 items in stock the increment goes pass the 5th item.</p> <p>How do I limit the customer from increasing the quantity if the customer wants to purchase all five items and for example mistakenly increments to 6 items.</p>
0debug
C++ Can't Return A Vector of Textures : <p>I have a class that keeps track of objects I've declared. This class also has a vector as a member. I add textures through a function (probably, there is a leak). I am probably doing a mistake about c++ itself, not sfml.</p> <p>in Item.h:</p> <pre><code> #ifndef ITEM_H #define ITEM_H class ItemTexture { public: static std::vector&lt;ItemTexture*&gt; textures; std::vector&lt;sf::Texture*&gt; variation; ItemTexture(std::string file); void addTexture(std::string file); static sf::Texture getTexture(int id, int no) { return *textures[id]-&gt;variation[no]; //Program crashes here } static void declare_textures(); }; #endif </code></pre> <p>in the Item.cpp:</p> <pre><code>#include "Item.h" std::vector&lt;ItemTexture*&gt; ItemTexture::textures; ItemTexture::ItemTexture(std::string file) { sf::Texture *tex = new sf::Texture; tex-&gt;setSmooth(false); tex-&gt;loadFromFile(file); variation.push_back(tex); textures.push_back(this); delete tex; } void ItemTexture::addTexture(std::string file) { sf::Texture *tex = new sf::Texture; tex-&gt;setSmooth(false); tex-&gt;loadFromFile(file); variation.push_back(tex); delete tex; } </code></pre> <p>This doesn't give any error messages, program crashes at the line return *textures[id]->variation[no];</p>
0debug
Nginx: Redirect non-www to www https : <p>I have my below nginx config, I'm trying to redirect everything to <a href="https://www" rel="noreferrer">https://www</a> regardless of what comes in for example <a href="http://example.com" rel="noreferrer">http://example.com</a>, <a href="http://www.example.com" rel="noreferrer">http://www.example.com</a> or <a href="https://example.com" rel="noreferrer">https://example.com</a>.</p> <p>I've looked at numerous topics on SO and tried a couple of things but still stumped, I can't ever get <a href="https://example.com" rel="noreferrer">https://example.com</a> to redirect to the <a href="https://www" rel="noreferrer">https://www</a> pattern!?</p> <pre><code>server { listen 80; listen 443 ssl; server_name example.com; return 301 https://www.example.com$request_uri; } server { listen 443 ssl; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; ssl_dhparam /etc/nginx/ssl/dhparams.pem; ssl_session_timeout 30m; ssl_session_cache shared:SSL:10m; ssl_buffer_size 8k; add_header Strict-Transport-Security max-age=31536000; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } } </code></pre>
0debug
static void test_lifecycle(void) { Coroutine *coroutine; bool done = false; coroutine = qemu_coroutine_create(set_and_exit); qemu_coroutine_enter(coroutine, &done); g_assert(done); done = false; coroutine = qemu_coroutine_create(set_and_exit); qemu_coroutine_enter(coroutine, &done); g_assert(done); }
1threat
Escape from a Number TextField in a JavaFX dialog : <p>I've a custom dialog with several UI elements. Some TextFields are for <a href="https://stackoverflow.com/a/31043122">numeric input</a>. This dialog does not close when the escape key is hit and the focus is on any of the numeric text fields. The dialog closes fine when focus is on other TextFields which do not have this custom TextFormatter.</p> <p>Here's the simplified code:</p> <pre><code>package application; import java.text.DecimalFormat; import java.text.ParsePosition; import javafx.application.Application; import javafx.application.Platform; import javafx.scene.control.ButtonType; import javafx.scene.control.Dialog; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.control.TextFormatter; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class Main extends Application { @Override public void start(Stage primaryStage) { try { TextField name = new TextField(); HBox hb1 = new HBox(); hb1.getChildren().addAll(new Label("Name: "), name); TextField id = new TextField(); id.setTextFormatter(getNumberFormatter()); // numbers only HBox hb2 = new HBox(); hb2.getChildren().addAll(new Label("ID: "), id); VBox vbox = new VBox(); vbox.getChildren().addAll(hb1, hb2); Dialog&lt;ButtonType&gt; dialog = new Dialog&lt;&gt;(); dialog.setTitle("Number Escape"); dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL); dialog.getDialogPane().setContent(vbox); Platform.runLater(() -&gt; name.requestFocus()); if (dialog.showAndWait().get() == ButtonType.OK) { System.out.println("OK: " + name.getText() + id.getText()); } else { System.out.println("Cancel"); } } catch (Exception e) { e.printStackTrace(); } } TextFormatter&lt;Number&gt; getNumberFormatter() { // from https://stackoverflow.com/a/31043122 DecimalFormat format = new DecimalFormat("#"); TextFormatter&lt;Number&gt; tf = new TextFormatter&lt;&gt;(c -&gt; { if (c.getControlNewText().isEmpty()) { return c; } ParsePosition parsePosition = new ParsePosition(0); Object object = format.parse(c.getControlNewText(), parsePosition); if (object == null || parsePosition.getIndex() &lt; c.getControlNewText().length()) { return null; } else { return c; } }); return tf; } public static void main(String[] args) { launch(args); } } </code></pre> <p>How do I close the dialog when escape key is hit while focus is on <code>id</code>?</p>
0debug
formatting string to a number : <p>I am parsing a string with text and numbers in it e.g. abc00123.</p> <p>When i extract numbers 00123 it is still a string so i cast to a double.</p> <p>After i do this it it loses the zeros at the beginning of this.</p> <p>Also the length of the numbers can vary.</p> <p>Is there anyway to keep the zero when casting the string to a double ?</p> <p>if not maybe i will compare the two strings and if the size of the original array is bigger append the differences onto the beginning of the number if possible?</p> <p>Thanks in advance for the help.</p>
0debug
Can't register new Client ID on Instagram developers page : <p>I can't register new client because always have a wrong captcha, I tried to create it with different browsers but same effect :(</p> <blockquote> <p>The captcha solution was not correct. Please try again.</p> </blockquote> <p><a href="https://i.stack.imgur.com/QtNmJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QtNmJ.png" alt="captcha always wrong"></a></p>
0debug
Flutter Network Image does not fit in Circular Avatar : <p>I am trying to retrieve bunch of images from an api. I want the images to be displayed in Circular form so I am using <code>CircleAvatar</code> Widget, but I keep getting images in square format. Here is a screenshot of images</p> <p><a href="https://i.stack.imgur.com/zXU6v.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zXU6v.png" alt="enter image description here"></a></p> <p>Here is the code I am using</p> <pre><code>ListTile(leading: CircleAvatar(child: Image.network("${snapshot.data.hitsList[index].previewUrl}",fit: BoxFit.scaleDown,)),), </code></pre> <p>I tryied using all the properties of <code>BoxFit</code> like <code>cover</code>, <code>contain</code>,<code>fitWidth</code>,<code>fitHeight</code> etc but none of them works.</p>
0debug
In this code, I am displaying 3 buttons and if I click the start and stop button within 1 second, then it is not showing any effects : but if i do that multiple number of times then that should result in the increment which it is not. i want it to show the miliseconds that have passed between the simultaneous start stop buttons also javascript code: var secs=0; var mins=0; var timer; var start=0; var stop=0; function add(){ secs++; if(secs==60) { mins++; secs=0; } if(mins==6) { mins=0; secs=0; } display(); } function startc(){ if(start==0) { timer=setInterval(add,1000); start=1; } } function stopc(){ clearInterval(timer); start=0; stop=1; } function clearc(){ secs=0; mins=0; clearInterval(timer); display(); if(stop!=1) { start=0; startc(); } }
0debug
struct GuestFileSeek *qmp_guest_file_seek(int64_t handle, int64_t offset, int64_t whence, Error **errp) { GuestFileHandle *gfh = guest_file_handle_find(handle, errp); GuestFileSeek *seek_data = NULL; FILE *fh; int ret; if (!gfh) { return NULL; fh = gfh->fh; ret = fseek(fh, offset, whence); if (ret == -1) { error_setg_errno(errp, errno, "failed to seek file"); } else { seek_data = g_new0(GuestFileSeek, 1); seek_data->position = ftell(fh); seek_data->eof = feof(fh); clearerr(fh); return seek_data;
1threat
why printf() is being partial here : I'm wondering why printf() when provided an array and no formatting options, successfully prints character arrays but while using integer arrays the compiler throws a warning and a garbage value is printed. Here's my code : [![enter image description here][1]][1] and here's my output : [![][2]][2] why this behavior by printf()? [1]: https://i.stack.imgur.com/BhE4p.png [2]: https://i.stack.imgur.com/SFfNz.jpg
0debug
replace password reset mail template with custom template laravel 5.3 : <p>I did the laravel command for authentication system , <code>php artisan make:auth</code> it made the authentication system for my app and almost everything is working.</p> <p>Now when i use the forgot password and it sends me a token to my mail id , i see that the template contains laravel and some other things that i might wanna edit or ommit, to be precise , i want my custom template to be used there.</p> <p>I looked up at the controllers and their source files but i can't find the template or the code that is displaying the html in the mail.</p> <p>How do i do it ? </p> <p>How do i change it?</p> <p>This is the default template that comes from laravel to the mail. <a href="https://i.stack.imgur.com/Gw6XX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Gw6XX.png" alt="enter image description here"></a></p>
0debug
What is different between props and vars object in JMeter : <p>Im new in load and performance testing so could anyone explain me, what is difference between vars object and props object in JMeter beanshell script.</p> <p>Im also bit confuse about JMeter variable and properties.</p> <p>Thanks.</p>
0debug
Average of empty list throws InvalidOperationException: Sequence contains no elements : <p>The following code</p> <pre><code>double avg = item?.TechnicianTasks?.Average(x =&gt; x.Rating) ?? 0 </code></pre> <p>throws </p> <blockquote> <p>InvalidOperationException: Sequence contains no elements</p> </blockquote> <p>the <code>item.TechnicianTasks</code> was supposed to be null, however I saw that it is an empty list, however why wouldn't the average just be zero? I'm not understanding the exception.</p>
0debug
void msi_write_config(PCIDevice *dev, uint32_t addr, uint32_t val, int len) { uint16_t flags = pci_get_word(dev->config + msi_flags_off(dev)); bool msi64bit = flags & PCI_MSI_FLAGS_64BIT; bool msi_per_vector_mask = flags & PCI_MSI_FLAGS_MASKBIT; unsigned int nr_vectors; uint8_t log_num_vecs; uint8_t log_max_vecs; unsigned int vector; uint32_t pending; if (!ranges_overlap(addr, len, dev->msi_cap, msi_cap_sizeof(flags))) { return; } #ifdef MSI_DEBUG MSI_DEV_PRINTF(dev, "addr 0x%"PRIx32" val 0x%"PRIx32" len %d\n", addr, val, len); MSI_DEV_PRINTF(dev, "ctrl: 0x%"PRIx16" address: 0x%"PRIx32, flags, pci_get_long(dev->config + msi_address_lo_off(dev))); if (msi64bit) { fprintf(stderr, " address-hi: 0x%"PRIx32, pci_get_long(dev->config + msi_address_hi_off(dev))); } fprintf(stderr, " data: 0x%"PRIx16, pci_get_word(dev->config + msi_data_off(dev, msi64bit))); if (flags & PCI_MSI_FLAGS_MASKBIT) { fprintf(stderr, " mask 0x%"PRIx32" pending 0x%"PRIx32, pci_get_long(dev->config + msi_mask_off(dev, msi64bit)), pci_get_long(dev->config + msi_pending_off(dev, msi64bit))); } fprintf(stderr, "\n"); #endif if (!(flags & PCI_MSI_FLAGS_ENABLE)) { return; } pci_device_deassert_intx(dev); log_num_vecs = (flags & PCI_MSI_FLAGS_QSIZE) >> (ffs(PCI_MSI_FLAGS_QSIZE) - 1); log_max_vecs = (flags & PCI_MSI_FLAGS_QMASK) >> (ffs(PCI_MSI_FLAGS_QMASK) - 1); if (log_num_vecs > log_max_vecs) { flags &= ~PCI_MSI_FLAGS_QSIZE; flags |= log_max_vecs << (ffs(PCI_MSI_FLAGS_QSIZE) - 1); pci_set_word(dev->config + msi_flags_off(dev), flags); } if (!msi_per_vector_mask) { return; } nr_vectors = msi_nr_vectors(flags); pending = pci_get_long(dev->config + msi_pending_off(dev, msi64bit)); pending &= 0xffffffff >> (PCI_MSI_VECTORS_MAX - nr_vectors); pci_set_long(dev->config + msi_pending_off(dev, msi64bit), pending); for (vector = 0; vector < nr_vectors; ++vector) { if (msi_is_masked(dev, vector) || !(pending & (1U << vector))) { continue; } pci_long_test_and_clear_mask( dev->config + msi_pending_off(dev, msi64bit), 1U << vector); msi_notify(dev, vector); } }
1threat
How to generate OpenApi 3.0 spec from existing Spring Boot App? : <p>I have a project (Spring Boot App + Kotlin) that I would like to have an Open API 3.0 spec for (preferably in YAML). The Springfox libraries are nice but they generate Swagger 2.0 JSON. What is the best way to generate an Open Api 3.0 spec from the annotations in my controllers? Is writing it from scratch the only way?</p>
0debug
How to change content of character array in C? : <pre><code>char a[]="abcd"; a[]="zxc"; printf("%s",a); </code></pre> <p>it gives me the error saying "error: expected expression before ']' token ". How do I change the value of my character array then?</p>
0debug
Hi, I can't read the txt file in to my array of objects and then print out the result : I am trying to read a file in to my array of objects from my Movie class and then print the results. public class Movie_Class { private int MovieID; private String MovieTitle; private String Director; private String Writer; private String Duration; private String Genre; private String Classification; private String ReleaseDate; private Double Rating; public Movie_18512117(int ID, String Title, String Mdirector, String Mwriter, String Mduration, String Mgenre, String Mclassification, String MreleaseDate, Double Mrating) { MovieID = ID; MovieTitle= Title; Director= Mdirector; Writer= Mwriter; Duration= Mduration; Genre= Mgenre; Classification= Mclassification; ReleaseDate= MreleaseDate; Rating= Mrating; } public int getMovieID(){ return MovieID; } public String getMovieTitle(){ return MovieTitle; } public String getDirector(){ return Director; } public String getWriter(){ return Writer; } public String getDuration(){ return Duration; } public String getGenre(){ return Genre; } public String getClassification(){ return Classification; } public String getReleaseDate(){ return ReleaseDate; } public Double getRating(){ return Rating; } public void setMovieID(int MovieID) { this.MovieID = MovieID; } public void setMovieTitle(String MovieTitle){ this.MovieTitle = MovieTitle; } public void setDirector(String Director) { this.Director = Director; } public void setWriter(String Writer) { this. Writer = Writer; } public void setDuration(String Duration) { this. Duration = Duration; } public void setGenre(String Genre) { this.Genre = Genre; } public void setClassification(String Classification){ this.Classification = Classification; } public void setReleaseDate(String ReleaseDate){ this.ReleaseDate = ReleaseDate; } public void setRating(Double Rating){ this.Rating = Rating; } } import java.io.File; import java.util.Scanner; import java.io.FileNotFoundException; public class movie { public static void main(String[] args) throws FileNotFoundException { File myFile = new File ("movieLibrary.txt"); Scanner inputFile = new Scanner(myFile); String str; Movie_Class[] movie = new Movie_Class[100]; String[] tokens; while (inputFile.hasNext()){ str=inputFile.next(); tokens = str.split(","); for(int i = 0; i < movies.length; i++){ movie[i] = new Movie_18512117(1); > //I don't know how to read the lines in to //my array and split the spaces, then print the result. System.out.println(movie); } } inputFile.close(); } } > thanks i am still new to java
0debug
convert array from inches to cm : <p>I was tasked with having an array that starts with size 10, then have user input heights in inches and stores it inside the array and then a new array converts all of those elements inside the initial array to cm. I have absolutely no idea what to do and really need help. How do I fix this?</p> <pre><code>double[] heightInches = new double[10]; int currentSize = 0; Scanner in = new Scanner(System.in); System.out.print("Please enter heights (inches), Q to quit: "); while (in.hasNextDouble() &amp;&amp; currentSize &lt; heightInches.length) { heightInches[currentSize] = in.nextDouble(); currentSize++; } double[] result = convert(heightInches); System.out.println("Heights in cm: " + result); } public static double[] convert(double[] inches) { double heightCm[] = new double[inches.length]; for( int i = 0; i &lt; inches.length; i++) { heightCm[i] = inches[i] * 2.54; } return heightCm; } } </code></pre>
0debug
VBA Code to copy specific range cells from multiple sheets to one sheet : I am new to VBA Coding hence this question here. I have tried with few samples but didn't work out. I have a master excel workbook in one folder and 100+ child excel workbook in different folder. Every week I need to copy specific range of cells from 100 + child excel work books (sheet name is same for all child books) to master workbook (specific sheet). Can someone help me with VBA Code?
0debug
round up an integer to decimal - SQL : My issue is the following: I have an integer (i.e. 345) and i want to have a comma after the first number (so, 3,45) and to be rounded up to 1 decimal place (3,5). How can I get this using SQL?
0debug
What is the difference between type, value_type and element_type, and when to use each? : <p>I have written a template class that should expose its template parameter, but I am unsure of the appropriate naming.</p> <p>I have found three different names for essentially the same thing (as far as I can tell):</p> <ul> <li>containers, e.g., <code>std::vector</code> use <code>value_type</code></li> <li>smart pointers, e.g., <code>std::unique_ptr</code> use <code>element_type</code></li> <li><code>std::reference_wrapper</code> uses just <code>type</code></li> </ul> <p>What is the idea behind these different names? What standard algorithms or trait classes depend on which name? Which name should I use for my class (something in between a smart pointer and reference wrapper)?</p>
0debug
Swift development pods : <p>is there some good tutorial where I can follow, is there a good tutorial for better understanding, the ones I find i just create the pod and them publish, there is no implementation for me start to develop my own</p>
0debug
how to change install postgis location? postgres : <p>When I am in my postgres db and tried to create an extension for my db, I get this error</p> <p><code>ERROR: could not open extension control file "/usr/share/postgresql/9.5/extension/postgis.control": No such file or directory</code></p> <p>I know there are so many posts out there with this error and solutions and I tried them all too. Found so much in stackoverflow but none of them worked.</p> <p>I realized in my <code>postgresql</code> directory there are <code>9.2</code>, <code>9.3</code>, <code>9.4</code>, <code>9.5</code>, <code>9.6</code>, </p> <p>I went into the directory in the error and I realized there is really no <code>postgis.control</code> inside <code>9.5</code></p> <p>I checked my psql version and showed 9.6.1</p> <p>I went into <code>9.6</code> folder and I DO see a <code>postgis.control</code> in it.</p> <p>I want to changed the installation directory so when i run</p> <p><code>create extension postgis</code></p> <p>it would go</p> <p><code>"/usr/share/postgresql/9.6/extension/postgis.control"</code></p> <p>instead of</p> <p><code>"/usr/share/postgresql/9.5/extension/postgis.control"</code></p> <p>Can someone please give me a hand?</p> <p>Thanks in advance.</p> <p>P.S. Using Ubuntu 14.04 and also have Ubuntu 16.04 as desktop which I haven't try to install postgis yet</p>
0debug
Video Editor in Flutter using dart : <p>I am looking for a plugin or example of a video editor in flutter using dart.</p> <p>I have tried the following plugin <a href="https://pub.dartlang.org/packages/video_player" rel="noreferrer">https://pub.dartlang.org/packages/video_player</a>, but it doesn't seems to have properties that I can edit the video. Example trim or add a watermark on the video.</p> <p>Many Thanks</p>
0debug