problem
stringlengths
26
131k
labels
class label
2 classes
How can stop show notification when chat activity is already opened using firebase in android? : <p>I want to stop show notification when chat activity is already opened.</p>
0debug
List of values to list of strings : <p>How to convert it:</p> <pre><code>var values = new List&lt;object&gt; { 1, 5, "eeE", MyEnum.Value }; </code></pre> <p>To</p> <pre><code>var stringValues = new List&lt;object&gt; { "1", "5", "eeE", MyEnum.Value.ToString() }; </code></pre> <p>But do it in fast way? </p>
0debug
Use if in sql-server : I have a small query in my stored procedure: (case when t.status =4 and (select top 1 nd.status from tableND nd where nd.Code= t.Code order by nd.ID desc)=4 then 6 else t.status end) as status from tableTC t The problem is the speed performance too slow. So, I wanna change it into another query. What should i do now ?
0debug
java pattern ....code for the pattern : 1 1 2 1 1 3 3 1 n lines the logic i made import java.io.*; class pat { public static void main(String[] args)throws IOException { BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); int n,p=0; System.out.println("Enter value of n"); n=Integer .parseInt(in.readLine()); for(int i=0;i<n;i++) { for(int j=0;j<n-i;j++) { System.out.print(" "); } for(int k=0;k<=i;k++) { System.out.print((int)Math.pow(11,p)); } System.out.println(); p++; } } }
0debug
static int32_t scsi_send_command(SCSIRequest *req, uint8_t *buf) { SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req); SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); int32_t len; uint8_t command; uint8_t *outbuf; int rc; command = buf[0]; outbuf = (uint8_t *)r->iov.iov_base; DPRINTF("Command: lun=%d tag=0x%x data=0x%02x", req->lun, req->tag, buf[0]); #ifdef DEBUG_SCSI { int i; for (i = 1; i < r->req.cmd.len; i++) { printf(" 0x%02x", buf[i]); } printf("\n"); } #endif if (req->lun) { DPRINTF("Unimplemented LUN %d\n", req->lun); if (command != REQUEST_SENSE && command != INQUIRY) { scsi_check_condition(r, SENSE_CODE(LUN_NOT_SUPPORTED)); return 0; } } switch (command) { case TEST_UNIT_READY: case REQUEST_SENSE: case INQUIRY: case MODE_SENSE: case MODE_SENSE_10: case RESERVE: case RESERVE_10: case RELEASE: case RELEASE_10: case START_STOP: case ALLOW_MEDIUM_REMOVAL: case READ_CAPACITY_10: case SYNCHRONIZE_CACHE: case READ_TOC: case GET_CONFIGURATION: case SERVICE_ACTION_IN: case REPORT_LUNS: case VERIFY_10: rc = scsi_disk_emulate_command(r, outbuf); if (rc < 0) { return 0; } r->iov.iov_len = rc; break; case READ_6: case READ_10: case READ_12: case READ_16: len = r->req.cmd.xfer / s->qdev.blocksize; DPRINTF("Read (sector %" PRId64 ", count %d)\n", r->req.cmd.lba, len); if (r->req.cmd.lba > s->max_lba) goto illegal_lba; r->sector = r->req.cmd.lba * s->cluster_size; r->sector_count = len * s->cluster_size; break; case WRITE_6: case WRITE_10: case WRITE_12: case WRITE_16: case WRITE_VERIFY_10: case WRITE_VERIFY_12: case WRITE_VERIFY_16: len = r->req.cmd.xfer / s->qdev.blocksize; DPRINTF("Write %s(sector %" PRId64 ", count %d)\n", (command & 0xe) == 0xe ? "And Verify " : "", r->req.cmd.lba, len); if (r->req.cmd.lba > s->max_lba) goto illegal_lba; r->sector = r->req.cmd.lba * s->cluster_size; r->sector_count = len * s->cluster_size; break; case MODE_SELECT: DPRINTF("Mode Select(6) (len %lu)\n", (long)r->req.cmd.xfer); if (r->req.cmd.xfer > 12) { goto fail; } break; case MODE_SELECT_10: DPRINTF("Mode Select(10) (len %lu)\n", (long)r->req.cmd.xfer); if (r->req.cmd.xfer > 16) { goto fail; } break; case SEEK_6: case SEEK_10: DPRINTF("Seek(%d) (sector %" PRId64 ")\n", command == SEEK_6 ? 6 : 10, r->req.cmd.lba); if (r->req.cmd.lba > s->max_lba) { goto illegal_lba; } break; case WRITE_SAME_16: len = r->req.cmd.xfer / s->qdev.blocksize; DPRINTF("WRITE SAME(16) (sector %" PRId64 ", count %d)\n", r->req.cmd.lba, len); if (r->req.cmd.lba > s->max_lba) { goto illegal_lba; } if (!(buf[1] & 0x8)) { goto fail; } rc = bdrv_discard(s->bs, r->req.cmd.lba * s->cluster_size, len * s->cluster_size); if (rc < 0) { goto fail; } break; default: DPRINTF("Unknown SCSI command (%2.2x)\n", buf[0]); scsi_check_condition(r, SENSE_CODE(INVALID_OPCODE)); return 0; fail: scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); return 0; illegal_lba: scsi_check_condition(r, SENSE_CODE(LBA_OUT_OF_RANGE)); return 0; } if (r->sector_count == 0 && r->iov.iov_len == 0) { scsi_req_complete(&r->req, GOOD); } len = r->sector_count * 512 + r->iov.iov_len; if (r->req.cmd.mode == SCSI_XFER_TO_DEV) { return -len; } else { if (!r->sector_count) r->sector_count = -1; return len; } }
1threat
static void do_change(const char *device, const char *target, const char *fmt) { if (strcmp(device, "vnc") == 0) { do_change_vnc(target); } else { do_change_block(device, target, fmt); } }
1threat
Hi,Do you encounter some problems about linux version and jdk version is not compatible : the same code ,when I use maven to package codes on the linux Linux 6.0.10,the final jar can not run successful,but I do this on Linux 8 ,it works well The jdk version is 1.8 Exception as following: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.context.event.internalEventListenerProcessor': Instantiation of bean failed; nested exception is java.lang.IllegalStateException: No bean class specified on bean definition at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1287) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1181) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:179) ~[spring-context-5.1.5.RELEASE.jar!/:5.1.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705) ~[spring-context-5.1.5.RELEASE.jar!/:5.1.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) ~[spring-context-5.1.5.RELEASE.jar!/:5.1.5.RELEASE] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:142) ~[spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:775) [spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:316) [spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1260) [spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1248) [spring-boot-2.1.3.RELEASE.jar!/:2.1.3.RELEASE] at cn.j.lithium.LithiumApplication.main(LithiumApplication.java:16) [classes!/:0.0.1-SNAPSHOT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_131] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_131] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_131] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_131] at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [lithium-0.0.1-test.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [lithium-0.0.1-test.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [lithium-0.0.1-test.jar:0.0.1-SNAPSHOT] at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [lithium-0.0.1-test.jar:0.0.1-SNAPSHOT] Caused by: java.lang.IllegalStateException: No bean class specified on bean definition at org.springframework.beans.factory.support.AbstractBeanDefinition.getBeanClass(AbstractBeanDefinition.java:407) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE] at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:68) ~[spring-beans-5.1.5.RELEASE.jar!/:5.1.5.RELEASE
0debug
How to connect to the DB with DBIx::Class without repeating connection details? : https://metacpan.org/pod/distribution/DBIx-Class/lib/DBIx/Class/Manual/Intro.pod suggest to connect to the DB as the following: my $schema = MyApp::Schema->connect(...); explicitly providing the connection details such as the password. However I want to connect to the same database from different scripts. It would be unwise to provide the password in each of the scripts again and again. So my question: What is the "official" way to create a connection method with fixed connection details? I realize that I can write something like: package MyApp::Schema; use base qw/DBIx::Class::Schema/; sub my_connect { $_[0]::SUPER->connect(...); } 1; But is this the right "official" way to do this? I realize that providing another connection details may be useful for testing scripts, but in the reality we do not (yet) use testing scripts, so this is largely irrelevant for out team.
0debug
Need Db audit info query in SQL server for these columns : Good day will you please provide a single query in SQL Server to fetch Audit information of databases and tables in the server as below Database audit should include records count in each table, tables size, databases size and drives size in the server including Server name Thanks in advance
0debug
how to solve System.Drawing - Parameter is not valid : how to solve System.Drawing Parameter is not valid when i use code: string img2 = "http://13.228.146.249:8080/jcr/groups/629.png; byte[] toBytes = Encoding.ASCII.GetBytes(img2); if (toBytes != null) { MemoryStream ms = new MemoryStream(toBytes); ms.Position = 0; picboxserver.Image = Image.FromStream(ms); } picboxserver is picturebox type.
0debug
How to prevent IIS from shutting down Web Site when not in use? : <p>I have a web application hosted under IIS. It is a data warehouse, and during its startup process it requires instantiating a large set of items in memory (takes roughly ~20 minutes to fully set up). Because this website is critical to our company, this system <strong>must be online 100%</strong> during the daytime, and only can be restarted during off-work hours.</p> <p>For some reason, this web application seems to be "offline" when there is no usage for some time. I know this because the cache is not fully instantiated when the website is visited. This is unacceptable.</p> <p>It is not clear to me why the website is shut off. The application pool is only set to recycle daily at 4:00 AM (it is 11 AM now). </p> <p>Are there other settings which I'm not aware of on the IIS part that causes it to shut down the website automatically?</p> <p>Addl Note: The website does not shut off automatically when running in <strong>IISExpress</strong> in Visual Studio. Only the production version hosted on IIS shuts off.</p> <p>Here's a screen of the Advanced Settings for the Application Pool the web site is running under. (Not sure if it's useful.)</p> <p><a href="https://i.stack.imgur.com/J86DI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/J86DI.png" alt="Application Pool Settings"></a></p> <p>I'm on IIS 7.5, Server 2008 R2. It is an ASP.NET 5 Web App.</p>
0debug
Jupyter command `jupyter-lab` not found : <p>I have tried to install jupyter lab on my Kubuntu machine. If I install jupyter lab with 'pip3 install jupyter jupyterlab' the command 'jupyter notebook' works completly fine. But if I try to run 'jupyter lab' every time I get the message:</p> <pre><code>Traceback (most recent call last): File "/usr/local/bin/jupyter", line 11, in &lt;module&gt; sys.exit(main()) File "/usr/local/lib/python3.6/dist-packages/jupyter_core/command.py", line 230, in main command = _jupyter_abspath(subcommand) File "/usr/local/lib/python3.6/dist-packages/jupyter_core/command.py", line 133, in _jupyter_abspath 'Jupyter command `{}` not found.'.format(jupyter_subcommand) Exception: Jupyter command `jupyter-lab` not found. </code></pre> <p>What is wrong?</p> <p>I tried to reinstall jupyter and jupyterlab multiple times with the same issue.</p>
0debug
static void pulse_get_output_timestamp(AVFormatContext *h, int stream, int64_t *dts, int64_t *wall) { PulseData *s = h->priv_data; pa_usec_t latency; int neg; pa_threaded_mainloop_lock(s->mainloop); pa_stream_get_latency(s->stream, &latency, &neg); pa_threaded_mainloop_unlock(s->mainloop); *wall = av_gettime(); *dts = s->timestamp - (neg ? -latency : latency); }
1threat
no writing on output file c++ : <p>a strange thing happens when i try to write on a output file:</p> <pre><code> int main(int argc, char* argv[]) { std::string outputFile = "fitness.out"; ofstream output( outputFile.c_str() ); FitnessFactory fitnessFactory; //if i write on file here it's ok vector&lt;string&gt; params; params[0]= 10; params[1]=120; //if i write on file here not ok, file empty Strategy* strategy = fitnessFactory.getStrategy("OneMax", params); vector&lt;string&gt; individual; for(unsigned i = 0; i &lt; argc-1; i++){ string inputFile = argv[i+1]; ifstream input( inputFile.c_str() ); while( input.good() ) { string temp; input&gt;&gt;temp; individual.push_back(temp); } input.close(); // if i write on file, before call strategy-&gt;evaluate,for example // output &lt;&lt; "hello"&lt;&lt;endl; // file contains "hello" string res = strategy-&gt;evaluate(individual); //if i write here file is empty //output&lt;&lt; res &lt;&lt; endl; } </code></pre> <p>Others cpp file are: </p> <p>factoryMethod.cpp</p> <pre><code> #include &lt;stdio.h&gt; #include "strategy.cpp" using namespace std; class factoryMethod { public: virtual Strategy* getStrategy(string x, vector&lt;string&gt; params) = 0; }; Strategy* factoryMethod :: getStrategy(string x, vector&lt;string&gt; params) { } class FitnessFactory : public factoryMethod { public: Strategy* getStrategy(string x, vector&lt;string&gt; params) { Strategy* s; if(x=="OneMax") s = new OneMax(); else if (x=="Weierstrass") s = new Weiestrass(); return s; } }; </code></pre> <p>strategy.cpp</p> <pre><code>std::string Convert (float number){ std::ostringstream buff; buff&lt;&lt;number; return buff.str(); } class Strategy { public: virtual string evaluate(vector&lt;string&gt; v) = 0; virtual void strategy(vector&lt;string&gt; params); public: vector&lt;string&gt; fparams; }; string Strategy :: evaluate(vector&lt;string&gt; v) { } void Strategy :: strategy(vector&lt;string&gt; v){ fparams = v; } class OneMax : public Strategy { public: string evaluate(vector&lt;string&gt; v) { string x = v[0]; int count = 0; for (int i = 0; i &lt; x.size(); i++) if (x[i] == '1') count = count + 1; string ret = static_cast&lt;ostringstream*&gt;( &amp; (ostringstream() &lt;&lt; count) )-&gt;str(); return ret; } }; class Weiestrass: public Strategy { public: string evaluate(vector&lt;string&gt; v) { // int repetitions = atoi( fparams[0].c_str() ); // int iterations = atoi( fparams[1].c_str() ); int repetitions = 10; int iterations = 120; vector&lt;float&gt; x; for(int i = 0; i &lt; v.size(); i++){ float temp = ::atof(v[i].c_str()); x[i] = temp; } float fRes=0, fSum, b=2, h=0.5; for (int j = 0; j &lt; repetitions; j++) { fRes = 0; for (int i = 0; i &lt; x.size(); i++) { fSum=0; for (int k = 0; k &lt; iterations; k++) fSum += pow(b,- (float)k*h) * sin(pow(b,(float)k)*x[i]); fRes += abs(fSum); } } string s = Convert(fRes); return s; } }; </code></pre> <p>So when I try to write the result of the function or any other value after the call to evaluate the file is blank. I do not understand why??!!</p>
0debug
Python: How to show matplotlib in flask : <p>I'm very new to Flask and Matplotlib. I'd like to be able to show a simple chart I generated in some html, but I'm having a very hard time figuring out how. Here is my Python code:</p> <pre><code>from flask import Flask, render_template import numpy as np import pandas import matplotlib.pyplot as plt app = Flask(__name__) variables = pandas.read_csv('C:\\path\\to\\variable.csv') price =variables['price'] @app.route('/test') def chartTest(): lnprice=np.log(price) plt.plot(lnprice) return render_template('untitled1.html', name = plt.show()) if __name__ == '__main__': app.run(debug = True) </code></pre> <p>And here is my HTML:</p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;body&gt; &lt;h1&gt;Price Chart&lt;/h1&gt; &lt;p&gt;{{ name }}&lt;/p&gt; &lt;img src={{ name }} alt="Chart" height="42" width="42"&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
0debug
SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockDriverState *bdrv, int unit) { const char *driver; DeviceState *dev; driver = bdrv_is_sg(bdrv) ? "scsi-generic" : "scsi-disk"; dev = qdev_create(&bus->qbus, driver); qdev_prop_set_uint32(dev, "scsi-id", unit); if (qdev_prop_set_drive(dev, "drive", bdrv) < 0) { qdev_free(dev); return NULL; } if (qdev_init(dev) < 0) return NULL; return DO_UPCAST(SCSIDevice, qdev, dev); }
1threat
Dictionary Contain NSNULL Swift : Is there any way to detect that Dictionary contain NSNull Value. Is there any way to detect that Dictionary contain NSNull Value.
0debug
import sys def find_max_val(n, x, y): ans = -sys.maxsize for k in range(n + 1): if (k % x == y): ans = max(ans, k) return (ans if (ans >= 0 and ans <= n) else -1)
0debug
File download through Angular 2 : <p>I have a backend that I set up to return a file through setting the header</p> <pre><code>Content-Disposition: attachment;filename=somefile.csv </code></pre> <p>It works directly in the browser and downloads the file immediately upon invoking the URL that points to that resource.</p> <p>My goal is to have a button in an Angular 2 template. When the user clicks that button, I'd need to collect some data from the client-side (some IDs) and send it to the server to invoke that file download URL.</p> <p>I'd like the user to stay on the same page and not have any new tabs open up but simply have the file start downloading (just like when the URL is invoked directly).</p> <p>It will need to be done through a <strong>POST request</strong> because I can have quite a bit of data to send to identify what resource needs to be downloaded.</p> <p>What does the call on the Angular 2 side look like for this? I tried a couple of things but I am obviously on the wrong path.</p> <p>Any help would be appreciated!</p>
0debug
static inline void RENAME(rgb15to16)(const uint8_t *src,uint8_t *dst,long src_size) { register const uint8_t* s=src; register uint8_t* d=dst; register const uint8_t *end; const uint8_t *mm_end; end = s + src_size; #ifdef HAVE_MMX __asm __volatile(PREFETCH" %0"::"m"(*s)); __asm __volatile("movq %0, %%mm4"::"m"(mask15s)); mm_end = end - 15; while(s<mm_end) { __asm __volatile( PREFETCH" 32%1\n\t" "movq %1, %%mm0\n\t" "movq 8%1, %%mm2\n\t" "movq %%mm0, %%mm1\n\t" "movq %%mm2, %%mm3\n\t" "pand %%mm4, %%mm0\n\t" "pand %%mm4, %%mm2\n\t" "paddw %%mm1, %%mm0\n\t" "paddw %%mm3, %%mm2\n\t" MOVNTQ" %%mm0, %0\n\t" MOVNTQ" %%mm2, 8%0" :"=m"(*d) :"m"(*s) ); d+=16; s+=16; } __asm __volatile(SFENCE:::"memory"); __asm __volatile(EMMS:::"memory"); #endif mm_end = end - 3; while(s < mm_end) { register unsigned x= *((uint32_t *)s); *((uint32_t *)d) = (x&0x7FFF7FFF) + (x&0x7FE07FE0); d+=4; s+=4; } if(s < end) { register unsigned short x= *((uint16_t *)s); *((uint16_t *)d) = (x&0x7FFF) + (x&0x7FE0); } }
1threat
order by charindex >0 and SQL concat : <p>I want to order Recordset by setting priority when ID is in an array:</p> <p>This is the comma separated <strong>myString</strong> which holds a series of ID: <code>,1,2,4,6,8,12,34,</code></p> <p>I use concat to add comma before and after ID so I can compare it against the string:</p> <pre><code>sql="select * from customers order by case when charindex( concat(','," &amp; id &amp; ",',') , '" &amp; myString &amp; "' )&gt;0 then 1 else 0 end desc" </code></pre> <p>I get <strong>syntax error</strong> message. I am not sure if there is error in SQL structure as I used <code>concat</code> in deep structure or there is error in using quote and double quote?</p>
0debug
Getting Permission denied (publickey) : <p>I am trying to do ssh to Google Cloud instance.I am able to do ssh to my username (lets say my pc user name is apple then I can access apple username) but when I am trying to access different username on same instance (lets say info) then its giving me "Permission Denied (public key)".</p> <p>I am new bee in linux, please help me how I can access different username directory from my system.</p>
0debug
How to run .exe file within program : <p>In eclipse, if you have a .exe file in the package how would you run it? I know if it is outside you would just add in the path, but what would the path be for something inside the project?</p>
0debug
static void close_file(OutputStream *os) { int64_t pos = avio_tell(os->out); avio_seek(os->out, 0, SEEK_SET); avio_wb32(os->out, pos); avio_flush(os->out); avio_close(os->out); os->out = NULL; }
1threat
Why PHP echo printf adds unexpected symbols : <p>I have php code:</p> <pre><code>$searchTitlePersonType = ($isTravelAgency == true ? "tourists" : "persons"); var_dump($searchTitlePersonType); // Right behavior </code></pre> <p>The same time, when I try to implement it on my template:</p> <pre><code>&lt;?php echo printf( $this-&gt;translate("Поиск %s"), $searchTitlePersonType ); ?&gt; </code></pre> <p>I'm taking different unexpected numbers at the end of string: "tourists33" or "persons27". It's not depend of coding page of string and there is a lot of people who find the way to resolve it - do not combine <code>echo printf</code> in one line of code, but here my question about this problem: WHY does it happen?</p> <p>Links: </p> <p><a href="https://stackoverflow.com/questions/10849470/php-printf-adds-number-to-output">php printf adds number to output</a></p> <p><a href="https://stackoverflow.com/questions/13776231/php-printf-adds-something-after-formatted-string">PHP printf adds something after formatted string</a></p>
0debug
GCC can't find stdio.h in Alpine Linux : <p>In a fresh Alpine Linux I installed GCC by</p> <pre><code>apk add --update-cache gcc </code></pre> <p>but still a simple program</p> <pre><code>#include &lt;stdio.h&gt; int main(int argc, char *argv[]) { return 0; } </code></pre> <p>compiled with message</p> <pre class="lang-none prettyprint-override"><code>fatal error: stdio.h: No such file or directory </code></pre>
0debug
Python : list of strings to list of unique characters : <p>I have a list of strings </p> <pre><code>ll = ['abc', 'abd', 'xyz', 'xzk'] </code></pre> <p>I want a list of unique characters across all strings in the given list. </p> <p>For ll, output should be </p> <pre><code>['a','b','c','d','x','y','z','k'] </code></pre> <p>is there a clean way to do this ?</p>
0debug
How to properly make REST calls from ReactJS + Redux application? : <p>I'm using ReactJS + Redux, along with Express and Webpack. There is an API built, and I want to be able to make REST calls -- GET, POST, PUT, DELETE -- from the client-side. </p> <p>How and what is the properly way to go about doing so with the Redux architecture? Any good example of the flow, in terms of reducers, action creators, store, and react routes, would be extremely helpful. </p> <p>Thank you in advance!</p>
0debug
static void quantize_and_encode_band_cost_NONE_mips(struct AACEncContext *s, PutBitContext *pb, const float *in, float *out, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, const float ROUNDING) { av_assert0(0); }
1threat
my code doesn't work (php) : <p>my code save info in database but doesn't send the message to email and the alert message not work. can you help me , please ? </p> <p>` <pre><code>if(isset($_POST['send'])){ $to = "nada_26_@hotmail.com"; // this is your Email address $subject = "Form contact"; $subject2 = "Copy of your form submission"; $name = $_POST['name']; $from = $_POST['email']; $subject3 = $_POST['subject']; $company = $_POST['company']; $content = $_POST['message']; $message = "Name: ".$name ." Subject: " . $subject3 . " Company: " . $company ."\n\n".$content; $message2 = "Here is a copy of your message " . "\n\n" . $_POST['message']; $headers = "From:" . $from; $headers2 = "From:" . $to; mail($to,$subject,$message,$headers); //send the message to the admin mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender $sql ="INSERT INTO threadnn_arab.contactus VALUES('$name','$from','$subject3','$company','$message','')"; $result=mysql_query($sql); echo "&lt;script&gt; alert('Mail Sent, Thank you, we will contact you shortly.'); &lt;/script&gt;"; header('Location: index.php?#contact'); } ?&gt; ` </code></pre>
0debug
Ruby - The integers in the array are either entirely odd or entirely even except for a single integer : You are given an array (which will have a length of at least 3, but could be very large) containing integers. The array is either entirely comprised of odd integers or entirely comprised of even integers except for a single integer N. Write a method that takes the array as an argument and returns this “outlier” N. My code so far, that doesn't seem to work: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> arr = [160, 3, 1719, 19, 11, 13, -21] n = arr.length def getOddOccurrence(arr, arr_size) for i in range(0, arr_size) count = 0 for j in range(0, arr_size) if arr[i] == arr[j] count +=1 end if(count % 2 != 0) return arr[i] end end end return -1 end print getOddOccurrence(arr,n) <!-- end snippet --> What do I need to change with this code please?
0debug
static int vf_open(vf_instance_t *vf, char *args){ vf->config=config; vf->put_image=put_image; vf->get_image=get_image; vf->query_format=query_format; vf->uninit=uninit; vf->control= control; vf->priv=malloc(sizeof(struct vf_priv_s)); memset(vf->priv, 0, sizeof(struct vf_priv_s)); if (args) sscanf(args, "%d:%d", &vf->priv->qp, &vf->priv->mode); if(vf->priv->qp < 0) vf->priv->qp = 0; init_thres2(); switch(vf->priv->mode){ case 0: requantize= hardthresh_c; break; case 1: requantize= softthresh_c; break; default: case 2: requantize= mediumthresh_c; break; } #if HAVE_MMX if(ff_gCpuCaps.hasMMX){ dctB= dctB_mmx; } #endif #if 0 if(ff_gCpuCaps.hasMMX){ switch(vf->priv->mode){ case 0: requantize= hardthresh_mmx; break; case 1: requantize= softthresh_mmx; break; } } #endif return 1; }
1threat
int kvm_s390_cpu_restart(S390CPU *cpu) { kvm_s390_interrupt(cpu, KVM_S390_RESTART, 0); s390_add_running_cpu(cpu); qemu_cpu_kick(CPU(cpu)); DPRINTF("DONE: KVM cpu restart: %p\n", &cpu->env); return 0; }
1threat
void register_watchdogs(void) { wdt_ib700_init(); wdt_i6300esb_init(); }
1threat
static int no_init_in (HWVoiceIn *hw, audsettings_t *as) { audio_pcm_init_info (&hw->info, as); hw->samples = 1024; return 0; }
1threat
static coroutine_fn int qcow_co_writev(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov) { BDRVQcowState *s = bs->opaque; int index_in_cluster; uint64_t cluster_offset; int ret = 0, n; struct iovec hd_iov; QEMUIOVector hd_qiov; uint8_t *buf; void *orig_buf; s->cluster_cache_offset = -1; if (bs->encrypted || qiov->niov > 1) { buf = orig_buf = qemu_try_blockalign(bs, qiov->size); if (buf == NULL) { return -ENOMEM; } qemu_iovec_to_buf(qiov, 0, buf, qiov->size); } else { orig_buf = NULL; buf = (uint8_t *)qiov->iov->iov_base; } qemu_co_mutex_lock(&s->lock); while (nb_sectors != 0) { index_in_cluster = sector_num & (s->cluster_sectors - 1); n = s->cluster_sectors - index_in_cluster; if (n > nb_sectors) { n = nb_sectors; } cluster_offset = get_cluster_offset(bs, sector_num << 9, 1, 0, index_in_cluster, index_in_cluster + n); if (!cluster_offset || (cluster_offset & 511) != 0) { ret = -EIO; break; } if (bs->encrypted) { assert(s->crypto); if (qcrypto_block_encrypt(s->crypto, sector_num, buf, n * BDRV_SECTOR_SIZE, NULL) < 0) { ret = -EIO; break; } } hd_iov.iov_base = (void *)buf; hd_iov.iov_len = n * 512; qemu_iovec_init_external(&hd_qiov, &hd_iov, 1); qemu_co_mutex_unlock(&s->lock); ret = bdrv_co_writev(bs->file, (cluster_offset >> 9) + index_in_cluster, n, &hd_qiov); qemu_co_mutex_lock(&s->lock); if (ret < 0) { break; } ret = 0; nb_sectors -= n; sector_num += n; buf += n * 512; } qemu_co_mutex_unlock(&s->lock); qemu_vfree(orig_buf); return ret; }
1threat
Why Angular method binding firing continiously? : <pre><code>@Component({ selector: 'calc', template: '&lt;p *ngIf="isCalculatable()"&gt;&lt;/p&gt;' }) export class CalcComponent { isCalculatable(){ console.log("yes"); return true; } } </code></pre> <p>When I use this component <code>&lt;calc&gt;&lt;/calc&gt;</code>, it writes "yes" to console continiously. I mean <code>isCalculatable()</code> method firing. So I am using this method so many times in my applicaitons. May this stuation be performance issue?</p>
0debug
static target_ulong h_put_term_char(CPUState *env, sPAPREnvironment *spapr, target_ulong opcode, target_ulong *args) { target_ulong reg = args[0]; target_ulong len = args[1]; target_ulong char0_7 = args[2]; target_ulong char8_15 = args[3]; VIOsPAPRDevice *sdev = spapr_vio_find_by_reg(spapr->vio_bus, reg); uint8_t buf[16]; if (!sdev) { return H_PARAMETER; } if (len > 16) { return H_PARAMETER; } *((uint64_t *)buf) = cpu_to_be64(char0_7); *((uint64_t *)buf + 1) = cpu_to_be64(char8_15); vty_putchars(sdev, buf, len); return H_SUCCESS; }
1threat
DoubleLinkedList adding element doesn't work and somehow it always stays empty : <p>As I said before DoubleLinkedList always stays empty...</p> <p>I have reread code. Firstly add utility seemed a bit suspicious but it looks correct for me. I have tried adding an element into the list but when I'm calling <em>empty()</em> function it always displays <em>True</em>. Given function seems right for me.</p> <pre><code>template &lt;typename T&gt; class DoubleLinkedList; // simple class declaration template &lt;typename T&gt; class Node { // double linked list node private: T data; // node element value Node *next; // next node in list Node *previous; // previous node in list friend DoubleLinkedList&lt;T&gt;; // allow DoubleLinkedList access }; template &lt;typename T&gt; class DoubleLinkedList { // doubly linked list; public: DoubleLinkedList(); // constructor ~DoubleLinkedList(); // destructor bool empty() const; // is list empty? const T&amp; front() const; // get front element const T&amp; back() const; // get back element void add_front(const T&amp; e); // add to front of list void add_back(const T&amp; e); // ad to back of list void remove_front(); // remove from front void remove_back(); // remove from back void ordered_traverse() const; private: // local type definitions // list sentinels (dummy nodes) Node&lt;T&gt;* header; Node&lt;T&gt;* tailer; protected: // local utilities void add(Node&lt;T&gt;* v, const T&amp; e); // insert new node before v void remove(Node&lt;T&gt;* v); // remove v node }; template &lt;typename T&gt; DoubleLinkedList&lt;T&gt;::DoubleLinkedList() { //constructor // create sentinels header = new Node&lt;T&gt;; tailer = new Node&lt;T&gt;; // have them point to each other header-&gt;next = tailer; tailer-&gt;previous = header; } template &lt;typename T&gt; // destructor, removing all but sentinels; remove the sentinels DoubleLinkedList&lt;T&gt;::~DoubleLinkedList() { while (!empty()) {remove_front(); delete header; delete tailer; }} template &lt;typename T&gt; void DoubleLinkedList&lt;T&gt;::ordered_traverse() const { Node&lt;T&gt;* cur = header-&gt;next; cout &lt;&lt; "Starting Traversing... \n"; while (cur != tailer){ cout &lt;&lt; cur-&gt;data &lt;&lt; endl; } } template &lt;typename T&gt; // is list empty? bool DoubleLinkedList&lt;T&gt;::empty() const { return header-&gt;next == tailer;} template &lt;typename T&gt; // get front element const T&amp; DoubleLinkedList&lt;T&gt;::front() const { return header-&gt;next-&gt;data; } template &lt;typename T&gt; // get back element const T&amp; DoubleLinkedList&lt;T&gt;::back() const { return tailer-&gt;previous-&gt;data; } template &lt;typename T&gt; // insert new node before v void DoubleLinkedList&lt;T&gt;::add(Node&lt;T&gt; *v, const T &amp;e) { auto* u = new Node&lt;T&gt;; u-&gt;data = e; // create a new node for e // link new node to its appropriate place u-&gt;next = v; u-&gt;previous = v-&gt;previous; v-&gt;previous-&gt;next = v-&gt;previous = u; } template &lt;typename T&gt; // add to front of list void DoubleLinkedList&lt;T&gt;::add_front(const T &amp;e) { add(header-&gt;next, e);} template &lt;typename T&gt; // add to back of list void DoubleLinkedList&lt;T&gt;::add_back(const T &amp;e) { add(tailer, e);} template &lt;typename T&gt; // remove node v void DoubleLinkedList&lt;T&gt;::remove(Node&lt;T&gt; *v) { if (empty()) throw std::out_of_range("Error: list is empty... \n"); Node&lt;T&gt;* u = v-&gt;previous; Node&lt;T&gt;* w = v-&gt;next; u-&gt;next = w; w-&gt;previous = u; delete v; } template &lt;typename T&gt; // remove from front void DoubleLinkedList&lt;T&gt;::remove_front() { remove(header-&gt;next);} template &lt;typename T&gt; // remove from back void DoubleLinkedList&lt;T&gt;::remove_back() { remove(tailer-&gt;previous);} </code></pre> <p>I need that adding method work the way it should and if you don't mind, please give me some advice about code's other flaws which I am not able to see because of my ignorance.</p>
0debug
python regex polish characters fail : I need to replace a string with polish characters. I tried something like that: k = 'aąkkk cdkkk aą xskkk' odp = re.sub('(?<!aą|cd)kkk', '***', k) print (odp) but it doesn't work. I get an error: File "/usr/lib/python2.7/re.py", line 244, in _compile raise error, v # invalid expression It's a problem with polish characters, because when I replace 'ą' character with 'a' char it work: k = 'aąkkk cdkkk aą xskkk' odp = re.sub('(?<!aa|cd)kkk', '***', k) print (odp) The answer is: aą*** cdkkk aą xs*** I found info that I should to use UNICODE, but it still doesn't work: a = re.compile(ur'(?<!\u0061\u0105|\u0063\u0064)kkk', re.UNICODE) a k = u'aąkkk cdkkk aą xskkk' odp = a.sub('***', k) print (odp) but the answear is : aą*** cdkkk aą xs*** Can you help me how resolve my problem? I'm so sorry for my mistakes with the English mistakes.
0debug
Deserializing json strings with go language : I want to deserialize json strings with the go language. The value types of different keys are different. for example,in string `{\"category\":\"6\",\"cid\":2511993760745787586}`,`category` type is `string`, `cid` type is int64. my code are as follws: ```go func main() { oriInfo := make([]interface{}, 0) pickled := "[{\"category\":\"6\",\"cid\":2511993760745787586},{\"category\":\"5\",\"cid\":2504429915944783937}]" err := json.Unmarshal([]byte(pickled), &oriInfo) if err != nil { fmt.Println(err) return } all := make([]map[string]interface{}, 0, len(oriInfo)) for _, val := range oriInfo { m := make(map[string]interface{}) for k, v := range val.(map[string]interface{}) { switch k { case "category": m[k] = v.(string) case "cid": m[k] = int64(v.(float64)) } } all = append(all, m) } fmt.Println(all) } ``` The results are as follows: `[map[category:6 cid:2511993760745787392] map[category:5 cid:2504429915944783872]]` Obviously, this is not what I want, is there a better way?
0debug
ClassCastException: java.lang.String cannot be cast : I need help. I have two methods of shared preference. They are getList and setList. This is setList() public static void setList(Application activity, List<tcmb> mValuesList) { StringBuilder valuesBuilder = new StringBuilder(); /*Log.d(TAG, "List Size ------ \t: " + mValuesList.size());*/ for (tcmb s : mValuesList) { valuesBuilder.append(s); valuesBuilder.append(","); Log.d(TAG, "setValuestcmb: " + valuesBuilder.toString()); } SharedPreferences values = activity.getSharedPreferences("dd", MODE_PRIVATE); SharedPreferences.Editor editor = values.edit(); editor.putString("ss", valuesBuilder.toString()); editor.apply(); } This is getList() public static List<tcmbDoviz> getValuesAltın(Activity a) { SharedPreferences values = a.getSharedPreferences("dd", MODE_PRIVATE); String wordsString = values.getString("ss", ""); /* Log.d(TAG, "wordsString \t:" + wordsString);*/ String[] itemWords = wordsString.split(","); List<String> itemList = new ArrayList<String>(); itemList.addAll(Arrays.asList(itemWords)); List<String> itemsList = new ArrayList<>(); dovizList = (List)itemsList; Log.d(TAG, "getValuesAltın: " + dovizList.size()); return dovizList; } For the values I got, I run the setList method in the asyncTask class of Main Activity that assigns to shared preference. Then for I get to values, I run the getList method in the asyncTask class of Fragment. And I get the object values.namely, I can see the values I get from the logcat. [com.example.lscodex.ddddd.Model.tcmb@4ff695, com.example.lscodex.ddddd.Model.tcmb@b6b93aa, com.example.lscodex.ddddd.Model.tcmb@347db9b, com.example.lscodex.ddddd.Model.tcmb@f63eb38, com.example.lscodex.ddddd.Model.tcmb@4866711, com.example.lscodex.ddddd.Model.tcmb@8c74076, com.example.lscodex.ddddd.Model.tcmb@3be9677, com.example.lscodex.ddddd.Model.tcmb@10882e4, com.example.lscodex.ddddd.Model.tcmb@8d9634d, com.example.lscodex.ddddd.Model.tcmb@b5eee02, com.example.lscodex.ddddd.Model.tcmb@b7c2313, com.example.lscodex.ddddd.Model.tcmb@a3ce950, com.example.lscodex.ddddd.Model.tcmb@ee5e749, com.example.lscodex.ddddd.Model.tcmb@fd1e84e, com.example.lscodex.ddddd.Model.tcmb@b7bdd6f, com.example.lscodex.ddddd.Model.tcmb@40f4a7c, com.example.lscodex.ddddd.Model.tcmb@b1caf05, com.example.lscodex.ddddd.Model.tcmb@b683b5a, com.example.lscodex.ddddd.Model.tcmb@f12e18b] totally 19 values. But when I cast values to recylerView's bindHolder in the fragment class, I get an error is that java.lang.ClassCastException: java.lang.String cannot be cast to com.example.lscodex.ddddd.Model.tcmb This is asyncTask from fragment private class DownloadXmlTask extends AsyncTask<Void, Integer, List<tcmb>> { @Override protected void onPreExecute() { super.onPreExecute(); mProgressBar.setVisibility(View.VISIBLE); } @Override protected List<tcmb> doInBackground(Void... voids) { return SharedPreferenceValues.getList(getActivity()); } @Override protected void onPostExecute(List<tcmb> tcmb) { if (tcmb.size() == 0) { mtcmbList = tcmb; setupAdapter(); mRecyclerViewAnim.runLayoutAnimation(getContext(), mRecyclerView); mProgressBar.setVisibility(View.INVISIBLE); } else if (mRecyclerView != null) { mtcmbList.addAll(tcmb); Log.d(TAG, "onPostExecute: " + mtcmbList.size()); mRecyclerView.getAdapter().notifyDataSetChanged(); dateUpdate(); mRecyclerViewAnim.runLayoutAnimation(getContext(), mRecyclerView); mProgressBar.setVisibility(View.INVISIBLE); mSwipeRefreshLayout.setRefreshing(false); } } } and the place where I got the error. @Override public void onBindViewHolder(tcmbHolder holder, int position) { tcmb tcmb= mtcmbList.get(position); ---- the error here holder.bindTcmb(tcmb); I don't know why?
0debug
I would like to convert 'A+B+C.E+F.G' into 'A.E.G+A.F.G+B.E.G+B.F.G+C.E.G+C.F.G' using R : I would like to convert this:</BR> `v_in <- 'A+B+C.E+F.G'` into this: </BR> `v_out <- 'A.E.G+A.F.G+B.E.G+B.F.G+C.E.G+C.F.G'` using R. ANy idea?
0debug
def mul_even_odd(list1): first_even = next((el for el in list1 if el%2==0),-1) first_odd = next((el for el in list1 if el%2!=0),-1) return (first_even*first_odd)
0debug
Cannot connect to Elasticsearch from Go server running in Docker : <p>I have set up an environment today that runs a <code>golang:1.13-alpine</code> image, along with the latest images for Elasticsearch and Kibana.</p> <p>Elasticsearch and Kibana are running fine when accessing from my local machine, but I cannot connect to Elasticsearch through the Go server. I have put this together from guides I have found and followed. </p> <p>I am still a bit green using Docker. I have an idea that I am pointing at the wrong ip address in the container, but I am unsure how to fix it. Hope someone can guide me in the right direction.</p> <p><strong>docker-compose.yml:</strong></p> <pre><code>version: "3.7" services: web: image: go-docker-webserver build: . ports: - "8080:8080" elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch:7.4.2 environment: node.name: elasticsearch cluster.initial_master_nodes: elasticsearch cluster.name: docker-cluster bootstrap.memory_lock: "true" ES_JAVA_OPTS: -Xms256m -Xmx256m ulimits: memlock: soft: -1 hard: -1 ports: - "9200:9200" kibana: image: docker.elastic.co/kibana/kibana:7.4.2 ports: - "5601:5601" links: - elasticsearch </code></pre> <p><strong>Dockefile:</strong></p> <pre><code>FROM golang:1.13-alpine as builder RUN apk add --no-cache --virtual .build-deps \ bash \ gcc \ git \ musl-dev RUN mkdir build COPY . /build WORKDIR /build RUN go get RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags '-extldflags "-static"' -o webserver . RUN adduser -S -D -H -h /build webserver USER webserver FROM scratch COPY --from=builder /build/webserver /app/ WORKDIR /app EXPOSE 8080 EXPOSE 9200 CMD ["./webserver"] </code></pre> <p><strong>main.go</strong>:</p> <pre><code>func webserver(logger *log.Logger) *http.Server { router := http.NewServeMux() router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { es, err := elasticsearch.NewDefaultClient() if err != nil { log.Fatalf("Error creating the client: %s", err) } res, err := es.Info() if err != nil { log.Fatalf("Error getting response: %s", err) } log.Println(res) }) return &amp;http.Server{ Addr: listenAddr, Handler: router, ErrorLog: logger, ReadTimeout: 5 * time.Second, WriteTimeout: 10 * time.Second, IdleTimeout: 15 * time.Second, } } </code></pre> <p>When I boot the server, everything is running fine and I can access Kibana and query the data that I have indexed, but as soon as I hit <code>localhost:8080</code> in Postman, the server dies and outputs: </p> <pre><code>web_1 | 2019/11/26 16:40:40 Error getting response: dial tcp 127.0.0.1:9200: connect: connection refused go-api_web_1 exited with code 1 </code></pre>
0debug
Why do we need to use import 'babel-polyfill'; in react components? : <p>I wonder if we user babel loader + all the presets, why do we need to include babel-polyfill anyway into our components? I just think that babel-loader should do all the job itself.</p> <p>Examples were taken here <a href="https://github.com/reactjs/redux/tree/master/examples" rel="noreferrer">https://github.com/reactjs/redux/tree/master/examples</a></p> <p>What i am asking about is:</p> <pre><code>import 'babel-polyfill'; import React from 'react'; import { render } from 'react-dom'; import App from './containers/App'; </code></pre> <p>Here is package example:</p> <pre><code>{ "name": "redux-shopping-cart-example", "version": "0.0.0", "description": "Redux shopping-cart example", "scripts": { "start": "node server.js", "test": "cross-env NODE_ENV=test mocha --recursive --compilers js:babel-register", "test:watch": "npm test -- --watch" }, "repository": { "type": "git", "url": "https://github.com/reactjs/redux.git" }, "license": "MIT", "bugs": { "url": "https://github.com/reactjs/redux/issues" }, "homepage": "http://redux.js.org", "dependencies": { "babel-polyfill": "^6.3.14", "react": "^0.14.7", "react-dom": "^0.14.7", "react-redux": "^4.2.1", "redux": "^3.2.1", "redux-thunk": "^1.0.3" }, "devDependencies": { "babel-core": "^6.3.15", "babel-loader": "^6.2.0", "babel-preset-es2015": "^6.3.13", "babel-preset-react": "^6.3.13", "babel-preset-react-hmre": "^1.1.1", "cross-env": "^1.0.7", "enzyme": "^2.0.0", "express": "^4.13.3", "json-loader": "^0.5.3", "react-addons-test-utils": "^0.14.7", "redux-logger": "^2.0.1", "mocha": "^2.2.5", "node-libs-browser": "^0.5.2", "webpack": "^1.9.11", "webpack-dev-middleware": "^1.2.0", "webpack-hot-middleware": "^2.9.1" } } </code></pre> <p>Here is webpack config example taken from <a href="https://github.com/reactjs/redux/tree/master/examples" rel="noreferrer">https://github.com/reactjs/redux/tree/master/examples</a></p> <pre><code>var path = require('path') var webpack = require('webpack') module.exports = { devtool: 'cheap-module-eval-source-map', entry: [ 'webpack-hot-middleware/client', './index' ], output: { path: path.join(__dirname, 'dist'), filename: 'bundle.js', publicPath: '/static/' }, plugins: [ new webpack.optimize.OccurenceOrderPlugin(), new webpack.HotModuleReplacementPlugin() ], module: { loaders: [ { test: /\.js$/, loaders: [ 'babel?presets[]=react,presets[]=es2015,presets[]=react-hmre' ], exclude: /node_modules/, include: __dirname }, { test: /\.json$/, loaders: [ 'json' ], exclude: /node_modules/, include: __dirname } ] } } </code></pre>
0debug
static void display_picref(AVFilterBufferRef *picref, AVRational time_base) { int x, y; uint8_t *p0, *p; int64_t delay; if (picref->pts != AV_NOPTS_VALUE) { if (last_pts != AV_NOPTS_VALUE) { delay = av_rescale_q(picref->pts - last_pts, time_base, AV_TIME_BASE_Q); if (delay > 0 && delay < 1000000) usleep(delay); } last_pts = picref->pts; } p0 = picref->data[0]; puts("\033c"); for (y = 0; y < picref->video->h; y++) { p = p0; for (x = 0; x < picref->video->w; x++) putchar(" .-+#"[*(p++) / 52]); putchar('\n'); p0 += picref->linesize[0]; } fflush(stdout); }
1threat
How do i make random letter from a string? : <p>In python I want to know how to get random letter from string.</p> <p>eg. </p> <pre><code>randomize("HELLO") </code></pre> <blockquote> <pre><code>returns "L" </code></pre> </blockquote>
0debug
how to create ul li autocomplete input using pure JavaScript : <p>How to create ul/li autocomplete input using pure javascript without jquery.do not use option only ul/li.</p>
0debug
void ff_mpeg_unref_picture(MpegEncContext *s, Picture *pic) { int off = offsetof(Picture, mb_mean) + sizeof(pic->mb_mean); pic->tf.f = &pic->f; if (s->codec_id != AV_CODEC_ID_WMV3IMAGE && s->codec_id != AV_CODEC_ID_VC1IMAGE && s->codec_id != AV_CODEC_ID_MSS2) ff_thread_release_buffer(s->avctx, &pic->tf); else av_frame_unref(&pic->f); av_buffer_unref(&pic->hwaccel_priv_buf); if (pic->needs_realloc) ff_free_picture_tables(pic); memset((uint8_t*)pic + off, 0, sizeof(*pic) - off); }
1threat
Why didn't they design array index to start from 1? : <p>In many programming languages, the array index begins with 0. Is there a reason why it was designed so?</p> <p>According to me, it would have been more convenient if the length of the array was equal to the last index. We could avoid most of the <code>ArrayIndexOutOfBounds</code> exceptions. </p> <p>I can understand when it comes to a language like <code>C</code>. <code>C</code> is an old language and the developers may have not thought about the issues and discomfort. But in case of modern languages like java, they still had a chance to redefine the design. Why have they chosen to keep it the same?</p> <p>Is it somehow related to working of operating systems or did they actually wanted to continue with the familiar behaviour or design structure (though new programmers face a lot of problems related to this)?</p>
0debug
To JAVA professionals I want change value of the variable to value another to another value : i am try change value the variable NO_OF_QUESTIONS_PER_LEVEL from value 9 to 19 by By a function " IF " public class Constant { public static int NO_OF_QUESTIONS_PER_LEVEL = 9 ; public static int NO_OF_QUESTIONS_PER_LEVEL (int[] args ) { if( NO_OF_QUESTIONS_PER_LEVEL == 10 ) { NO_OF_QUESTIONS_PER_LEVEL = 11 ; //i want change value to 11 } else if( NO_OF_QUESTIONS_PER_LEVEL == 9 ) { NO_OF_QUESTIONS_PER_LEVEL = 19 ; //i want change value to 19 } else { NO_OF_QUESTIONS_PER_LEVEL = 10 ; // } } Where is the wrong place in the code
0debug
i want last 12 month + current month sale and my date format is string in mysql : select pd.DC_Date,sum(pd.Quantity-pd.Credit_Quantity) as 'Sales' from past_year_data pd inner join idash_tb2_product_list PL ON PD.Product_Name=PL.Product_Name where pd.Branch_Name = 'Delhi' and DATE_FORMAT(STR_TO_DATE(DC_Date,'%m'), '%M')=DATE_FORMAT(STR_TO_DATE('7/31/2017', '%m'), '%M') This is what i m trying to do
0debug
AWS ECS restart Service with the same task definition and image with no downtime : <p>I am trying to restart an AWS service (basically stop and start all tasks within the service) without making any changes to the task definition.</p> <p>The reason for this is because the image has the <code>latest</code> tag attached with every build.</p> <p>I have tried stopping all tasks and having the services recreate them but this means that there is some <code>temporarily unavailable</code> error when the services are restarting in my instances (2).</p> <p>What is the best way to handle this? Say, A blue-green deployment strategy so that there is no downtime?</p> <p>This is what I have currently. It'shortcomings is that my app will be down for a couple of seconds as the service's tasks are being rebuilt after deleting them.</p> <pre><code>configure_aws_cli(){ aws --version aws configure set default.region us-east-1 aws configure set default.output json } start_tasks() { start_task=$(aws ecs start-task --cluster $CLUSTER --task-definition $DEFINITION --container-instances $EC2_INSTANCE --group $SERVICE_GROUP --started-by $SERVICE_ID) echo "$start_task" } stop_running_tasks() { tasks=$(aws ecs list-tasks --cluster $CLUSTER --service $SERVICE | $JQ ".taskArns | . []"); tasks=( $tasks ) for task in "${tasks[@]}" do [[ ! -z "$task" ]] &amp;&amp; stop_task=$(aws ecs stop-task --cluster $CLUSTER --task "$task") done } push_ecr_image(){ echo "Push built image to ECR" eval $(aws ecr get-login --region us-east-1) docker push $AWS_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/repository:$TAG } configure_aws_cli push_ecr_image stop_running_tasks start_tasks </code></pre>
0debug
static int vorbis_encode_frame(AVCodecContext *avccontext, unsigned char *packets, int buf_size, void *data) { vorbis_enc_context *venc = avccontext->priv_data; const signed short *audio = data; int samples = data ? avccontext->frame_size : 0; vorbis_enc_mode *mode; vorbis_enc_mapping *mapping; PutBitContext pb; int i; if (!apply_window_and_mdct(venc, audio, samples)) return 0; samples = 1 << (venc->log2_blocksize[0] - 1); init_put_bits(&pb, packets, buf_size); put_bits(&pb, 1, 0); put_bits(&pb, ilog(venc->nmodes - 1), 0); mode = &venc->modes[0]; mapping = &venc->mappings[mode->mapping]; if (mode->blockflag) { put_bits(&pb, 1, 0); put_bits(&pb, 1, 0); } for (i = 0; i < venc->channels; i++) { vorbis_enc_floor *fc = &venc->floors[mapping->floor[mapping->mux[i]]]; uint16_t posts[MAX_FLOOR_VALUES]; floor_fit(venc, fc, &venc->coeffs[i * samples], posts, samples); floor_encode(venc, fc, &pb, posts, &venc->floor[i * samples], samples); } for (i = 0; i < venc->channels * samples; i++) venc->coeffs[i] /= venc->floor[i]; for (i = 0; i < mapping->coupling_steps; i++) { float *mag = venc->coeffs + mapping->magnitude[i] * samples; float *ang = venc->coeffs + mapping->angle[i] * samples; int j; for (j = 0; j < samples; j++) { float a = ang[j]; ang[j] -= mag[j]; if (mag[j] > 0) ang[j] = -ang[j]; if (ang[j] < 0) mag[j] = a; } } residue_encode(venc, &venc->residues[mapping->residue[mapping->mux[0]]], &pb, venc->coeffs, samples, venc->channels); avccontext->coded_frame->pts = venc->sample_count; venc->sample_count += avccontext->frame_size; flush_put_bits(&pb); return put_bits_count(&pb) >> 3; }
1threat
Why mutex is not working with 2 threads sharing resource c++? : I want to test a scenario where I check weak_ptr for validity and return shared_ptr. between checking and returning if some other thread delete the shared_ptr we would face exception. I tried to simulate same scenario using windows sleep or cout but it seems to be not working. code is as follows: #include <iostream> #include <thread> #include <windows.h> #include <mutex> using namespace std; mutex m; struct Block { int * p_ = nullptr; Block() { p_ = new int[10000]; refCount_++; } int refCount_; }; struct Weak_ptr { Block * p_ = nullptr; Weak_ptr() { p_ = new Block(); } void Addref() { p_->refCount_++; } void release() { delete[] p_; p_ = nullptr; cout << "\nptr deleted\n"; } }; void funct1(int x, Weak_ptr *ptr) { cout << "\nin thread 1 \n"; cout << "\nSleep thread 1\n"; //Sleep(x) for (int i = 0; i < x; i++) cout << "."; cout << "\nAwake thread 1\n"; ptr->release(); } void funct2(int x, Weak_ptr *ptr) { m.lock(); cout << "\nin thread 2 \n"; if (ptr->p_) { cout << "\nptr checked \n"; //Sleep(x) for (int i = 0; i < x; i++) cout << "|"; cout << "\nusing ptr in t2\n"; ptr->Addref(); } else { cout << "\ncheck succeeded \n"; } m.unlock(); } int main() { Weak_ptr s; thread t1(&funct1, 2000, &s); thread t2(&funct2, 4000, &s); t1.join(); t2.join(); }
0debug
uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size, uint8_t lock) { MapCacheEntry *entry, *pentry = NULL; hwaddr address_index; hwaddr address_offset; hwaddr cache_size = size; hwaddr test_bit_size; bool translated = false; tryagain: address_index = phys_addr >> MCACHE_BUCKET_SHIFT; address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1); trace_xen_map_cache(phys_addr); if (size) { test_bit_size = size + (phys_addr & (XC_PAGE_SIZE - 1)); if (test_bit_size % XC_PAGE_SIZE) { test_bit_size += XC_PAGE_SIZE - (test_bit_size % XC_PAGE_SIZE); } } else { test_bit_size = XC_PAGE_SIZE; } if (mapcache->last_entry != NULL && mapcache->last_entry->paddr_index == address_index && !lock && !size && test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, mapcache->last_entry->valid_mapping)) { trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_offset); return mapcache->last_entry->vaddr_base + address_offset; } if (size) { cache_size = size + address_offset; if (cache_size % MCACHE_BUCKET_SIZE) { cache_size += MCACHE_BUCKET_SIZE - (cache_size % MCACHE_BUCKET_SIZE); } } else { cache_size = MCACHE_BUCKET_SIZE; } entry = &mapcache->entry[address_index % mapcache->nr_buckets]; while (entry && entry->lock && entry->vaddr_base && (entry->paddr_index != address_index || entry->size != cache_size || !test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping))) { pentry = entry; entry = entry->next; } if (!entry) { entry = g_malloc0(sizeof (MapCacheEntry)); pentry->next = entry; xen_remap_bucket(entry, cache_size, address_index); } else if (!entry->lock) { if (!entry->vaddr_base || entry->paddr_index != address_index || entry->size != cache_size || !test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping)) { xen_remap_bucket(entry, cache_size, address_index); } } if(!test_bits(address_offset >> XC_PAGE_SHIFT, test_bit_size >> XC_PAGE_SHIFT, entry->valid_mapping)) { mapcache->last_entry = NULL; if (!translated && mapcache->phys_offset_to_gaddr) { phys_addr = mapcache->phys_offset_to_gaddr(phys_addr, size, mapcache->opaque); translated = true; goto tryagain; } trace_xen_map_cache_return(NULL); return NULL; } mapcache->last_entry = entry; if (lock) { MapCacheRev *reventry = g_malloc0(sizeof(MapCacheRev)); entry->lock++; reventry->vaddr_req = mapcache->last_entry->vaddr_base + address_offset; reventry->paddr_index = mapcache->last_entry->paddr_index; reventry->size = entry->size; QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next); } trace_xen_map_cache_return(mapcache->last_entry->vaddr_base + address_offset); return mapcache->last_entry->vaddr_base + address_offset; }
1threat
static char *spapr_get_fw_dev_path(FWPathProvider *p, BusState *bus, DeviceState *dev) { #define CAST(type, obj, name) \ ((type *)object_dynamic_cast(OBJECT(obj), (name))) SCSIDevice *d = CAST(SCSIDevice, dev, TYPE_SCSI_DEVICE); sPAPRPHBState *phb = CAST(sPAPRPHBState, dev, TYPE_SPAPR_PCI_HOST_BRIDGE); VHostSCSICommon *vsc = CAST(VHostSCSICommon, dev, TYPE_VHOST_SCSI_COMMON); if (d) { void *spapr = CAST(void, bus->parent, "spapr-vscsi"); VirtIOSCSI *virtio = CAST(VirtIOSCSI, bus->parent, TYPE_VIRTIO_SCSI); USBDevice *usb = CAST(USBDevice, bus->parent, TYPE_USB_DEVICE); if (spapr) { unsigned id = 0x8000 | (d->id << 8) | d->lun; return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev), (uint64_t)id << 48); } else if (virtio) { unsigned id = 0x1000000 | (d->id << 16) | d->lun; return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev), (uint64_t)id << 32); } else if (usb) { unsigned usb_port = atoi(usb->port->path); unsigned id = 0x1000000 | (usb_port << 16) | d->lun; return g_strdup_printf("%s@%"PRIX64, qdev_fw_name(dev), (uint64_t)id << 32); if (strcmp("usb-host", qdev_fw_name(dev)) == 0) { USBDevice *usbdev = CAST(USBDevice, dev, TYPE_USB_DEVICE); if (usb_host_dev_is_scsi_storage(usbdev)) { return g_strdup_printf("storage@%s/disk", usbdev->port->path); if (phb) { return g_strdup_printf("pci@%"PRIX64, phb->buid); if (vsc) { unsigned id = 0x1000000 | (vsc->target << 16) | vsc->lun; return g_strdup_printf("disk@%"PRIX64, (uint64_t)id << 32); if (g_str_equal("pci-bridge", qdev_fw_name(dev))) { PCIDevice *pcidev = CAST(PCIDevice, dev, TYPE_PCI_DEVICE); return g_strdup_printf("pci@%x", PCI_SLOT(pcidev->devfn)); return NULL;
1threat
PHP - How to rate limit an API? : <p>I have a custom api page. How can I limit the number of requests by IP address?</p> <p>I need some examples in PHP, I'm not too experienced with this.</p> <p>I'm running an apache2 server. </p>
0debug
static void iothread_complete(UserCreatable *obj, Error **errp) { Error *local_error = NULL; IOThread *iothread = IOTHREAD(obj); iothread->stopping = false; iothread->thread_id = -1; iothread->ctx = aio_context_new(&local_error); if (!iothread->ctx) { error_propagate(errp, local_error); return; } qemu_mutex_init(&iothread->init_done_lock); qemu_cond_init(&iothread->init_done_cond); qemu_thread_create(&iothread->thread, "iothread", iothread_run, iothread, QEMU_THREAD_JOINABLE); qemu_mutex_lock(&iothread->init_done_lock); while (iothread->thread_id == -1) { qemu_cond_wait(&iothread->init_done_cond, &iothread->init_done_lock); } qemu_mutex_unlock(&iothread->init_done_lock); }
1threat
uint32_t ide_status_read(void *opaque, uint32_t addr) { IDEBus *bus = opaque; IDEState *s = idebus_active_if(bus); int ret; if ((!bus->ifs[0].bs && !bus->ifs[1].bs) || (s != bus->ifs && !s->bs)) ret = 0; else ret = s->status; #ifdef DEBUG_IDE printf("ide: read status addr=0x%x val=%02x\n", addr, ret); #endif return ret; }
1threat
static void microdrive_realize(DeviceState *dev, Error **errp) { MicroDriveState *md = MICRODRIVE(dev); ide_init2(&md->bus, qemu_allocate_irqs(md_set_irq, md, 1)[0]); }
1threat
bash eval in if with piped command : <p>piped eval in bash for string length comparison</p> <p>i am trying to check if a certain device with a given id is plugged in and trigger a action based on that </p> <p>i tried eval / exec</p> <p>here is what i have so far</p> <pre><code>#!/bin/bash KBP='[["lsusb -d 1c11:b04d | wc -c" == "0"]]' if eval $KBP; then echo expression evaluated as true else echo expression evaluated as false fi </code></pre> <p>expected result:</p> <p>if device is plugged in and string is not 0 it would hop in the false condition </p> <p>actual result - cant evaluate the piped condition </p>
0debug
static void thread_pool_completion_bh(void *opaque) { ThreadPool *pool = opaque; ThreadPoolElement *elem, *next; restart: QLIST_FOREACH_SAFE(elem, &pool->head, all, next) { if (elem->state != THREAD_DONE) { continue; } trace_thread_pool_complete(pool, elem, elem->common.opaque, elem->ret); QLIST_REMOVE(elem, all); if (elem->common.cb) { smp_rmb(); qemu_bh_schedule(pool->completion_bh); elem->common.cb(elem->common.opaque, elem->ret); qemu_aio_unref(elem); goto restart; } else { qemu_aio_unref(elem); } } }
1threat
I have an array and I want change it to a multi dimensional array. How can i do this? : This is my array: $array=["a2","a5","a7","b3","b8","b9"]; And i want change it to: $result=["a"=>[2,5,7],"b"=>[3,8,9];
0debug
null is not an object(evaluating this.state.count) : <p>I am facing the above mentioned error when i am trying to set a count for everytime the button is pressed. </p> <pre><code>export default class ViewIdeas extends Component{ get InitialState(){ return { count : 0 } } render(){ return( ....... &lt;Button transparent&gt; &lt;Icon name='ios-thumbs-up-outline' style={{fontSize:21}} onPress={() =&gt; this.setState({count: ++this.state.count})}/&gt; &lt;Text&gt;{'Like' + this.state.count}&lt;/Text&gt; &lt;/Button&gt; </code></pre>
0debug
static int oss_open (int in, struct oss_params *req, struct oss_params *obt, int *pfd) { int fd; int oflags; int mmmmssss; audio_buf_info abinfo; int fmt, freq, nchannels; const char *dspname = in ? conf.devpath_in : conf.devpath_out; const char *typ = in ? "ADC" : "DAC"; oflags = conf.try_mmap ? O_RDWR : (in ? O_RDONLY : O_WRONLY); fd = open (dspname, oflags | O_NONBLOCK); if (-1 == fd) { oss_logerr2 (errno, typ, "Failed to open `%s'\n", dspname); return -1; } freq = req->freq; nchannels = req->nchannels; fmt = req->fmt; if (ioctl (fd, SNDCTL_DSP_SAMPLESIZE, &fmt)) { oss_logerr2 (errno, typ, "Failed to set sample size %d\n", req->fmt); goto err; } if (ioctl (fd, SNDCTL_DSP_CHANNELS, &nchannels)) { oss_logerr2 (errno, typ, "Failed to set number of channels %d\n", req->nchannels); goto err; } if (ioctl (fd, SNDCTL_DSP_SPEED, &freq)) { oss_logerr2 (errno, typ, "Failed to set frequency %d\n", req->freq); goto err; } if (ioctl (fd, SNDCTL_DSP_NONBLOCK, NULL)) { oss_logerr2 (errno, typ, "Failed to set non-blocking mode\n"); goto err; } mmmmssss = (req->nfrags << 16) | ctz32 (req->fragsize); if (ioctl (fd, SNDCTL_DSP_SETFRAGMENT, &mmmmssss)) { oss_logerr2 (errno, typ, "Failed to set buffer length (%d, %d)\n", req->nfrags, req->fragsize); goto err; } if (ioctl (fd, in ? SNDCTL_DSP_GETISPACE : SNDCTL_DSP_GETOSPACE, &abinfo)) { oss_logerr2 (errno, typ, "Failed to get buffer length\n"); goto err; } if (!abinfo.fragstotal || !abinfo.fragsize) { AUD_log (AUDIO_CAP, "Returned bogus buffer information(%d, %d) for %s\n", abinfo.fragstotal, abinfo.fragsize, typ); goto err; } obt->fmt = fmt; obt->nchannels = nchannels; obt->freq = freq; obt->nfrags = abinfo.fragstotal; obt->fragsize = abinfo.fragsize; *pfd = fd; #ifdef DEBUG_MISMATCHES if ((req->fmt != obt->fmt) || (req->nchannels != obt->nchannels) || (req->freq != obt->freq) || (req->fragsize != obt->fragsize) || (req->nfrags != obt->nfrags)) { dolog ("Audio parameters mismatch\n"); oss_dump_info (req, obt); } #endif #ifdef DEBUG oss_dump_info (req, obt); #endif return 0; err: oss_anal_close (&fd); return -1; }
1threat
Java 8 Stream | Add a value of the stream to another List/Collection without using foreach or any terminal Operation : <p>So far i tried to add values from a stream to a list with peek() but later I found out that peek() is only used "to support debugging, where you want to see the elements as they flow past a certain point in a pipeline".</p> <p>Now my question is whats the coding-convention here ?</p> <p>Do I map it in a second stream or can I map it one String like my Code with Peek() ?</p> <pre><code> final int range = 9; List &lt;String&gt; help = new ArrayList&lt;String&gt;(); //random numbers to fill help for(int i = 5;i&lt; range;i++) { help.add(String.valueOf(i+(i*2)+(i*(i+2))) ); } List&lt;Test&gt; others = new LinkedList&lt;&gt;(); List&lt;Test&gt; tests = help.stream().map(s-&gt; new Test(s,(int) Integer.valueOf("10"))) .peek(t-&gt;System.out.println(t.getText())) .peek(t-&gt; others.add(t)).collect(Collectors.toList()); </code></pre> <p>The class Test looks like this:</p> <pre><code>public class Test { String text; int id; public Test(String text, int id) { this.text = text; this.id = id; } public String getText() { return text; } public int getId() { return id; } } </code></pre>
0debug
static int ipvideo_decode_block_opcode_0xA(IpvideoContext *s, AVFrame *frame) { int x, y; unsigned char P[8]; int flags = 0; bytestream2_get_buffer(&s->stream_ptr, P, 4); if (P[0] <= P[1]) { for (y = 0; y < 16; y++) { if (!(y & 3)) { if (y) bytestream2_get_buffer(&s->stream_ptr, P, 4); flags = bytestream2_get_le32(&s->stream_ptr); for (x = 0; x < 4; x++, flags >>= 2) *s->pixel_ptr++ = P[flags & 0x03]; s->pixel_ptr += s->stride - 4; if (y == 7) s->pixel_ptr -= 8 * s->stride - 4; } else { int vert; uint64_t flags = bytestream2_get_le64(&s->stream_ptr); bytestream2_get_buffer(&s->stream_ptr, P + 4, 4); vert = P[4] <= P[5]; for (y = 0; y < 16; y++) { for (x = 0; x < 4; x++, flags >>= 2) *s->pixel_ptr++ = P[flags & 0x03]; if (vert) { s->pixel_ptr += s->stride - 4; if (y == 7) s->pixel_ptr -= 8 * s->stride - 4; } else if (y & 1) s->pixel_ptr += s->line_inc; if (y == 7) { memcpy(P, P + 4, 4); flags = bytestream2_get_le64(&s->stream_ptr); return 0;
1threat
notifyicon in visual studio 2015 missing : <p>I have a WPF application and I'm trying to send it to notification tray following the instructions in this page <a href="http://www.developer.com/net/net/article.php/3336751/C-Tip-Placing-Your-C-Application-in-the-System-Tray.htm" rel="nofollow">http://www.developer.com/net/net/article.php/3336751/C-Tip-Placing-Your-C-Application-in-the-System-Tray.htm</a></p> <p>But I cannot find the NotifyIcon control in Toolbox. Is there a new control for doing this task?</p>
0debug
Usort multidimensional array in PHP is broken : Using the example straight from the docs, I can't see to figure out why I am getting the results I am. function cmp($a, $b) { return strcmp($a["fruit"], $b["fruit"]); } $fruits[0]["fruit"] = 1000; $fruits[1]["fruit"] = 600; $fruits[2]["fruit"] = 2180; echo ("<pre>"); echo " before \n"; print_r($fruits); echo ("</pre>"); usort($fruits, "cmp"); echo ("<pre>"); echo " after \n"; print_r($fruits); echo ("</pre>"); These are the results: before Array ( [0] => Array ( [fruit] => 1000 ) [1] => Array ( [fruit] => 600 ) [2] => Array ( [fruit] => 2180 ) ) after Array ( [0] => Array ( [fruit] => 1000 ) [1] => Array ( [fruit] => 2180 ) [2] => Array ( [fruit] => 600 ) ) I thought usort was meant to organise based on a value within a multidimensional array. Sometimes it sorts it, sometimes it just gives a random order as the output array. Am I missing something? Also, this is defo not a duplicate question, read it carefully there is nothing like it on this site.
0debug
bdrv_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie, int64_t bytes, enum BlockAcctType type) { assert(type < BDRV_MAX_IOTYPE); cookie->bytes = bytes; cookie->start_time_ns = get_clock(); cookie->type = type; }
1threat
Why I get error: are you missing a using directive or an assembly reference? : <p>I added C# code in <code>aspx</code> file, but it is showing error.</p> <p>This code I add to asp file:</p> <pre><code> [System.Web.Services.WebMethodAttribute, System.Web.Script.Services.ScriptMethodAttribute] public static string[] GetCompletionList(string prefixText, int count) { string[] names = {"Ram","Ankit","Sam","Sahil","Rajan","Rahul","Sajan"}; var namesList = from tmp in names where tmp.ToLower().StartWith(prefixText) select tmp; return names; } </code></pre> <p>I get this error:</p> <pre><code>Compiler Error Message: CS1061: 'string' does not contain a definition for 'StartWith' and no extension method 'StartWith' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?) </code></pre> <p>Here is n declared in my page:</p> <pre><code>&lt;%@ Import Namespace="System" %&gt; &lt;%@ Import Namespace="System.IO" %&gt; &lt;%@ Import Namespace="System.Collections" %&gt; &lt;%@ Import Namespace="System.Collections.Specialized" %&gt; &lt;%@ Import Namespace="System.Runtime.Serialization" %&gt; &lt;%@ Import Namespace="System.Text" %&gt; </code></pre> <p>Any idea how can I fix the error?</p>
0debug
void nand_setio(DeviceState *dev, uint32_t value) { int i; NANDFlashState *s = (NANDFlashState *) dev; if (!s->ce && s->cle) { if (nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP) { if (s->cmd == NAND_CMD_READ0 && value == NAND_CMD_LPREAD2) return; if (value == NAND_CMD_RANDOMREAD1) { s->addr &= ~((1 << s->addr_shift) - 1); s->addrlen = 0; return; } } if (value == NAND_CMD_READ0) s->offset = 0; else if (value == NAND_CMD_READ1) { s->offset = 0x100; value = NAND_CMD_READ0; } else if (value == NAND_CMD_READ2) { s->offset = 1 << s->page_shift; value = NAND_CMD_READ0; } s->cmd = value; if (s->cmd == NAND_CMD_READSTATUS || s->cmd == NAND_CMD_PAGEPROGRAM2 || s->cmd == NAND_CMD_BLOCKERASE1 || s->cmd == NAND_CMD_BLOCKERASE2 || s->cmd == NAND_CMD_NOSERIALREAD2 || s->cmd == NAND_CMD_RANDOMREAD2 || s->cmd == NAND_CMD_RESET) nand_command(s); if (s->cmd != NAND_CMD_RANDOMREAD2) { s->addrlen = 0; } } if (s->ale) { unsigned int shift = s->addrlen * 8; unsigned int mask = ~(0xff << shift); unsigned int v = value << shift; s->addr = (s->addr & mask) | v; s->addrlen ++; switch (s->addrlen) { case 1: if (s->cmd == NAND_CMD_READID) { nand_command(s); } break; case 2: s->addr <<= (s->buswidth - 1); break; case 3: if (!(nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP) && (s->cmd == NAND_CMD_READ0 || s->cmd == NAND_CMD_PAGEPROGRAM1)) { nand_command(s); } break; case 4: if ((nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP) && nand_flash_ids[s->chip_id].size < 256 && (s->cmd == NAND_CMD_READ0 || s->cmd == NAND_CMD_PAGEPROGRAM1)) { nand_command(s); } break; case 5: if ((nand_flash_ids[s->chip_id].options & NAND_SAMSUNG_LP) && nand_flash_ids[s->chip_id].size >= 256 && (s->cmd == NAND_CMD_READ0 || s->cmd == NAND_CMD_PAGEPROGRAM1)) { nand_command(s); } break; default: break; } } if (!s->cle && !s->ale && s->cmd == NAND_CMD_PAGEPROGRAM1) { if (s->iolen < (1 << s->page_shift) + (1 << s->oob_shift)) { for (i = s->buswidth; i--; value >>= 8) { s->io[s->iolen ++] = (uint8_t) (value & 0xff); } } } else if (!s->cle && !s->ale && s->cmd == NAND_CMD_COPYBACKPRG1) { if ((s->addr & ((1 << s->addr_shift) - 1)) < (1 << s->page_shift) + (1 << s->oob_shift)) { for (i = s->buswidth; i--; s->addr++, value >>= 8) { s->io[s->iolen + (s->addr & ((1 << s->addr_shift) - 1))] = (uint8_t) (value & 0xff); } } } }
1threat
static void filter1(int32_t *dst, const int32_t *src, int32_t coeff, ptrdiff_t len) { int i; for (i = 0; i < len; i++) dst[i] -= mul23(src[i], coeff); }
1threat
USBDevice *usbdevice_create(const char *cmdline) { USBBus *bus = usb_bus_find(-1 ); LegacyUSBFactory *f = NULL; Error *err = NULL; GSList *i; char driver[32]; const char *params; int len; USBDevice *dev; ObjectClass *klass; DeviceClass *dc; params = strchr(cmdline,':'); if (params) { params++; len = params - cmdline; if (len > sizeof(driver)) len = sizeof(driver); pstrcpy(driver, len, cmdline); } else { params = ""; pstrcpy(driver, sizeof(driver), cmdline); for (i = legacy_usb_factory; i; i = i->next) { f = i->data; if (strcmp(f->usbdevice_name, driver) == 0) { break; if (i == NULL) { #if 0 error_report("usbdevice %s not found", driver); #endif if (!bus) { error_report("Error: no usb bus to attach usbdevice %s, " "please try -machine usb=on and check that " "the machine model supports USB", driver); if (f->usbdevice_init) { dev = f->usbdevice_init(bus, params); } else { if (*params) { error_report("usbdevice %s accepts no params", driver); dev = usb_create(bus, f->name); if (!dev) { error_report("Failed to create USB device '%s'", f->name); object_property_set_bool(OBJECT(dev), true, "realized", &err); if (err) { error_reportf_err(err, "Failed to initialize USB device '%s': ", f->name); object_unparent(OBJECT(dev)); return dev;
1threat
Define a Class Function Operator : <p>How can I define in PHP a class <code>Foo</code> that allows to do something like:</p> <pre><code>$foo = new Foo(); $foo-&gt;bar; $foo(); </code></pre>
0debug
import re def text_match_string(text): patterns = '^\w+' if re.search(patterns, text): return 'Found a match!' else: return 'Not matched!'
0debug
patchvalue or setvalue of formbuilder does not mark field as dirty or touched : <p>I have a multi step form where user traverses back and forth to the form. I save the form data in service and when he comes back i use patchvalue to patch all the data to form. I tried setvalue also, but the form fields are not marked as either dirty or touched. How to i mark fields updated as dirty and touched? </p> <pre><code>this.formBuilder.pathValue(formData); </code></pre>
0debug
static av_cold int g722_encode_close(AVCodecContext *avctx) { G722Context *c = avctx->priv_data; int i; for (i = 0; i < 2; i++) { av_freep(&c->paths[i]); av_freep(&c->node_buf[i]); av_freep(&c->nodep_buf[i]); } return 0; }
1threat
How to display dependency diagram for java program? : <p>I want to display the dependency relationship (import) on my Java program. I know IntelliJ has diagram > show diagram feature, but it is used for "is-a" relationship, not "has-a" relationship between different class. Which tool provide dependency relationship diagram?</p>
0debug
Checking if array is nil or not : <p>I have a array of my custom model, and I want to check if it is not nil and its size is greater then 0. </p> <p>Following is my array with custom object </p> <blockquote> <p><code>var listCountries : [Countries]? = nil</code></p> </blockquote> <p>now In viewDIdLoad I want to make a check on it. I am new to Swift. I have good experience in working in Java. </p> <p>I have read out Optional values concept and guard, if let statements. But I am unable to understand how efficiently they may be used. I have read too much SO questions but failed to figure out. </p> <p>for example , if I want to check the upper given array in java I have only to do </p> <pre><code>if(listCountries != null &amp;&amp; listCountries.size()&gt;0){ //DO something } </code></pre> <p>So to summarize my question:</p> <ol> <li>How to make the upper given(Java code) check in to swift 4.? What is more smooth and reliable way. </li> <li>What is a use of if let , guard, guard let statements. if I declare a variable (array, string) as optional I have to bear optional check like force wrapping each and every place. This is for me so making too much confusion. </li> </ol> <p>Please help. I know this question has been asked in different ways. But this has some different context. </p>
0debug
void qemu_del_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque) { int i, found; WaitObjects *w = &wait_objects; found = 0; for (i = 0; i < w->num; i++) { if (w->events[i] == handle) found = 1; if (found) { w->events[i] = w->events[i + 1]; w->func[i] = w->func[i + 1]; w->opaque[i] = w->opaque[i + 1]; } } if (found) w->num--; }
1threat
gen_intermediate_code_internal(TriCoreCPU *cpu, struct TranslationBlock *tb, int search_pc) { CPUState *cs = CPU(cpu); CPUTriCoreState *env = &cpu->env; DisasContext ctx; target_ulong pc_start; int num_insns; uint16_t *gen_opc_end; if (search_pc) { qemu_log("search pc %d\n", search_pc); } num_insns = 0; pc_start = tb->pc; gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE; ctx.pc = pc_start; ctx.saved_pc = -1; ctx.tb = tb; ctx.singlestep_enabled = cs->singlestep_enabled; ctx.bstate = BS_NONE; ctx.mem_idx = cpu_mmu_index(env); tcg_clear_temp_count(); gen_tb_start(); while (ctx.bstate == BS_NONE) { ctx.opcode = cpu_ldl_code(env, ctx.pc); decode_opc(env, &ctx, 0); num_insns++; if (tcg_ctx.gen_opc_ptr >= gen_opc_end) { gen_save_pc(ctx.next_pc); tcg_gen_exit_tb(0); break; } if (singlestep) { gen_save_pc(ctx.next_pc); tcg_gen_exit_tb(0); break; } ctx.pc = ctx.next_pc; } gen_tb_end(tb, num_insns); *tcg_ctx.gen_opc_ptr = INDEX_op_end; if (search_pc) { printf("done_generating search pc\n"); } else { tb->size = ctx.pc - pc_start; tb->icount = num_insns; } if (tcg_check_temp_count()) { printf("LEAK at %08x\n", env->PC); } #ifdef DEBUG_DISAS if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) { qemu_log("IN: %s\n", lookup_symbol(pc_start)); log_target_disas(env, pc_start, ctx.pc - pc_start, 0); qemu_log("\n"); } #endif }
1threat
Simple Webscraping with Xcode/Swift : I am just getting started with Xcode and Swift. I have done a ton of webscrping with B4S in Python, but I am having trouble with Xcode. Does anyone know how I can request html data from a website? How would I get the html from http://www.example.com/ Or does anyone have a site they would recommend to get started? Thanks!
0debug
failed building wheel for Levenshtein : I am trying to install Levenshtein and Fuzzy on my laptop, but for a reason, that i dont understand i get: Failed building wheel for Levenshtein and the same error for Fuzzy every time. I have windows 10 64bit and Python 3.6 on my system. I appreciate it, if somebpdy could help me with concrete hint, if he/she experiencd such an error.
0debug
What is the default z-index value of <header>, <main> and <section> tags in html and css? : I just wanted to know if we are using these tags in a code, which layer would be on the top and which would be beneath it. Is there any default value specified for these tags?
0debug
nltk wordpunct_tokenize vs word_tokenize : <p>Does anyone know the difference between <code>nltk</code>'s <code>wordpunct_tokenize</code> and <code>word_tokenize</code>? I'm using <code>nltk=3.2.4</code> and there's nothing on the doc string of <code>wordpunct_tokenize</code> that explains the difference. I couldn't find this info either in the documentation of <code>nltk</code> (perhaps I didn't search in the right place!). I would have expected that first one would get rid of punctuation tokens or the like, but it doesn't. </p> <p><a href="https://i.stack.imgur.com/yCbSq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yCbSq.png" alt="enter image description here"></a></p>
0debug
Obtain the pdf file path from a website after being execute from a Delphi application? : <p>So I am trying to figure out a way when users open a pdf file from a website then have a Delphi application to execute and show the pdf. Is it possible to somehow copy the url location where the file originated from and pass it to a string when the form is created. </p>
0debug
numbers present in an array : <p>i have a text file containing several lines of real numbers, I should count how many numbers are present in each line. My idea is to insert with a for loop each row inside an array of unknown size. But I don't know how to count how many numbers are present in each array per line of text. How could I do it? Thanks</p> <pre><code>#define n 1000 #include &lt;fstream&gt; #include &lt;iostream&gt; using namespace std; int main(){ ifstream in("input.txt"); ofstream out("output.txt"); for(int i=0; i&lt;100; i++){ double* vec= new doule[n]; for(int j=0; j&lt;n; j++) in &gt;&gt; vec[j]; } } </code></pre>
0debug
int kvm_arch_post_run(CPUState *env, struct kvm_run *run) { return 0; }
1threat
int ff_eac3_parse_header(AC3DecodeContext *s) { int i, blk, ch; int ac3_exponent_strategy, parse_aht_info, parse_spx_atten_data; int parse_transient_proc_info; int num_cpl_blocks; GetBitContext *gbc = &s->gbc; if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) { avpriv_request_sample(s->avctx, "Dependent substream decoding"); return AAC_AC3_PARSE_ERROR_FRAME_TYPE; } else if (s->frame_type == EAC3_FRAME_TYPE_RESERVED) { av_log(s->avctx, AV_LOG_ERROR, "Reserved frame type\n"); return AAC_AC3_PARSE_ERROR_FRAME_TYPE; } if (s->substreamid) { avpriv_request_sample(s->avctx, "Additional substreams"); return AAC_AC3_PARSE_ERROR_FRAME_TYPE; } if (s->bit_alloc_params.sr_code == EAC3_SR_CODE_REDUCED) { avpriv_request_sample(s->avctx, "Reduced sampling rate"); return AVERROR_PATCHWELCOME; } skip_bits(gbc, 5); for (i = 0; i < (s->channel_mode ? 1 : 2); i++) { skip_bits(gbc, 5); if (get_bits1(gbc)) { skip_bits(gbc, 8); } } if (s->frame_type == EAC3_FRAME_TYPE_DEPENDENT) { if (get_bits1(gbc)) { skip_bits(gbc, 16); } } if (get_bits1(gbc)) { if (s->channel_mode > AC3_CHMODE_STEREO) { s->preferred_downmix = get_bits(gbc, 2); if (s->channel_mode & 1) { s->center_mix_level_ltrt = get_bits(gbc, 3); s->center_mix_level = get_bits(gbc, 3); } if (s->channel_mode & 4) { s->surround_mix_level_ltrt = av_clip(get_bits(gbc, 3), 3, 7); s->surround_mix_level = av_clip(get_bits(gbc, 3), 3, 7); } } if (s->lfe_on && (s->lfe_mix_level_exists = get_bits1(gbc))) { s->lfe_mix_level = get_bits(gbc, 5); } if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT) { for (i = 0; i < (s->channel_mode ? 1 : 2); i++) { if (get_bits1(gbc)) { skip_bits(gbc, 6); } } if (get_bits1(gbc)) { skip_bits(gbc, 6); } switch(get_bits(gbc, 2)) { case 1: skip_bits(gbc, 5); break; case 2: skip_bits(gbc, 12); break; case 3: { int mix_data_size = (get_bits(gbc, 5) + 2) << 3; skip_bits_long(gbc, mix_data_size); break; } } if (s->channel_mode < AC3_CHMODE_STEREO) { for (i = 0; i < (s->channel_mode ? 1 : 2); i++) { if (get_bits1(gbc)) { skip_bits(gbc, 8); skip_bits(gbc, 6); } } } if (get_bits1(gbc)) { for (blk = 0; blk < s->num_blocks; blk++) { if (s->num_blocks == 1 || get_bits1(gbc)) { skip_bits(gbc, 5); } } } } } if (get_bits1(gbc)) { s->bitstream_mode = get_bits(gbc, 3); skip_bits(gbc, 2); if (s->channel_mode == AC3_CHMODE_STEREO) { s->dolby_surround_mode = get_bits(gbc, 2); s->dolby_headphone_mode = get_bits(gbc, 2); } if (s->channel_mode >= AC3_CHMODE_2F2R) { s->dolby_surround_ex_mode = get_bits(gbc, 2); } for (i = 0; i < (s->channel_mode ? 1 : 2); i++) { if (get_bits1(gbc)) { skip_bits(gbc, 8); } } if (s->bit_alloc_params.sr_code != EAC3_SR_CODE_REDUCED) { skip_bits1(gbc); } } if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT && s->num_blocks != 6) { skip_bits1(gbc); } if (s->frame_type == EAC3_FRAME_TYPE_AC3_CONVERT && (s->num_blocks == 6 || get_bits1(gbc))) { skip_bits(gbc, 6); } if (get_bits1(gbc)) { int addbsil = get_bits(gbc, 6); for (i = 0; i < addbsil + 1; i++) { skip_bits(gbc, 8); } } if (s->num_blocks == 6) { ac3_exponent_strategy = get_bits1(gbc); parse_aht_info = get_bits1(gbc); } else { ac3_exponent_strategy = 1; parse_aht_info = 0; } s->snr_offset_strategy = get_bits(gbc, 2); parse_transient_proc_info = get_bits1(gbc); s->block_switch_syntax = get_bits1(gbc); if (!s->block_switch_syntax) memset(s->block_switch, 0, sizeof(s->block_switch)); s->dither_flag_syntax = get_bits1(gbc); if (!s->dither_flag_syntax) { for (ch = 1; ch <= s->fbw_channels; ch++) s->dither_flag[ch] = 1; } s->dither_flag[CPL_CH] = s->dither_flag[s->lfe_ch] = 0; s->bit_allocation_syntax = get_bits1(gbc); if (!s->bit_allocation_syntax) { s->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[2]; s->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[1]; s->bit_alloc_params.slow_gain = ff_ac3_slow_gain_tab [1]; s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[2]; s->bit_alloc_params.floor = ff_ac3_floor_tab [7]; } s->fast_gain_syntax = get_bits1(gbc); s->dba_syntax = get_bits1(gbc); s->skip_syntax = get_bits1(gbc); parse_spx_atten_data = get_bits1(gbc); num_cpl_blocks = 0; if (s->channel_mode > 1) { for (blk = 0; blk < s->num_blocks; blk++) { s->cpl_strategy_exists[blk] = (!blk || get_bits1(gbc)); if (s->cpl_strategy_exists[blk]) { s->cpl_in_use[blk] = get_bits1(gbc); } else { s->cpl_in_use[blk] = s->cpl_in_use[blk-1]; } num_cpl_blocks += s->cpl_in_use[blk]; } } else { memset(s->cpl_in_use, 0, sizeof(s->cpl_in_use)); } if (ac3_exponent_strategy) { for (blk = 0; blk < s->num_blocks; blk++) { for (ch = !s->cpl_in_use[blk]; ch <= s->fbw_channels; ch++) { s->exp_strategy[blk][ch] = get_bits(gbc, 2); } } } else { for (ch = !((s->channel_mode > 1) && num_cpl_blocks); ch <= s->fbw_channels; ch++) { int frmchexpstr = get_bits(gbc, 5); for (blk = 0; blk < 6; blk++) { s->exp_strategy[blk][ch] = ff_eac3_frm_expstr[frmchexpstr][blk]; } } } if (s->lfe_on) { for (blk = 0; blk < s->num_blocks; blk++) { s->exp_strategy[blk][s->lfe_ch] = get_bits1(gbc); } } if (s->frame_type == EAC3_FRAME_TYPE_INDEPENDENT && (s->num_blocks == 6 || get_bits1(gbc))) { skip_bits(gbc, 5 * s->fbw_channels); } if (parse_aht_info) { s->channel_uses_aht[CPL_CH]=0; for (ch = (num_cpl_blocks != 6); ch <= s->channels; ch++) { int use_aht = 1; for (blk = 1; blk < 6; blk++) { if ((s->exp_strategy[blk][ch] != EXP_REUSE) || (!ch && s->cpl_strategy_exists[blk])) { use_aht = 0; break; } } s->channel_uses_aht[ch] = use_aht && get_bits1(gbc); } } else { memset(s->channel_uses_aht, 0, sizeof(s->channel_uses_aht)); } if (!s->snr_offset_strategy) { int csnroffst = (get_bits(gbc, 6) - 15) << 4; int snroffst = (csnroffst + get_bits(gbc, 4)) << 2; for (ch = 0; ch <= s->channels; ch++) s->snr_offset[ch] = snroffst; } if (parse_transient_proc_info) { for (ch = 1; ch <= s->fbw_channels; ch++) { if (get_bits1(gbc)) { skip_bits(gbc, 10); skip_bits(gbc, 8); } } } for (ch = 1; ch <= s->fbw_channels; ch++) { if (parse_spx_atten_data && get_bits1(gbc)) { s->spx_atten_code[ch] = get_bits(gbc, 5); } else { s->spx_atten_code[ch] = -1; } } if (s->num_blocks > 1 && get_bits1(gbc)) { int block_start_bits = (s->num_blocks-1) * (4 + av_log2(s->frame_size-2)); skip_bits_long(gbc, block_start_bits); avpriv_request_sample(s->avctx, "Block start info"); } for (ch = 1; ch <= s->fbw_channels; ch++) { s->first_spx_coords[ch] = 1; s->first_cpl_coords[ch] = 1; } s->first_cpl_leak = 1; return 0; }
1threat
creating train/test csv files out of a original csv file for 10 fold cross validation experiment : I have a csv file (main.csv) that has a unique column ID that also pertains to my image names (minus their .jpg extension). I want to do 10 fold cross-validation and create train and test CSV such that test csv for each fold would only contain 10 percent of the original CSV. Is there a straighforward path (already done) to this? Basically, I want my eventual train and test csv files to have the same exact column names but designed such that I could perform 10 fold cross validation with them (aka randomly sampled/shuffled and 10% selected). I don't mind pandas in Python or R.
0debug
What are the scenarios we can use for loop in selenium webdriver? : <p>What is the main use of for loop in Automation testing(Selenium Webdriver?</p>
0debug
Disable resubmission of form when the browser is refreshed : <p>I have a form that takes inputs from user then searches the database and displays the result. Everything is working fine except when the user refreshes the browser there comes an alert about re submission. If I re-submit I get the same data but is there a way to disable that alert? Only refresh and get the same result set.</p> <p>Here is a screenshot. <a href="https://i.stack.imgur.com/547Nw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/547Nw.png" alt="Re-submission alert"></a> Backend - PHP</p>
0debug
Gitlab only build for specific tag names : <p>Are there any way to instruct the pipeline to only do a step for certain tags that matches a regex? I would like it to do a deploy when I push a tag on the format 1.2.3 (for example) are there any way to do this?</p>
0debug
Showing true and false : <p>Hi I wrote this program in python and unable to show true and false. Please help out </p> <pre><code>a= raw_input("Enter data") print a b=a.count("e") print b if b &gt;= 0: print True else : print False </code></pre> <p>I also tried with "True " and "False" yet not getting the answer. It keeps on repeating True. </p> <p>I tried in interpreter it is working fine. I don't what I am doing wrong</p>
0debug
My Sql Sintax Error : I cant find the error in MYSQL Sintax: "SELECT customer.CustomerCode, customer.CustomerName, customer.CustomerAddress, customer.CustomerHandphone, customer,CustomerEmail, product.ProductCode, product.ProductName, product.ProductPrice, orderdetail.OrderCode, orderdetail.ProductCode, orderdetail.ProductPrice, orderlist.OrderCode, orderlist.CustomerCode, orderlist.OrderPrice " + "FROM customer INNER JOIN (product INNER JOIN (orderlist INNER JOIN(orderdetail INNER JOIN ON orderlist.OrderCode = orderdetail.OrderCode) ON product.ProductCode = orderdetail.ProductCode) ON customer.CustomerCode = orderlist.CustomerCode) " + "Where orderlist.OrderCode =@orderdetail.OrderCode " + "GROUP BY customer.CustomerCode, customer.CustomerName, customer.CustomerAddress, customer.CustomerHandphone, customer,CustomerEmail, product.ProductCode, product.ProductName, product.ProductPrice, orderdetail.OrderCode, orderdetail.ProductCode, orderdetail.ProductPrice, orderlist.OrderCode, orderlist.CustomerCode, orderlist.OrderPrice";" #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ON orderlist.OrderCode = orderdetail.OrderCode) ON product.ProductCode = orderde' at line 1
0debug
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
Can someone help: Use Python to count the number of words and mean length of words in each sentence of a text file as input : I cannot use NLTK or Regex :( The sentence in the file ends with a period, exclamation point, or question mark. A hyphen, dash, or apostrophe does not end a sentence. Quotation marks do not end a sentence. But also, some periods do not end sentences. For example, Mrs., Mr., Dr., Fr., Jr., St., are all commonly occurring abbreviations.
0debug