problem
stringlengths
26
131k
labels
class label
2 classes
When is DbConnection.StateChange called? : <p>I have the following code:</p> <pre><code> class Program { static void Main() { var connection = new SqlConnection("myConnectionString"); connection.Open(); connection.StateChange += HandleSqlConnectionDrop; Console.WriteLine("Hi"); Console.ReadLine(); } private static void HandleSqlConnectionDrop(object connection, StateChangeEventArgs args) { Console.WriteLine("DB change detected"); } } </code></pre> <p>I start the above code while the SQL server instance is running. I then proceed to execute</p> <pre><code>SHUTDOWN WITH NOWAIT; </code></pre> <p>on the sql server instance that the program is connected to. I then observer the SQL server service stopping. However, I never see the "DB change detected" message in the output. Why is this?</p> <p><strong>Aside:</strong> I will see the StateChange handler get called if I then attempt to perform an operation on the SQL connection, but never before hand. Is there a way this behavior can be changed?</p>
0debug
Time complexity for recursive function with random input : <p>I'm a beginner in C programming so i need some help for my time complexity function.</p> <pre><code>int function(int n) { if (n &lt;= 1) return n; int i = random(n-1); return test(i) + test(n - 1 - i); } </code></pre> <p>I don't know how to deal with this problem because of the random function which have O(1) complexity which return randomly numbers.</p>
0debug
Have to restart Android studio for it to recognise my android device. how to solve it ? : I have an MI4I device and this is causing a lot of lost time during development. I have tried all the solutions that I googled, but didn't find a proper way yet to resolve this issue
0debug
Confirmation Email for publishing pdf : <p>I have a question about developing a webapi. I want to send someone an email with an confirmation Link and If he clicks on it he should be redirected to a thanks page and get a second email with a pdf. </p> <p>Unfortunatly I have no idea how to create the confirmation link. I can use every web language as php and node js.</p>
0debug
How to link data to another page by id : if($result-> num_rows > 0){ while ($row = $result-> fetch_assoc()) { echo "<tr><td>". $row["ic"] ."</td><td>". $row["name"] ."</td><td>". $row["jawatan"] ."</td></tr>"; echo "<tr><td><button onclick="location.href='testProfile.php?id= $row["ic"]';">quick view</button></td></tr>"; } echo "</table>"; }
0debug
Make Some Text Bold in Sqlite Database, Android Studio : I want to make only some heading bold of text stored in sqlite database.[text in dots should be bold][1] [1]: https://i.stack.imgur.com/pHtAh.png
0debug
Wipe AsyncStorage in react native : <p>I notice that I am wasting a certain amount of time debugging <strong>redux</strong> actions that I am persisting to <code>AsyncStorage</code> in <strong>react-native</strong> thanks to <a href="https://github.com/rt2zz/redux-persist" rel="noreferrer">redux-persist</a>. Sometimes I'd just like to wipe AsyncStorage to save some development time and try with fresh data.</p> <p>EDIT: Best case the solution should work on simulators and real devices, iOS and Android. Maybe there are different work arounds for different platforms.</p> <p>Thanks</p>
0debug
static void v9fs_synth_fill_statbuf(V9fsSynthNode *node, struct stat *stbuf) { stbuf->st_dev = 0; stbuf->st_ino = node->attr->inode; stbuf->st_mode = node->attr->mode; stbuf->st_nlink = node->attr->nlink; stbuf->st_uid = 0; stbuf->st_gid = 0; stbuf->st_rdev = 0; stbuf->st_size = 0; stbuf->st_blksize = 0; stbuf->st_blocks = 0; stbuf->st_atime = 0; stbuf->st_mtime = 0; stbuf->st_ctime = 0; }
1threat
static int thread_get_buffer_internal(AVCodecContext *avctx, ThreadFrame *f, int flags) { PerThreadContext *p = avctx->thread_opaque; int err; f->owner = avctx; ff_init_buffer_info(avctx, f->f); if (!(avctx->active_thread_type & FF_THREAD_FRAME)) return ff_get_buffer(avctx, f->f, flags); if (p->state != STATE_SETTING_UP && (avctx->codec->update_thread_context || (!avctx->thread_safe_callbacks && avctx->get_buffer != avcodec_default_get_buffer))) { av_log(avctx, AV_LOG_ERROR, "get_buffer() cannot be called after ff_thread_finish_setup()\n"); return -1; } if (avctx->internal->allocate_progress) { int *progress; f->progress = av_buffer_alloc(2 * sizeof(int)); if (!f->progress) { return AVERROR(ENOMEM); } progress = (int*)f->progress->data; progress[0] = progress[1] = -1; } pthread_mutex_lock(&p->parent->buffer_mutex); if (avctx->thread_safe_callbacks || ( #if FF_API_GET_BUFFER !avctx->get_buffer && #endif avctx->get_buffer2 == avcodec_default_get_buffer2)) { err = ff_get_buffer(avctx, f->f, flags); } else { pthread_mutex_lock(&p->progress_mutex); p->requested_frame = f->f; p->requested_flags = flags; p->state = STATE_GET_BUFFER; pthread_cond_broadcast(&p->progress_cond); while (p->state != STATE_SETTING_UP) pthread_cond_wait(&p->progress_cond, &p->progress_mutex); err = p->result; pthread_mutex_unlock(&p->progress_mutex); if (!avctx->codec->update_thread_context) ff_thread_finish_setup(avctx); } if (err) av_buffer_unref(&f->progress); pthread_mutex_unlock(&p->parent->buffer_mutex); return err; }
1threat
How to insert data MySQL using PHP + Ajax : <p>There are a lot of similar questions out there, but my issue is a little bit more complicated.</p> <p>I have a table called <code>movies</code> from which I am displaying data in a loop using the code below:</p> <pre><code>&lt;?php // LISTS MOVIES ORDERED BY RELEASE DATE -- LATEST MOVIES BY YEAR. $stmt = $connect-&gt;prepare("SELECT id, title, releaseDate, posterUrl FROM movies ORDER BY releaseDate DESC LIMIT 4"); $stmt-&gt;execute(); $stmt-&gt;store_result(); $stmt-&gt;bind_result($movieId, $movieTitle, $movieDate, $moviePoster); while ($stmt-&gt;fetch()) { ?&gt; &lt;div class="index-movie"&gt; &lt;div class="meta-container"&gt; &lt;img src="&lt;?php echo $moviePoster; ?&gt;" alt="&lt;?php echo $movieTitle; ?&gt;" class="poster"&gt; &lt;div class="meta"&gt; &lt;span class="title"&gt;&lt;?php echo $movieTitle . ' (' . substr($movieDate, 0, 4) . ')'; ?&gt;&lt;/span&gt; &lt;/div&gt; &lt;/div&gt; &lt;form method="POST" class="watchlist-form"&gt; &lt;input type="text" name="watchlist-movie-id" style="display: none;" class="watchlist-movie-id" value="&lt;?php echo $movieId; ?&gt;"&gt; &lt;input type="submit" class="add-to-watchlist" value="Add to Watchlist" name="add-to-watchlist"&gt; &lt;/form&gt; &lt;/div&gt; &lt;?php } $stmt-&gt;free_result(); $stmt-&gt;close(); ?&gt; </code></pre> <p>This loop displays four entries from the <code>movies</code> table. When the user clicks the <code>.add-to-watchlist</code> button, the movie is to be added to the user's list. I have a two separate tables <code>users</code> for users and <code>watchlist</code> for the junction table between <code>users</code> and <code>movies</code>.</p> <p>My question is, how do I implement a function so that I can add the "specific" movie from the list of four to the user's list? For fetching the <code>movieId</code> I echoed that into a hidden input field, but still can't get that to work.</p> <p>My jQuery code is:</p> <pre><code>$('.add-to-watchlist').on('click', function(e) { e.preventDefault(); var data = $(this).parent().find('.watchlist-movie-id').val(); $.ajax({ type: 'POST', url: 'includes/watchlist.php', dataType: 'text', data: data, success: function() { $(this).hide(); }, error: function(error) { alert(error); } }); }); </code></pre> <p>And <code>watchlist.php</code> is:</p> <pre><code>&lt;?php require('includes/config.php'); require('includes/auth.php'); $defaultId = 'DEFAULT'; $currentDate = 'now()'; $movieId = $_POST['watchlist-movie-id']; $stmt = $connect-&gt;prepare("INSERT INTO watchlist (id, date, userId, movieId) VALUES (?, ?, ?, ?)"); $stmt-&gt;bind_param("ssii", $defaultId, $currentDate, $currentUser, $movieId); $stmt-&gt;execute(); $stmt-&gt;close(); ?&gt; </code></pre>
0debug
void av_register_input_format(AVInputFormat *format) { AVInputFormat **p = last_iformat; format->next = NULL; while(*p || avpriv_atomic_ptr_cas((void * volatile *)p, NULL, format)) p = &(*p)->next; last_iformat = &format->next; }
1threat
syntax error, unexpected 'try' in PHP : <p>Have error with my registration page i get this error:</p> <pre><code>Parse error: syntax error, unexpected 'try' (T_TRY) in /home/catchpokem/domains/catchpokemons.lt/public_html/sargcs/admin/register.php on line 18 </code></pre> <p>My code is : <code>http://pastebin.com/kamBT8J3</code> Really want to fix this error but i don't know how?</p>
0debug
What is meant by event i n azure event hub : <p>I would like to know what is meant by an event in azure event hub. I thought it's like getting some content(string) from source and process it by other services is one event. if so, what is maximum content(string) I can send at one event</p>
0debug
Is it possible to trigger a lambda on creation from CloudFormation template : <p>I tried creating a set of lambdas using cloudformation. I want the lambdas to get triggered once they are created. I saw at various blogs to create a trigger to <code>s3</code> or <code>sns</code> but none seems to be a option to trigger <code>lambda</code> once it has been created. Any options?</p>
0debug
static void vde_to_qemu(void *opaque) { VDEState *s = opaque; uint8_t buf[4096]; int size; size = vde_recv(s->vde, (char *)buf, sizeof(buf), 0); if (size > 0) { qemu_send_packet(&s->nc, buf, size); } }
1threat
def is_subset(arr1, m, arr2, n): hashset = set() for i in range(0, m): hashset.add(arr1[i]) for i in range(0, n): if arr2[i] in hashset: continue else: return False return True
0debug
static int qcow_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { BDRVQcowState *s = bs->opaque; int len, i, shift, ret; QCowHeader header; ret = bdrv_pread(bs->file, 0, &header, sizeof(header)); if (ret < 0) { goto fail; } be32_to_cpus(&header.magic); be32_to_cpus(&header.version); be64_to_cpus(&header.backing_file_offset); be32_to_cpus(&header.backing_file_size); be32_to_cpus(&header.mtime); be64_to_cpus(&header.size); be32_to_cpus(&header.crypt_method); be64_to_cpus(&header.l1_table_offset); if (header.magic != QCOW_MAGIC) { error_setg(errp, "Image not in qcow format"); ret = -EINVAL; goto fail; } if (header.version != QCOW_VERSION) { char version[64]; snprintf(version, sizeof(version), "QCOW version %" PRIu32, header.version); error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE, bs->device_name, "qcow", version); ret = -ENOTSUP; goto fail; } if (header.size <= 1) { error_setg(errp, "Image size is too small (must be at least 2 bytes)"); ret = -EINVAL; goto fail; } if (header.cluster_bits < 9 || header.cluster_bits > 16) { error_setg(errp, "Cluster size must be between 512 and 64k"); ret = -EINVAL; goto fail; } if (header.l2_bits < 9 - 3 || header.l2_bits > 16 - 3) { error_setg(errp, "L2 table size must be between 512 and 64k"); ret = -EINVAL; goto fail; } if (header.crypt_method > QCOW_CRYPT_AES) { error_setg(errp, "invalid encryption method in qcow header"); ret = -EINVAL; goto fail; } s->crypt_method_header = header.crypt_method; if (s->crypt_method_header) { bs->encrypted = 1; } s->cluster_bits = header.cluster_bits; s->cluster_size = 1 << s->cluster_bits; s->cluster_sectors = 1 << (s->cluster_bits - 9); s->l2_bits = header.l2_bits; s->l2_size = 1 << s->l2_bits; bs->total_sectors = header.size / 512; s->cluster_offset_mask = (1LL << (63 - s->cluster_bits)) - 1; shift = s->cluster_bits + s->l2_bits; if (header.size > UINT64_MAX - (1LL << shift)) { error_setg(errp, "Image too large"); ret = -EINVAL; goto fail; } else { uint64_t l1_size = (header.size + (1LL << shift) - 1) >> shift; if (l1_size > INT_MAX / sizeof(uint64_t)) { error_setg(errp, "Image too large"); ret = -EINVAL; goto fail; } s->l1_size = l1_size; } s->l1_table_offset = header.l1_table_offset; s->l1_table = g_malloc(s->l1_size * sizeof(uint64_t)); ret = bdrv_pread(bs->file, s->l1_table_offset, s->l1_table, s->l1_size * sizeof(uint64_t)); if (ret < 0) { goto fail; } for(i = 0;i < s->l1_size; i++) { be64_to_cpus(&s->l1_table[i]); } s->l2_cache = g_malloc(s->l2_size * L2_CACHE_SIZE * sizeof(uint64_t)); s->cluster_cache = g_malloc(s->cluster_size); s->cluster_data = g_malloc(s->cluster_size); s->cluster_cache_offset = -1; if (header.backing_file_offset != 0) { len = header.backing_file_size; if (len > 1023) { len = 1023; } ret = bdrv_pread(bs->file, header.backing_file_offset, bs->backing_file, len); if (ret < 0) { goto fail; } bs->backing_file[len] = '\0'; } error_set(&s->migration_blocker, QERR_BLOCK_FORMAT_FEATURE_NOT_SUPPORTED, "qcow", bs->device_name, "live migration"); migrate_add_blocker(s->migration_blocker); qemu_co_mutex_init(&s->lock); return 0; fail: g_free(s->l1_table); g_free(s->l2_cache); g_free(s->cluster_cache); g_free(s->cluster_data); return ret; }
1threat
Javascript function returning NaN even though value is a number : I am very irritated. Please note that I have researched this for 2 days and simply cant waste time on this anymore, thus this is my last resort. I am working on a course assignment where random questions are asked with 4 possible answers each. (This all runs in the console only, working with alert()). My issue is the score of the user. It is supposed to increment by 1 with each correct iteration and I attempted resolving this using a function, but the function returns NaN and I simply cant see the problem. Please have a look. //to hold score accumulation var s = 0; //function to increase score per correct answer function incrementScore(){ s++; return s; }; //function to prompt user to enter/capture the answer & check whether its correct or not function captureAnswer(el){ //el is the parameter from the random question function var promptAnswer = prompt('Capture your answer here'); if (promptAnswer === 'exit') { console.log('You entered ' + promptAnswer); console.log('Bye, thanks for playing'); }else if (promptAnswer == el) { console.log('You entered ' + promptAnswer); console.log('Your answer is correct!'); incrementScore(); console.log('Your score is ' + s); displayQandA(); //calling random question function }else if (promptAnswer !== el) { console.log('You entered ' + promptAnswer); console.log('Your answer is wrong!'); console.log('Your score remains ' + s); displayQandA(); //calling random question function } };
0debug
static TRBCCode xhci_address_slot(XHCIState *xhci, unsigned int slotid, uint64_t pictx, bool bsr) { XHCISlot *slot; USBPort *uport; USBDevice *dev; dma_addr_t ictx, octx, dcbaap; uint64_t poctx; uint32_t ictl_ctx[2]; uint32_t slot_ctx[4]; uint32_t ep0_ctx[5]; int i; TRBCCode res; trace_usb_xhci_slot_address(slotid); assert(slotid >= 1 && slotid <= xhci->numslots); dcbaap = xhci_addr64(xhci->dcbaap_low, xhci->dcbaap_high); poctx = ldq_le_pci_dma(&xhci->pci_dev, dcbaap + 8*slotid); ictx = xhci_mask64(pictx); octx = xhci_mask64(poctx); DPRINTF("xhci: input context at "DMA_ADDR_FMT"\n", ictx); DPRINTF("xhci: output context at "DMA_ADDR_FMT"\n", octx); xhci_dma_read_u32s(xhci, ictx, ictl_ctx, sizeof(ictl_ctx)); if (ictl_ctx[0] != 0x0 || ictl_ctx[1] != 0x3) { fprintf(stderr, "xhci: invalid input context control %08x %08x\n", ictl_ctx[0], ictl_ctx[1]); return CC_TRB_ERROR; } xhci_dma_read_u32s(xhci, ictx+32, slot_ctx, sizeof(slot_ctx)); xhci_dma_read_u32s(xhci, ictx+64, ep0_ctx, sizeof(ep0_ctx)); DPRINTF("xhci: input slot context: %08x %08x %08x %08x\n", slot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]); DPRINTF("xhci: input ep0 context: %08x %08x %08x %08x %08x\n", ep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]); uport = xhci_lookup_uport(xhci, slot_ctx); if (uport == NULL) { fprintf(stderr, "xhci: port not found\n"); return CC_TRB_ERROR; } dev = uport->dev; if (!dev) { fprintf(stderr, "xhci: port %s not connected\n", uport->path); return CC_USB_TRANSACTION_ERROR; } for (i = 0; i < xhci->numslots; i++) { if (i == slotid-1) { continue; } if (xhci->slots[i].uport == uport) { fprintf(stderr, "xhci: port %s already assigned to slot %d\n", uport->path, i+1); return CC_TRB_ERROR; } } slot = &xhci->slots[slotid-1]; slot->uport = uport; slot->ctx = octx; if (bsr) { slot_ctx[3] = SLOT_DEFAULT << SLOT_STATE_SHIFT; } else { USBPacket p; slot_ctx[3] = (SLOT_ADDRESSED << SLOT_STATE_SHIFT) | slotid; usb_device_reset(dev); usb_packet_setup(&p, USB_TOKEN_OUT, usb_ep_get(dev, USB_TOKEN_OUT, 0), 0, 0, false, false); usb_device_handle_control(dev, &p, DeviceOutRequest | USB_REQ_SET_ADDRESS, slotid, 0, 0, NULL); assert(p.status != USB_RET_ASYNC); } res = xhci_enable_ep(xhci, slotid, 1, octx+32, ep0_ctx); DPRINTF("xhci: output slot context: %08x %08x %08x %08x\n", slot_ctx[0], slot_ctx[1], slot_ctx[2], slot_ctx[3]); DPRINTF("xhci: output ep0 context: %08x %08x %08x %08x %08x\n", ep0_ctx[0], ep0_ctx[1], ep0_ctx[2], ep0_ctx[3], ep0_ctx[4]); xhci_dma_write_u32s(xhci, octx, slot_ctx, sizeof(slot_ctx)); xhci_dma_write_u32s(xhci, octx+32, ep0_ctx, sizeof(ep0_ctx)); return res; }
1threat
Microservices architecture best practises : <p>I don't know if this is the right platform for this question or not, either way, I am venturing into microservices, have been in for some time though not long and was stuck on the right architecture or rather, best practices:</p> <p>Which is better and why, having all services of a microservices architecture app inside one docker and running many containers in parallel or having each of those services running in their own docker container (which each docker can be run in multiple instances)?</p> <p><strong>P.S.</strong> The services must not necessarily be run using docker</p>
0debug
static void qcow_close(BlockDriverState *bs) { BDRVQcowState *s = bs->opaque; g_free(s->l1_table); g_free(s->l2_cache); g_free(s->cluster_cache); g_free(s->cluster_data); migrate_del_blocker(s->migration_blocker); error_free(s->migration_blocker); }
1threat
static void FUNCC(pred4x4_128_dc)(uint8_t *_src, const uint8_t *topright, int _stride){ pixel *src = (pixel*)_src; int stride = _stride/sizeof(pixel); ((pixel4*)(src+0*stride))[0]= ((pixel4*)(src+1*stride))[0]= ((pixel4*)(src+2*stride))[0]= ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(1<<(BIT_DEPTH-1)); }
1threat
Find algorithm of creating folder Nodejs : <p>I have to save images in folders. I took ids of images from mysql and if id is smaller than 1000 Have to create folder 1000, then if it is smaller than 100, create folder 100 etc. Then 2000 and etc. How I should write this? I can do this with if-else statement or switch but it will be very long code. Help please!</p>
0debug
Lottie.Forms - Load from EmbeddedResources : <p>I've got a <code>AnimationView</code> defined in AirBnb's <code>Lottie</code> Framework which should load a file placed inside my Resource folder inside my Xamarin.Forms Project (the portable one)</p> <pre><code> &lt;forms:AnimationView x:Name="AnimationView" Animation="SharpLibrary.Forms.Assets.Images.WineGlass.json" Loop="True" AutoPlay="True" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand" /&gt; </code></pre> <p>But it seems it cannot resolve the string in <code>Animation</code> property, so it will not display the animation. If I place the file into the Resource folder and say <code>Animation="WineGlass.json"</code> it works.</p> <p>Is there a way to load it from EmbeddedResource, or is this not possible?</p>
0debug
void powerpc_display_perf_report(void) { int i; #ifndef POWERPC_PERF_USE_PMC fprintf(stderr, "PowerPC performance report\n Values are from the Time Base register, and represent 4 bus cycles.\n"); #else fprintf(stderr, "PowerPC performance report\n Values are from the PMC registers, and represent whatever the registers are set to record.\n"); #endif for(i = 0 ; i < powerpc_perf_total ; i++) { if (perfdata[i][powerpc_data_num] != (unsigned long long)0) fprintf(stderr, " Function \"%s\" (pmc1):\n\tmin: %llu\n\tmax: %llu\n\tavg: %1.2lf (%llu)\n", perfname[i], perfdata[i][powerpc_data_min], perfdata[i][powerpc_data_max], (double)perfdata[i][powerpc_data_sum] / (double)perfdata[i][powerpc_data_num], perfdata[i][powerpc_data_num]); #ifdef POWERPC_PERF_USE_PMC if (perfdata_pmc2[i][powerpc_data_num] != (unsigned long long)0) fprintf(stderr, " Function \"%s\" (pmc2):\n\tmin: %llu\n\tmax: %llu\n\tavg: %1.2lf (%llu)\n", perfname[i], perfdata_pmc2[i][powerpc_data_min], perfdata_pmc2[i][powerpc_data_max], (double)perfdata_pmc2[i][powerpc_data_sum] / (double)perfdata_pmc2[i][powerpc_data_num], perfdata_pmc2[i][powerpc_data_num]); if (perfdata_pmc3[i][powerpc_data_num] != (unsigned long long)0) fprintf(stderr, " Function \"%s\" (pmc3):\n\tmin: %llu\n\tmax: %llu\n\tavg: %1.2lf (%llu)\n", perfname[i], perfdata_pmc3[i][powerpc_data_min], perfdata_pmc3[i][powerpc_data_max], (double)perfdata_pmc3[i][powerpc_data_sum] / (double)perfdata_pmc3[i][powerpc_data_num], perfdata_pmc3[i][powerpc_data_num]); #endif } }
1threat
static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce, int win, int group_len, const float lambda) { BandCodingPath path[120][12]; int w, swb, cb, start, size; int i, j; const int max_sfb = sce->ics.max_sfb; const int run_bits = sce->ics.num_windows == 1 ? 5 : 3; const int run_esc = (1 << run_bits) - 1; int idx, ppos, count; int stackrun[120], stackcb[120], stack_len; float next_minbits = INFINITY; int next_mincb = 0; abs_pow34_v(s->scoefs, sce->coeffs, 1024); start = win*128; for (cb = 0; cb < 12; cb++) { path[0][cb].cost = run_bits+4; path[0][cb].prev_idx = -1; path[0][cb].run = 0; } for (swb = 0; swb < max_sfb; swb++) { size = sce->ics.swb_sizes[swb]; if (sce->zeroes[win*16 + swb]) { float cost_stay_here = path[swb][0].cost; float cost_get_here = next_minbits + run_bits + 4; if ( run_value_bits[sce->ics.num_windows == 8][path[swb][0].run] != run_value_bits[sce->ics.num_windows == 8][path[swb][0].run+1]) cost_stay_here += run_bits; if (cost_get_here < cost_stay_here) { path[swb+1][0].prev_idx = next_mincb; path[swb+1][0].cost = cost_get_here; path[swb+1][0].run = 1; } else { path[swb+1][0].prev_idx = 0; path[swb+1][0].cost = cost_stay_here; path[swb+1][0].run = path[swb][0].run + 1; } next_minbits = path[swb+1][0].cost; next_mincb = 0; for (cb = 1; cb < 12; cb++) { path[swb+1][cb].cost = 61450; path[swb+1][cb].prev_idx = -1; path[swb+1][cb].run = 0; } } else { float minbits = next_minbits; int mincb = next_mincb; int startcb = sce->band_type[win*16+swb]; next_minbits = INFINITY; next_mincb = 0; for (cb = 0; cb < startcb; cb++) { path[swb+1][cb].cost = 61450; path[swb+1][cb].prev_idx = -1; path[swb+1][cb].run = 0; } for (cb = startcb; cb < 12; cb++) { float cost_stay_here, cost_get_here; float bits = 0.0f; for (w = 0; w < group_len; w++) { bits += quantize_band_cost(s, sce->coeffs + start + w*128, s->scoefs + start + w*128, size, sce->sf_idx[(win+w)*16+swb], cb, 0, INFINITY, NULL); } cost_stay_here = path[swb][cb].cost + bits; cost_get_here = minbits + bits + run_bits + 4; if ( run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run] != run_value_bits[sce->ics.num_windows == 8][path[swb][cb].run+1]) cost_stay_here += run_bits; if (cost_get_here < cost_stay_here) { path[swb+1][cb].prev_idx = mincb; path[swb+1][cb].cost = cost_get_here; path[swb+1][cb].run = 1; } else { path[swb+1][cb].prev_idx = cb; path[swb+1][cb].cost = cost_stay_here; path[swb+1][cb].run = path[swb][cb].run + 1; } if (path[swb+1][cb].cost < next_minbits) { next_minbits = path[swb+1][cb].cost; next_mincb = cb; } } } start += sce->ics.swb_sizes[swb]; } stack_len = 0; idx = 0; for (cb = 1; cb < 12; cb++) if (path[max_sfb][cb].cost < path[max_sfb][idx].cost) idx = cb; ppos = max_sfb; while (ppos > 0) { av_assert1(idx >= 0); cb = idx; stackrun[stack_len] = path[ppos][cb].run; stackcb [stack_len] = cb; idx = path[ppos-path[ppos][cb].run+1][cb].prev_idx; ppos -= path[ppos][cb].run; stack_len++; } start = 0; for (i = stack_len - 1; i >= 0; i--) { put_bits(&s->pb, 4, stackcb[i]); count = stackrun[i]; memset(sce->zeroes + win*16 + start, !stackcb[i], count); for (j = 0; j < count; j++) { sce->band_type[win*16 + start] = stackcb[i]; start++; } while (count >= run_esc) { put_bits(&s->pb, run_bits, run_esc); count -= run_esc; } put_bits(&s->pb, run_bits, count); } }
1threat
append dropdown box selections to a textbox : <p>I am wondering if someone can point me in the right direction for what I am looking for... Basically, I would like to have 3-5 dropdown boxes (and maybe 2 textboxes) with each their own specific options. I would then like to append (or as excel would call it, CONCATENATE) the selected options into a string of text in a textbox after pressing a button (call it generate). I could define the string of text and where the options would reside.</p> <p>Crude example;</p> <p><strong>Selections:</strong></p> <p>Dropdown 1 - Dropdown 2 - Dropdown 3 - Textbox 1 - Textbox 2</p> <p><strong>Output in textbox:</strong></p> <p>Selection 1 - Selection 2 - Selection 3 - optional text - optional text</p> <p>If anyone knows of an example that would best suit my needs that would be awesome so I can sort of figure it out... I have yet to come across one.</p>
0debug
static void compute_rematrixing_strategy(AC3EncodeContext *s) { int nb_coefs; int blk, bnd, i; AC3Block *block, *av_uninit(block0); if (s->channel_mode != AC3_CHMODE_STEREO) return; for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { block = &s->blocks[blk]; block->new_rematrixing_strategy = !blk; if (!s->rematrixing_enabled) { block0 = block; continue; } block->num_rematrixing_bands = 4; if (block->cpl_in_use) { block->num_rematrixing_bands -= (s->start_freq[CPL_CH] <= 61); block->num_rematrixing_bands -= (s->start_freq[CPL_CH] == 37); if (blk && block->num_rematrixing_bands != block0->num_rematrixing_bands) block->new_rematrixing_strategy = 1; } nb_coefs = FFMIN(block->end_freq[1], block->end_freq[2]); for (bnd = 0; bnd < block->num_rematrixing_bands; bnd++) { int start = ff_ac3_rematrix_band_tab[bnd]; int end = FFMIN(nb_coefs, ff_ac3_rematrix_band_tab[bnd+1]); CoefSumType sum[4] = {0,}; for (i = start; i < end; i++) { CoefType lt = block->mdct_coef[1][i]; CoefType rt = block->mdct_coef[2][i]; CoefType md = lt + rt; CoefType sd = lt - rt; MAC_COEF(sum[0], lt, lt); MAC_COEF(sum[1], rt, rt); MAC_COEF(sum[2], md, md); MAC_COEF(sum[3], sd, sd); } if (FFMIN(sum[2], sum[3]) < FFMIN(sum[0], sum[1])) block->rematrixing_flags[bnd] = 1; else block->rematrixing_flags[bnd] = 0; if (blk && block->rematrixing_flags[bnd] != block0->rematrixing_flags[bnd]) { block->new_rematrixing_strategy = 1; } } block0 = block; } }
1threat
how can i use a path in a variable ? (Shell) : [I would like to store the path of a file typed by the user in a variable and then use it][1] [1]: https://i.stack.imgur.com/KXVK6.png
0debug
What kind of component is this? : <p><a href="https://github.com/bvaughn/react-virtualized/blob/master/docs/creatingAnInfiniteLoadingList.md" rel="nofollow noreferrer">https://github.com/bvaughn/react-virtualized/blob/master/docs/creatingAnInfiniteLoadingList.md</a></p> <p>How does one incorporate <code>MyComponent</code> into a React app?</p>
0debug
What is the difference between object and object[] in java : <p>So i wrote a method that accepts any java object and i figured out that </p> <pre><code>public void mymethod(Object javaobject) { } </code></pre> <p>works, but with</p> <pre><code>public void mymethod(Object[] javaobject) { } </code></pre> <p>Eclipse trows an error</p> <pre><code>The method mymethod(Object[]) in the type myClass is not applicable for the arguments (Object) </code></pre> <p>So my question is, where is the difference between these two types ?</p>
0debug
XML comments file could not be found - Swagger : <p>This is certainly one of those that drives you nuts. As the title indicates all I'm simply trying to do is display comments pulled from an xml file using swagger.</p> <p>I appear to have taken all steps according to the swagger documentation but to no avail. Hopefully you kind folk can point me in the right direction.</p> <p><strong>Steps Taken:</strong> <a href="https://i.stack.imgur.com/TbVwq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/TbVwq.png" alt="enter image description here"></a></p> <p><strong>Ensured file exists:</strong></p> <p><a href="https://i.stack.imgur.com/kWraQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kWraQ.png" alt="enter image description here"></a></p> <p>Configured <code>SwaggerConfig.cs</code></p> <p><a href="https://i.stack.imgur.com/66a3h.png" rel="noreferrer"><img src="https://i.stack.imgur.com/66a3h.png" alt="enter image description here"></a></p> <p>I've tried changing the path too: @"bin/....xml"</p> <p>Nothing seems to work.</p> <p>**The Error "Could not find file": **</p> <p><a href="https://i.stack.imgur.com/RW2Mb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/RW2Mb.png" alt="enter image description here"></a></p> <p>Can anyone point me in the right direction please? </p> <p>Regards,</p>
0debug
Msg 201, Procedure stp_DespatchedJob, Line 0 Procedure or Function 'stp_DespatchedJob' expects parameter '@jobId', which was not supplied : USE [taxi] GO DECLARE @return_value int EXEC @return_value = [dbo].[stp_DespatchedJob] @JobStatusId = NULL SELECT 'Return Value' = @return_value GO
0debug
No list returned by random.shuffle() : <p>I wrote some code in two different ways which I thought were exacly equivalent but I got two very differnt answers:</p> <p>This first way worked exactly as expected:</p> <pre><code>test_listA = list(range(0, 5)) random.shuffle(test_listA) print(test_listA) </code></pre> <p>It printed out:</p> <pre><code>[2, 1, 0, 3, 4] </code></pre> <p>But when I reorganised it like so:</p> <pre><code>test_listB = random.shuffle(list(range(0, 5))) print(test_listB) </code></pre> <p>It prints out:</p> <pre><code>None </code></pre> <p>Why the difference?</p>
0debug
can AVSpeechSynthesizer solve speech recognition in background? : unfortunately, i didn't find any solution to recognize user speech in background, I just yesterday read about AVSpeechSynthesizer. sorry i didn't read a lot about AVSpeechSynthesizer and I should submit my project on Thursday. really I need to solve this problem, so any one know about AVSpeechSynthesizer is it possiable to help me when I want to recognize user voice if he/she say specified word? for example say "hello" in background. thank you for your time.
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
What's the difference between Remove and Exclude when refactoring with PyCharm? : <p>The <a href="https://www.jetbrains.com/help/pycharm/2016.1/refactoring-source-code.html?origin=old_help" rel="noreferrer">official PyCharm docs</a> explain <code>Exclude</code> when it comes to refactoring: One can, say, rename something with refactoring (Shift+F6), causing the Find window to pop up with a Preview. Within, it shows files which will be updated as a result of the refactor. One can right-click on a file or folder in this Preview and choose <code>Remove</code> or <code>Exclude</code>. What's the difference? </p>
0debug
Intellij "Jar with dependencies" artifact Creates Different Looking Jar File : *Left side of picture:* It is when it is run directly from intellij *Right side of picture:* Created fat jar (which is created by the feature called *"Jar with dependencies"*) is run as double click from mouse [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/h7ghN.png What can be the cause of this?
0debug
static void test_media_insert(void) { uint8_t dir; qmp_discard_response("{'execute':'change', 'arguments':{" " 'device':'floppy0', 'target': '%s' }}", test_image); qmp_discard_response(""); qmp_discard_response(""); dir = inb(FLOPPY_BASE + reg_dir); assert_bit_set(dir, DSKCHG); dir = inb(FLOPPY_BASE + reg_dir); assert_bit_set(dir, DSKCHG); send_seek(0); dir = inb(FLOPPY_BASE + reg_dir); assert_bit_set(dir, DSKCHG); dir = inb(FLOPPY_BASE + reg_dir); assert_bit_set(dir, DSKCHG); send_seek(1); dir = inb(FLOPPY_BASE + reg_dir); assert_bit_clear(dir, DSKCHG); dir = inb(FLOPPY_BASE + reg_dir); assert_bit_clear(dir, DSKCHG); }
1threat
static inline void softusb_read_pmem(MilkymistSoftUsbState *s, uint32_t offset, uint8_t *buf, uint32_t len) { if (offset + len >= s->pmem_size) { error_report("milkymist_softusb: read pmem out of bounds " "at offset 0x%x, len %d", offset, len); return; } memcpy(buf, s->pmem_ptr + offset, len); }
1threat
how to check if the javascript contains atleast 2 alphabets : i need to check if test contains atleast 2 alphabets like SC then do something. var test='SC129h'; if(test.containsalphabets atleast 2){ alert('success'); } else{ alert('condition not satisfied for alphabets'); } please let me know how to check the if condition for any alphabets with length 2
0debug
How to use (for loop) and (if conditionals) when I have float numbers in string : we have a string called (A) contain float numbers : A="1.65, 1.46, 2.05, 3.03, 3.35, 3.46, 2.83, 3.23, 3.5, 2.52, 2.8, 1.85" How can I compute the the number of items with values >3.0 please?
0debug
Get unique values from an multidimensional array : Can anyone give me VBA code to help me with the following problem ?: I have this array called "data" with some repeated values in the columns: **INPUT** data()= { 0,0,0,a,b,a,c,b,c,d,0,0 0,0,0,1,2,1,9,2,9,4,0,0 0,0,0,r,g,r,w,g,t,w,0,0 } I want to populate an multidimensional "arr()" with the information of the non repeated values of the "data()" array. And also: not considering zero values and it does matter which value you will choose from the repeated ones (since the columns are equal) **OUTPUT** arr()= { a,b,c,d 1,2,9,4 r,g,w,w }
0debug
Python Integers into lists : Hi I am using the following code to break an integer up into bits and store in a list but instead of 12345 I would like it to use the contents of a variable that have already been entered previously in the code but I cant seem to get it to work on a variable. Any suggestions? digits = [] digits += str(12345)
0debug
How to run Periodically Work request in android with Work Manager : <p>I have implement following code in my application, but not executing on specific time. I want to run a task on every 1 minute interval while app is in Background. </p> <pre><code> WorkManager workManager = WorkManager.getInstance(); List&lt;WorkStatus&gt; value = workManager.getStatusesByTag(CALL_INFO_WORKER).getValue(); if (value == null) { PeriodicWorkRequest callDataRequest1 = new PeriodicWorkRequest.Builder(CallInfoWorker.class,10,TimeUnit.SECONDS,3, TimeUnit.SECONDS).build(); workManager.enqueue(callDataRequest1); } </code></pre>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
void usb_packet_setup(USBPacket *p, int pid, USBEndpoint *ep, uint64_t id, bool short_not_ok, bool int_req) { assert(!usb_packet_is_inflight(p)); assert(p->iov.iov != NULL); p->id = id; p->pid = pid; p->ep = ep; p->result = 0; p->parameter = 0; p->short_not_ok = short_not_ok; p->int_req = int_req; qemu_iovec_reset(&p->iov); usb_packet_set_state(p, USB_PACKET_SETUP); }
1threat
static void rtas_int_off(sPAPREnvironment *spapr, uint32_t token, uint32_t nargs, target_ulong args, uint32_t nret, target_ulong rets) { struct ics_state *ics = spapr->icp->ics; uint32_t nr; if ((nargs != 1) || (nret != 1)) { rtas_st(rets, 0, -3); return; } nr = rtas_ld(args, 0); if (!ics_valid_irq(ics, nr)) { rtas_st(rets, 0, -3); return; } ics_write_xive(ics, nr, ics->irqs[nr - ics->offset].server, 0xff, ics->irqs[nr - ics->offset].priority); rtas_st(rets, 0, 0); }
1threat
How to use wildcards in javascript : Here is my code : if(status == "*Contacted*") { jQuery("#list2").jqGrid('setRowData',rows[i],false, { color:'black',weightfont:'bold',background:'yellow'}); } I want the "*" to act like a wildcard, so that if it finds a string like : Contacted,Scheduled it will still execute the code. Am I using the wildcard incorrectly - because the way I have it, the code only works if the string is simply "Contacted" with nothing else mixed in Thanks!
0debug
How do I connect my files from Windows 7 laptop to my Raspbian Raspberry Pi 2 (using LAN)? : <p>I have recently bought a Raspberry Pi 2. I am using it to test some python socket server games that I made, but it takes me ages to put the client's .py file on my memory stick, then put it on my Pi every time I update the code. I would like an easy way to connect the two's files, preferably using LAN. Thanks :)</p>
0debug
What is the function of return in python? : According to my understanding:return is the meaning of returning a value. One example, the python1 script: def func(): try: print 98 return 'ok' finally: print 98 print fun() The output of the script is : 98 98 ok So my question is why the output of the script is not: 98 OK 98 Why is the output of the OK line at the end?
0debug
Should I store function references in Redux store? : <p>I'm trying to build <strong>keyboard shortcut support</strong> into my React/Redux app in an <strong>idiomatic React/Redux way</strong>. The way I am planning to do this is to have the following action creator and associated action:</p> <pre><code>registerShortcut(keyCode, actionCreatorFuncReference) </code></pre> <p>The reducer would then update a registeredShortcuts object in the redux store with a mapping of keyCodes to actionCreatorFuncReferences. Then my root component would listen for keyup and see if there is an associated keyCode registered and if so, then dispatch the mapped action via the action creator function reference.</p> <p>However, this would be the first time I am <strong>storing function references in my Redux store</strong>. To date I've only had objects with keys with vanilla values (strings, ints, etc).</p> <p>The Redux docs says "You should do your best to keep the state serializable. Don’t put anything inside it that you can’t easily turn into JSON.". <strong>Does this suggest it's a bad idea to store such function references in my Redux store?</strong> If so, what is a better way to accomplish what I'm trying to do in React/Redux?</p> <p>An alternative approach is just to store the mapping of keyCodes and function references in the root react component itself, but that didn't feel very Redux-like since now application state is not in the Redux store.</p>
0debug
void ahci_init(AHCIState *s, DeviceState *qdev, DMAContext *dma, int ports) { qemu_irq *irqs; int i; s->dma = dma; s->ports = ports; s->dev = g_malloc0(sizeof(AHCIDevice) * ports); ahci_reg_init(s); memory_region_init_io(&s->mem, &ahci_mem_ops, s, "ahci", AHCI_MEM_BAR_SIZE); memory_region_init_io(&s->idp, &ahci_idp_ops, s, "ahci-idp", 32); irqs = qemu_allocate_irqs(ahci_irq_set, s, s->ports); for (i = 0; i < s->ports; i++) { AHCIDevice *ad = &s->dev[i]; ide_bus_new(&ad->port, qdev, i); ide_init2(&ad->port, irqs[i]); ad->hba = s; ad->port_no = i; ad->port.dma = &ad->dma; ad->port.dma->ops = &ahci_dma_ops; ad->port_regs.cmd = PORT_CMD_SPIN_UP | PORT_CMD_POWER_ON; } }
1threat
Union Assigned Values in C : <p>Given the following union definition:</p> <pre><code>typedef union{ int i; char ch; float f;}record; record a; //a.i = 10; a.ch = 'A'; //a.f = 10.56; printf("printing a.i: %p \n", a.i); printf("printing a.ch: %c \n", a.ch); printf("printing a.f: %f \n", a.f); return 0; </code></pre> <p>I get the following output:</p> <p>printing a.i: 65<br> printing a.ch: A<br> printing a.f: 0.000000</p> <p>Why does a.i not print 0 (the default value for undefined integers) but instead the ASCII value for 'A'. Does this somehow have access to a.ch?? </p>
0debug
void av_bsf_list_free(AVBSFList **lst) { int i; if (*lst) return; for (i = 0; i < (*lst)->nb_bsfs; ++i) av_bsf_free(&(*lst)->bsfs[i]); av_free((*lst)->bsfs); av_freep(lst); }
1threat
static int kvm_log_start(CPUPhysMemoryClient *client, target_phys_addr_t phys_addr, ram_addr_t size) { return kvm_dirty_pages_log_change(phys_addr, size, true); }
1threat
Sorting a 2d array by column : <p>Here is my code, im kinda lost as to how to make this work the way i want to, i have made it so the user will enter a 3x3 2d array, im trying to sort each column but im having a hard time figuring it out and then printing the array while still keeping the original in tack....</p> <pre><code>package newproject; import java.util.Scanner; public class ColumnSorting { public static void main(String [] args){ double a[][]=new double[3][3]; Scanner input = new Scanner(System.in); for(int row=0;row&lt;3;row++){ for(int col=0;col&lt;3;col++){ System.out.println("Enter value: "); a[row][col]=input.nextDouble(); } } displayArray(a); } public static void displayArray(double x[][]) { for (int row=0;row&lt;x.length;row++) { for(int column = 0;column&lt;x[row].length; column++) { System.out.print(x[row][column]+"\t"); } System.out.println(); } } public static double[][] sortColumns(double[][] m){ java.util.Arrays.sort(m, new java.util.Comparator&lt;double[]&gt;() { public int compare(double[] a, double[] b) { return Double.compare(a[0], b[0]); } }); } } </code></pre>
0debug
Andorid You must supply a layout_width attribute : below xml layout is my simple application layout, but after compile application i get this error: Unable to start activity ComponentInfo{ir.pishguy.signalpresentationproject/ir.pishguy. signalpresentationproject.Activities.ActivityMain}: android.view.InflateException: Binary XML file line #147: Binary XML file line #147: You must supply a layout_width attribute. my all widgets have `layout_width` but i dont know why i get this error <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent"> xmlns:android="http://schemas.android.com/apk/res/android"/> <android.support.design.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ffffff" android:orientation="vertical"> <!--<android.support.v4.widget.SwipeRefreshLayout--> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="65dp" android:background="@color/signal_toolbar_color" android:titleTextColor="#ffffff"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <com.joanzapata.iconify.widget.IconTextView android:id="@+id/signal_robot" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginLeft="10dp" android:clickable="true" android:gravity="center|right" android:shadowColor="#22000000" android:shadowDx="3" android:shadowDy="3" android:shadowRadius="1" android:text="{fa-android}" android:textColor="@color/quote" android:textSize="25sp"/> <com.joanzapata.iconify.widget.IconTextView android:id="@+id/search_icon" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginLeft="10dp" android:layout_marginRight="10dp" android:gravity="center|right" android:shadowColor="#22000000" android:shadowDx="3" android:shadowDy="3" android:shadowRadius="1" android:text="{fa-search}" android:textColor="#ffffff" android:textSize="25sp"/> <com.gigamole.library.ntb.NavigationTabBar android:id="@+id/navigationTabBar" android:layout_width="150dp" android:layout_height="30dp" android:layout_gravity="center_vertical|left" android:background="@drawable/bg_round_circle" app:ntb_active_color="#4527A0" app:ntb_animation_duration="150" app:ntb_corners_radius="50dp" app:ntb_inactive_color="#dddfec" app:ntb_preview_colors="@array/red_wine"/> <TextView android:id="@+id/activity_market_robot_title" android:layout_width="0dp" android:layout_height="match_parent" android:layout_marginRight="10dp" android:layout_weight="1" android:gravity="center|right" android:text="@string/app_name" android:textColor="#ffffff" android:textSize="18sp"/> </LinearLayout> </android.support.v7.widget.Toolbar> </android.support.design.widget.AppBarLayout> <!-- android.support.v4.widget.NestedScrollView --> <android.support.v4.view.ViewPager android:id="@+id/vp_horizontal_ntb" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" app:layout_behavior="@string/appbar_scrolling_view_behavior"/> </LinearLayout> <android.support.design.widget.FloatingActionButton android:id="@+id/activity_main_fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="end|bottom" android:layout_margin="20dp" android:clickable="true" android:src="@drawable/ic_add_circle_outline" android:tint="@color/white" android:visibility="gone" app:backgroundTint="@color/signal_secondary_color" app:layout_behavior="ir.pishguy.signalpresentationproject.Configurations.ScrollAwareFABBehavior"/> <ir.pishguy.signalpresentationproject.Widgets.CircularRevealView android:id="@+id/market_item_reveal" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/transparent"/> </android.support.design.widget.CoordinatorLayout> <com.lapism.searchview.SearchView android:id="@+id/searchView" android:layout_width="match_parent" android:layout_height="match_parent"/> </FrameLayout>
0debug
def harmonic_sum(n): if n < 2: return 1 else: return 1 / n + (harmonic_sum(n - 1))
0debug
def maximum(a,b): if a >= b: return a else: return b
0debug
after changing the date format it is not getting reflected in the table : [enter image description here][1] [1]: http://i.stack.imgur.com/uItaU.png why can i see the change in the table???
0debug
static void qemu_chr_parse_common(QemuOpts *opts, ChardevCommon *backend) { const char *logfile = qemu_opt_get(opts, "logfile"); backend->has_logfile = logfile != NULL; backend->logfile = logfile ? g_strdup(logfile) : NULL; backend->has_logappend = true; backend->logappend = qemu_opt_get_bool(opts, "logappend", false); }
1threat
Issue in converting Python code to Pyspark : Hello I have written python code which I need to convert to PySpark, But I am new to PySpark. I am trying to convert my Python code to PySpark but getting syntax error. Can someone assist me here for PySpark. Below is my Python code. import datetime import time import warnings warnings.filterwarnings('ignore') data = data_pit.copy(deep=True) # Begin preprocessing # Capture time metrics to support tuning start_time = time.time() # Enrich data with L2 Function and Source columns for deeper analysis ''' pivoted = data.groupby([data.index, 'OrgUnit_Function_L2_NEWCO'], as_index=True)['Shortname'].count().unstack() data = pd.concat([data, pivoted], axis=1) pivoted = data.groupby([data.index, 'Source'], as_index=True)['Shortname'].count().unstack() data = pd.concat([data, pivoted], axis=1) ''' data ['X_Work_Location_City'] = data['Work_Location_City']+data['work_location_state_desc'].fillna('') # Consolidate status for reference purposes data['Current Status'] = 'Involuntary Term.' data.loc[(data['Termination_Action']=='Voluntary'), 'Current Status'] = 'Voluntary Term.' data.loc[(data['Employee_Status_Alt'].isin(['Active','Inactive'])), 'Current Status'] = 'Active' data['target'] = data['Current Status'] # Remove all with Unknown status #data = data[(data['target']=='Active') | (data['target']=='Involuntary Term.') | (data['target']=='Voluntary Term.')] columns_for_scaler = list(set(data.columns.values)-\ set(['Shortname','Current Status','PIT_Date','target',\ 'Termination_Date','employee_id'])) # Normalize columns to categories and normal distribution from sklearn.preprocessing import MinMaxScaler import datetime as dt scaler = MinMaxScaler(feature_range=(0, 1)) for column in columns_for_scaler: # 2018-01-10 begin print(column+' '+str(data[column].dtype)) if str(data[column].dtype) == 'datetime64[ns]': data[column] = pd.to_datetime(data[column], errors='coerce').astype('int64') # Convert all remaining columns to Categorical data[column] = pd.Categorical(data[column]) data[column] = data[column].cat.codes # 2018-01-10 end # Scale All values data[column].fillna(value=0,inplace =True) col_values = data[column].values.reshape(data.shape[0], 1) data[column] = scaler.fit_transform(col_values) print('Data scaling successfully applied. Time: '+str(datetime.timedelta(seconds=(time.time() - start_time)))[:-7]) data_scaled = data.copy(deep=True) pd.options.display.float_format = '{:.4f}'.format Thanks in advance for your prompt assistance.
0debug
PyTorch custom loss function : <p>How should a custom loss function be implemented ? Using below code is causing error : </p> <pre><code>import torch import torch.nn as nn import torchvision import torchvision.transforms as transforms import numpy as np import matplotlib.pyplot as plt import torch.utils.data as data_utils import torch.nn as nn import torch.nn.functional as F num_epochs = 20 x1 = np.array([0,0]) x2 = np.array([0,1]) x3 = np.array([1,0]) x4 = np.array([1,1]) num_epochs = 200 class cus2(torch.nn.Module): def __init__(self): super(cus2,self).__init__() def forward(self, outputs, labels): # reshape labels to give a flat vector of length batch_size*seq_len labels = labels.view(-1) # mask out 'PAD' tokens mask = (labels &gt;= 0).float() # the number of tokens is the sum of elements in mask num_tokens = int(torch.sum(mask).data[0]) # pick the values corresponding to labels and multiply by mask outputs = outputs[range(outputs.shape[0]), labels]*mask # cross entropy loss for all non 'PAD' tokens return -torch.sum(outputs)/num_tokens x = torch.tensor([x1,x2,x3,x4]).float() y = torch.tensor([0,1,1,0]).long() train = data_utils.TensorDataset(x,y) train_loader = data_utils.DataLoader(train , batch_size=2 , shuffle=True) device = 'cpu' input_size = 2 hidden_size = 100 num_classes = 2 learning_rate = .0001 class NeuralNet(nn.Module) : def __init__(self, input_size, hidden_size, num_classes) : super(NeuralNet, self).__init__() self.fc1 = nn.Linear(input_size , hidden_size) self.relu = nn.ReLU() self.fc2 = nn.Linear(hidden_size , num_classes) def forward(self, x) : out = self.fc1(x) out = self.relu(out) out = self.fc2(out) return out for i in range(0 , 1) : model = NeuralNet(input_size, hidden_size, num_classes).to(device) criterion = nn.CrossEntropyLoss() # criterion = Regress_Loss() # criterion = cus2() optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate) total_step = len(train_loader) for epoch in range(num_epochs) : for i,(images , labels) in enumerate(train_loader) : images = images.reshape(-1 , 2).to(device) labels = labels.to(device) outputs = model(images) loss = criterion(outputs , labels) optimizer.zero_grad() loss.backward() optimizer.step() # print(loss) outputs = model(x) print(outputs.data.max(1)[1]) </code></pre> <p>makes perfect predictions on training data : </p> <pre><code>tensor([0, 1, 1, 0]) </code></pre> <p>Using a custom loss function from <a href="https://cs230-stanford.github.io/pytorch-nlp.html#writing-a-custom-loss-function" rel="noreferrer">https://cs230-stanford.github.io/pytorch-nlp.html#writing-a-custom-loss-function</a> : </p> <p><a href="https://i.stack.imgur.com/Eh3bZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Eh3bZ.png" alt="enter image description here"></a></p> <p>is implemented in above code as <code>cus2</code></p> <p>Un-commenting code <code># criterion = cus2()</code> to use this loss function returns : </p> <pre><code>tensor([0, 0, 0, 0]) </code></pre> <p>A warning is also returned : </p> <blockquote> <p>UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python number</p> </blockquote> <p>I've not implemented the custom loss function correctly ?</p>
0debug
UITableViewController - image background : <p>i have UITableViewController, and I'm trying to set a image background. the issue is the background image does not fit the whole screen, in other words, the image background <strong>does not</strong> stretch with the table cells. this my code</p> <pre><code> let imgView = UIImageView(frame: self.tableView.frame) let img = UIImage(named: "b2") imgView.image = img imgView.frame = CGRectMake(0, 0, self.tableView.frame.width, self.tableView.frame.height) imgView.contentMode = UIViewContentMode.ScaleAspectFill self.tableView.addSubview(imgView) self.tableView.sendSubviewToBack(imgView) </code></pre> <p><a href="https://i.stack.imgur.com/XxUrk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XxUrk.png" alt="enter image description here"></a></p>
0debug
static void xen_platform_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, unsigned int size) { PCIXenPlatformState *s = opaque; PCIDevice *pci_dev = PCI_DEVICE(s); switch (addr) { case 0: platform_fixed_ioport_writeb(opaque, 0, (uint32_t)val); break; case 4: if (val == 1) { pci_unplug_disks(pci_dev->bus); pci_unplug_nics(pci_dev->bus); } break; case 8: switch (val) { case 1: pci_unplug_disks(pci_dev->bus); break; case 2: pci_unplug_nics(pci_dev->bus); break; default: log_writeb(s, (uint32_t)val); break; } break; default: break; } }
1threat
Muted autoplay videos stop playing in Safari 11.0 : <p>I have these videos on my site with attributes listed below:</p> <pre><code>&lt;video width="100%" poster="poster_url.png" autoplay loop muted playsinline&gt; &lt;source src="video_url.mp4" type="video/mp4"&gt; &lt;/video&gt; </code></pre> <p>Everything worked just fine until I’ve installed Safari 11. This version shows poster images and does not autoplay videos even though they don't have an audio track. Take a look at it on my <a href="http://www.grabelnikov.com/#plentiful" rel="noreferrer">site</a>.</p> <p>I saw autoplay videos working <a href="http://www.elirousso.com/" rel="noreferrer">on other sites</a> (even without muted property) on my own laptop in Safari.</p> <p>Any help would be greatly appreciated!</p>
0debug
Using if statement to turn to a line in code? Java : <p>I have program that asks for user to "wanna try again" .. So I can write the code again for them to use over an over or is there a things for code to start over from a chosen line.??</p>
0debug
What's the mean of "?ac_id=2" in url? : <p>For example there is a url <code>http://***.***.***.**/srun_portal_pc_us.php?ac_id=2&amp;</code>, what is the mean of "?ac_id=2" in this url?</p>
0debug
static void opt_output_file(void *optctx, const char *filename) { OptionsContext *o = optctx; AVFormatContext *oc; int i, err; AVOutputFormat *file_oformat; OutputStream *ost; InputStream *ist; if (!strcmp(filename, "-")) filename = "pipe:"; err = avformat_alloc_output_context2(&oc, NULL, o->format, filename); if (!oc) { print_error(filename, err); exit_program(1); } file_oformat= oc->oformat; oc->interrupt_callback = int_cb; if (!strcmp(file_oformat->name, "ffm") && av_strstart(filename, "http:", NULL)) { int j; int err = read_ffserver_streams(o, oc, filename); if (err < 0) { print_error(filename, err); exit_program(1); } for(j = nb_output_streams - oc->nb_streams; j < nb_output_streams; j++) { ost = &output_streams[j]; for (i = 0; i < nb_input_streams; i++) { ist = &input_streams[i]; if(ist->st->codec->codec_type == ost->st->codec->codec_type){ ost->sync_ist= ist; ost->source_index= i; ist->discard = 0; break; } } if(!ost->sync_ist){ av_log(NULL, AV_LOG_FATAL, "Missing %s stream which is required by this ffm\n", av_get_media_type_string(ost->st->codec->codec_type)); exit_program(1); } } } else if (!o->nb_stream_maps) { #define NEW_STREAM(type, index)\ if (index >= 0) {\ ost = new_ ## type ## _stream(o, oc);\ ost->source_index = index;\ ost->sync_ist = &input_streams[index];\ input_streams[index].discard = 0;\ } if (!o->video_disable && oc->oformat->video_codec != CODEC_ID_NONE) { int area = 0, idx = -1; for (i = 0; i < nb_input_streams; i++) { ist = &input_streams[i]; if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ist->st->codec->width * ist->st->codec->height > area) { area = ist->st->codec->width * ist->st->codec->height; idx = i; } } NEW_STREAM(video, idx); } if (!o->audio_disable && oc->oformat->audio_codec != CODEC_ID_NONE) { int channels = 0, idx = -1; for (i = 0; i < nb_input_streams; i++) { ist = &input_streams[i]; if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO && ist->st->codec->channels > channels) { channels = ist->st->codec->channels; idx = i; } } NEW_STREAM(audio, idx); } if (!o->subtitle_disable && (oc->oformat->subtitle_codec != CODEC_ID_NONE || subtitle_codec_name)) { for (i = 0; i < nb_input_streams; i++) if (input_streams[i].st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) { NEW_STREAM(subtitle, i); break; } } } else { for (i = 0; i < o->nb_stream_maps; i++) { StreamMap *map = &o->stream_maps[i]; if (map->disabled) continue; ist = &input_streams[input_files[map->file_index].ist_index + map->stream_index]; if(o->subtitle_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) continue; if(o-> audio_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) continue; if(o-> video_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO) continue; if(o-> data_disable && ist->st->codec->codec_type == AVMEDIA_TYPE_DATA) continue; switch (ist->st->codec->codec_type) { case AVMEDIA_TYPE_VIDEO: ost = new_video_stream(o, oc); break; case AVMEDIA_TYPE_AUDIO: ost = new_audio_stream(o, oc); break; case AVMEDIA_TYPE_SUBTITLE: ost = new_subtitle_stream(o, oc); break; case AVMEDIA_TYPE_DATA: ost = new_data_stream(o, oc); break; case AVMEDIA_TYPE_ATTACHMENT: ost = new_attachment_stream(o, oc); break; default: av_log(NULL, AV_LOG_FATAL, "Cannot map stream #%d:%d - unsupported type.\n", map->file_index, map->stream_index); exit_program(1); } ost->source_index = input_files[map->file_index].ist_index + map->stream_index; ost->sync_ist = &input_streams[input_files[map->sync_file_index].ist_index + map->sync_stream_index]; ist->discard = 0; } } for (i = 0; i < o->nb_attachments; i++) { AVIOContext *pb; uint8_t *attachment; const char *p; int64_t len; if ((err = avio_open2(&pb, o->attachments[i], AVIO_FLAG_READ, &int_cb, NULL)) < 0) { av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n", o->attachments[i]); exit_program(1); } if ((len = avio_size(pb)) <= 0) { av_log(NULL, AV_LOG_FATAL, "Could not get size of the attachment %s.\n", o->attachments[i]); exit_program(1); } if (!(attachment = av_malloc(len))) { av_log(NULL, AV_LOG_FATAL, "Attachment %s too large to fit into memory.\n", o->attachments[i]); exit_program(1); } avio_read(pb, attachment, len); ost = new_attachment_stream(o, oc); ost->stream_copy = 0; ost->source_index = -1; ost->attachment_filename = o->attachments[i]; ost->st->codec->extradata = attachment; ost->st->codec->extradata_size = len; p = strrchr(o->attachments[i], '/'); av_dict_set(&ost->st->metadata, "filename", (p && *p) ? p + 1 : o->attachments[i], AV_DICT_DONT_OVERWRITE); avio_close(pb); } output_files = grow_array(output_files, sizeof(*output_files), &nb_output_files, nb_output_files + 1); output_files[nb_output_files - 1].ctx = oc; output_files[nb_output_files - 1].ost_index = nb_output_streams - oc->nb_streams; output_files[nb_output_files - 1].recording_time = o->recording_time; output_files[nb_output_files - 1].start_time = o->start_time; output_files[nb_output_files - 1].limit_filesize = o->limit_filesize; av_dict_copy(&output_files[nb_output_files - 1].opts, format_opts, 0); if (oc->oformat->flags & AVFMT_NEEDNUMBER) { if (!av_filename_number_test(oc->filename)) { print_error(oc->filename, AVERROR(EINVAL)); exit_program(1); } } if (!(oc->oformat->flags & AVFMT_NOFILE)) { assert_file_overwrite(filename); if ((err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE, &oc->interrupt_callback, &output_files[nb_output_files - 1].opts)) < 0) { print_error(filename, err); exit_program(1); } } if (o->mux_preload) { uint8_t buf[64]; snprintf(buf, sizeof(buf), "%d", (int)(o->mux_preload*AV_TIME_BASE)); av_dict_set(&output_files[nb_output_files - 1].opts, "preload", buf, 0); } oc->max_delay = (int)(o->mux_max_delay * AV_TIME_BASE); if (loop_output >= 0) { av_log(NULL, AV_LOG_WARNING, "-loop_output is deprecated, use -loop\n"); oc->loop_output = loop_output; } for (i = 0; i < o->nb_metadata_map; i++) { char *p; int in_file_index = strtol(o->metadata_map[i].u.str, &p, 0); if (in_file_index < 0) continue; if (in_file_index >= nb_input_files) { av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d while processing metadata maps\n", in_file_index); exit_program(1); } copy_metadata(o->metadata_map[i].specifier, *p ? p + 1 : p, oc, input_files[in_file_index].ctx, o); } if (o->chapters_input_file >= nb_input_files) { if (o->chapters_input_file == INT_MAX) { o->chapters_input_file = -1; for (i = 0; i < nb_input_files; i++) if (input_files[i].ctx->nb_chapters) { o->chapters_input_file = i; break; } } else { av_log(NULL, AV_LOG_FATAL, "Invalid input file index %d in chapter mapping.\n", o->chapters_input_file); exit_program(1); } } if (o->chapters_input_file >= 0) copy_chapters(&input_files[o->chapters_input_file], &output_files[nb_output_files - 1], !o->metadata_chapters_manual); if (!o->metadata_global_manual && nb_input_files){ av_dict_copy(&oc->metadata, input_files[0].ctx->metadata, AV_DICT_DONT_OVERWRITE); if(o->recording_time != INT64_MAX) av_dict_set(&oc->metadata, "duration", NULL, 0); } if (!o->metadata_streams_manual) for (i = output_files[nb_output_files - 1].ost_index; i < nb_output_streams; i++) { InputStream *ist; if (output_streams[i].source_index < 0) continue; ist = &input_streams[output_streams[i].source_index]; av_dict_copy(&output_streams[i].st->metadata, ist->st->metadata, AV_DICT_DONT_OVERWRITE); } for (i = 0; i < o->nb_metadata; i++) { AVDictionary **m; char type, *val; const char *stream_spec; int index = 0, j, ret; val = strchr(o->metadata[i].u.str, '='); if (!val) { av_log(NULL, AV_LOG_FATAL, "No '=' character in metadata string %s.\n", o->metadata[i].u.str); exit_program(1); } *val++ = 0; parse_meta_type(o->metadata[i].specifier, &type, &index, &stream_spec); if (type == 's') { for (j = 0; j < oc->nb_streams; j++) { if ((ret = check_stream_specifier(oc, oc->streams[j], stream_spec)) > 0) { av_dict_set(&oc->streams[j]->metadata, o->metadata[i].u.str, *val ? val : NULL, 0); } else if (ret < 0) exit_program(1); } printf("ret %d, stream_spec %s\n", ret, stream_spec); } else { switch (type) { case 'g': m = &oc->metadata; break; case 'c': if (index < 0 || index >= oc->nb_chapters) { av_log(NULL, AV_LOG_FATAL, "Invalid chapter index %d in metadata specifier.\n", index); exit_program(1); } m = &oc->chapters[index]->metadata; break; default: av_log(NULL, AV_LOG_FATAL, "Invalid metadata specifier %s.\n", o->metadata[i].specifier); exit_program(1); } av_dict_set(m, o->metadata[i].u.str, *val ? val : NULL, 0); } } reset_options(o, 0); }
1threat
SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c) { int cpu_flags = av_get_cpu_flags(); if (c->srcFormat != PIX_FMT_YUV420P && c->srcFormat != PIX_FMT_YUVA420P) return NULL; if (HAVE_MMX2 && cpu_flags & AV_CPU_FLAG_MMX2) { switch (c->dstFormat) { case PIX_FMT_RGB24: return yuv420_rgb24_MMX2; case PIX_FMT_BGR24: return yuv420_bgr24_MMX2; } } if (HAVE_MMX && cpu_flags & AV_CPU_FLAG_MMX) { switch (c->dstFormat) { case PIX_FMT_RGB32: if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) { #if HAVE_7REGS return yuva420_rgb32_MMX; #endif break; } else return yuv420_rgb32_MMX; case PIX_FMT_BGR32: if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) { #if HAVE_7REGS return yuva420_bgr32_MMX; #endif break; } else return yuv420_bgr32_MMX; case PIX_FMT_RGB24: return yuv420_rgb24_MMX; case PIX_FMT_BGR24: return yuv420_bgr24_MMX; case PIX_FMT_RGB565: return yuv420_rgb16_MMX; case PIX_FMT_RGB555: return yuv420_rgb15_MMX; } } return NULL; }
1threat
How would improve this O(n^2 ) string manipulation solution? : Write a function that takes in an input of a string and returns the count of tuples. Tuples in the form (x,y) where x = index of 'a', y = index of 'b' and x < y. Examples: For “aab” the answer is two For "ababab" the answer is six It can be done in O(n^2) by simply looking for the number of b's after each 'a' but I'm not sure how to do it in O(n). I've tried traversing the string with 2 pointers but I keep missing some tuples. I'm not sure if this can be done in O(n) time.
0debug
Automatic exploitation via Return Oritented Programming : I need help understanding what is going on in this image [image][1]. [1]: http://i.stack.imgur.com/dC3NC.png What I fail to see is what the `@ .data` instructions accomplish in combination with the `mov dword ptr [edx], eax`, especially considered that edx is popped right after. Thanks in advance!
0debug
static SpiceChannelList *qmp_query_spice_channels(void) { SpiceChannelList *cur_item = NULL, *head = NULL; ChannelList *item; QTAILQ_FOREACH(item, &channel_list, link) { SpiceChannelList *chan; char host[NI_MAXHOST], port[NI_MAXSERV]; struct sockaddr *paddr; socklen_t plen; assert(item->info->flags & SPICE_CHANNEL_EVENT_FLAG_ADDR_EXT); chan = g_malloc0(sizeof(*chan)); chan->value = g_malloc0(sizeof(*chan->value)); chan->value->base = g_malloc0(sizeof(*chan->value->base)); paddr = (struct sockaddr *)&item->info->paddr_ext; plen = item->info->plen_ext; getnameinfo(paddr, plen, host, sizeof(host), port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV); chan->value->base->host = g_strdup(host); chan->value->base->port = g_strdup(port); chan->value->base->family = inet_netfamily(paddr->sa_family); chan->value->connection_id = item->info->connection_id; chan->value->channel_type = item->info->type; chan->value->channel_id = item->info->id; chan->value->tls = item->info->flags & SPICE_CHANNEL_EVENT_FLAG_TLS; if (!cur_item) { head = cur_item = chan; } else { cur_item->next = chan; cur_item = chan; } } return head; }
1threat
C# How to call an async method from another method : Am having a difficult time calling an async method from my current method. Trying to do something like this: int i; public void Method1() { while (statement1) { ~code~ Method2(i); } while (statement2) { ~code~ Method2(i); } } public async void Method2(int i) { if(statement){ ~code~ await Task.Delay(2000); } else { ~code~ await Task.Delay(2000); } } So i want basically Method2 to be a method for controlling the flow(uses another method which changes pictures in pictureboxes), but i cant get it to work and when it works it never delays anything.. Does anyone know what am doing wrong? Method2 changes Method1's while statements eventually.
0debug
Why is there no output in the console while accessing the database using java in eclipse? Database connection - java - Eclipse : This is the first time i'm using eclipse and i was trying to create a connection to the database using java.I did the procedure step by step and finally when i clicked on run there was no output in the console. What am i doing wrong? [enter image description here][1] [1]: https://i.stack.imgur.com/iY8eV.png
0debug
Remove word that ends with a period : <p>I'm trying to use regex to remove a word that ends with a period.</p> <p>I want to only remove <code>Ep.</code> as a whole word, but not if it's part of another word.</p> <p>Also I will use <code>RegexOptions.IgnoreCase</code>.</p> <hr> <blockquote> <p>This Ep. is 01. TestEp.01Test.</p> </blockquote> <p>Should be:</p> <blockquote> <p>This is 01. TestEp.01Test.</p> </blockquote> <hr> <p>I thought it should be <code>\b(Ep\.)\b</code> but it doesn't work.</p> <p><a href="https://regex101.com/r/QcOiMR/2/" rel="nofollow noreferrer">https://regex101.com/r/QcOiMR/2/</a></p> <hr> <p>I have tried <a href="https://stackoverflow.com/a/5696940/6806643">https://stackoverflow.com/a/5696940/6806643</a></p>
0debug
We want to build a tokenizer for simple expressions such as xpr = "res = 3 + x_sum*11" : We want to build a tokenizer for simple expressions such as xpr = "res = 3 + x_sum*11". Such expressions comprise only three tokens, as follows: (1) Integer literals: one or more digits e.g., 3 11; (2) Identifiers: strings starting with a letter or an underscore and followed by more letters, digits, or underscores e.g., res x_sum; (3) Operators: = + * . Leading or trailing whitespace characters should be skipped. (c) To find which token each lexeme is associated with, we only need to find the first non-empty item in each tuple. Write a tokenize generator (using re.findall and map) that returns all pairs (tuples) of lexemes and tokens. The output of list(tokenize(xpr)) should thus be: [('res', 'id'), ('=', 'op'), ('3', 'int'), ('+', 'op'), ('x_sum', 'id'), ('*', 'op'), ('11', 'int')]
0debug
removed duplicate print python : How can i removed duplicate i just want to remove issue_assign duplicate and go to the nextline. The output should be like this. issue_assign def assigne(username): responses = fetch(server + Ticket_Week + ' and assignee='+ username) duplicate = [] object = {} for issue in responses['issues']: issue_fields = issue['fields'] issue_status = issue_fields['status'] issue_reporter = issue_fields['reporter']['displayName'] issue_created = issue_fields['created'] issue_updated = issue_fields['updated'] issue_assign = 'Unassigned' issue_resolution = 'Unresolved' issue_due = 'null' issue_serviceteam = 'null' issue_createdate = datetime.datetime.strptime(issue_created[:-5], '%Y-%m-%dT%H:%M:%S.%f').strftime("%m/%d/%y") issue_updatedate = datetime.datetime.strptime(issue_updated[:-5], '%Y-%m-%dT%H:%M:%S.%f').strftime("%m/%d/%y") if issue_fields['assignee']: issue_assign = issue_fields['assignee']['displayName'] if issue_fields['resolution']: issue_resolution = issue_fields['resolution']['name'] if issue_fields.get('duedate', None): issue_due = issue_fields['duedate'] if issue_fields.get('customfield_10506', None): issue_serviceteam = issue_fields['customfield_10506']['name'] print(issue_assign) print(issue['key'], issue_fields['summary'], issue_reporter, issue_status['name'], issue_resolution, issue_createdate, issue_updatedate, issue_due, issue_serviceteam) **Assign** Key, Summary , Reporter , Name , Resolution , Createdate , UpdateDate , Due , Team Assign Key, Summary , Reporter , Name , Resolution , Createdate , UpdateDate , Due , Team **Assign** Key, Summary , Reporter , Name , Resolution , Createdate , UpdateDate , Due , Team **Assign** Key, Summary , Reporter , Name , Resolution , Createdate , UpdateDate , Due , Team **I want the output to be like this.** **Assign** Key, Summary , Reporter , Name , Resolution , Createdate , UpdateDate , Due ,Team Key, Summary , Reporter , Name , Resolution , Createdate , UpdateDate , Due , Team Key, Summary , Reporter , Name , Resolution , Createdate , UpdateDate , Due , Team Key, Summary , Reporter , Name , Resolution , Createdate , UpdateDate , Due , Team Key, Summary , Reporter , Name , Resolution , Createdate , UpdateDate , Due , Team
0debug
index out of range error in java : <p>I am trying to find the max value of a 2D array in java.</p> <pre><code> import java.util.*; public class ikiBoyutlu { public static void ikiBoyut(int[][]a){ int eb= a[0][0]; for(int i=0;i&lt;a.length;i++){ for(int j=0; j&lt;(a[0].length);j++){ if(a[i][j]&gt;eb){ eb=a[i][j]; } } } System.out.println("The max value of array= "+ eb); } public static void main(String[] args){ int a[][] ={{2,5,7,0,-6,28,43},{-96,45,3,21}}; ikiBoyut(a); } } </code></pre> <p>But I get index out of range error. I wonder why?</p> <p>Thanks!</p>
0debug
How to replace a string with linebreaks in Jinja2 : <p>I have some data in jinja2 like this </p> <pre><code>'item1|item2|item3' </code></pre> <p>And I want to turn it into rendered linebreaks. However, when I replace it with br/ tags, I get the br tags rendered on the page. So</p> <pre><code>{{ 'item1|item2|item3' | replace("|", "&lt;br/&gt;") }} </code></pre> <p>renders as</p> <pre><code>item1&lt;br/&gt;item2&lt;br/&gt;item3&lt;br/&gt; </code></pre> <p>When I want</p> <pre><code>item1 item2 item3 </code></pre> <p>on my page. I feel like I'm missing some obvious trick here...</p>
0debug
Sorting top three using mysql/php : <p>I want to get the three entities with highest value from my database, sort them and place them in each their div's just like a scoreboard with the top three. I will also be able to separate the fields (id, name, description etc.) and retrieve those by using for example:</p> <pre><code>&lt;?php echo $sql['id']; ?&gt; </code></pre> <p>I already know the code to retrieve the info and sort it:</p> <pre><code>$sql = ("SELECT * FROM table ORDER BY tablefield DESC LIMIT 3"); </code></pre> <p>But I don't know how to place the three entities into each their div's and separate the entity's fields like name, description etc.</p>
0debug
void ff_g729_postfilter(DSPContext *dsp, int16_t* ht_prev_data, int* voicing, const int16_t *lp_filter_coeffs, int pitch_delay_int, int16_t* residual, int16_t* res_filter_data, int16_t* pos_filter_data, int16_t *speech, int subframe_size) { int16_t residual_filt_buf[SUBFRAME_SIZE+10]; int16_t lp_gn[33]; int16_t lp_gd[11]; int tilt_comp_coeff; int i; memset(lp_gn, 0, 33 * sizeof(int16_t)); for (i = 0; i < 10; i++) lp_gn[i + 11] = (lp_filter_coeffs[i + 1] * formant_pp_factor_num_pow[i] + 0x4000) >> 15; for (i = 0; i < 10; i++) lp_gd[i + 1] = (lp_filter_coeffs[i + 1] * formant_pp_factor_den_pow[i] + 0x4000) >> 15; memcpy(speech - 10, res_filter_data, 10 * sizeof(int16_t)); residual_filter(residual + RES_PREV_DATA_SIZE, lp_gn + 11, speech, subframe_size); memcpy(res_filter_data, speech + subframe_size - 10, 10 * sizeof(int16_t)); *voicing = FFMAX(*voicing, long_term_filter(dsp, pitch_delay_int, residual, residual_filt_buf + 10, subframe_size)); memmove(residual, residual + subframe_size, RES_PREV_DATA_SIZE * sizeof(int16_t)); tilt_comp_coeff = get_tilt_comp(dsp, lp_gn, lp_gd, residual_filt_buf + 10, subframe_size); ff_celp_lp_synthesis_filter(pos_filter_data + 10, lp_gd + 1, residual_filt_buf + 10, subframe_size, 10, 0, 0, 0x800); memcpy(pos_filter_data, pos_filter_data + subframe_size, 10 * sizeof(int16_t)); *ht_prev_data = apply_tilt_comp(speech, pos_filter_data + 10, tilt_comp_coeff, subframe_size, *ht_prev_data); }
1threat
How to dynamically hide a menu item in BottomNavigationView? : <p>I want to hide a menu item of BottomNavigationView dynamically based on some conditions. I tried the following but it is not working.</p> <pre><code>mBottomNavigationView.getMenu() .findItem(R.id.item_name) .setVisible(false); mBottomNavigationView.invalidate(); </code></pre>
0debug
I'm trying to compare 2 variables with my enum's type : <p>I created an Enum wearState and then gave wearState as a type for two variables. But when I try to put them in a if condition with '||' or '&amp;&amp;', it doesn't work. It says : "error : bad operand types for binary operator '||' "</p> <pre><code>enum wearState { WRIST_MOVE, WRIST_IMMOBILE, BELT_NECK_MOVE, BELT_NECK_IMMOBILE, OTHER_IMMOBILE_STATE; } enum chargingState { YES, NO, } wearState lastState; wearState currentState; chargingState lastStateCharging; chargingState currentStateCharging; if (((currentState = wearState.BELT_NECK_IMMOBILE) || (currentState = wearState.WRIST_IMMOBILE)) &amp;&amp; (lastStateCharging = chargingState.NO)) { /* .... */ } </code></pre>
0debug
static inline void kqemu_load_seg(struct kqemu_segment_cache *ksc, const SegmentCache *sc) { ksc->selector = sc->selector; ksc->flags = sc->flags; ksc->limit = sc->limit; ksc->base = sc->base; }
1threat
size_t qemu_file_set_rate_limit(QEMUFile *f, size_t new_rate) { if (f->set_rate_limit) return f->set_rate_limit(f->opaque, new_rate); return 0; }
1threat
void ide_exec_cmd(IDEBus *bus, uint32_t val) { uint16_t *identify_data; IDEState *s; int n; int lba48 = 0; #if defined(DEBUG_IDE) printf("ide: CMD=%02x\n", val); #endif s = idebus_active_if(bus); if (s != bus->ifs && !s->bs) return; if ((s->status & (BUSY_STAT|DRQ_STAT)) && val != WIN_DEVICE_RESET) return; if (!ide_cmd_permitted(s, val)) { goto abort_cmd; } if (ide_cmd_table[val].handler != NULL) { bool complete; s->status = READY_STAT | BUSY_STAT; s->error = 0; complete = ide_cmd_table[val].handler(s, val); if (complete) { s->status &= ~BUSY_STAT; assert(!!s->error == !!(s->status & ERR_STAT)); if ((ide_cmd_table[val].flags & SET_DSC) && !s->error) { s->status |= SEEK_STAT; } ide_set_irq(s->bus); } return; } switch(val) { case WIN_SETMULT: if (s->drive_kind == IDE_CFATA && s->nsector == 0) { s->mult_sectors = 0; s->status = READY_STAT | SEEK_STAT; } else if ((s->nsector & 0xff) != 0 && ((s->nsector & 0xff) > MAX_MULT_SECTORS || (s->nsector & (s->nsector - 1)) != 0)) { ide_abort_command(s); } else { s->mult_sectors = s->nsector & 0xff; s->status = READY_STAT | SEEK_STAT; } ide_set_irq(s->bus); break; case WIN_VERIFY_EXT: lba48 = 1; case WIN_VERIFY: case WIN_VERIFY_ONCE: ide_cmd_lba48_transform(s, lba48); s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; case WIN_READ_EXT: lba48 = 1; case WIN_READ: case WIN_READ_ONCE: if (s->drive_kind == IDE_CD) { ide_set_signature(s); goto abort_cmd; } if (!s->bs) { goto abort_cmd; } ide_cmd_lba48_transform(s, lba48); s->req_nb_sectors = 1; ide_sector_read(s); break; case WIN_WRITE_EXT: lba48 = 1; case WIN_WRITE: case WIN_WRITE_ONCE: case CFA_WRITE_SECT_WO_ERASE: case WIN_WRITE_VERIFY: if (!s->bs) { goto abort_cmd; } ide_cmd_lba48_transform(s, lba48); s->error = 0; s->status = SEEK_STAT | READY_STAT; s->req_nb_sectors = 1; ide_transfer_start(s, s->io_buffer, 512, ide_sector_write); s->media_changed = 1; break; case WIN_MULTREAD_EXT: lba48 = 1; case WIN_MULTREAD: if (!s->bs) { goto abort_cmd; } if (!s->mult_sectors) { goto abort_cmd; } ide_cmd_lba48_transform(s, lba48); s->req_nb_sectors = s->mult_sectors; ide_sector_read(s); break; case WIN_MULTWRITE_EXT: lba48 = 1; case WIN_MULTWRITE: case CFA_WRITE_MULTI_WO_ERASE: if (!s->bs) { goto abort_cmd; } if (!s->mult_sectors) { goto abort_cmd; } ide_cmd_lba48_transform(s, lba48); s->error = 0; s->status = SEEK_STAT | READY_STAT; s->req_nb_sectors = s->mult_sectors; n = s->nsector; if (n > s->req_nb_sectors) n = s->req_nb_sectors; ide_transfer_start(s, s->io_buffer, 512 * n, ide_sector_write); s->media_changed = 1; break; case WIN_READDMA_EXT: lba48 = 1; case WIN_READDMA: case WIN_READDMA_ONCE: if (!s->bs) { goto abort_cmd; } ide_cmd_lba48_transform(s, lba48); ide_sector_start_dma(s, IDE_DMA_READ); break; case WIN_WRITEDMA_EXT: lba48 = 1; case WIN_WRITEDMA: case WIN_WRITEDMA_ONCE: if (!s->bs) { goto abort_cmd; } ide_cmd_lba48_transform(s, lba48); ide_sector_start_dma(s, IDE_DMA_WRITE); s->media_changed = 1; break; case WIN_READ_NATIVE_MAX_EXT: lba48 = 1; case WIN_READ_NATIVE_MAX: if (s->nb_sectors == 0) { goto abort_cmd; } ide_cmd_lba48_transform(s, lba48); ide_set_sector(s, s->nb_sectors - 1); s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; case WIN_CHECKPOWERMODE1: case WIN_CHECKPOWERMODE2: s->error = 0; s->nsector = 0xff; s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; case WIN_SETFEATURES: if (!s->bs) goto abort_cmd; switch(s->feature) { case 0x02: bdrv_set_enable_write_cache(s->bs, true); identify_data = (uint16_t *)s->identify_data; put_le16(identify_data + 85, (1 << 14) | (1 << 5) | 1); s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; case 0x82: bdrv_set_enable_write_cache(s->bs, false); identify_data = (uint16_t *)s->identify_data; put_le16(identify_data + 85, (1 << 14) | 1); ide_flush_cache(s); break; case 0xcc: case 0x66: case 0xaa: case 0x55: case 0x05: case 0x85: case 0x69: case 0x67: case 0x96: case 0x9a: case 0x42: case 0xc2: s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; case 0x03: { uint8_t val = s->nsector & 0x07; identify_data = (uint16_t *)s->identify_data; switch (s->nsector >> 3) { case 0x00: case 0x01: put_le16(identify_data + 62,0x07); put_le16(identify_data + 63,0x07); put_le16(identify_data + 88,0x3f); break; case 0x02: put_le16(identify_data + 62,0x07 | (1 << (val + 8))); put_le16(identify_data + 63,0x07); put_le16(identify_data + 88,0x3f); break; case 0x04: put_le16(identify_data + 62,0x07); put_le16(identify_data + 63,0x07 | (1 << (val + 8))); put_le16(identify_data + 88,0x3f); break; case 0x08: put_le16(identify_data + 62,0x07); put_le16(identify_data + 63,0x07); put_le16(identify_data + 88,0x3f | (1 << (val + 8))); break; default: goto abort_cmd; } s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; } default: goto abort_cmd; } break; case WIN_FLUSH_CACHE: case WIN_FLUSH_CACHE_EXT: ide_flush_cache(s); break; case WIN_SEEK: s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; case WIN_PIDENTIFY: ide_atapi_identify(s); s->status = READY_STAT | SEEK_STAT; ide_transfer_start(s, s->io_buffer, 512, ide_transfer_stop); ide_set_irq(s->bus); break; case WIN_DIAGNOSE: ide_set_signature(s); if (s->drive_kind == IDE_CD) s->status = 0; else s->status = READY_STAT | SEEK_STAT; s->error = 0x01; ide_set_irq(s->bus); break; case WIN_DEVICE_RESET: ide_set_signature(s); s->status = 0x00; s->error = 0x01; break; case WIN_PACKETCMD: if (s->feature & 0x02) goto abort_cmd; s->status = READY_STAT | SEEK_STAT; s->atapi_dma = s->feature & 1; s->nsector = 1; ide_transfer_start(s, s->io_buffer, ATAPI_PACKET_SIZE, ide_atapi_cmd); break; case CFA_REQ_EXT_ERROR_CODE: s->error = 0x09; s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; case CFA_ERASE_SECTORS: case CFA_WEAR_LEVEL: #if 0 case WIN_SECURITY_FREEZE_LOCK: #endif if (val == CFA_WEAR_LEVEL) s->nsector = 0; if (val == CFA_ERASE_SECTORS) s->media_changed = 1; s->error = 0x00; s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; case CFA_TRANSLATE_SECTOR: s->error = 0x00; s->status = READY_STAT | SEEK_STAT; memset(s->io_buffer, 0, 0x200); s->io_buffer[0x00] = s->hcyl; s->io_buffer[0x01] = s->lcyl; s->io_buffer[0x02] = s->select; s->io_buffer[0x03] = s->sector; s->io_buffer[0x04] = ide_get_sector(s) >> 16; s->io_buffer[0x05] = ide_get_sector(s) >> 8; s->io_buffer[0x06] = ide_get_sector(s) >> 0; s->io_buffer[0x13] = 0x00; s->io_buffer[0x18] = 0x00; s->io_buffer[0x19] = 0x00; s->io_buffer[0x1a] = 0x01; ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop); ide_set_irq(s->bus); break; case CFA_ACCESS_METADATA_STORAGE: switch (s->feature) { case 0x02: ide_cfata_metadata_inquiry(s); break; case 0x03: ide_cfata_metadata_read(s); break; case 0x04: ide_cfata_metadata_write(s); break; default: goto abort_cmd; } ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop); s->status = 0x00; ide_set_irq(s->bus); break; case IBM_SENSE_CONDITION: switch (s->feature) { case 0x01: s->nsector = 0x50; break; default: goto abort_cmd; } s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; case WIN_SMART: if (s->hcyl != 0xc2 || s->lcyl != 0x4f) goto abort_cmd; if (!s->smart_enabled && s->feature != SMART_ENABLE) goto abort_cmd; switch (s->feature) { case SMART_DISABLE: s->smart_enabled = 0; s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; case SMART_ENABLE: s->smart_enabled = 1; s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; case SMART_ATTR_AUTOSAVE: switch (s->sector) { case 0x00: s->smart_autosave = 0; break; case 0xf1: s->smart_autosave = 1; break; default: goto abort_cmd; } s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; case SMART_STATUS: if (!s->smart_errors) { s->hcyl = 0xc2; s->lcyl = 0x4f; } else { s->hcyl = 0x2c; s->lcyl = 0xf4; } s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; case SMART_READ_THRESH: memset(s->io_buffer, 0, 0x200); s->io_buffer[0] = 0x01; for (n = 0; n < ARRAY_SIZE(smart_attributes); n++) { s->io_buffer[2+0+(n*12)] = smart_attributes[n][0]; s->io_buffer[2+1+(n*12)] = smart_attributes[n][11]; } for (n=0; n<511; n++) s->io_buffer[511] += s->io_buffer[n]; s->io_buffer[511] = 0x100 - s->io_buffer[511]; s->status = READY_STAT | SEEK_STAT; ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop); ide_set_irq(s->bus); break; case SMART_READ_DATA: memset(s->io_buffer, 0, 0x200); s->io_buffer[0] = 0x01; for (n = 0; n < ARRAY_SIZE(smart_attributes); n++) { int i; for(i = 0; i < 11; i++) { s->io_buffer[2+i+(n*12)] = smart_attributes[n][i]; } } s->io_buffer[362] = 0x02 | (s->smart_autosave?0x80:0x00); if (s->smart_selftest_count == 0) { s->io_buffer[363] = 0; } else { s->io_buffer[363] = s->smart_selftest_data[3 + (s->smart_selftest_count - 1) * 24]; } s->io_buffer[364] = 0x20; s->io_buffer[365] = 0x01; s->io_buffer[367] = (1<<4 | 1<<3 | 1); s->io_buffer[368] = 0x03; s->io_buffer[369] = 0x00; s->io_buffer[370] = 0x01; s->io_buffer[372] = 0x02; s->io_buffer[373] = 0x36; s->io_buffer[374] = 0x01; for (n=0; n<511; n++) s->io_buffer[511] += s->io_buffer[n]; s->io_buffer[511] = 0x100 - s->io_buffer[511]; s->status = READY_STAT | SEEK_STAT; ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop); ide_set_irq(s->bus); break; case SMART_READ_LOG: switch (s->sector) { case 0x01: memset(s->io_buffer, 0, 0x200); s->io_buffer[0] = 0x01; s->io_buffer[1] = 0x00; s->io_buffer[452] = s->smart_errors & 0xff; s->io_buffer[453] = (s->smart_errors & 0xff00) >> 8; for (n=0; n<511; n++) s->io_buffer[511] += s->io_buffer[n]; s->io_buffer[511] = 0x100 - s->io_buffer[511]; break; case 0x06: memset(s->io_buffer, 0, 0x200); s->io_buffer[0] = 0x01; if (s->smart_selftest_count == 0) { s->io_buffer[508] = 0; } else { s->io_buffer[508] = s->smart_selftest_count; for (n=2; n<506; n++) s->io_buffer[n] = s->smart_selftest_data[n]; } for (n=0; n<511; n++) s->io_buffer[511] += s->io_buffer[n]; s->io_buffer[511] = 0x100 - s->io_buffer[511]; break; default: goto abort_cmd; } s->status = READY_STAT | SEEK_STAT; ide_transfer_start(s, s->io_buffer, 0x200, ide_transfer_stop); ide_set_irq(s->bus); break; case SMART_EXECUTE_OFFLINE: switch (s->sector) { case 0: case 1: case 2: s->smart_selftest_count++; if(s->smart_selftest_count > 21) s->smart_selftest_count = 0; n = 2 + (s->smart_selftest_count - 1) * 24; s->smart_selftest_data[n] = s->sector; s->smart_selftest_data[n+1] = 0x00; s->smart_selftest_data[n+2] = 0x34; s->smart_selftest_data[n+3] = 0x12; s->status = READY_STAT | SEEK_STAT; ide_set_irq(s->bus); break; default: goto abort_cmd; } break; default: goto abort_cmd; } break; default: abort_cmd: ide_abort_command(s); ide_set_irq(s->bus); break; } }
1threat
static inline int check_input_motion(MpegEncContext * s, int mb_x, int mb_y, int p_type){ MotionEstContext * const c= &s->me; Picture *p= s->current_picture_ptr; int mb_xy= mb_x + mb_y*s->mb_stride; int xy= 2*mb_x + 2*mb_y*s->b8_stride; int mb_type= s->current_picture.mb_type[mb_xy]; int flags= c->flags; int shift= (flags&FLAG_QPEL) + 1; int mask= (1<<shift)-1; int x, y, i; int d=0; me_cmp_func cmpf= s->dsp.sse[0]; me_cmp_func chroma_cmpf= s->dsp.sse[1]; assert(p_type==0 || !USES_LIST(mb_type, 1)); assert(IS_INTRA(mb_type) || USES_LIST(mb_type,0) || USES_LIST(mb_type,1)); if(IS_INTERLACED(mb_type)){ int xy2= xy + s->b8_stride; s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTRA; c->stride<<=1; c->uvstride<<=1; if(!(s->flags & CODEC_FLAG_INTERLACED_ME)){ av_log(c->avctx, AV_LOG_ERROR, "Interlaced macroblock selected but interlaced motion estimation disabled\n"); return -1; } if(USES_LIST(mb_type, 0)){ int field_select0= p->ref_index[0][xy ]; int field_select1= p->ref_index[0][xy2]; assert(field_select0==0 ||field_select0==1); assert(field_select1==0 ||field_select1==1); init_interlaced_ref(s, 0); if(p_type){ s->p_field_select_table[0][mb_xy]= field_select0; s->p_field_select_table[1][mb_xy]= field_select1; *(uint32_t*)s->p_field_mv_table[0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[0][xy ]; *(uint32_t*)s->p_field_mv_table[1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[0][xy2]; s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER_I; }else{ s->b_field_select_table[0][0][mb_xy]= field_select0; s->b_field_select_table[0][1][mb_xy]= field_select1; *(uint32_t*)s->b_field_mv_table[0][0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[0][xy ]; *(uint32_t*)s->b_field_mv_table[0][1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[0][xy2]; s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_FORWARD_I; } x= p->motion_val[0][xy ][0]; y= p->motion_val[0][xy ][1]; d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0, 0, cmpf, chroma_cmpf, flags); x= p->motion_val[0][xy2][0]; y= p->motion_val[0][xy2][1]; d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1, 1, cmpf, chroma_cmpf, flags); } if(USES_LIST(mb_type, 1)){ int field_select0= p->ref_index[1][xy ]; int field_select1= p->ref_index[1][xy2]; assert(field_select0==0 ||field_select0==1); assert(field_select1==0 ||field_select1==1); init_interlaced_ref(s, 2); s->b_field_select_table[1][0][mb_xy]= field_select0; s->b_field_select_table[1][1][mb_xy]= field_select1; *(uint32_t*)s->b_field_mv_table[1][0][field_select0][mb_xy]= *(uint32_t*)p->motion_val[1][xy ]; *(uint32_t*)s->b_field_mv_table[1][1][field_select1][mb_xy]= *(uint32_t*)p->motion_val[1][xy2]; if(USES_LIST(mb_type, 0)){ s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_BIDIR_I; }else{ s->mb_type[mb_xy]= CANDIDATE_MB_TYPE_BACKWARD_I; } x= p->motion_val[1][xy ][0]; y= p->motion_val[1][xy ][1]; d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select0+2, 0, cmpf, chroma_cmpf, flags); x= p->motion_val[1][xy2][0]; y= p->motion_val[1][xy2][1]; d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 8, field_select1+2, 1, cmpf, chroma_cmpf, flags); } c->stride>>=1; c->uvstride>>=1; }else if(IS_8X8(mb_type)){ if(!(s->flags & CODEC_FLAG_4MV)){ av_log(c->avctx, AV_LOG_ERROR, "4MV macroblock selected but 4MV encoding disabled\n"); return -1; } cmpf= s->dsp.sse[1]; chroma_cmpf= s->dsp.sse[1]; init_mv4_ref(c); for(i=0; i<4; i++){ xy= s->block_index[i]; x= p->motion_val[0][xy][0]; y= p->motion_val[0][xy][1]; d+= cmp(s, x>>shift, y>>shift, x&mask, y&mask, 1, 8, i, i, cmpf, chroma_cmpf, flags); } s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER4V; }else{ if(USES_LIST(mb_type, 0)){ if(p_type){ *(uint32_t*)s->p_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy]; s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTER; }else if(USES_LIST(mb_type, 1)){ *(uint32_t*)s->b_bidir_forw_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy]; *(uint32_t*)s->b_bidir_back_mv_table[mb_xy]= *(uint32_t*)p->motion_val[1][xy]; s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_BIDIR; }else{ *(uint32_t*)s->b_forw_mv_table[mb_xy]= *(uint32_t*)p->motion_val[0][xy]; s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_FORWARD; } x= p->motion_val[0][xy][0]; y= p->motion_val[0][xy][1]; d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 0, 0, cmpf, chroma_cmpf, flags); }else if(USES_LIST(mb_type, 1)){ *(uint32_t*)s->b_back_mv_table[mb_xy]= *(uint32_t*)p->motion_val[1][xy]; s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_BACKWARD; x= p->motion_val[1][xy][0]; y= p->motion_val[1][xy][1]; d = cmp(s, x>>shift, y>>shift, x&mask, y&mask, 0, 16, 2, 0, cmpf, chroma_cmpf, flags); }else s->mb_type[mb_xy]=CANDIDATE_MB_TYPE_INTRA; } return d; }
1threat
Why scanf is performing 11 times? : [C Language Array][1] Clearly, The first loop condition should run only 10times but instead it asks me for 11th value. Anyone knows about this? Or it's just one of many weird behaviours of C? But in the 2nd loop it's working the way I want! [1]: https://i.stack.imgur.com/aWeLM.png
0debug
Why does Javasctipt Array.push not use variable if the pushed element is not a primitive : Consider this classic Javacrit closure function. I understand how the closure is exhibited. I understand that the inner function closes in on the variable i, which is 3. What I dont understand is why the array should contain the variable i, when all we are doing is pushing a function into an array where i has a value from the for loop. function buildFunctions() { var arr = []; for (var i = 0; i < 3; i++) { arr.push(function() { console.log(i) }) } return arr; } var fs = buildFunctions(); // [function(){console.log(1)}, ...and so on] //not [function(){console.log(i)} ...and so on] fs[0](); // outputs 3 fs[1](); // 3 fs[2](); // 3 otherwise, this would return the correct(imo) contents of the array: function buildFunctions() { var arr = []; for (var i = 0; i < 3; i++) { arr.push(i) } return arr; // [0, 1, 2] }
0debug
static int convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, int max_size) { switch (AV_RB32(src)) { case DCA_SYNCWORD_CORE_BE: case DCA_SYNCWORD_SUBSTREAM: memcpy(dst, src, src_size); return src_size; case DCA_SYNCWORD_CORE_LE: case DCA_SYNCWORD_CORE_14B_BE: case DCA_SYNCWORD_CORE_14B_LE: return avpriv_dca_convert_bitstream(src, src_size, dst, max_size); default: return AVERROR_INVALIDDATA; } }
1threat
Django Oauth Toolkit Application Settings : <p>Django Oauth Toolkit docs don't describe the redirect uris, authorization grant type, or client type fields when registering your application.</p> <p>The tutorial says to set client type to confidential, grant type to password, and leave uris blank.</p> <p>What do the other options do?</p> <p>e.g. What is client type public vs confidential? What do the grant type password, credentials, authorization, implicit do? And what are the redirect uris for?</p> <p>I have found sparse information about them but no actual explanations as they pertain to django rest framework and django oauth toolkit.</p>
0debug
sort a CSV file using CMD or javascript : I have a file like this 9007,5001,800085,,100,40.00,,,,,20170923,,,8157,60400,,,,,,,5001,,,,,51815720718 9007,5001,9995,,100,40.00,,,,,20170930,,,8157,60400,,,,,,,5001,,,,,51815720718 9007,5001,35787654,,370,2.00,,,,,20170923,,,8157,60405,,,,,,,5001,,,,,51815720718 2001,5001,557,,370,4.25,,,,,20170930,,,8157,60405,,,,,,,5001,,,,,51815720718 9007,5001,657,,704,3.75,,4,,,20170930,,,8157,60400,,,,,,,5001,,,,,51815720718 And i have to sort the file like this 2001,5001,557,,370,4.25,,,,,20170930,,,8157,60405,,,,,,,5001,,,,,51815720718 9007,5001,657,,704,3.75,,4,,,20170930,,,8157,60400,,,,,,,5001,,,,,51815720718 9007,5001,800085,,100,40.00,,,,,20170923,,,8157,60400,,,,,,,5001,,,,,51815720718 9007,5001,9995,,100,40.00,,,,,20170930,,,8157,60400,,,,,,,5001,,,,,51815720718 9007,5001,35787654,,370,2.00,,,,,20170923,,,8157,60405,,,,,,,5001,,,,,51815720718 I had used sort <filename> command but there is no use because i am getting result like 9007,5001,35787654,,370,2.00,,,,,20170923,,,8157,60405,,,,,,,5001,,,,,51815720718 9007,5001,557,,370,4.25,,,,,20170930,,,8157,60405,,,,,,,5001,,,,,51815720718 9007,5001,657,,704,3.75,,4,,,20170930,,,8157,60400,,,,,,,5001,,,,,51815720718 9007,5001,800085,,100,40.00,,,,,20170923,,,8157,60400,,,,,,,5001,,,,,51815720718 9007,5001,9995,,100,40.00,,,,,20170930,,,8157,60400,,,,,,,5001,,,,,51815720718 can anyone help me on this please???
0debug
Stop ReSharper from putting JavaScript function parameter onto new line : <p>How can I stop ReSharper formatting from turning this:</p> <pre><code>define(['Spec'], function (Spec) { }); </code></pre> <p>into this:</p> <pre><code>define(['Spec'], function(Spec) { }); </code></pre> <p>I've tried various combinations of settings but have not hit upon the right one yet. </p>
0debug
multiple criteria for aggregation on pySpark Dataframe : <p>I have a pySpark dataframe that looks like this:</p> <pre><code>+-------------+----------+ | sku| date| +-------------+----------+ |MLA-603526656|02/09/2016| |MLA-603526656|01/09/2016| |MLA-604172009|02/10/2016| |MLA-605470584|02/09/2016| |MLA-605502281|02/10/2016| |MLA-605502281|02/09/2016| +-------------+----------+ </code></pre> <p>I want to group by sku, and then calculate the min and max dates. If I do this:</p> <pre><code>df_testing.groupBy('sku') \ .agg({'date': 'min', 'date':'max'}) \ .limit(10) \ .show() </code></pre> <p>the behavior is the same as Pandas, where I only get the <code>sku</code> and <code>max(date)</code> columns. In Pandas I would normally do the following to get the results I want:</p> <pre><code>df_testing.groupBy('sku') \ .agg({'day': ['min','max']}) \ .limit(10) \ .show() </code></pre> <p>However on pySpark this does not work, and I get a <code>java.util.ArrayList cannot be cast to java.lang.String</code> error. Could anyone please point me to the correct syntax?</p> <p>Thanks.</p>
0debug
void helper_movcal(CPUSH4State *env, uint32_t address, uint32_t value) { if (cpu_sh4_is_cached (env, address)) { memory_content *r = malloc (sizeof(memory_content)); r->address = address; r->value = value; r->next = NULL; *(env->movcal_backup_tail) = r; env->movcal_backup_tail = &(r->next); } }
1threat
static char *vnc_socket_local_addr(const char *format, int fd) { struct sockaddr_storage sa; socklen_t salen; salen = sizeof(sa); if (getsockname(fd, (struct sockaddr*)&sa, &salen) < 0) return NULL; return addr_to_string(format, &sa, salen); }
1threat
static void print_samplesref(AVFilterBufferRef *samplesref) { const AVFilterBufferRefAudioProps *props = samplesref->audio; const int n = props->nb_samples * av_get_channel_layout_nb_channels(props->channel_layout); const uint16_t *p = (uint16_t*)samplesref->data[0]; const uint16_t *p_end = p + n; while (p < p_end) { fputc(*p & 0xff, stdout); fputc(*p>>8 & 0xff, stdout); p++; } fflush(stdout); }
1threat
Steps to Install and run headless chrome browser on centos 6.5 using chrome driver : <p>I need to install chrome browser on centos 6.5, Here i need to automate some web gui. I have installed chrome driver. Can anyone please provide the steps and download link of chrome-61 and how to install it. My operating system does not have any Gui. Kindly provide the commands.</p> <p>I am using java selenium.</p> <p>Thanks in advance</p>
0debug