problem
stringlengths
26
131k
labels
class label
2 classes
Requires extended permission on facebook for send notification : <p>I am new in developing Facebook App. When i am trying to send user notification and test sent notification on <strong>Graph API Explorer</strong> ,I am getting this error <strong>(#200) Requires extended permission: manage_notifications</strong> .</p>
0debug
CoroutineAction qemu_coroutine_switch(Coroutine *from_, Coroutine *to_, CoroutineAction action) { CoroutineWin32 *from = DO_UPCAST(CoroutineWin32, base, from_); CoroutineWin32 *to = DO_UPCAST(CoroutineWin32, base, to_); current = to_; to->action = action; SwitchToFiber(to->fiber); return from->action; }
1threat
Javascript Array operations on string-index array : <p>It seems like <code>map</code>, <code>forEach</code>, <code>filter</code> and this sort of operators don't work with string-indexed arrays like so:</p> <pre><code>let a = []; a['first element'] = 1; a['second element'] = 2; a['third element'] = 3; a.forEach(console.log) //undefined </code></pre>
0debug
C# SQL SERVER CONVERTING DATE TIME ERROR WHEN TRANSFERING TO ANOTHER PC : I am using VS2012 and SQL SERVER 2012 as database it all works good but when i transfer it to another laptop which also using VS2012 and SQL SERVER 2012 i am having an error in converting date in data base to date time here is the code. DateTime date = DateTime.Parse(dr8["Date Added"].toString()); The Date Added is in VARCHAR(MAX) but it works well in my pc but when transfered to my laptop it shows String was not recognized as a valid DateTime[enter image description here][1] [enter image description here][2] [1]: https://i.stack.imgur.com/GNMPd.png [2]: https://i.stack.imgur.com/Ci1xI.png
0debug
Dynamic Zero-Length Arrays in C++ : <pre><code>#include &lt;stdlib.h&gt; void *operator new[](size_t size, int n){ if( size != 0 &amp;&amp; n != 0 ) return calloc(n, size); return calloc(1, 1); } int main(){ int * p1; const int i = 0; // p1 = new (20) int[i] ; // Case 1 (OK) p1 = new (20) (int[i]); // Case 2 (Warning) if( p1 == 0 ) return 1; return 0; } </code></pre> <p>This code (<a href="https://godbolt.org/g/hjo7Xn" rel="noreferrer">https://godbolt.org/g/hjo7Xn</a>) compiles successfully with Clang 6.0.0, however, GCC 7.3 issues a warning saying that zero-length arrays are forbidden in C++. If the parentheses are removed (Case 1), the warning goes away. </p> <p>Unlike statically allocated zero-length arrays (C++03:8.3.4/1), dynamically allocated zero-length arrays are allowed (C++03:5.3.4/6). Nevertheless, in the C++ Standard the latter are explicitly allowed only when following one of the two possible syntax paths of the <em>new-expression</em>, that is, the one with <em>new-type-id</em> and without parentheses (Case 1). </p> <p><strong>Is it allowed by the C++ Standard to use the <em>new-expression</em> with a zero-length array following the second syntax path, that is, with <em>type-id</em> and parentheses (Case 2)?</strong></p> <p>The only related quote is C++03:5.3.4/5:</p> <blockquote> <p>When the allocated object is an array (that is, the <em>direct-new-declarator</em> syntax is used or the <em>new-type-id</em> or <em>type-id</em> denotes an array type), the <em>new-expression</em> yields a pointer to the initial element (if any) of the array.</p> </blockquote> <p>The wording <code>(if any)</code> would allow an array with no elements, however, it does not seem clear if it refers to both cases or only to the one with <em>new-type-id</em> and without parentheses (Case 1).</p> <p>Thanks in advance.</p> <p>Notes:</p> <ol> <li>ISO/IEC 14882:2003, Section 8.3.4, Paragraph 1: <blockquote> <p>If the <em>constant-expression</em> (5.19) is present, it shall be an integral constant expression and its value shall be greater than zero.</p> </blockquote></li> <li>ISO/IEC 14882:2003, Section 5.3.4, Paragraph 6: <blockquote> <p>The <em>expression</em> in a <em>direct-new-declarator</em> shall have integral or enumeration type (3.9.1) with a non-negative value.</p> </blockquote></li> <li>ISO/IEC 14882:2003, Section 5.3.4, Paragraph 7: <blockquote> <p>When the value of the <em>expression</em> in a <em>direct-new-declarator</em> is zero, the allocation function is called to allocate an array with no elements.</p> </blockquote></li> <li>ISO/IEC 14882:2003, Section 5.3.4, Paragraph 1: <blockquote> <p><em>new-expression</em>:</p> <p>::<code>opt</code> <strong>new</strong> <em>new-placement</em><code>opt</code> <em>new-type-id</em> <em>new-initializer</em><code>opt</code></p> <p>::<code>opt</code> <strong>new</strong> <em>new-placement</em><code>opt</code> ( <em>type-id</em> ) <em>new-initializer</em><code>opt</code></p> </blockquote></li> <li>Although the above quotes are from the C++03 Standard, to the best of my knowledge this issue is still unclear in newer versions of the C++ Standard (C++11, C++14 and C++17).</li> <li>Interesting Herb Sutter's <a href="https://herbsutter.com/2009/09/02/when-is-a-zero-length-array-okay/" rel="noreferrer">post</a> about zero-length arrays.</li> <li>The code in the example is a slightly modified test from <a href="https://www.solidsands.nl" rel="noreferrer">SolidSands'</a> SuperTest suite.</li> </ol>
0debug
what does `yield from asyncio.sleep(delay)` do? : <p>The following example from Python in a Nutshell sets <code>x</code> to <code>23</code> after a delay of a second and a half:</p> <pre><code>@asyncio.coroutine def delayed_result(delay, result): yield from asyncio.sleep(delay) return result loop = asyncio.get_event_loop() x = loop.run_until_complete(delayed_result(1.5, 23)) </code></pre> <p>I feel difficult to understand what <code>yield from asyncio.sleep(delay)</code> does.</p> <p>From <a href="https://docs.python.org/3/library/asyncio-task.html#asyncio.sleep" rel="noreferrer">https://docs.python.org/3/library/asyncio-task.html#asyncio.sleep</a></p> <blockquote> <pre><code>Coroutine asyncio.sleep(delay, result=None, *, loop=None) </code></pre> <p>Create a coroutine that completes after a given time (in seconds). If result is provided, it is produced to the caller when the coroutine completes.</p> </blockquote> <p>So <code>asyncio.sleep(delay)</code> returns a coroutine object.</p> <p>What does a coroutine object "completes" mean?</p> <p>What values does <code>yield from asyncio.sleep(delay)</code> provide to the main program?</p> <p>Thanks.</p>
0debug
static void tcg_out_brcond(TCGContext *s, TCGMemOp ext, TCGCond c, TCGArg a, TCGArg b, bool b_const, int label) { TCGLabel *l = &s->labels[label]; intptr_t offset; bool need_cmp; if (b_const && b == 0 && (c == TCG_COND_EQ || c == TCG_COND_NE)) { need_cmp = false; } else { need_cmp = true; tcg_out_cmp(s, ext, a, b, b_const); } if (!l->has_value) { tcg_out_reloc(s, s->code_ptr, R_AARCH64_CONDBR19, label, 0); offset = tcg_in32(s) >> 5; } else { offset = l->u.value_ptr - s->code_ptr; assert(offset == sextract64(offset, 0, 19)); } if (need_cmp) { tcg_out_insn(s, 3202, B_C, c, offset); } else if (c == TCG_COND_EQ) { tcg_out_insn(s, 3201, CBZ, ext, a, offset); } else { tcg_out_insn(s, 3201, CBNZ, ext, a, offset); } }
1threat
static int vc9_init_common(VC9Context *v) { static int done = 0; int i; v->mv_type_mb_plane = (struct BitPlane) { NULL, 0, 0, 0 }; v->direct_mb_plane = (struct BitPlane) { NULL, 0, 0, 0 }; v->skip_mb_plane = (struct BitPlane) { NULL, 0, 0, 0 }; #if HAS_ADVANCED_PROFILE v->ac_pred_plane = v->over_flags_plane = (struct BitPlane) { NULL, 0, 0, 0 }; v->hrd_rate = v->hrd_buffer = NULL; #endif #if VLC_NORM6_METH0D == 1 # if 0 for(i=0; i<64; i++){ int code= (vc9_norm6_spec[i][1] << vc9_norm6_spec[i][4]) + vc9_norm6_spec[i][3]; av_log(NULL, AV_LOG_DEBUG, "0x%03X, ", code); if(i%16==15) av_log(NULL, AV_LOG_DEBUG, "\n"); } for(i=0; i<64; i++){ int code= vc9_norm6_spec[i][2] + vc9_norm6_spec[i][4]; av_log(NULL, AV_LOG_DEBUG, "%2d, ", code); if(i%16==15) av_log(NULL, AV_LOG_DEBUG, "\n"); } # endif #endif if(!done) { done = 1; INIT_VLC(&vc9_bfraction_vlc, VC9_BFRACTION_VLC_BITS, 23, vc9_bfraction_bits, 1, 1, vc9_bfraction_codes, 1, 1, 1); INIT_VLC(&vc9_norm2_vlc, VC9_NORM2_VLC_BITS, 4, vc9_norm2_bits, 1, 1, vc9_norm2_codes, 1, 1, 1); #if VLC_NORM6_METH0D == 1 INIT_VLC(&vc9_norm6_vlc, VC9_NORM6_VLC_BITS, 64, vc9_norm6_bits, 1, 1, vc9_norm6_codes, 2, 2, 1); #endif #if VLC_NORM6_METH0D == 2 INIT_VLC(&vc9_norm6_first_vlc, VC9_NORM6_FIRST_BITS, 24, &vc9_norm6_first[0][1], 1, 1, &vc9_norm6_first[0][0], 1, 1, 1); INIT_VLC(&vc9_norm6_second_vlc, VC9_NORM6_SECOND_BITS, 22, &vc9_norm6_second[0][1], 1, 1, &vc9_norm6_second[0][0], 1, 1, 1); #endif INIT_VLC(&vc9_imode_vlc, VC9_IMODE_VLC_BITS, 7, vc9_imode_bits, 1, 1, vc9_imode_codes, 1, 1, 1); for (i=0; i<3; i++) { INIT_VLC(&vc9_ttmb_vlc[i], VC9_TTMB_VLC_BITS, 16, vc9_ttmb_bits[i], 1, 1, vc9_ttmb_codes[i], 2, 2, 1); } for(i=0; i<4; i++) { INIT_VLC(&vc9_4mv_block_pattern_vlc[i], VC9_4MV_BLOCK_PATTERN_VLC_BITS, 16, vc9_4mv_block_pattern_bits[i], 1, 1, vc9_4mv_block_pattern_codes[i], 1, 1, 1); INIT_VLC(&vc9_cbpcy_p_vlc[i], VC9_CBPCY_P_VLC_BITS, 64, vc9_cbpcy_p_bits[i], 1, 1, vc9_cbpcy_p_codes[i], 2, 2, 1); INIT_VLC(&vc9_mv_diff_vlc[i], VC9_MV_DIFF_VLC_BITS, 73, vc9_mv_diff_bits[i], 1, 1, vc9_mv_diff_codes[i], 2, 2, 1); } } v->pq = -1; v->mvrange = 0; return 0; }
1threat
static av_cold int wavpack_encode_init(AVCodecContext *avctx) { WavPackEncodeContext *s = avctx->priv_data; s->avctx = avctx; if (!avctx->frame_size) { int block_samples; if (!(avctx->sample_rate & 1)) block_samples = avctx->sample_rate / 2; else block_samples = avctx->sample_rate; while (block_samples * avctx->channels > 150000) block_samples /= 2; while (block_samples * avctx->channels < 40000) block_samples *= 2; avctx->frame_size = block_samples; } else if (avctx->frame_size && (avctx->frame_size < 128 || avctx->frame_size > WV_MAX_SAMPLES)) { av_log(avctx, AV_LOG_ERROR, "invalid block size: %d\n", avctx->frame_size); return AVERROR(EINVAL); } if (avctx->compression_level != FF_COMPRESSION_DEFAULT) { if (avctx->compression_level >= 3) { s->decorr_filter = 3; s->num_passes = 9; if (avctx->compression_level >= 8) { s->num_branches = 4; s->extra_flags = EXTRA_TRY_DELTAS|EXTRA_ADJUST_DELTAS|EXTRA_SORT_FIRST|EXTRA_SORT_LAST|EXTRA_BRANCHES; } else if (avctx->compression_level >= 7) { s->num_branches = 3; s->extra_flags = EXTRA_TRY_DELTAS|EXTRA_ADJUST_DELTAS|EXTRA_SORT_FIRST|EXTRA_BRANCHES; } else if (avctx->compression_level >= 6) { s->num_branches = 2; s->extra_flags = EXTRA_TRY_DELTAS|EXTRA_ADJUST_DELTAS|EXTRA_SORT_FIRST|EXTRA_BRANCHES; } else if (avctx->compression_level >= 5) { s->num_branches = 1; s->extra_flags = EXTRA_TRY_DELTAS|EXTRA_ADJUST_DELTAS|EXTRA_SORT_FIRST|EXTRA_BRANCHES; } else if (avctx->compression_level >= 4) { s->num_branches = 1; s->extra_flags = EXTRA_TRY_DELTAS|EXTRA_ADJUST_DELTAS|EXTRA_BRANCHES; } } else if (avctx->compression_level == 2) { s->decorr_filter = 2; s->num_passes = 4; } else if (avctx->compression_level == 1) { s->decorr_filter = 1; s->num_passes = 2; } else if (avctx->compression_level < 1) { s->decorr_filter = 0; s->num_passes = 0; } } s->num_decorrs = decorr_filter_sizes[s->decorr_filter]; s->decorr_specs = decorr_filters[s->decorr_filter]; s->delta_decay = 2.0; return 0; }
1threat
static void init_blk_migration(Monitor *mon, QEMUFile *f) { BlkMigDevState *bmds; BlockDriverState *bs; block_mig_state.submitted = 0; block_mig_state.read_done = 0; block_mig_state.transferred = 0; block_mig_state.total_sector_sum = 0; block_mig_state.prev_progress = -1; for (bs = bdrv_first; bs != NULL; bs = bs->next) { if (bs->type == BDRV_TYPE_HD) { bmds = qemu_mallocz(sizeof(BlkMigDevState)); bmds->bs = bs; bmds->bulk_completed = 0; bmds->total_sectors = bdrv_getlength(bs) >> BDRV_SECTOR_BITS; bmds->completed_sectors = 0; bmds->shared_base = block_mig_state.shared_base; block_mig_state.total_sector_sum += bmds->total_sectors; if (bmds->shared_base) { monitor_printf(mon, "Start migration for %s with shared base " "image\n", bs->device_name); } else { monitor_printf(mon, "Start full migration for %s\n", bs->device_name); } QSIMPLEQ_INSERT_TAIL(&block_mig_state.bmds_list, bmds, entry); } } }
1threat
How to get front camera, back camera and audio with AVCaptureDeviceDiscoverySession : <p>Before iOS 10 came out I was using the following code to get the video and audio capture for my video recorder:</p> <pre><code> for device in AVCaptureDevice.devices() { if (device as AnyObject).hasMediaType( AVMediaTypeAudio ) { self.audioCapture = device as? AVCaptureDevice } else if (device as AnyObject).hasMediaType( AVMediaTypeVideo ) { if (device as AnyObject).position == AVCaptureDevicePosition.back { self.backCameraVideoCapture = device as? AVCaptureDevice } else { self.frontCameraVideoCapture = device as? AVCaptureDevice } } } </code></pre> <p>When iOS 10 finally came out, I received the following warning when I was running my code. Note that my video recorder was still working smoothly for about 2 weeks.</p> <blockquote> <p>'devices()' was deprecated in iOS 10.0: Use AVCaptureDeviceDiscoverySession instead.</p> </blockquote> <p>As I was running my code this morning, my video recorder stopped working. xCode8 does not give me any errors but the previewLayer for the camera capture is completely white. When I then start recording I receive the following error:</p> <blockquote> <p>Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x17554440 {Error Domain=NSOSStatusErrorDomain Code=-12780 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-12780)}</p> </blockquote> <p>I believe that has something to do with the fact that I am using the deprecated approach <code>AVCaptureDevice.devices()</code>. Hence, I was wondering how to use <code>AVCaptureDeviceDiscoverySession</code> instead?</p> <p>Thank you for your help in advance!</p>
0debug
Spark on Amazon EMR: "Timeout waiting for connection from pool" : <p>I'm running a Spark job on a small three server Amazon EMR 5 (Spark 2.0) cluster. My job runs for an hour or so, fails with the error below. I can manually restart and it works, processes more data, and eventually fails again.</p> <p>My Spark code is fairly simple and is not using any Amazon or S3 APIs directly. My Spark code passes S3 text string paths to Spark and Spark uses S3 internally.</p> <p>My Spark program just does the following in a loop: Load data from S3 -> Process -> Write data to different location on S3. </p> <p>My first suspicion is that some internal Amazon or Spark code is not properly disposing of connections and the connection pool becomes exhausted.</p> <pre><code>com.amazon.ws.emr.hadoop.fs.shaded.com.amazonaws.AmazonClientException: Unable to execute HTTP request: Timeout waiting for connection from pool at com.amazon.ws.emr.hadoop.fs.shaded.com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:618) at com.amazon.ws.emr.hadoop.fs.shaded.com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:376) at com.amazon.ws.emr.hadoop.fs.shaded.com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:338) at com.amazon.ws.emr.hadoop.fs.shaded.com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:287) at com.amazon.ws.emr.hadoop.fs.shaded.com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3826) at com.amazon.ws.emr.hadoop.fs.shaded.com.amazonaws.services.s3.AmazonS3Client.getObjectMetadata(AmazonS3Client.java:1015) at com.amazon.ws.emr.hadoop.fs.shaded.com.amazonaws.services.s3.AmazonS3Client.getObjectMetadata(AmazonS3Client.java:991) at com.amazon.ws.emr.hadoop.fs.s3n.Jets3tNativeFileSystemStore.retrieveMetadata(Jets3tNativeFileSystemStore.java:212) at sun.reflect.GeneratedMethodAccessor45.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:191) at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:102) at com.sun.proxy.$Proxy44.retrieveMetadata(Unknown Source) at com.amazon.ws.emr.hadoop.fs.s3n.S3NativeFileSystem.getFileStatus(S3NativeFileSystem.java:780) at org.apache.hadoop.fs.FileSystem.exists(FileSystem.java:1428) at com.amazon.ws.emr.hadoop.fs.EmrFileSystem.exists(EmrFileSystem.java:313) at org.apache.spark.sql.execution.datasources.InsertIntoHadoopFsRelationCommand.run(InsertIntoHadoopFsRelationCommand.scala:85) at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult$lzycompute(commands.scala:60) at org.apache.spark.sql.execution.command.ExecutedCommandExec.sideEffectResult(commands.scala:58) at org.apache.spark.sql.execution.command.ExecutedCommandExec.doExecute(commands.scala:74) at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:115) at org.apache.spark.sql.execution.SparkPlan$$anonfun$execute$1.apply(SparkPlan.scala:115) at org.apache.spark.sql.execution.SparkPlan$$anonfun$executeQuery$1.apply(SparkPlan.scala:136) at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151) at org.apache.spark.sql.execution.SparkPlan.executeQuery(SparkPlan.scala:133) at org.apache.spark.sql.execution.SparkPlan.execute(SparkPlan.scala:114) at org.apache.spark.sql.execution.QueryExecution.toRdd$lzycompute(QueryExecution.scala:86) at org.apache.spark.sql.execution.QueryExecution.toRdd(QueryExecution.scala:86) at org.apache.spark.sql.execution.datasources.DataSource.write(DataSource.scala:487) at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:211) at org.apache.spark.sql.DataFrameWriter.save(DataFrameWriter.scala:194) at sun.reflect.GeneratedMethodAccessor85.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:237) at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357) at py4j.Gateway.invoke(Gateway.java:280) at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:128) at py4j.commands.CallCommand.execute(CallCommand.java:79) at py4j.GatewayConnection.run(GatewayConnection.java:211) at java.lang.Thread.run(Thread.java:745) Caused by: com.amazon.ws.emr.hadoop.fs.shaded.org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool at com.amazon.ws.emr.hadoop.fs.shaded.org.apache.http.impl.conn.PoolingClientConnectionManager.leaseConnection(PoolingClientConnectionManager.java:226) at com.amazon.ws.emr.hadoop.fs.shaded.org.apache.http.impl.conn.PoolingClientConnectionManager$1.getConnection(PoolingClientConnectionManager.java:195) at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.amazon.ws.emr.hadoop.fs.shaded.com.amazonaws.http.conn.ClientConnectionRequestFactory$Handler.invoke(ClientConnectionRequestFactory.java:70) at com.amazon.ws.emr.hadoop.fs.shaded.com.amazonaws.http.conn.$Proxy45.getConnection(Unknown Source) at com.amazon.ws.emr.hadoop.fs.shaded.org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:423) at com.amazon.ws.emr.hadoop.fs.shaded.org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863) at com.amazon.ws.emr.hadoop.fs.shaded.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82) at com.amazon.ws.emr.hadoop.fs.shaded.org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57) at com.amazon.ws.emr.hadoop.fs.shaded.com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:837) at com.amazon.ws.emr.hadoop.fs.shaded.com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:607) ... 41 more </code></pre>
0debug
static void test_validate_qmp_introspect(TestInputVisitorData *data, const void *unused) { do_test_validate_qmp_introspect(data, test_qmp_schema_json); do_test_validate_qmp_introspect(data, qmp_schema_json); }
1threat
Could someone help me out with this SQL query? : I am asked this: > Use a subquery in the FROM clause to only retrieve invoices from > chamber 'H' and the invoice amount of larger than 10000 and join the > result with the voyages table using the number column. Project to only > retrieve the boatname and the invoice amount of the join result. Order > by invoice amount. So, I made this: SELECT chamber=(SELECT chamber FROM invoices INNER JOIN voyages ON chambers.chamber='H' AND chambers.invoice > 10000 AND invoice.number=voyages.number), boatname, invoice FROM chambers, voyages, invoices WHERE chambers.chamber=invoices.chamber, invoices.number=voyages.number *This is the chambers table:* # chamber name 1 A New York *This is the invoices table:* # number invoice chamber 1 8300 9189 A Yet it keeps giving me this error: `Query failed: near ",": syntax error` I can't solve it. Could someone help me out?
0debug
static void fdctrl_start_transfer(FDCtrl *fdctrl, int direction) { FDrive *cur_drv; uint8_t kh, kt, ks; SET_CUR_DRV(fdctrl, fdctrl->fifo[1] & FD_DOR_SELMASK); cur_drv = get_cur_drv(fdctrl); kt = fdctrl->fifo[2]; kh = fdctrl->fifo[3]; ks = fdctrl->fifo[4]; FLOPPY_DPRINTF("Start transfer at %d %d %02x %02x (%d)\n", GET_CUR_DRV(fdctrl), kh, kt, ks, fd_sector_calc(kh, kt, ks, cur_drv->last_sect, NUM_SIDES(cur_drv))); switch (fd_seek(cur_drv, kh, kt, ks, fdctrl->config & FD_CONFIG_EIS)) { case 2: fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, 0x00, 0x00); fdctrl->fifo[3] = kt; fdctrl->fifo[4] = kh; fdctrl->fifo[5] = ks; return; case 3: fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, FD_SR1_EC, 0x00); fdctrl->fifo[3] = kt; fdctrl->fifo[4] = kh; fdctrl->fifo[5] = ks; return; case 4: fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, 0x00, 0x00); fdctrl->fifo[3] = kt; fdctrl->fifo[4] = kh; fdctrl->fifo[5] = ks; return; case 1: fdctrl->status0 |= FD_SR0_SEEK; break; default: break; } if (fdctrl->check_media_rate && (fdctrl->dsr & FD_DSR_DRATEMASK) != cur_drv->media_rate) { FLOPPY_DPRINTF("data rate mismatch (fdc=%d, media=%d)\n", fdctrl->dsr & FD_DSR_DRATEMASK, cur_drv->media_rate); fdctrl_stop_transfer(fdctrl, FD_SR0_ABNTERM, FD_SR1_MA, 0x00); fdctrl->fifo[3] = kt; fdctrl->fifo[4] = kh; fdctrl->fifo[5] = ks; return; } fdctrl->data_dir = direction; fdctrl->data_pos = 0; fdctrl->msr |= FD_MSR_CMDBUSY; if (fdctrl->fifo[0] & 0x80) fdctrl->data_state |= FD_STATE_MULTI; else fdctrl->data_state &= ~FD_STATE_MULTI; if (fdctrl->fifo[5] == 00) { fdctrl->data_len = fdctrl->fifo[8]; } else { int tmp; fdctrl->data_len = 128 << (fdctrl->fifo[5] > 7 ? 7 : fdctrl->fifo[5]); tmp = (fdctrl->fifo[6] - ks + 1); if (fdctrl->fifo[0] & 0x80) tmp += fdctrl->fifo[6]; fdctrl->data_len *= tmp; } fdctrl->eot = fdctrl->fifo[6]; if (fdctrl->dor & FD_DOR_DMAEN) { int dma_mode; dma_mode = DMA_get_channel_mode(fdctrl->dma_chann); dma_mode = (dma_mode >> 2) & 3; FLOPPY_DPRINTF("dma_mode=%d direction=%d (%d - %d)\n", dma_mode, direction, (128 << fdctrl->fifo[5]) * (cur_drv->last_sect - ks + 1), fdctrl->data_len); if (((direction == FD_DIR_SCANE || direction == FD_DIR_SCANL || direction == FD_DIR_SCANH) && dma_mode == 0) || (direction == FD_DIR_WRITE && dma_mode == 2) || (direction == FD_DIR_READ && dma_mode == 1)) { fdctrl->msr &= ~FD_MSR_RQM; DMA_hold_DREQ(fdctrl->dma_chann); DMA_schedule(fdctrl->dma_chann); return; } else { FLOPPY_DPRINTF("bad dma_mode=%d direction=%d\n", dma_mode, direction); } } FLOPPY_DPRINTF("start non-DMA transfer\n"); fdctrl->msr |= FD_MSR_NONDMA; if (direction != FD_DIR_WRITE) fdctrl->msr |= FD_MSR_DIO; fdctrl_raise_irq(fdctrl); }
1threat
static QObject *qmp_input_get_object(QmpInputVisitor *qiv, const char *name, bool consume) { StackObject *tos; QObject *qobj; QObject *ret; if (!qiv->nb_stack) { return qiv->root; } tos = &qiv->stack[qiv->nb_stack - 1]; qobj = tos->obj; assert(qobj); if (qobject_type(qobj) == QTYPE_QDICT) { assert(name); ret = qdict_get(qobject_to_qdict(qobj), name); if (tos->h && consume && ret) { bool removed = g_hash_table_remove(tos->h, name); assert(removed); } } else { assert(qobject_type(qobj) == QTYPE_QLIST); assert(!name); ret = qlist_entry_obj(tos->entry); if (consume) { tos->entry = qlist_next(tos->entry); } } return ret; }
1threat
How to access host component from directive? : <p>Say I have the following markup:</p> <pre><code>&lt;my-comp myDirective&gt;&lt;/my-comp&gt; </code></pre> <p>Is there any way I can access the component instance <strong>from the directive</strong>?</p> <p>More specifically I want to be able to access the properties and methods of <code>MyComponent</code> from <code>MyDirective</code>, ideally <strong>without adding anything to the HTML above</strong>.</p>
0debug
What is the best way to initialize instance variable : <p>Which is the best way to initialize instance variable?</p> <p>1 - instance initializer block inside default constructor</p> <pre><code>myClass(){ { instanceVariable = 1; } } </code></pre> <p>2 - assign value inside default constructor block</p> <pre><code>myClass(){ instanceVariable = 1; } </code></pre> <p>3 - make my own instance (with parameter) </p> <pre><code>myClass(int instanceVariable){ this.instanceVariable = 1; } </code></pre> <p>Many thanks, John</p>
0debug
import re def split_list(text): return (re.findall('[A-Z][^A-Z]*', text))
0debug
static inline void RENAME(yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, unsigned int width, unsigned int height, int lumStride, int chromStride, int dstStride) { RENAME(yuvPlanartoyuy2)(ysrc, usrc, vsrc, dst, width, height, lumStride, chromStride, dstStride, 1); }
1threat
def all_unique(test_list): if len(test_list) > len(set(test_list)): return False return True
0debug
Java - what is the algorithm for converting decimal to any other number system : <p>i'm trying to find an algorithm to convert any positive decimal number(integer) to any other number system. I cant seem to get my head arround it. Can anyone help?</p>
0debug
static inline uint32_t ldl_phys_internal(target_phys_addr_t addr, enum device_endian endian) { uint8_t *ptr; uint32_t val; MemoryRegionSection *section; section = phys_page_find(address_space_memory.dispatch, addr >> TARGET_PAGE_BITS); if (!(memory_region_is_ram(section->mr) || memory_region_is_romd(section->mr))) { addr = memory_region_section_addr(section, addr); val = io_mem_read(section->mr, addr, 4); #if defined(TARGET_WORDS_BIGENDIAN) if (endian == DEVICE_LITTLE_ENDIAN) { val = bswap32(val); } #else if (endian == DEVICE_BIG_ENDIAN) { val = bswap32(val); } #endif } else { ptr = qemu_get_ram_ptr((memory_region_get_ram_addr(section->mr) & TARGET_PAGE_MASK) + memory_region_section_addr(section, addr)); switch (endian) { case DEVICE_LITTLE_ENDIAN: val = ldl_le_p(ptr); break; case DEVICE_BIG_ENDIAN: val = ldl_be_p(ptr); break; default: val = ldl_p(ptr); break; } } return val; }
1threat
Deployment target iOS 9.0 to 7.0 : <p>I have developed the application using iOS 9 components(Stack view and CNContact).</p> <p>While developing on project i have given deployment target is iOS9.0, now i have to support iOS 7.0, so iam trying to change deployment target 9.0 to 7.0 but i am getting lot of errors.</p> <p>Request you to give me suggestion to solve these issues.</p>
0debug
static void unpack_superblocks(Vp3DecodeContext *s, GetBitContext *gb) { int bit = 0; int current_superblock = 0; int current_run = 0; int decode_fully_flags = 0; int decode_partial_blocks = 0; int i, j; int current_fragment; debug_vp3(" vp3: unpacking superblock coding\n"); if (s->keyframe) { debug_vp3(" keyframe-- all superblocks are fully coded\n"); memset(s->superblock_coding, SB_FULLY_CODED, s->superblock_count); } else { bit = get_bits(gb, 1); bit ^= 1; while (current_superblock < s->superblock_count) { if (current_run == 0) { bit ^= 1; current_run = get_superblock_run_length(gb); debug_block_coding(" setting superblocks %d..%d to %s\n", current_superblock, current_superblock + current_run - 1, (bit) ? "partially coded" : "not coded"); if (bit == 0) decode_fully_flags = 1; } else { decode_partial_blocks = 1; } s->superblock_coding[current_superblock++] = (bit) ? SB_PARTIALLY_CODED : SB_NOT_CODED; current_run--; } if (decode_fully_flags) { current_superblock = 0; current_run = 0; bit = get_bits(gb, 1); bit ^= 1; while (current_superblock < s->superblock_count) { if (s->superblock_coding[current_superblock] == SB_NOT_CODED) { if (current_run == 0) { bit ^= 1; current_run = get_superblock_run_length(gb); } debug_block_coding(" setting superblock %d to %s\n", current_superblock, (bit) ? "fully coded" : "not coded"); s->superblock_coding[current_superblock] = (bit) ? SB_FULLY_CODED : SB_NOT_CODED; current_run--; } current_superblock++; } } if (decode_partial_blocks) { current_run = 0; bit = get_bits(gb, 1); bit ^= 1; } } s->coded_fragment_list_index = 0; s->first_coded_y_fragment = s->first_coded_c_fragment = 0; s->last_coded_y_fragment = s->last_coded_c_fragment = -1; memset(s->macroblock_coded, 0, s->macroblock_count); for (i = 0; i < s->superblock_count; i++) { for (j = 0; j < 16; j++) { current_fragment = s->superblock_fragments[i * 16 + j]; if (current_fragment != -1) { if (s->superblock_coding[i] == SB_NOT_CODED) { s->all_fragments[current_fragment].coding_method = MODE_COPY; } else if (s->superblock_coding[i] == SB_PARTIALLY_CODED) { if (current_run == 0) { bit ^= 1; current_run = get_fragment_run_length(gb); } if (bit) { s->all_fragments[current_fragment].coding_method = MODE_INTER_NO_MV; s->coded_fragment_list[s->coded_fragment_list_index] = current_fragment; if ((current_fragment >= s->u_fragment_start) && (s->last_coded_y_fragment == -1)) { s->first_coded_c_fragment = s->coded_fragment_list_index; s->last_coded_y_fragment = s->first_coded_c_fragment - 1; } s->coded_fragment_list_index++; s->macroblock_coded[s->all_fragments[current_fragment].macroblock] = 1; debug_block_coding(" superblock %d is partially coded, fragment %d is coded\n", i, current_fragment); } else { s->all_fragments[current_fragment].coding_method = MODE_COPY; debug_block_coding(" superblock %d is partially coded, fragment %d is not coded\n", i, current_fragment); } current_run--; } else { s->all_fragments[current_fragment].coding_method = MODE_INTER_NO_MV; s->coded_fragment_list[s->coded_fragment_list_index] = current_fragment; if ((current_fragment >= s->u_fragment_start) && (s->last_coded_y_fragment == -1)) { s->first_coded_c_fragment = s->coded_fragment_list_index; s->last_coded_y_fragment = s->first_coded_c_fragment - 1; } s->coded_fragment_list_index++; s->macroblock_coded[s->all_fragments[current_fragment].macroblock] = 1; debug_block_coding(" superblock %d is fully coded, fragment %d is coded\n", i, current_fragment); } } } } if (s->first_coded_c_fragment == 0) s->last_coded_y_fragment = s->coded_fragment_list_index - 1; else s->last_coded_c_fragment = s->coded_fragment_list_index - 1; debug_block_coding(" %d total coded fragments, y: %d -> %d, c: %d -> %d\n", s->coded_fragment_list_index, s->first_coded_y_fragment, s->last_coded_y_fragment, s->first_coded_c_fragment, s->last_coded_c_fragment); }
1threat
elemnts are not centered inside the wrapper and when I set the width of the wrapper it goes out of the browser..any solution? : `<footer id="footer"> <div class="wrapper"> <div class="col right-list"> </div> <div class="col middle-list"> </div> <div class="col left-list"> </div> </div> </footer> css #footer {width:100%;} #footer .wrapper{background:red;margin:0 auto;position:relative; width: 1024px;height: 192px;font-size:} #footer .wrapper .col {width: 20%;height: 192px; background: green; display: inline-block;}`
0debug
git submodule init does absolutely nothing : <p>I have a strange problem with "git submodule init"</p> <p>When I added the submodules using "git submodule add url location" it cloned the repository just fine and everything was ok.</p> <p>When I pushed all my changes back to the parent repository, added the .gitmodules files, etc and cloned the repository back, I tried to initialise all the submodules using "git submodule init" </p> <p>And nothing happens :( Literally nothing, no output, no extra files, it does not even attempt to do anything actually.</p> <p>So I am wondering, what did I do wrong?</p> <p>.gitmodules:</p> <pre><code>bash$ cat .gitmodules [submodule "projects/subprojectA"] path = projects/subprojectA url = ssh://user@bitbucket.company.com/test/projectA.git [submodule "projects/subprojectB"] path = projects/subprojectB url = ssh://user@bitbucket.company.com/test/projectB.git </code></pre>
0debug
syntax error, unexpected '<', expecting ';' or '\n' : <p>Tried to include a module in another one, but something goes wrong</p> <pre><code>ruby pipboy.rb pipboy.rb:3: syntax error, unexpected '&lt;', expecting ';' or '\n' def Pipboy &lt; Person ^ pipboy.rb:22: syntax error, unexpected keyword_end, expecting end-of-input </code></pre>
0debug
[Gitlab]Where can I find Gitlab Pages hosted on my private Gitlab instance? : <p>I tried to set up Gitlab Pages, until now I finished uploading my static website files👇</p> <pre><code>Uploading artifacts... coverage/lcov-report: found 77 matching files Uploading artifacts to coordinator... ok id=1038 responseStatus=201 Created token=QXJjgkf2 </code></pre> <p>But I got no idea where my page hosted.</p> <p>I took a glance at <a href="https://docs.gitlab.com/ce/user/project/pages/getting_started_part_one.html#practical-examples" rel="noreferrer">this documentation</a> but it was still vague to me.</p> <ul> <li>I have a private Gitlab instance.</li> <li>My Gitlab entry is under <a href="http://abc.def.com" rel="noreferrer">http://abc.def.com</a> (I configured a type A DNS to my host IP 111.111.111.111, a reverse proxy pointing at localhost:9000).</li> <li>My project <code>project1</code> is under my team <code>team1</code>.</li> <li>I have also configured DNS <a href="http://team1.abc.def.com" rel="noreferrer">http://team1.abc.def.com</a> to 111.111.111.111 , and there is a nginx reverse proxy on my server which <a href="http://team1.abc.def.com" rel="noreferrer">http://team1.abc.def.com</a> -> localhost:9000.</li> </ul> <p>I assume I should see my static page available on <a href="http://team1.abc.def.com/project1" rel="noreferrer">http://team1.abc.def.com/project1</a> , but nothing was there. Where exactly are my pages hosted?</p>
0debug
Why Java 8 Stream interface does not have min() no-parameter version? : <p><code>java.util.stream.Stream</code> interface has two versions of <code>sorted</code> method – <code>sorted()</code> which sorts elements in natural order and <code>sorted(Comparator)</code>. Why <code>min()</code> method was not introduced to <code>Stream</code> interface, which would return minimal element from natural-ordering point of view?</p>
0debug
static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; MSS2Context *ctx = avctx->priv_data; MSS12Context *c = &ctx->c; AVFrame *frame = data; GetBitContext gb; GetByteContext gB; ArithCoder acoder; int keyframe, has_wmv9, has_mv, is_rle, is_555, ret; Rectangle wmv9rects[MAX_WMV9_RECTANGLES], *r; int used_rects = 0, i, implicit_rect = 0, av_uninit(wmv9_mask); if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0) return ret; if (keyframe = get_bits1(&gb)) skip_bits(&gb, 7); has_wmv9 = get_bits1(&gb); has_mv = keyframe ? 0 : get_bits1(&gb); is_rle = get_bits1(&gb); is_555 = is_rle && get_bits1(&gb); if (c->slice_split > 0) ctx->split_position = c->slice_split; else if (c->slice_split < 0) { if (get_bits1(&gb)) { if (get_bits1(&gb)) { if (get_bits1(&gb)) ctx->split_position = get_bits(&gb, 16); else ctx->split_position = get_bits(&gb, 12); } else ctx->split_position = get_bits(&gb, 8) << 4; } else { if (keyframe) ctx->split_position = avctx->height / 2; } } else ctx->split_position = avctx->height; if (c->slice_split && (ctx->split_position < 1 - is_555 || ctx->split_position > avctx->height - 1)) return AVERROR_INVALIDDATA; align_get_bits(&gb); buf += get_bits_count(&gb) >> 3; buf_size -= get_bits_count(&gb) >> 3; if (buf_size < 1) return AVERROR_INVALIDDATA; if (is_555 && (has_wmv9 || has_mv || c->slice_split && ctx->split_position)) return AVERROR_INVALIDDATA; avctx->pix_fmt = is_555 ? AV_PIX_FMT_RGB555 : AV_PIX_FMT_RGB24; if (ctx->last_pic->format != avctx->pix_fmt) av_frame_unref(ctx->last_pic); if (has_wmv9) { bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING); arith2_init(&acoder, &gB); implicit_rect = !arith2_get_bit(&acoder); while (arith2_get_bit(&acoder)) { if (used_rects == MAX_WMV9_RECTANGLES) return AVERROR_INVALIDDATA; r = &wmv9rects[used_rects]; if (!used_rects) r->x = arith2_get_number(&acoder, avctx->width); else r->x = arith2_get_number(&acoder, avctx->width - wmv9rects[used_rects - 1].x) + wmv9rects[used_rects - 1].x; r->y = arith2_get_number(&acoder, avctx->height); r->w = arith2_get_number(&acoder, avctx->width - r->x) + 1; r->h = arith2_get_number(&acoder, avctx->height - r->y) + 1; used_rects++; } if (implicit_rect && used_rects) { av_log(avctx, AV_LOG_ERROR, "implicit_rect && used_rects > 0\n"); return AVERROR_INVALIDDATA; } if (implicit_rect) { wmv9rects[0].x = 0; wmv9rects[0].y = 0; wmv9rects[0].w = avctx->width; wmv9rects[0].h = avctx->height; used_rects = 1; } for (i = 0; i < used_rects; i++) { if (!implicit_rect && arith2_get_bit(&acoder)) { av_log(avctx, AV_LOG_ERROR, "Unexpected grandchildren\n"); return AVERROR_INVALIDDATA; } if (!i) { wmv9_mask = arith2_get_bit(&acoder) - 1; if (!wmv9_mask) wmv9_mask = arith2_get_number(&acoder, 256); } wmv9rects[i].coded = arith2_get_number(&acoder, 2); } buf += arith2_get_consumed_bytes(&acoder); buf_size -= arith2_get_consumed_bytes(&acoder); if (buf_size < 1) return AVERROR_INVALIDDATA; } c->mvX = c->mvY = 0; if (keyframe && !is_555) { if ((i = decode_pal_v2(c, buf, buf_size)) < 0) return AVERROR_INVALIDDATA; buf += i; buf_size -= i; } else if (has_mv) { buf += 4; buf_size -= 4; if (buf_size < 1) return AVERROR_INVALIDDATA; c->mvX = AV_RB16(buf - 4) - avctx->width; c->mvY = AV_RB16(buf - 2) - avctx->height; } if (c->mvX < 0 || c->mvY < 0) { FFSWAP(uint8_t *, c->pal_pic, c->last_pal_pic); if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0) return ret; if (ctx->last_pic->data[0]) { av_assert0(frame->linesize[0] == ctx->last_pic->linesize[0]); c->last_rgb_pic = ctx->last_pic->data[0] + ctx->last_pic->linesize[0] * (avctx->height - 1); } else { av_log(avctx, AV_LOG_ERROR, "Missing keyframe\n"); return AVERROR_INVALIDDATA; } } else { if ((ret = ff_reget_buffer(avctx, ctx->last_pic)) < 0) return ret; if ((ret = av_frame_ref(frame, ctx->last_pic)) < 0) return ret; c->last_rgb_pic = NULL; } c->rgb_pic = frame->data[0] + frame->linesize[0] * (avctx->height - 1); c->rgb_stride = -frame->linesize[0]; frame->key_frame = keyframe; frame->pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; if (is_555) { bytestream2_init(&gB, buf, buf_size); if (decode_555(&gB, (uint16_t *)c->rgb_pic, c->rgb_stride >> 1, keyframe, avctx->width, avctx->height)) return AVERROR_INVALIDDATA; buf_size -= bytestream2_tell(&gB); } else { if (keyframe) { c->corrupted = 0; ff_mss12_slicecontext_reset(&ctx->sc[0]); if (c->slice_split) ff_mss12_slicecontext_reset(&ctx->sc[1]); } if (is_rle) { if ((ret = init_get_bits8(&gb, buf, buf_size)) < 0) return ret; if (ret = decode_rle(&gb, c->pal_pic, c->pal_stride, c->rgb_pic, c->rgb_stride, c->pal, keyframe, ctx->split_position, 0, avctx->width, avctx->height)) return ret; align_get_bits(&gb); if (c->slice_split) if (ret = decode_rle(&gb, c->pal_pic, c->pal_stride, c->rgb_pic, c->rgb_stride, c->pal, keyframe, ctx->split_position, 1, avctx->width, avctx->height)) return ret; align_get_bits(&gb); buf += get_bits_count(&gb) >> 3; buf_size -= get_bits_count(&gb) >> 3; } else if (!implicit_rect || wmv9_mask != -1) { if (c->corrupted) return AVERROR_INVALIDDATA; bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING); arith2_init(&acoder, &gB); c->keyframe = keyframe; if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[0], &acoder, 0, 0, avctx->width, ctx->split_position)) return AVERROR_INVALIDDATA; buf += arith2_get_consumed_bytes(&acoder); buf_size -= arith2_get_consumed_bytes(&acoder); if (c->slice_split) { if (buf_size < 1) return AVERROR_INVALIDDATA; bytestream2_init(&gB, buf, buf_size + ARITH2_PADDING); arith2_init(&acoder, &gB); if (c->corrupted = ff_mss12_decode_rect(&ctx->sc[1], &acoder, 0, ctx->split_position, avctx->width, avctx->height - ctx->split_position)) return AVERROR_INVALIDDATA; buf += arith2_get_consumed_bytes(&acoder); buf_size -= arith2_get_consumed_bytes(&acoder); } } else memset(c->pal_pic, 0, c->pal_stride * avctx->height); } if (has_wmv9) { for (i = 0; i < used_rects; i++) { int x = wmv9rects[i].x; int y = wmv9rects[i].y; int w = wmv9rects[i].w; int h = wmv9rects[i].h; if (wmv9rects[i].coded) { int WMV9codedFrameSize; if (buf_size < 4 || !(WMV9codedFrameSize = AV_RL24(buf))) return AVERROR_INVALIDDATA; if (ret = decode_wmv9(avctx, buf + 3, buf_size - 3, x, y, w, h, wmv9_mask)) return ret; buf += WMV9codedFrameSize + 3; buf_size -= WMV9codedFrameSize + 3; } else { uint8_t *dst = c->rgb_pic + y * c->rgb_stride + x * 3; if (wmv9_mask != -1) { ctx->dsp.mss2_gray_fill_masked(dst, c->rgb_stride, wmv9_mask, c->pal_pic + y * c->pal_stride + x, c->pal_stride, w, h); } else { do { memset(dst, 0x80, w * 3); dst += c->rgb_stride; } while (--h); } } } } if (buf_size) av_log(avctx, AV_LOG_WARNING, "buffer not fully consumed\n"); if (c->mvX < 0 || c->mvY < 0) { av_frame_unref(ctx->last_pic); ret = av_frame_ref(ctx->last_pic, frame); if (ret < 0) return ret; } *got_frame = 1; return avpkt->size; }
1threat
void op_div (void) { if (T1 != 0) { env->LO = (int32_t)((int32_t)T0 / (int32_t)T1); env->HI = (int32_t)((int32_t)T0 % (int32_t)T1); } RETURN(); }
1threat
void avfilter_destroy(AVFilterContext *filter) { int i; if(filter->filter->uninit) filter->filter->uninit(filter); for(i = 0; i < filter->input_count; i ++) { if(filter->inputs[i]) { filter->inputs[i]->src->outputs[filter->inputs[i]->srcpad] = NULL; avfilter_formats_unref(&filter->inputs[i]->in_formats); avfilter_formats_unref(&filter->inputs[i]->out_formats); } av_freep(&filter->inputs[i]); } for(i = 0; i < filter->output_count; i ++) { if(filter->outputs[i]) { if (filter->outputs[i]->dst) filter->outputs[i]->dst->inputs[filter->outputs[i]->dstpad] = NULL; avfilter_formats_unref(&filter->outputs[i]->in_formats); avfilter_formats_unref(&filter->outputs[i]->out_formats); } av_freep(&filter->outputs[i]); } av_freep(&filter->name); av_freep(&filter->input_pads); av_freep(&filter->output_pads); av_freep(&filter->inputs); av_freep(&filter->outputs); av_freep(&filter->priv); av_free(filter); }
1threat
to replace globally in javascript with replace function : <p>I want to replace some texts in javascript. But it is working only one time.</p> <pre><code> passageText = passageText.replace('&lt;/span&gt;&lt;span alignmentBaseline="useDominantBaseline"', '&lt;/span&gt;&lt;br&gt;&lt;span alignmentBaseline="useDominantBaseline"'); </code></pre>
0debug
What is the (condition) ? val1 : val2 statement called? : <p>I am working on a project and need to know what the name of the statement if officially called. I have used it a lot, I just no clue what the name is.</p> <p>Example statement:</p> <pre><code>let x = didJump ? 10 : 5 </code></pre>
0debug
void bmdma_cmd_writeb(BMDMAState *bm, uint32_t val) { #ifdef DEBUG_IDE printf("%s: 0x%08x\n", __func__, val); #endif if ((val & BM_CMD_START) != (bm->cmd & BM_CMD_START)) { if (!(val & BM_CMD_START)) { if (bm->bus->dma->aiocb) { qemu_aio_flush(); assert(bm->bus->dma->aiocb == NULL); assert((bm->status & BM_STATUS_DMAING) == 0); } } else { bm->cur_addr = bm->addr; if (!(bm->status & BM_STATUS_DMAING)) { bm->status |= BM_STATUS_DMAING; if (bm->dma_cb) bm->dma_cb(bmdma_active_if(bm), 0); } } } bm->cmd = val & 0x09; }
1threat
void kvm_s390_cmma_reset(void) { int rc; struct kvm_device_attr attr = { .group = KVM_S390_VM_MEM_CTRL, .attr = KVM_S390_VM_MEM_CLR_CMMA, }; if (mem_path || !kvm_s390_cmma_available()) { return; } rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr); trace_kvm_clear_cmma(rc); }
1threat
void visit_end_struct(Visitor *v, Error **errp) { assert(!error_is_set(errp)); v->end_struct(v, errp); }
1threat
Powershell script extract excel table auto connect to Visio : May I know the solutions or hints to extract excel table by using powershell script? Then, by using the powershell script, read through the excel table then link to visio (Example: draw column 1-5, a rectangular shape) Thanks.
0debug
MySQL database Links to HTML Table : <p>I am trying to learn more about html, php, and mysql. I am trying to retrieve a link from the database that is just stored as a varchar, then display it in a table.</p> <p>Each entry will have a different link, they are all linked to external website and I couldn't figure this out. Here is my current code.</p> <p><div class="snippet" data-lang="js" data-hide="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php include("connection.php"); $sql = "SELECT Username, Location, Points FROM database ORDER BY Points DESC"; $result1 = mysqli_query($db_con, $sql); while($row1 = mysqli_fetch_array($result1)):;?&gt; &lt;tr&gt; &lt;td&gt;&lt;a href="'.$row['Location'].'"&gt;&lt;?php echo $row1[0]; ?&gt;&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row1[1]; ?&gt;&lt;/td&gt; &lt;td&gt;&lt;?php echo $row1[2]; ?&gt;&lt;/td&gt; &lt;/tr&gt; &lt;?php endwhile; ?&gt; &lt;?php</code></pre> </div> </div> </p> <p>The Location is where the links are stored, as you can tell I had a fairly sad attempt as I don't know mysql, php to well.</p> <p>Thanks for your time!</p>
0debug
static int overlay_opencl_blend(FFFrameSync *fs) { AVFilterContext *avctx = fs->parent; AVFilterLink *outlink = avctx->outputs[0]; OverlayOpenCLContext *ctx = avctx->priv; AVFrame *input_main, *input_overlay; AVFrame *output; cl_mem mem; cl_int cle, x, y; size_t global_work[2]; int kernel_arg = 0; int err, plane; err = ff_framesync_get_frame(fs, 0, &input_main, 0); if (err < 0) return err; err = ff_framesync_get_frame(fs, 1, &input_overlay, 0); if (err < 0) return err; if (!ctx->initialised) { AVHWFramesContext *main_fc = (AVHWFramesContext*)input_main->hw_frames_ctx->data; AVHWFramesContext *overlay_fc = (AVHWFramesContext*)input_overlay->hw_frames_ctx->data; err = overlay_opencl_load(avctx, main_fc->sw_format, overlay_fc->sw_format); if (err < 0) return err; } output = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!output) { err = AVERROR(ENOMEM); goto fail; } for (plane = 0; plane < ctx->nb_planes; plane++) { kernel_arg = 0; mem = (cl_mem)output->data[plane]; cle = clSetKernelArg(ctx->kernel, kernel_arg++, sizeof(cl_mem), &mem); if (cle != CL_SUCCESS) goto fail_kernel_arg; mem = (cl_mem)input_main->data[plane]; cle = clSetKernelArg(ctx->kernel, kernel_arg++, sizeof(cl_mem), &mem); if (cle != CL_SUCCESS) goto fail_kernel_arg; mem = (cl_mem)input_overlay->data[plane]; cle = clSetKernelArg(ctx->kernel, kernel_arg++, sizeof(cl_mem), &mem); if (cle != CL_SUCCESS) goto fail_kernel_arg; if (ctx->alpha_separate) { mem = (cl_mem)input_overlay->data[ctx->nb_planes]; cle = clSetKernelArg(ctx->kernel, kernel_arg++, sizeof(cl_mem), &mem); if (cle != CL_SUCCESS) goto fail_kernel_arg; } x = ctx->x_position / (plane == 0 ? 1 : ctx->x_subsample); y = ctx->y_position / (plane == 0 ? 1 : ctx->y_subsample); cle = clSetKernelArg(ctx->kernel, kernel_arg++, sizeof(cl_int), &x); if (cle != CL_SUCCESS) goto fail_kernel_arg; cle = clSetKernelArg(ctx->kernel, kernel_arg++, sizeof(cl_int), &y); if (cle != CL_SUCCESS) goto fail_kernel_arg; if (ctx->alpha_separate) { cl_int alpha_adj_x = plane == 0 ? 1 : ctx->x_subsample; cl_int alpha_adj_y = plane == 0 ? 1 : ctx->y_subsample; cle = clSetKernelArg(ctx->kernel, kernel_arg++, sizeof(cl_int), &alpha_adj_x); if (cle != CL_SUCCESS) goto fail_kernel_arg; cle = clSetKernelArg(ctx->kernel, kernel_arg++, sizeof(cl_int), &alpha_adj_y); if (cle != CL_SUCCESS) goto fail_kernel_arg; } global_work[0] = output->width; global_work[1] = output->height; cle = clEnqueueNDRangeKernel(ctx->command_queue, ctx->kernel, 2, NULL, global_work, NULL, 0, NULL, NULL); if (cle != CL_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed to enqueue " "overlay kernel for plane %d: %d.\n", cle, plane); err = AVERROR(EIO); goto fail; } } cle = clFinish(ctx->command_queue); if (cle != CL_SUCCESS) { av_log(avctx, AV_LOG_ERROR, "Failed to finish " "command queue: %d.\n", cle); err = AVERROR(EIO); goto fail; } err = av_frame_copy_props(output, input_main); av_log(avctx, AV_LOG_DEBUG, "Filter output: %s, %ux%u (%"PRId64").\n", av_get_pix_fmt_name(output->format), output->width, output->height, output->pts); return ff_filter_frame(outlink, output); fail_kernel_arg: av_log(avctx, AV_LOG_ERROR, "Failed to set kernel arg %d: %d.\n", kernel_arg, cle); err = AVERROR(EIO); fail: return err; }
1threat
for loop for MATLAB code to calculate Mean value : I have an excel sheet of 41 columns and 513 rows. I want to use a loop which will calculate the mean of 4 columns. The interval is i = 2:4:41. I need help with writing down the loop. for i = 2:4:41 *the formula for the mean calculation, V()=V()/41;* Need help with the **. Thank you
0debug
How to add a request interceptor to a feign client? : <p>I want every time when I make a request through feign client, to set a specific header with my authenticated user. </p> <p>This is my filter from which I get the authentication and set it to the spring security context:</p> <pre><code>@EnableEurekaClient @SpringBootApplication @EnableFeignClients public class PerformanceApplication { @Bean public Filter requestDetailsFilter() { return new RequestDetailsFilter(); } public static void main(String[] args) { SpringApplication.run(PerformanceApplication.class, args); } private class RequestDetailsFilter implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { } @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { String userName = ((HttpServletRequest)servletRequest).getHeader("Z-User-Details"); String pass = ((HttpServletRequest)servletRequest).getHeader("X-User-Details"); if (pass != null) pass = decrypt(pass); SecurityContext secure = new SecurityContextImpl(); org.springframework.security.core.Authentication token = new UsernamePasswordAuthenticationToken(userName, pass); secure. setAuthentication(token); SecurityContextHolder.setContext(secure); filterChain.doFilter(servletRequest, servletResponse); } @Override public void destroy() { } } private String decrypt(String str) { try { Cipher dcipher = new NullCipher(); // Decode base64 to get bytes byte[] dec = new sun.misc.BASE64Decoder().decodeBuffer(str); // Decrypt byte[] utf8 = dcipher.doFinal(dec); // Decode using utf-8 return new String(utf8, "UTF8"); } catch (javax.crypto.BadPaddingException e) { } catch (IllegalBlockSizeException e) { } catch (UnsupportedEncodingException e) { } catch (java.io.IOException e) { } return null; } } </code></pre> <p>This is my feign client:</p> <pre><code>@FeignClient("holiday-client") public interface EmailClient { @RequestMapping(value = "/api/email/send", method = RequestMethod.POST) void sendEmail(@RequestBody Email email); } </code></pre> <p>And here I have a request interceptor:</p> <pre><code>@Component public class FeignRequestInterceptor implements RequestInterceptor { private String headerValue; public FeignRequestInterceptor() { } public FeignRequestInterceptor(String username, String password) { this(username, password, ISO_8859_1); } public FeignRequestInterceptor(String username, String password, Charset charset) { checkNotNull(username, "username"); checkNotNull(password, "password"); this.headerValue = "Basic " + base64encode((username + ":" + password).getBytes(charset)); } private static String base64encode(byte[] bytes) { BASE64Encoder encoder = new BASE64Encoder(); return encoder.encode(bytes); } @Override public void apply(RequestTemplate requestTemplate) { requestTemplate.header("Authorization", headerValue); } } </code></pre> <p>I don't know how to configure this interceptor to my client and how to set the header with the username and password. How can I accomplish that ?</p>
0debug
Need to parse the data from Json file using python script : I created the json from a python script, and here is the code what I wrote to get the json data: import requests import json import ConfigParser url = "xxx" payload = "items.find({ \"repo\": {\"$match\" : \"nswps-*\"}}).include(\"name\",\"repo\",\"path\")\r\n" headers = { 'Content-Type': "text/plain", 'Authorization': "Basic xxxxxxxxx", 'Accept': "*/*", 'Cache-Control': "no-cache", 'Host': "xxxxxx.com", 'accept-encoding': "gzip, deflate", 'content-length': "77", 'Connection': "keep-alive", 'cache-control': "no-cache" } response = requests.request("POST", url, data=payload, headers=headers) print(response.text) the above code gives me the json file which is a huge file of multiple objects. Due to some limitation in artifactory I am unable to get the repos starting with nswps but rather the result is all the repository names. The json file has data like this: "repo" : "npm-remote-cache", "path" : "zrender/-", "name" : "zrender-4.0.7.tgz" },{ "repo" : "npm-remote-cache", "path" : "ztree/-", "name" : "ztree-3.5.24.tgz" },{ "repo" : "nswps-docker-inprogress-local", "path" : "ace/core/latest", "name" : "manifest.json" },{ "repo" : "nswps-docker-inprogress-local", "path" : "ace/core/latest", "name" : "sha256__0a381222a179dbaef7d1f50914549a84e922162a772ca5346b5f6147d0e5aab4" },{ ......... Now I need to create a python script which fetches out the objects in which only the object that has value of nswps , lets say from the above json I need data like this: { "repo" : "nswps-docker-inprogress-local", "path" : "ace/core/latest", "name" : "manifest.json" },{ "repo" : "nswps-docker-inprogress-local", "path" : "ace/core/latest", "name" : "sha256__0a381222a179dbaef7d1f50914549a84e922162a772ca5346b5f6147d0e5aab4" } Please suggest!
0debug
static int imx_eth_can_receive(NetClientState *nc) { IMXFECState *s = IMX_FEC(qemu_get_nic_opaque(nc)); FEC_PRINTF("\n"); return s->regs[ENET_RDAR] ? 1 : 0; }
1threat
How can I call a class method inside a promise in Angular 2? : <p>If I have an Angular 2 component and I get data from a service that returns an async promise or observable how can I then call a method in the component to display that data?</p> <pre><code>@Component({ moduleId: module.id, selector: 'charts', templateUrl: 'charts.component.html', providers: [DataService] }) export class ChartsComponent implements OnInit { constructor(private dataService:DataService) ngOnInit() { this.getData(); } getData(){ this.dataService.getData().then(function (data) { this.drawChart(data); }); } drawChart(){ //implement drawing chart } } </code></pre> <p>The problem is that inside a promise "this" in "this.drawChart()" no longer refers to the ChartsComponent class. How can I call a class method post promise?</p> <p>Also, I cant put drawChart() inside the promise because it needs to use other class properties.</p>
0debug
static inline void rv40_weak_loop_filter(uint8_t *src, const int step, const int filter_p1, const int filter_q1, const int alpha, const int beta, const int lim_p0q0, const int lim_q1, const int lim_p1, const int diff_p1p0, const int diff_q1q0, const int diff_p1p2, const int diff_q1q2) { uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; int t, u, diff; t = src[0*step] - src[-1*step]; if(!t) return; u = (alpha * FFABS(t)) >> 7; if(u > 3 - (filter_p1 && filter_q1)) return; t <<= 2; if(filter_p1 && filter_q1) t += src[-2*step] - src[1*step]; diff = CLIP_SYMM((t + 4) >> 3, lim_p0q0); src[-1*step] = cm[src[-1*step] + diff]; src[ 0*step] = cm[src[ 0*step] - diff]; if(FFABS(diff_p1p2) <= beta && filter_p1){ t = (diff_p1p0 + diff_p1p2 - diff) >> 1; src[-2*step] = cm[src[-2*step] - CLIP_SYMM(t, lim_p1)]; } if(FFABS(diff_q1q2) <= beta && filter_q1){ t = (diff_q1q0 + diff_q1q2 + diff) >> 1; src[ 1*step] = cm[src[ 1*step] - CLIP_SYMM(t, lim_q1)]; } }
1threat
static int posix_aio_init(void) { sigset_t mask; PosixAioState *s; if (posix_aio_state) return 0; s = qemu_malloc(sizeof(PosixAioState)); if (s == NULL) return -ENOMEM; sigemptyset(&mask); sigaddset(&mask, SIGUSR2); sigprocmask(SIG_BLOCK, &mask, NULL); s->first_aio = NULL; s->fd = qemu_signalfd(&mask); if (s->fd == -1) { fprintf(stderr, "failed to create signalfd\n"); return -errno; } fcntl(s->fd, F_SETFL, O_NONBLOCK); qemu_aio_set_fd_handler(s->fd, posix_aio_read, NULL, posix_aio_flush, s); #if defined(__linux__) { struct aioinit ai; memset(&ai, 0, sizeof(ai)); #if defined(__GLIBC_PREREQ) && __GLIBC_PREREQ(2, 4) ai.aio_threads = 64; ai.aio_num = 64; #else ai.aio_threads = 1; ai.aio_num = 1; ai.aio_idle_time = 365 * 100000; #endif aio_init(&ai); } #endif posix_aio_state = s; return 0; }
1threat
Nested json golang maps : i know im stupid but cant found same problem like mine there i have json: `{ result: "true", data: [ { randomName: { val: 2, secval: 0.142412, thirdval: 0.5235325, }, secRandomName: { val: 8, secval: 0.152512, thirdval: 0.6574, }, thiRandomName: { val: 6, secval: 0.4121, thirdval: 0.2123 }, } ]}` how to make type for that json in golang, ive tryed something like this: type TheData struct { Result string `json:"result"` Data map[string]DataInfo `json:"data"` } type DataInfo struct { Value int `json:"val"` SecondValue float32 `json:"secval"` ThirdValue float32 `json:"thirdval"` } but its wrong. p.s sorry for english, hope you understand, thx
0debug
Search View not Searching List view : I am Trying to Display the Contact From Phone to the List View(Which is used in a Fragment)..... I have Tried Putting a Search View to Filter Data from List View..... **Search View Does Not Filter Data ....** Pls Help ...I Am badly Stuck... ScreenShot of App having SearchView over List View Showing Contact Details.... https://drive.google.com/file/d/0B8sFN35Zdhnfa0RtVEJKc2V2WG8/view?usp=sharing https://drive.google.com/file/d/0B8sFN35ZdhnfWTljaTRWaGY3c1E/view?usp=sharing contactfragment.xml , GetContactAdapter.java , **Contact_Fragment3.java** are three different files.. **contractfragment.xml** <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <SearchView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/searchContactLIST" android:queryHint="Search...." android:clickable="true" > </SearchView> <ListView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/lists" android:scrollbarStyle="outsideOverlay" /> </LinearLayout> **GetContactAdapter.java** package com.example.cosmic.zumi_test; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.BaseAdapter; import android.widget.Filter; import android.widget.Filterable; import android.widget.ImageView; import android.widget.TextView; import java.util.ArrayList; import java.util.List; public class GetContactAdapter extends ArrayAdapter<String> implements Filterable { String[] phone = {}; String[] names = {}; int[] img = {}; Context c; LayoutInflater inflater; public class Viewholder { TextView names; TextView address; ImageView img; } public GetContactAdapter(Context context, String[] names, String[] add) { super(context, R.layout.customcontactlist, names); this.c = context; this.names = names; this.phone = add; this.img = img; } @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { inflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = inflater.inflate(R.layout.customcontactlist, null); } Viewholder viewholder = new Viewholder(); viewholder.names = (TextView) convertView.findViewById(R.id.contact_name); viewholder.address = (TextView) convertView.findViewById(R.id.contact_no); viewholder.img = (ImageView) convertView.findViewById(R.id.image_contactlist); //ASSIGN DATA viewholder.img.setImageResource(R.drawable.com_facebook_button_icon_blue); viewholder.names.setText(names[position]); viewholder.address.setText(phone[position]); return convertView; } } **Contact_Fragment3.java** package com.example.cosmic.zumi_test; import android.Manifest; import android.content.ContentResolver; import android.content.ContentUris; import android.content.Intent; import android.content.pm.PackageManager; import android.database.Cursor; import android.graphics.Bitmap; import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.provider.ContactsContract; import android.support.annotation.Nullable; import android.support.v4.app.Fragment; import android.support.v4.content.ContextCompat; import android.support.v4.view.MenuItemCompat; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.SearchView; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.Filterable; import android.widget.ListView; import android.widget.Toast; import java.io.InputStream; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.List; /** * Created by cosmic on 31/12/16. */ public class Contact_FRAGMENT3 extends Fragment { private Uri uriContact; private String contactID; private ListView lstNames; private GetContactAdapter adapter; // Request code for READ_CONTACTS. It can be any number > 0. private static final int PERMISSIONS_REQUEST_READ_CONTACTS = 100; private android.widget.SearchView search; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.contactfragment, container, false); this.lstNames = (ListView) v.findViewById(R.id.lists); this.search = (android.widget.SearchView) v.findViewById(R.id.searchContactLIST); // Read and show the contacts showContacts(); return v; } private void showContacts() { // Check the SDK version and whether the permission is already granted or not. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_CONTACTS) != PackageManager.PERMISSION_GRANTED) { requestPermissions(new String[]{Manifest.permission.READ_CONTACTS}, PERMISSIONS_REQUEST_READ_CONTACTS); //After this point you wait for callback in onRequestPermissionsResult(int, String[], int[]) overriden method } else { // Android version is lesser than 6.0 or the permission is already granted. List<String> contacts = getContactNames(); // String[] arr_contact=contacts.to List<String> contacts_no = getContactNo(); String[] strarray = new String[contacts.size()]; contacts.toArray(strarray); String[] strarray2 = new String[contacts_no.size()]; contacts_no.toArray(strarray2); adapter = new GetContactAdapter(getContext(), strarray, strarray2); lstNames.setAdapter(adapter); search.setOnQueryTextListener(new android.widget.SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { return false; } @Override public boolean onQueryTextChange(String newText) { adapter.getFilter().filter(newText); return true; } }); } } @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { if (requestCode == PERMISSIONS_REQUEST_READ_CONTACTS) { if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { // Permission is granted showContacts(); } else { Toast.makeText(getContext(), "Until you grant the permission, we cannot display the names", Toast.LENGTH_SHORT).show(); } } } private List<String> getContactNames() { List<String> contacts = new ArrayList<>(); List<String> number = new ArrayList<>(); // Get the ContentResolver ContentResolver cr = getActivity().getContentResolver(); // Get the Cursor of all the contacts Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); // Move the cursor to first. Also check whether the cursor is empty or not. if (cursor.moveToFirst()) { // Iterate through the cursor do { // Get the contacts name String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); String numbers = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)); number.add(numbers); contacts.add(name); } while (cursor.moveToNext()); } // Close the curosor cursor.close(); return contacts; } private List<String> getContactNo() { List<String> number = new ArrayList<>(); // Get the ContentResolver ContentResolver cr = getActivity().getContentResolver(); // Get the Cursor of all the contacts Cursor cursor = cr.query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null); // Move the cursor to first. Also check whether the cursor is empty or not. if (cursor.moveToFirst()) { // Iterate through the cursor do { // Get the contacts name // String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME)); String numbers = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER)); number.add(numbers); // contacts.add(name); } while (cursor.moveToNext()); } // Close the curosor cursor.close(); return number; } }
0debug
static void search_for_quantizers_anmr(AVCodecContext *avctx, AACEncContext *s, SingleChannelElement *sce, const float lambda) { int q, w, w2, g, start = 0; int i, j; int idx; TrellisPath paths[TRELLIS_STAGES][TRELLIS_STATES]; int bandaddr[TRELLIS_STAGES]; int minq; float mincost; float q0f = FLT_MAX, q1f = 0.0f, qnrgf = 0.0f; int q0, q1, qcnt = 0; for (i = 0; i < 1024; i++) { float t = fabsf(sce->coeffs[i]); if (t > 0.0f) { q0f = FFMIN(q0f, t); q1f = FFMAX(q1f, t); qnrgf += t*t; qcnt++; } } if (!qcnt) { memset(sce->sf_idx, 0, sizeof(sce->sf_idx)); memset(sce->zeroes, 1, sizeof(sce->zeroes)); return; } q0 = coef2minsf(q0f); q1 = coef2maxsf(q1f); if (q1 - q0 > 60) { int q0low = q0; int q1high = q1; int qnrg = av_clip_uint8(log2f(sqrtf(qnrgf/qcnt))*4 - 31 + SCALE_ONE_POS - SCALE_DIV_512); q1 = qnrg + 30; q0 = qnrg - 30; if (q0 < q0low) { q1 += q0low - q0; q0 = q0low; } else if (q1 > q1high) { q0 -= q1 - q1high; q1 = q1high; } } for (i = 0; i < TRELLIS_STATES; i++) { paths[0][i].cost = 0.0f; paths[0][i].prev = -1; } for (j = 1; j < TRELLIS_STAGES; j++) { for (i = 0; i < TRELLIS_STATES; i++) { paths[j][i].cost = INFINITY; paths[j][i].prev = -2; } } idx = 1; abs_pow34_v(s->scoefs, sce->coeffs, 1024); for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) { start = w*128; for (g = 0; g < sce->ics.num_swb; g++) { const float *coefs = &sce->coeffs[start]; float qmin, qmax; int nz = 0; bandaddr[idx] = w * 16 + g; qmin = INT_MAX; qmax = 0.0f; for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; if (band->energy <= band->threshold || band->threshold == 0.0f) { sce->zeroes[(w+w2)*16+g] = 1; continue; } sce->zeroes[(w+w2)*16+g] = 0; nz = 1; for (i = 0; i < sce->ics.swb_sizes[g]; i++) { float t = fabsf(coefs[w2*128+i]); if (t > 0.0f) qmin = FFMIN(qmin, t); qmax = FFMAX(qmax, t); } } if (nz) { int minscale, maxscale; float minrd = INFINITY; float maxval; minscale = coef2minsf(qmin); maxscale = coef2maxsf(qmax); minscale = av_clip(minscale - q0, 0, TRELLIS_STATES - 1); maxscale = av_clip(maxscale - q0, 0, TRELLIS_STATES); maxval = find_max_val(sce->ics.group_len[w], sce->ics.swb_sizes[g], s->scoefs+start); for (q = minscale; q < maxscale; q++) { float dist = 0; int cb = find_min_book(maxval, sce->sf_idx[w*16+g]); for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) { FFPsyBand *band = &s->psy.ch[s->cur_channel].psy_bands[(w+w2)*16+g]; dist += quantize_band_cost(s, coefs + w2*128, s->scoefs + start + w2*128, sce->ics.swb_sizes[g], q + q0, cb, lambda / band->threshold, INFINITY, NULL, NULL, 0); } minrd = FFMIN(minrd, dist); for (i = 0; i < q1 - q0; i++) { float cost; cost = paths[idx - 1][i].cost + dist + ff_aac_scalefactor_bits[q - i + SCALE_DIFF_ZERO]; if (cost < paths[idx][q].cost) { paths[idx][q].cost = cost; paths[idx][q].prev = i; } } } } else { for (q = 0; q < q1 - q0; q++) { paths[idx][q].cost = paths[idx - 1][q].cost + 1; paths[idx][q].prev = q; } } sce->zeroes[w*16+g] = !nz; start += sce->ics.swb_sizes[g]; idx++; } } idx--; mincost = paths[idx][0].cost; minq = 0; for (i = 1; i < TRELLIS_STATES; i++) { if (paths[idx][i].cost < mincost) { mincost = paths[idx][i].cost; minq = i; } } while (idx) { sce->sf_idx[bandaddr[idx]] = minq + q0; minq = paths[idx][minq].prev; idx--; } for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) for (g = 0; g < sce->ics.num_swb; g++) for (w2 = 1; w2 < sce->ics.group_len[w]; w2++) sce->sf_idx[(w+w2)*16+g] = sce->sf_idx[w*16+g]; }
1threat
What is the job of autogen.sh when building a c++ package on Linux : <p>I saw a common pattern when installing a c/c++ package from source on Linux (Ubuntu 16.04):</p> <ol> <li>./autogen.sh</li> <li>./configure</li> <li>make</li> <li>make install</li> </ol> <p>I understand <code>make</code> and <code>make install</code>, and I guess <code>configure</code> creates a Makefile based on user preferences, but I don't see why <code>autogen.sh</code> is necessary. </p> <p>Does anyone know what it is there for?</p>
0debug
Implement Relu derivative in python numpy : <p>I'm trying to implement a function that computes the Relu derivative for each element in a matrix, and then return the result in a matrix. I'm using Python and Numpy.</p> <p>Based on other Cross Validation posts, the Relu derivative for x is 1 when x > 0, 0 when x &lt; 0, undefined or 0 when x == 0</p> <p>Currently, I have the following code so far:</p> <pre><code>def reluDerivative(self, x): return np.array([self.reluDerivativeSingleElement(xi) for xi in x]) def reluDerivativeSingleElement(self, xi): if xi &gt; 0: return 1 elif xi &lt;= 0: return 0 </code></pre> <p>Unfortunately, xi is an array because x is an matrix. reluDerivativeSingleElement function doesn't work on array. So I'm wondering is there a way to map values in a matrix to another matrix using numpy, like the exp function in numpy?</p> <p>Thanks a lot in advance.</p>
0debug
How to create a python virtual environment from the command line? : <p>What is the command to create a python virtual environment from the command line?</p>
0debug
static int check_pkt(AVFormatContext *s, AVPacket *pkt) { MOVMuxContext *mov = s->priv_data; MOVTrack *trk = &mov->tracks[pkt->stream_index]; if (trk->entry) { int64_t duration = pkt->dts - trk->cluster[trk->entry - 1].dts; if (duration < 0 || duration > INT_MAX) { av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" / timestamp: %"PRId64" is out of range for mov/mp4 format\n", duration, pkt->dts ); pkt->dts = trk->cluster[trk->entry - 1].dts + 1; pkt->pts = AV_NOPTS_VALUE; } } else if (pkt->dts <= INT_MIN || pkt->dts >= INT_MAX) { av_log(s, AV_LOG_ERROR, "Application provided initial timestamp: %"PRId64" is out of range for mov/mp4 format\n", pkt->dts ); pkt->dts = 0; pkt->pts = AV_NOPTS_VALUE; } if (pkt->duration < 0 || pkt->duration > INT_MAX) { av_log(s, AV_LOG_ERROR, "Application provided duration: %"PRId64" is invalid\n", pkt->duration); return AVERROR(EINVAL); } return 0; }
1threat
why the character x is used to mean extract in linux command.why not k or u.Does it means something special : why the character x is used to mean extract in linux command.why not k or u;For example,"tar xf helloworld".Does it means something special.
0debug
python regex carriage return : <p>please could you help with the regex to get everything unto the ";"..</p> <pre><code>window.egfunc = { name: "test name", type: "test type", storeId: "12345" }; </code></pre> <p>I have the following which works when all the data would be on one line, but as soon as there are returns, it won't work...</p> <pre><code>window.egfunc\s+=\s+(.*); </code></pre>
0debug
static void pci_qdev_unrealize(DeviceState *dev, Error **errp) { PCIDevice *pci_dev = PCI_DEVICE(dev); PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(pci_dev); pci_unregister_io_regions(pci_dev); pci_del_option_rom(pci_dev); if (pc->exit) { pc->exit(pci_dev); } do_pci_unregister_device(pci_dev); }
1threat
Cannot Resolve Method 'newDataOutputStream' (android studio) : I am getting an cannot resolve method error when i do this: DataOutputStream os = newDataOutputStream(client.getOutputStream()); My imports: import android.os.Bundle; import android.app.Activity; import android.net.wifi.WifiManager; import android.os.Bundle; import android.os.Handler; import android.text.format.Formatter; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; Code for class @SuppressWarnings("deprecation") class sentMessage implements Runnable { public void run() { try { Socket client = serverSocket.accept(); DataOutputStream os = newDataOutputStream(client.getOutputStream()); str = smessage.getText().toString(); msg = msg + "\n Server : " + str; handler.post(new Runnable() { public void run() { chat.setText(msg); } }); os.writeBytes(str); os.flush(); os.close(); client.close(); } catch (IOException e) { } } } Thanks In Advance :)
0debug
static int webm_dash_manifest_cues(AVFormatContext *s, int64_t init_range) { MatroskaDemuxContext *matroska = s->priv_data; EbmlList *seekhead_list = &matroska->seekhead; MatroskaSeekhead *seekhead = seekhead_list->elem; char *buf; int64_t cues_start = -1, cues_end = -1, before_pos, bandwidth; int i; int end = 0; for (i = 0; i < seekhead_list->nb_elem; i++) if (seekhead[i].id == MATROSKA_ID_CUES) break; if (i >= seekhead_list->nb_elem) return -1; before_pos = avio_tell(matroska->ctx->pb); cues_start = seekhead[i].pos + matroska->segment_start; if (avio_seek(matroska->ctx->pb, cues_start, SEEK_SET) == cues_start) { uint64_t cues_length = 0, cues_id = 0, bytes_read = 0; bytes_read += ebml_read_num(matroska, matroska->ctx->pb, 4, &cues_id); bytes_read += ebml_read_length(matroska, matroska->ctx->pb, &cues_length); cues_end = cues_start + cues_length + bytes_read - 1; } avio_seek(matroska->ctx->pb, before_pos, SEEK_SET); if (cues_start == -1 || cues_end == -1) return -1; matroska_parse_cues(matroska); av_dict_set_int(&s->streams[0]->metadata, CUES_START, cues_start, 0); av_dict_set_int(&s->streams[0]->metadata, CUES_END, cues_end, 0); if (cues_start <= init_range) av_dict_set_int(&s->streams[0]->metadata, INITIALIZATION_RANGE, cues_start - 1, 0); bandwidth = webm_dash_manifest_compute_bandwidth(s, cues_start); if (bandwidth < 0) return -1; av_dict_set_int(&s->streams[0]->metadata, BANDWIDTH, bandwidth, 0); av_dict_set_int(&s->streams[0]->metadata, CLUSTER_KEYFRAME, webm_clusters_start_with_keyframe(s), 0); buf = av_malloc_array(s->streams[0]->nb_index_entries, 20 * sizeof(char)); if (!buf) return -1; strcpy(buf, ""); for (i = 0; i < s->streams[0]->nb_index_entries; i++) { int ret = snprintf(buf + end, 20 * sizeof(char), "%" PRId64, s->streams[0]->index_entries[i].timestamp); if (ret <= 0 || (ret == 20 && i == s->streams[0]->nb_index_entries - 1)) { av_log(s, AV_LOG_ERROR, "timestamp too long.\n"); return AVERROR_INVALIDDATA; } end += ret; if (i != s->streams[0]->nb_index_entries - 1) { strncat(buf, ",", sizeof(char)); end++; } } av_dict_set(&s->streams[0]->metadata, CUE_TIMESTAMPS, buf, 0); return 0; }
1threat
bool virtio_scsi_handle_cmd_req_prepare(VirtIOSCSI *s, VirtIOSCSIReq *req) { VirtIOSCSICommon *vs = &s->parent_obj; SCSIDevice *d; int rc; rc = virtio_scsi_parse_req(req, sizeof(VirtIOSCSICmdReq) + vs->cdb_size, sizeof(VirtIOSCSICmdResp) + vs->sense_size); if (rc < 0) { if (rc == -ENOTSUP) { virtio_scsi_fail_cmd_req(req); } else { virtio_scsi_bad_req(); } return false; } d = virtio_scsi_device_find(s, req->req.cmd.lun); if (!d) { req->resp.cmd.response = VIRTIO_SCSI_S_BAD_TARGET; virtio_scsi_complete_cmd_req(req); return false; } if (s->dataplane_started && bdrv_get_aio_context(d->conf.bs) != s->ctx) { aio_context_acquire(s->ctx); bdrv_set_aio_context(d->conf.bs, s->ctx); aio_context_release(s->ctx); } req->sreq = scsi_req_new(d, req->req.cmd.tag, virtio_scsi_get_lun(req->req.cmd.lun), req->req.cdb, req); if (req->sreq->cmd.mode != SCSI_XFER_NONE && (req->sreq->cmd.mode != req->mode || req->sreq->cmd.xfer > req->qsgl.size)) { req->resp.cmd.response = VIRTIO_SCSI_S_OVERRUN; virtio_scsi_complete_cmd_req(req); return false; } scsi_req_ref(req->sreq); bdrv_io_plug(d->conf.bs); return true; }
1threat
Prevent automatic tab insertion or conversion of spaces to tabs : <p>Google Docs has a "feature" that sometimes converts four spaces to one tab.</p> <p>Copying and pasting text does not solve this problem, because the spaces in that text are converted to tabs automatically.</p> <p>Is there a way to turn this off?</p>
0debug
iscsi_abort_task_cb(struct iscsi_context *iscsi, int status, void *command_data, void *private_data) { IscsiAIOCB *acb = (IscsiAIOCB *)private_data; scsi_free_scsi_task(acb->task); acb->task = NULL; }
1threat
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
Why does the following Code throw a NullReferenceException? : <p>I know that most cases of a NullReferenceException are caused of missing initialization. But I initializated MTemp and FTemp. </p> <p>What I'm missing?</p> <hr> <p>Important code inside the class "Foo":</p> <pre><code>class Team { public List&lt;Fahrer&gt; TeamFahrer { get; set; } public void Bar(string salad, string hotdog, string brokkoli) { Motorrad MTemp = new Motorrad(brokkoli); Fahrer FTemp = new Fahrer(salad, hotdog, MTemp); TeamFahrer.Add(FTemp); } } </code></pre> <hr> <p>Important code inside Motorrad:</p> <pre><code>class Motorrad { public Motorrad(string marke) { Marke = marke; } public string Marke { get; set; } } </code></pre> <hr> <p>Important Code inside Fahrer:</p> <pre><code>class Fahrer { public Fahrer(string salad, string hotdog, Motorrad moped) { Vorname = salad; Nachname = hotdog; MotorradDesFahrers = moped; } public string Vorname { get; set; } public string Nachname { get; set; } public Motorrad MotorradDesFahrers { get; set; } } </code></pre>
0debug
void readline_handle_byte(ReadLineState *rs, int ch) { switch(rs->esc_state) { case IS_NORM: switch(ch) { case 1: readline_bol(rs); break; case 4: readline_delete_char(rs); break; case 5: readline_eol(rs); break; case 9: readline_completion(rs); break; case 10: case 13: rs->cmd_buf[rs->cmd_buf_size] = '\0'; if (!rs->read_password) readline_hist_add(rs, rs->cmd_buf); monitor_printf(rs->mon, "\n"); rs->cmd_buf_index = 0; rs->cmd_buf_size = 0; rs->last_cmd_buf_index = 0; rs->last_cmd_buf_size = 0; rs->readline_func(rs->mon, rs->cmd_buf, rs->readline_opaque); break; case 23: readline_backword(rs); break; case 27: rs->esc_state = IS_ESC; break; case 127: case 8: readline_backspace(rs); break; case 155: rs->esc_state = IS_CSI; break; default: if (ch >= 32) { readline_insert_char(rs, ch); } break; } break; case IS_ESC: if (ch == '[') { rs->esc_state = IS_CSI; rs->esc_param = 0; } else if (ch == 'O') { rs->esc_state = IS_SS3; rs->esc_param = 0; } else { rs->esc_state = IS_NORM; } break; case IS_CSI: switch(ch) { case 'A': case 'F': readline_up_char(rs); break; case 'B': case 'E': readline_down_char(rs); break; case 'D': readline_backward_char(rs); break; case 'C': readline_forward_char(rs); break; case '0' ... '9': rs->esc_param = rs->esc_param * 10 + (ch - '0'); goto the_end; case '~': switch(rs->esc_param) { case 1: readline_bol(rs); break; case 3: readline_delete_char(rs); break; case 4: readline_eol(rs); break; } break; default: break; } rs->esc_state = IS_NORM; the_end: break; case IS_SS3: switch(ch) { case 'F': readline_eol(rs); break; case 'H': readline_bol(rs); break; } rs->esc_state = IS_NORM; break; } readline_update(rs); }
1threat
How to update service worker cache in PWA? : <p>I use service worker with <a href="https://github.com/GoogleChrome/sw-toolbox" rel="noreferrer">sw-toolbox</a> library. My PWA caches everything except API queries (images, css, js, html). But what if some files will be changed someday. Or what if service-worker.js will be changed. How application should know about changes in files?</p> <p>My service-worker.js:</p> <pre><code>'use strict'; importScripts('./build/sw-toolbox.js'); self.toolbox.options.cache = { name: 'ionic-cache' }; // pre-cache our key assets self.toolbox.precache( [ './build/main.js', './build/main.css', './build/polyfills.js', 'index.html', 'manifest.json' ] ); // dynamically cache any other local assets self.toolbox.router.any('/*', self.toolbox.cacheFirst); // for any other requests go to the network, cache, // and then only use that cached resource if your user goes offline self.toolbox.router.default = self.toolbox.networkFirst; </code></pre> <p>I don't know what is the usual method to update cache in PWA. Maybe PWA should send AJAX request in background and check UI version?</p>
0debug
constraint satisfaction problem missing one constraint : <p>I'm a lab practises tutor at the university, based on last year student comments, we wanted, my boss and I, to address them. My boss chose to go with writing a C script and I pick python (python-constraint) to try to resolve our problem. </p> <h2>Informations</h2> <ul> <li>There are 6 sessions</li> <li>There are 4 roles</li> <li>There are 6 practices</li> <li>There are 32 students</li> <li>There are 4 students per team</li> </ul> <h2>Problem :</h2> <p>Assign each student to 4 roles, in 4 practices in 4 different sessions. </p> <h2>Constraints :</h2> <ol> <li>Students should do a role once </li> <li>Students should do 4 different practices out of 6</li> <li>Students should do only one practice per session</li> <li><strong>Student should meet the same mate only once</strong></li> </ol> <h2>Templates :</h2> <p>Here is the template that I feel with students, where each team is composed of 4 students, positions [0, 1, 2 or 3] are roles assigned to them. Each available position is numbering from 1 to 128</p> <pre class="lang-py prettyprint-override"><code>[# Semester [ # Session [ # Practice/Team 1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24]], [[25, 26, 27, 28], [29, 30, 31, 32], [33, 34, 35, 36], [37, 38, 39, 40], [41, 42, 43, 44], [45, 46, 47, 48]], [[49, 50, 51, 52], [53, 54, 55, 56], [57, 58, 59, 60], [61, 62, 63, 64], [65, 66, 67, 68], [69, 70, 71, 72]], [[73, 74, 75, 76], [77, 78, 79, 80], [81, 82, 83, 84], [85, 86, 87, 88], [89, 90, 91, 92], [93, 94, 95, 96]], [[97, 98, 99, 100], [101, 102, 103, 104], [105, 106, 107, 108], [109, 110, 111, 112]], [[113, 114, 115, 116], [117, 118, 119, 120], [121, 122, 123, 124], [125, 126, 127, 128]]] </code></pre> <p>In other words : </p> <p>This is a session : </p> <pre class="lang-py prettyprint-override"><code> [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16], [17, 18, 19, 20], [21, 22, 23, 24]], </code></pre> <p>Those team do the same practice: </p> <pre class="lang-py prettyprint-override"><code>[ [1, 2, 3, 4], [25, 26, 27, 28], [49, 50, 51, 52], [73, 74, 75, 76], [97, 98, 99, 100], [113, 114, 115, 116] ] </code></pre> <p>Those position do the same role : </p> <pre class="lang-py prettyprint-override"><code>[ 1, 5, 9, 13, 17, 21, 25, ... ] </code></pre> <h2>What I have so far :</h2> <p>Using <a href="http://labix.org/doc/constraint/" rel="noreferrer">python-constraint</a> I was able to validate the first three constraints : </p> <pre class="lang-py prettyprint-override"><code>Valid solution : False - sessions : [True, True, True, True, True, True] - practices : [True, True, True, True, True, True] - roles : [True, True, True, True] - teams : [False, False, True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True, False, False, False, False, False] </code></pre> <h3>For those that may interesting I simply do like this :</h3> <p>For each condition I use <a href="http://labix.org/doc/constraint/" rel="noreferrer">AllDifferentConstraint</a>. For example, for one session I do: </p> <pre class="lang-py prettyprint-override"><code>problem.addConstraint(AllDifferentConstraint(), [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]) </code></pre> <p>I'm not able to find a way to constraint team, my last attempt on the entire <code>semester</code> was this : </p> <pre class="lang-py prettyprint-override"><code> def team_constraint(self, *semester): students = defaultdict(list) # get back each teams based on the format [# Semester [ #Session [# Practice/Team ... teams = [list(semester[i:i+4]) for i in range(0, len(semester), 4)] # Update Students dict with all mate they work with for team in teams: for student in team: students[student] += [s for s in team if s != student] # Compute for each student if they meet someone more than once dupli = [] for student, mate in students.items(): dupli.append(len(mate) - len(set(mate))) # Loosly constraint, if a student meet somone 0 or one time it's find if max(dupli) &gt;= 2: print("Mate encounter more than one time", dupli, min(dupli) ,max(dupli)) return False pprint(students) return True </code></pre> <h1>Questions :</h1> <ol> <li>Is it possible to do what I want for the team conditions ? What I mean is I have no idea if it is possible to assign 12 mates to each student and each of them meet the same mate only once.</li> <li>For the team constraint, did I miss a more performant algorithm ? </li> <li>Any pist that I can follow ? </li> </ol>
0debug
How to convert a string to an integer in a JSON file using jq? : <p>I use jq to transform a complex json object into a tinier one. My query is:</p> <pre><code>jq 'to_entries[]| {companyId: (.key), companyTitle: (.value.title), companyCode: (.value.booking_service_code)}' companies.json </code></pre> <p>Now, the <code>(.key)</code> is parsed as a string, yet I want <code>companyId</code> to be a number.</p> <p>My result currently looks like this:</p> <pre><code>{ "companyId": "1337", "companyTitle": "Some company title", "companyCode": "oxo" } </code></pre> <p>yet it should be like:</p> <pre><code>{ "companyId": 1337, "companyTitle": "Some company title", "companyCode": "oxo" } </code></pre>
0debug
static int rpza_decode_init(AVCodecContext *avctx) { RpzaContext *s = avctx->priv_data; s->avctx = avctx; avctx->pix_fmt = PIX_FMT_RGB555; dsputil_init(&s->dsp, avctx); s->frame.data[0] = NULL; return 0; }
1threat
How to install Selenium in a conda environment? : <p>I'm trying to install Selenium in a conda environment in Windows 10 with</p> <pre><code>conda install --name myenv selenium </code></pre> <p>but this returns the error</p> <pre><code>PackageNotFoundError: Package missing in current win-64 channels: - selenium </code></pre> <p>How can I complete this package installation?</p>
0debug
how to make a "messagebox.askquestion using array variables : [i try to use the index and combining the x and y arrays so that they correspond, however they don't seem to be working][1] can anyone please help me with this **it is very urgent** and I thank you in advance [1]: https://i.stack.imgur.com/qCaSe.png
0debug
Avoid const locals that are returned? : <p>I always thought that it's good to have const locals be const</p> <pre><code>void f() { const resource_ptr p = get(); // ... } </code></pre> <p>However last week I watched students that worked on a C++ exercise and that wondered about a const pointer being returned</p> <pre><code>resource_ptr f() { const resource_ptr p = get(); // ... return p; } </code></pre> <p>Here, if the compiler can't apply NRVO (imagine some scenario under which that is true, perhaps returning one of two pointers, depending on a condition), suddenly the <code>const</code> becomes a pessimization because the compiler can't move from <code>p</code>, because it's const. </p> <p>Is it a good idea to try and avoid <code>const</code> on returned locals, or is there a better way to deal with this?</p>
0debug
How can I read a text from a php site with javascript : <p>my php site will echo a number. Now I want to read the content with JavaScript. How can i do this.</p>
0debug
How to know my permissions for bitbucket repo? : <p>Where can I see my permission level for someone's repository on bitbucket? I'm in a so called "cloud team". I've read <a href="https://confluence.atlassian.com/bitbucket/bitbucket-cloud-teams-321853005.html" rel="noreferrer" title="this page">this page</a> and <a href="https://confluence.atlassian.com/bitbucket/organize-your-team-into-user-groups-665225542.html" rel="noreferrer" title="this page">this page</a> from which I understood that I'm supposed to be in one of user groups which determines my access level. I couldn't find any info about which group I'm in.</p>
0debug
window.location.href = 'http://attack.com?user=' + user_input;
1threat
static inline target_phys_addr_t get_pgaddr (target_phys_addr_t sdr1, int sdr_sh, target_phys_addr_t hash, target_phys_addr_t mask) { return (sdr1 & ((target_ulong)(-1ULL) << sdr_sh)) | (hash & mask); }
1threat
In Django 1.9, what's the convention for using JSONField (native postgres jsonb)? : <p>Django <a href="https://docs.djangoproject.com/en/1.9/ref/models/fields/#null">highly suggests</a> <strong>not</strong> to use <code>null=True</code> for CharField and TextField string-based fields in order not to have two possible values for "no data" (assuming you're allowing empty strings with <code>blank=True</code>). This makes total sense to me and I do this in all my projects.</p> <p>Django 1.9 introduces <a href="https://docs.djangoproject.com/en/1.9/ref/contrib/postgres/fields/#django.contrib.postgres.fields.JSONField">JSONField</a>, which uses the underlying Postgres <code>jsonb</code> data type. Does the suggestion above carry over to JSONField (i.e. <code>blank=True</code> should be used instead of <code>null=True</code>)? Or, should <code>null=True</code> be used instead? Or, should <code>default=dict</code> be used instead? Or, ..? Why?</p> <p>In other words, what is the convention for the new native JSONField, when you want to allow only one "no data" value? Please support your answer because I did a lot of research and couldn't find anything official. Thanks in advance.</p>
0debug
Microsoft GraphQL - has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin : I'm running my Vue app locally from http://localhost:8080 and I keep getting a slew of CORS errors, I've added the Access-Control-Allow-Origin header as seen blow but keep getting the following warning: ' from origin 'http://localhost:8080' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. ``` const graphCall = () => { let tokenOptions = { method: 'POST', uri: 'https://login.microsoftonline.com/**key**/oauth2/v2.0/token', headers: { 'Access-Control-Allow-Origin': 'http://localhost:8080', 'contentType': 'application/x-www-form-urlencoded' }, form: { grant_type: VUE_APP_GRANT_TYPE, client_secret: VUE_APP_CLIENT_SECRET, scope: VUE_APP_SCOPE, client_id: VUE_APP_CLIENT_ID } }; return rp(tokenOptions) .then(data => { console.log(data) }).catch((err) => { console.log(err); }); }; ``` I've tried adding mode: 'no-cors' but just get the following - Error: Invalid value for opts.mode I've also tried '*' as the access control origin but to no avail. Is there a way through this CORS nightmare as we need to make this call to retrieve a key! Pretty new to all of this so please bare with me if I've not been as descriptive as I could have been!
0debug
How can i change constraints for different screen sizes : Hello I've just started programming and I'm trying to write with code instead of using the storyboard, but the constraints I added do not work at different screen sizes How do I solve this problem
0debug
static void netmap_send(void *opaque) { NetmapState *s = opaque; struct netmap_ring *ring = s->me.rx; while (!nm_ring_empty(ring) && qemu_can_send_packet(&s->nc)) { uint32_t i; uint32_t idx; bool morefrag; int iovcnt = 0; int iovsize; do { i = ring->cur; idx = ring->slot[i].buf_idx; morefrag = (ring->slot[i].flags & NS_MOREFRAG); s->iov[iovcnt].iov_base = (u_char *)NETMAP_BUF(ring, idx); s->iov[iovcnt].iov_len = ring->slot[i].len; iovcnt++; ring->cur = ring->head = nm_ring_next(ring, i); } while (!nm_ring_empty(ring) && morefrag); if (unlikely(nm_ring_empty(ring) && morefrag)) { RD(5, "[netmap_send] ran out of slots, with a pending" "incomplete packet\n"); } iovsize = qemu_sendv_packet_async(&s->nc, s->iov, iovcnt, netmap_send_completed); if (iovsize == 0) { netmap_read_poll(s, false); break; } } }
1threat
How to finish current view / activity in flutter? : <p>Is there any method similar to this.finish() in android to finish current flutter activity. </p>
0debug
Why can't I print outside loop : <p><a href="https://i.stack.imgur.com/UgUOV.png" rel="nofollow noreferrer">I am a code beginner.Can anyone tell me what happend if I get a syntaxerror when putting the "print" outside the loop</a></p>
0debug
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size) { int ret= av_new_packet(pkt, size); if(ret<0) return ret; pkt->pos= avio_tell(s); ret= avio_read(s, pkt->data, size); if(ret<=0) av_free_packet(pkt); else av_shrink_packet(pkt, ret); return ret; }
1threat
How to get condition where date > 24 hours : <p>Let say I have one field resolved.time. resolved.time="07/06/17 14:19:39"</p> <p>I would like to write a condition on javascript like this:</p> <pre><code>if resolved.time&gt;24 hours{ print("true"); } else { print("false"); } </code></pre> <p>How can i write this condition "if resolved.time>24 hours" on JS? Appreciate for anything help.</p> <p>Thanks and regards, Okik</p>
0debug
one column is Date and another column is Status but i need only after changed to status dates how to find? : I/P Date : Status: 6/20/2016 ABC, 6/21/2016 ABC, 6/22/2016 ABC, 6/23/2016 DEF 6/24/2016 ABC 6/25/2016 ABC, 6/26/2016 ABC, 6/27/2016 ABC, ; O/P Date :Status : 6/24/2016 ABC, 6/25/2016 ABC, 6/26/2016 ABC, 6/27/2016 ABC, above is my input and expected out put. what ever dates after changed status ABC continuously then showcase remaining changed before ABC is no need.
0debug
Fixing Disappearing Zeros : <p>I wanted to divide the integer and store it in an array</p> <p>For Ex:1000000000000 into two indexes</p> <p>arr[0]=1000000 arr[1]=000000</p> <p>but arr[1] stores it as 0 instead of 0000000.</p> <p>I wanted to perform some operations with it,so i needed 7 zeros in it ,instead of 1 zero.</p> <p>Is it achievable in some way ?</p>
0debug
static int g726_decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; G726Context *c = avctx->priv_data; int16_t *samples = data; GetBitContext gb; init_get_bits(&gb, buf, buf_size * 8); while (get_bits_count(&gb) + c->code_size <= buf_size*8) *samples++ = g726_decode(c, get_bits(&gb, c->code_size)); if(buf_size*8 != get_bits_count(&gb)) av_log(avctx, AV_LOG_ERROR, "Frame invalidly split, missing parser?\n"); *data_size = (uint8_t*)samples - (uint8_t*)data; return buf_size; }
1threat
How to chake if server connection is exist? : In my app I have asyncTask classes, that connect to the local/remote server to get some data, I want to check the server connection before the asyncTask is run, I got this function: public static boolean checkServerAvailable(String hostURL) { HttpURLConnection connection = null; try { URL u = new URL(hostURL); connection = (HttpURLConnection) u.openConnection(); connection.setConnectTimeout(5000); connection.setRequestMethod("HEAD"); int code = connection.getResponseCode(); System.out.println("" + code); return true; // You can determine on HTTP return code received. 200 is success. } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } finally { if (connection != null) { connection.disconnect(); } } } this function using timeout to connect to server, and if the timeout is finish it's mean that there is no server, the problem is that I'm run this code and it's returning "there is no server" if the server is exist too, I'm tried to set a big timeout like 5000ms but it's stop the UI very long time, and somtiems return "there is no server" when the server is exist too. what can I do? Thank you!
0debug
The max_connections in MySQL 5.7 : <p>I met a problem, the value of max_connction in MySQL is 214 after I set it 1000 via edit the my.cnf, just like below:</p> <pre><code>hadoop@node1:~$ mysql -V mysql Ver 14.14 Distrib 5.7.15, for Linux (x86_64) using EditLine wrapper </code></pre> <p>MySQL version: 5.7</p> <p>OS version : ubuntu 16.04LTS</p> <pre><code>mysql&gt; show variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 151 | +-----------------+-------+ 1 row in set (0.00 sec) </code></pre> <p>As we can see, the variable value of max_connections is 151. Then , I edit the configuration file of MySQL.</p> <pre><code>yang2@node1:~$ sudo vi /etc/mysql/my.cnf [mysqld] character-set-server=utf8 collation-server=utf8_general_ci max_connections=1000 </code></pre> <p>Restart MySQL service after save the configraion.</p> <pre><code>yang2@node1:~$ service mysql restart ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units === Authentication is required to restart 'mysql.service'. Multiple identities can be used for authentication: 1. yangqiang,,, (yang2) 2. ,,, (hadoop) Choose identity to authenticate as (1-2): 1 Password: ==== AUTHENTICATION COMPLETE === yang2@node1:~$ </code></pre> <p>Now, we guess the max_connection is 1000, really?</p> <pre><code>mysql&gt; show variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 214 | +-----------------+-------+ 1 row in set (0.00 sec) </code></pre> <p>It is 214. I do not really understand this result, who can help me? thx!</p>
0debug
static inline int snake_search(MpegEncContext * s, int *best, int dmin, UINT8 *new_pic, UINT8 *old_pic, int pic_stride, int pred_x, int pred_y, UINT16 *mv_penalty, int quant, int xmin, int ymin, int xmax, int ymax, int shift) { int dir=0; int c=1; static int x_dir[8]= {1,1,0,-1,-1,-1, 0, 1}; static int y_dir[8]= {0,1,1, 1, 0,-1,-1,-1}; int fails=0; int last_d[2]={dmin, dmin}; for(;;){ int x= best[0]; int y= best[1]; int d; x+=x_dir[dir]; y+=y_dir[dir]; if(x>=xmin && x<=xmax && y>=ymin && y<=ymax){ d = pix_abs16x16(new_pic, old_pic + (x) + (y)*pic_stride, pic_stride); d += (mv_penalty[((x)<<shift)-pred_x] + mv_penalty[((y)<<shift)-pred_y])*quant; }else{ d = dmin + 10000; } if(d<dmin){ best[0]=x; best[1]=y; dmin=d; if(last_d[1] - last_d[0] > last_d[0] - d) c= -c; dir+=c; fails=0; last_d[1]=last_d[0]; last_d[0]=d; }else{ if(fails){ if(fails>=3) return dmin; }else{ c= -c; } dir+=c*2; fails++; } dir&=7; } }
1threat
How to change column names from numbers to names : <p>I have a dataframe which looks like this:</p> <p><a href="https://i.stack.imgur.com/5Arqi.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Arqi.jpg" alt="dataframe"></a></p> <p>I want to change the columnnames, for example: "2018-12-31 00:00:00" to "year_2018". How can I do that?</p>
0debug
int cpu_ppc_register (CPUPPCState *env, ppc_def_t *def) { env->msr_mask = def->msr_mask; env->mmu_model = def->mmu_model; env->excp_model = def->excp_model; env->bus_model = def->bus_model; env->bfd_mach = def->bfd_mach; if (create_ppc_opcodes(env, def) < 0) return -1; init_ppc_proc(env, def); #if defined(PPC_DUMP_CPU) { const unsigned char *mmu_model, *excp_model, *bus_model; switch (env->mmu_model) { case POWERPC_MMU_32B: mmu_model = "PowerPC 32"; break; case POWERPC_MMU_64B: mmu_model = "PowerPC 64"; break; case POWERPC_MMU_601: mmu_model = "PowerPC 601"; break; case POWERPC_MMU_SOFT_6xx: mmu_model = "PowerPC 6xx/7xx with software driven TLBs"; break; case POWERPC_MMU_SOFT_74xx: mmu_model = "PowerPC 74xx with software driven TLBs"; break; case POWERPC_MMU_SOFT_4xx: mmu_model = "PowerPC 4xx with software driven TLBs"; break; case POWERPC_MMU_SOFT_4xx_Z: mmu_model = "PowerPC 4xx with software driven TLBs " "and zones protections"; break; case POWERPC_MMU_REAL_4xx: mmu_model = "PowerPC 4xx real mode only"; break; case POWERPC_MMU_BOOKE: mmu_model = "PowerPC BookE"; break; case POWERPC_MMU_BOOKE_FSL: mmu_model = "PowerPC BookE FSL"; break; case POWERPC_MMU_64BRIDGE: mmu_model = "PowerPC 64 bridge"; break; default: mmu_model = "Unknown or invalid"; break; } switch (env->excp_model) { case POWERPC_EXCP_STD: excp_model = "PowerPC"; break; case POWERPC_EXCP_40x: excp_model = "PowerPC 40x"; break; case POWERPC_EXCP_601: excp_model = "PowerPC 601"; break; case POWERPC_EXCP_602: excp_model = "PowerPC 602"; break; case POWERPC_EXCP_603: excp_model = "PowerPC 603"; break; case POWERPC_EXCP_603E: excp_model = "PowerPC 603e"; break; case POWERPC_EXCP_604: excp_model = "PowerPC 604"; break; case POWERPC_EXCP_7x0: excp_model = "PowerPC 740/750"; break; case POWERPC_EXCP_7x5: excp_model = "PowerPC 745/755"; break; case POWERPC_EXCP_74xx: excp_model = "PowerPC 74xx"; break; case POWERPC_EXCP_970: excp_model = "PowerPC 970"; break; case POWERPC_EXCP_BOOKE: excp_model = "PowerPC BookE"; break; default: excp_model = "Unknown or invalid"; break; } switch (env->bus_model) { case PPC_FLAGS_INPUT_6xx: bus_model = "PowerPC 6xx"; break; case PPC_FLAGS_INPUT_BookE: bus_model = "PowerPC BookE"; break; case PPC_FLAGS_INPUT_405: bus_model = "PowerPC 405"; break; case PPC_FLAGS_INPUT_970: bus_model = "PowerPC 970"; break; case PPC_FLAGS_INPUT_401: bus_model = "PowerPC 401/403"; break; default: bus_model = "Unknown or invalid"; break; } printf("PowerPC %-12s : PVR %08x MSR %016" PRIx64 "\n" " MMU model : %s\n", def->name, def->pvr, def->msr_mask, mmu_model); if (env->tlb != NULL) { printf(" %d %s TLB in %d ways\n", env->nb_tlb, env->id_tlbs ? "splitted" : "merged", env->nb_ways); } printf(" Exceptions model : %s\n" " Bus model : %s\n", excp_model, bus_model); } dump_ppc_insns(env); dump_ppc_sprs(env); fflush(stdout); #endif return 0; }
1threat
webpack live hot reload for sass : <p>I am building a workflow for a react starter and would like to have my browser auto reload when I make a change to my scss files.</p> <p>Currently, webpack will hot reload when I make a change in my index.js file (set as my entry point). However when I change/add scss code in my scss file, it gets compiled, but the css doesn't get output anywhere and does not trigger a browser reload. </p> <p>I am new to webpack would really appreciate some insight here.</p> <p>Here is my webpack.config.js</p> <pre><code>const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); module.exports = { entry: ['./src/js/index.js', './src/scss/style.scss'], output: { path: path.join(__dirname, 'dist'), filename: 'js/index_bundle.js', }, module: { rules: [ { test: /\.js$/, exclude: /node_modules/, use: { loader: 'babel-loader' } }, { test: /\.css$/, use: ['style-loader', 'css-loader'] }, { test: /\.scss$/, use: [ { loader: 'file-loader', options: { name: '[name].css', outputPath: 'css/' } }, { loader: 'extract-loader' }, { loader: 'css-loader' }, { loader: 'postcss-loader' }, { loader: 'sass-loader' } ] } ] }, plugins: [ new HtmlWebpackPlugin({ template: './src/index.html' }) ] } </code></pre> <p>My index.js entry point file</p> <pre><code>import React from 'react'; import ReactDOM from 'react-dom'; import App from '../components/App'; ReactDOM.render( &lt;App/&gt;, document.getElementById('App') ); </code></pre> <p>And my App component</p> <pre><code>import React, {Component} from 'react'; import '../../dist/css/style.css'; class App extends Component { render() { return ( &lt;div&gt; &lt;p&gt;Test&lt;/p&gt; &lt;/div&gt; ) } } export default App; </code></pre>
0debug
matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size, int64_t pos, uint64_t cluster_time, uint64_t duration, int is_keyframe, int is_bframe) { int res = 0; int track; AVStream *st; AVPacket *pkt; uint8_t *origdata = data; int16_t block_time; uint32_t *lace_size = NULL; int n, flags, laces = 0; uint64_t num; if ((n = matroska_ebmlnum_uint(data, size, &num)) < 0) { av_log(matroska->ctx, AV_LOG_ERROR, "EBML block data error\n"); av_free(origdata); return res; } data += n; size -= n; track = matroska_find_track_by_num(matroska, num); if (size <= 3 || track < 0 || track >= matroska->num_tracks) { av_log(matroska->ctx, AV_LOG_INFO, "Invalid stream %d or size %u\n", track, size); av_free(origdata); return res; } if (matroska->tracks[track]->stream_index < 0) return res; st = matroska->ctx->streams[matroska->tracks[track]->stream_index]; if (st->discard >= AVDISCARD_ALL) { av_free(origdata); return res; } if (duration == AV_NOPTS_VALUE) duration = matroska->tracks[track]->default_duration; block_time = AV_RB16(data); data += 2; flags = *data++; size -= 3; if (is_keyframe == -1) is_keyframe = flags & 1 ? PKT_FLAG_KEY : 0; if (matroska->skip_to_keyframe) { if (!is_keyframe || st != matroska->skip_to_stream) return res; matroska->skip_to_keyframe = 0; } switch ((flags & 0x06) >> 1) { case 0x0: laces = 1; lace_size = av_mallocz(sizeof(int)); lace_size[0] = size; break; case 0x1: case 0x2: case 0x3: if (size == 0) { res = -1; break; } laces = (*data) + 1; data += 1; size -= 1; lace_size = av_mallocz(laces * sizeof(int)); switch ((flags & 0x06) >> 1) { case 0x1: { uint8_t temp; uint32_t total = 0; for (n = 0; res == 0 && n < laces - 1; n++) { while (1) { if (size == 0) { res = -1; break; } temp = *data; lace_size[n] += temp; data += 1; size -= 1; if (temp != 0xff) break; } total += lace_size[n]; } lace_size[n] = size - total; break; } case 0x2: for (n = 0; n < laces; n++) lace_size[n] = size / laces; break; case 0x3: { uint32_t total; n = matroska_ebmlnum_uint(data, size, &num); if (n < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); break; } data += n; size -= n; total = lace_size[0] = num; for (n = 1; res == 0 && n < laces - 1; n++) { int64_t snum; int r; r = matroska_ebmlnum_sint (data, size, &snum); if (r < 0) { av_log(matroska->ctx, AV_LOG_INFO, "EBML block data error\n"); break; } data += r; size -= r; lace_size[n] = lace_size[n - 1] + snum; total += lace_size[n]; } lace_size[n] = size - total; break; } } break; } if (res == 0) { int real_v = matroska->tracks[track]->flags & MATROSKA_TRACK_REAL_V; uint64_t timecode = AV_NOPTS_VALUE; if (cluster_time != (uint64_t)-1 && cluster_time + block_time >= 0) timecode = cluster_time + block_time; for (n = 0; n < laces; n++) { int slice, slices = 1; if (real_v) { slices = *data++ + 1; lace_size[n]--; } for (slice=0; slice<slices; slice++) { int slice_size, slice_offset = 0; if (real_v) slice_offset = rv_offset(data, slice, slices); if (slice+1 == slices) slice_size = lace_size[n] - slice_offset; else slice_size = rv_offset(data, slice+1, slices) - slice_offset; if (st->codec->codec_id == CODEC_ID_RA_288 || st->codec->codec_id == CODEC_ID_COOK || st->codec->codec_id == CODEC_ID_ATRAC3) { MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)matroska->tracks[track]; int a = st->codec->block_align; int sps = audiotrack->sub_packet_size; int cfs = audiotrack->coded_framesize; int h = audiotrack->sub_packet_h; int y = audiotrack->sub_packet_cnt; int w = audiotrack->frame_size; int x; if (!audiotrack->pkt_cnt) { if (st->codec->codec_id == CODEC_ID_RA_288) for (x=0; x<h/2; x++) memcpy(audiotrack->buf+x*2*w+y*cfs, data+x*cfs, cfs); else for (x=0; x<w/sps; x++) memcpy(audiotrack->buf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), data+x*sps, sps); if (++audiotrack->sub_packet_cnt >= h) { audiotrack->sub_packet_cnt = 0; audiotrack->pkt_cnt = h*w / a; } } while (audiotrack->pkt_cnt) { pkt = av_mallocz(sizeof(AVPacket)); av_new_packet(pkt, a); memcpy(pkt->data, audiotrack->buf + a * (h*w / a - audiotrack->pkt_cnt--), a); pkt->pos = pos; pkt->stream_index = matroska->tracks[track]->stream_index; matroska_queue_packet(matroska, pkt); } } else { int offset = 0; if (st->codec->codec_id == CODEC_ID_TEXT && ((MatroskaSubtitleTrack *)(matroska->tracks[track]))->ass) { int i; for (i=0; i<8 && data[slice_offset+offset]; offset++) if (data[slice_offset+offset] == ',') i++; } pkt = av_mallocz(sizeof(AVPacket)); if (av_new_packet(pkt, slice_size-offset) < 0) { res = AVERROR(ENOMEM); n = laces-1; break; } memcpy (pkt->data, data+slice_offset+offset, slice_size-offset); if (n == 0) pkt->flags = is_keyframe; pkt->stream_index = matroska->tracks[track]->stream_index; pkt->pts = timecode; pkt->pos = pos; pkt->duration = duration; matroska_queue_packet(matroska, pkt); } if (timecode != AV_NOPTS_VALUE) timecode = duration ? timecode + duration : AV_NOPTS_VALUE; } data += lace_size[n]; } } av_free(lace_size); av_free(origdata); return res; }
1threat
void pdu_free(V9fsPDU *pdu) { if (pdu) { V9fsState *s = pdu->s; if (!pdu->cancelled) { QLIST_REMOVE(pdu, next); QLIST_INSERT_HEAD(&s->free_list, pdu, next); } } }
1threat
Azure Table Storage CreateQuery in .NET Core : <p>I'm porting my existing class library that targets .NET Framework 4.6.2 to .NET Core 1.1.</p> <p>Looks like some of the methods that are available in .NET Framework version are not there in .NET Core. Two such methods are <code>table.CreateQuery</code> and <code>table.ExecuteQuery</code>.</p> <p>Here's an existing function that's giving me an error for CreateQuery:</p> <pre><code>public T Get&lt;T&gt;(string partitionKey, string rowKey, string tableName) where T : ITableEntity, new() =&gt; getTable(tableName).CreateQuery&lt;T&gt;().Where(r =&gt; r.PartitionKey == partitionKey &amp;&amp; r.RowKey == rowKey).FirstOrDefault(); </code></pre> <p>How do I create query in .NET Core?</p>
0debug
How can I call a function in javascript that contains a period in it's name? : <p>If I have the following object:</p> <pre><code>var helloWorldFunctions = { 'hello.world': function () { return 'hello world'}, 'helloWorld' : function () { return 'hello world'} } </code></pre> <p>I can call the second 'helloWorld' function in the object by doing:</p> <pre><code>helloWorldFunctions.helloWorld() </code></pre> <p>How can I call the first 'hello.world' function? Naturally, doing the following gives me a type error:</p> <pre><code>helloWorldFunctions.hello.world() </code></pre>
0debug
How can I specify a python version using setuptools? : <p>Is there a way to specify a python version to be used with a python package defined in setup.py? </p> <p>My setup.py currently looks like this: </p> <pre><code>from distutils.core import setup setup( name = 'macroetym', packages = ['macroetym'], # this must be the same as the name above version = '0.1', description = 'A tool for macro-etymological textual analysis.', author = 'Jonathan Reeve', author_email = 'jon.reeve@gmail.com', url = 'https://github.com/JonathanReeve/macro-etym', download_url = 'https://github.com/JonathanReeve/macro-etym/tarball/0.1', # FIXME: make a git tag and confirm that this link works install_requires = ['Click', 'nltk', 'pycountry', 'pandas', 'matplotlib'], include_package_data = True, package_data = {'macroetym': ['etymwm-smaller.tsv']}, keywords = ['nlp', 'text-analysis', 'etymology'], classifiers = [], entry_points=''' [console_scripts] macroetym = macroetym.main:cli ''', ) </code></pre> <p>It's a command-line program. My script runs using Python 3, but a lot of operating systems still have Python 2 as the default. How can I specify a python version to be used here? I can't seem to find anything in <a href="https://pythonhosted.org/setuptools/setuptools.html#declaring-dependencies" rel="noreferrer">the docs</a>, but maybe I'm not looking in the right place? </p>
0debug
Client doesn't have permission to access the desired data in Firebase : <p>I have a page that is calling <code>addCheckin()</code> method which is inside a controller. In the controller, I am trying to create a reference as follows:</p> <pre><code>var ref = firebase.database().ref("users/" + $scope.whichuser + "/meetings/" +$scope.whichmeeting + "/checkins"); </code></pre> <p><code>$scope.whichuser</code> and <code>$scope.whichmeeting</code> are the <code>$routeParams</code> that I am passing from another route. Here's my checkin controller-</p> <pre><code>myApp.controller("CheckinsController", ['$scope','$rootScope','$firebaseArray','$routeParams','$firebaseObject', function($scope,$rootScope,$firebaseArray,$routeParams,$firebaseObject){ $scope.whichuser = $routeParams.uid; $scope.whichmeeting = $routeParams.mid; var ref = firebase.database().ref("users/" + $scope.whichuser + "/meetings/" +$scope.whichmeeting + "/checkins"); $scope.addCheckin = function(){ var checkinInfo = $firebaseArray(ref); var data={ firstname:$scope.firstname, lastname:$scope.lastname, email:$scope.email, date:firebase.database.ServerValue.TIMESTAMP } checkinInfo.$add(data); } }]);/*controller*/ </code></pre> <p>There are two errors that I am getting here-</p> <p>Error 1:</p> <p><code>Error: permission_denied at /users/Vp2P1MqKm7ckXqV2Uy3OzTnn6bB3/meetings: Client doesn't have permission to access the desired data.</code></p> <p>Error 2:</p> <p><code>Error: permission_denied at /users/Vp2P1MqKm7ckXqV2Uy3OzTnn6bB3/meetings/-KT5tqMYKXsFssmcRLm6/checkins: Client doesn't have permission to access the desired data.</code></p> <p>And this is what I am tring to achieve-</p> <p><a href="https://i.stack.imgur.com/WKNiI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WKNiI.png" alt="enter image description here"></a></p>
0debug