problem
stringlengths
26
131k
labels
class label
2 classes
static bool net_tx_pkt_rebuild_payload(struct NetTxPkt *pkt) { size_t payload_len = iov_size(pkt->raw, pkt->raw_frags) - pkt->hdr_len; pkt->payload_frags = iov_copy(&pkt->vec[NET_TX_PKT_PL_START_FRAG], pkt->max_payload_frags, pkt->raw, pkt->raw_frags, pkt->hdr_len, payload_len); if (pkt->payload_frags != (uint32_t) -1) { pkt->payload_len = payload_len; return true; } else { return false; } }
1threat
linux unix regex : Trying to extract the digit bewtween the parenthesis (AA) and modify (expl: times 300 ) and update the old value (AA) using the new value which is (AA*300) in the whole text. Exmp text: RRRR TTTTYYY (22); UUUUUUU IIIIII4 (55);
0debug
R: readr: is it possible to read HTML tables using this package : <p>I want to know if we can reach html tables using readr package with the url of the page where html table is published. For example, I want to import table on the <a href="http://sports.yahoo.com/nfl/stats/byteam?group=Offense&amp;cat=Total&amp;conference=NFL&amp;year=season_2010&amp;sort=530&amp;old_category=Total&amp;old_group=Offense" rel="nofollow">page</a> to be loaded into R.</p>
0debug
Javascript. Need error box if no question mark is input : I'm new to javascript. I need some help with the following project. I'm doing a magic 8 ball and need to display the following: If the same question is asked twice in a row, or if the question doesn’t end with a “?”, give appropriate error messages using the Alert function. Please help! Thank you!!
0debug
static int scsi_disk_emulate_start_stop(SCSIDiskReq *r) { SCSIRequest *req = &r->req; SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, req->dev); bool start = req->cmd.buf[4] & 1; bool loej = req->cmd.buf[4] & 2; if (s->qdev.type == TYPE_ROM && loej) { if (!start && !s->tray_open && s->tray_locked) { scsi_check_condition(r, bdrv_is_inserted(s->qdev.conf.bs) ? SENSE_CODE(ILLEGAL_REQ_REMOVAL_PREVENTED) : SENSE_CODE(NOT_READY_REMOVAL_PREVENTED)); return -1; } if (s->tray_open != !start) { bdrv_eject(s->qdev.conf.bs, !start); s->tray_open = !start; } } return 0; }
1threat
static void guess_mv(MpegEncContext *s) { uint8_t *fixed = av_malloc(s->mb_stride * s->mb_height); #define MV_FROZEN 3 #define MV_CHANGED 2 #define MV_UNCHANGED 1 const int mb_stride = s->mb_stride; const int mb_width = s->mb_width; const int mb_height = s->mb_height; int i, depth, num_avail; int mb_x, mb_y, mot_step, mot_stride; set_mv_strides(s, &mot_step, &mot_stride); num_avail = 0; for (i = 0; i < s->mb_num; i++) { const int mb_xy = s->mb_index2xy[i]; int f = 0; int error = s->error_status_table[mb_xy]; if (IS_INTRA(s->current_picture.f.mb_type[mb_xy])) f = MV_FROZEN; if (!(error & ER_MV_ERROR)) f = MV_FROZEN; fixed[mb_xy] = f; if (f == MV_FROZEN) num_avail++; else if(s->last_picture.f.data[0] && s->last_picture.f.motion_val[0]){ const int mb_y= mb_xy / s->mb_stride; const int mb_x= mb_xy % s->mb_stride; const int mot_index= (mb_x + mb_y*mot_stride) * mot_step; s->current_picture.f.motion_val[0][mot_index][0]= s->last_picture.f.motion_val[0][mot_index][0]; s->current_picture.f.motion_val[0][mot_index][1]= s->last_picture.f.motion_val[0][mot_index][1]; s->current_picture.f.ref_index[0][4*mb_xy] = s->last_picture.f.ref_index[0][4*mb_xy]; } } if ((!(s->avctx->error_concealment&FF_EC_GUESS_MVS)) || num_avail <= mb_width / 2) { for (mb_y = 0; mb_y < s->mb_height; mb_y++) { s->mb_x = 0; s->mb_y = mb_y; ff_init_block_index(s); for (mb_x = 0; mb_x < s->mb_width; mb_x++) { const int mb_xy = mb_x + mb_y * s->mb_stride; ff_update_block_index(s); if (IS_INTRA(s->current_picture.f.mb_type[mb_xy])) continue; if (!(s->error_status_table[mb_xy] & ER_MV_ERROR)) continue; s->mv_dir = s->last_picture.f.data[0] ? MV_DIR_FORWARD : MV_DIR_BACKWARD; s->mb_intra = 0; s->mv_type = MV_TYPE_16X16; s->mb_skipped = 0; s->dsp.clear_blocks(s->block[0]); s->mb_x = mb_x; s->mb_y = mb_y; s->mv[0][0][0] = 0; s->mv[0][0][1] = 0; decode_mb(s, 0); } } goto end; } for (depth = 0; ; depth++) { int changed, pass, none_left; none_left = 1; changed = 1; for (pass = 0; (changed || pass < 2) && pass < 10; pass++) { int mb_x, mb_y; int score_sum = 0; changed = 0; for (mb_y = 0; mb_y < s->mb_height; mb_y++) { s->mb_x = 0; s->mb_y = mb_y; ff_init_block_index(s); for (mb_x = 0; mb_x < s->mb_width; mb_x++) { const int mb_xy = mb_x + mb_y * s->mb_stride; int mv_predictor[8][2] = { { 0 } }; int ref[8] = { 0 }; int pred_count = 0; int j; int best_score = 256 * 256 * 256 * 64; int best_pred = 0; const int mot_index = (mb_x + mb_y * mot_stride) * mot_step; int prev_x, prev_y, prev_ref; ff_update_block_index(s); if ((mb_x ^ mb_y ^ pass) & 1) continue; if (fixed[mb_xy] == MV_FROZEN) continue; assert(!IS_INTRA(s->current_picture.f.mb_type[mb_xy])); assert(s->last_picture_ptr && s->last_picture_ptr->f.data[0]); j = 0; if (mb_x > 0 && fixed[mb_xy - 1] == MV_FROZEN) j = 1; if (mb_x + 1 < mb_width && fixed[mb_xy + 1] == MV_FROZEN) j = 1; if (mb_y > 0 && fixed[mb_xy - mb_stride] == MV_FROZEN) j = 1; if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_FROZEN) j = 1; if (j == 0) continue; j = 0; if (mb_x > 0 && fixed[mb_xy - 1 ] == MV_CHANGED) j = 1; if (mb_x + 1 < mb_width && fixed[mb_xy + 1 ] == MV_CHANGED) j = 1; if (mb_y > 0 && fixed[mb_xy - mb_stride] == MV_CHANGED) j = 1; if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_CHANGED) j = 1; if (j == 0 && pass > 1) continue; none_left = 0; if (mb_x > 0 && fixed[mb_xy - 1]) { mv_predictor[pred_count][0] = s->current_picture.f.motion_val[0][mot_index - mot_step][0]; mv_predictor[pred_count][1] = s->current_picture.f.motion_val[0][mot_index - mot_step][1]; ref[pred_count] = s->current_picture.f.ref_index[0][4 * (mb_xy - 1)]; pred_count++; } if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) { mv_predictor[pred_count][0] = s->current_picture.f.motion_val[0][mot_index + mot_step][0]; mv_predictor[pred_count][1] = s->current_picture.f.motion_val[0][mot_index + mot_step][1]; ref[pred_count] = s->current_picture.f.ref_index[0][4 * (mb_xy + 1)]; pred_count++; } if (mb_y > 0 && fixed[mb_xy - mb_stride]) { mv_predictor[pred_count][0] = s->current_picture.f.motion_val[0][mot_index - mot_stride * mot_step][0]; mv_predictor[pred_count][1] = s->current_picture.f.motion_val[0][mot_index - mot_stride * mot_step][1]; ref[pred_count] = s->current_picture.f.ref_index[0][4 * (mb_xy - s->mb_stride)]; pred_count++; } if (mb_y + 1<mb_height && fixed[mb_xy + mb_stride]) { mv_predictor[pred_count][0] = s->current_picture.f.motion_val[0][mot_index + mot_stride * mot_step][0]; mv_predictor[pred_count][1] = s->current_picture.f.motion_val[0][mot_index + mot_stride * mot_step][1]; ref[pred_count] = s->current_picture.f.ref_index[0][4 * (mb_xy + s->mb_stride)]; pred_count++; } if (pred_count == 0) continue; if (pred_count > 1) { int sum_x = 0, sum_y = 0, sum_r = 0; int max_x, max_y, min_x, min_y, max_r, min_r; for (j = 0; j < pred_count; j++) { sum_x += mv_predictor[j][0]; sum_y += mv_predictor[j][1]; sum_r += ref[j]; if (j && ref[j] != ref[j - 1]) goto skip_mean_and_median; } mv_predictor[pred_count][0] = sum_x / j; mv_predictor[pred_count][1] = sum_y / j; ref[pred_count] = sum_r / j; if (pred_count >= 3) { min_y = min_x = min_r = 99999; max_y = max_x = max_r = -99999; } else { min_x = min_y = max_x = max_y = min_r = max_r = 0; } for (j = 0; j < pred_count; j++) { max_x = FFMAX(max_x, mv_predictor[j][0]); max_y = FFMAX(max_y, mv_predictor[j][1]); max_r = FFMAX(max_r, ref[j]); min_x = FFMIN(min_x, mv_predictor[j][0]); min_y = FFMIN(min_y, mv_predictor[j][1]); min_r = FFMIN(min_r, ref[j]); } mv_predictor[pred_count + 1][0] = sum_x - max_x - min_x; mv_predictor[pred_count + 1][1] = sum_y - max_y - min_y; ref[pred_count + 1] = sum_r - max_r - min_r; if (pred_count == 4) { mv_predictor[pred_count + 1][0] /= 2; mv_predictor[pred_count + 1][1] /= 2; ref[pred_count + 1] /= 2; } pred_count += 2; } skip_mean_and_median: pred_count++; if (!fixed[mb_xy] && 0) { if (s->avctx->codec_id == CODEC_ID_H264) { } else { ff_thread_await_progress(&s->last_picture_ptr->f, mb_y, 0); } if (!s->last_picture.f.motion_val[0] || !s->last_picture.f.ref_index[0]) goto skip_last_mv; prev_x = s->last_picture.f.motion_val[0][mot_index][0]; prev_y = s->last_picture.f.motion_val[0][mot_index][1]; prev_ref = s->last_picture.f.ref_index[0][4 * mb_xy]; } else { prev_x = s->current_picture.f.motion_val[0][mot_index][0]; prev_y = s->current_picture.f.motion_val[0][mot_index][1]; prev_ref = s->current_picture.f.ref_index[0][4 * mb_xy]; } mv_predictor[pred_count][0] = prev_x; mv_predictor[pred_count][1] = prev_y; ref[pred_count] = prev_ref; pred_count++; skip_last_mv: s->mv_dir = MV_DIR_FORWARD; s->mb_intra = 0; s->mv_type = MV_TYPE_16X16; s->mb_skipped = 0; s->dsp.clear_blocks(s->block[0]); s->mb_x = mb_x; s->mb_y = mb_y; for (j = 0; j < pred_count; j++) { int score = 0; uint8_t *src = s->current_picture.f.data[0] + mb_x * 16 + mb_y * 16 * s->linesize; s->current_picture.f.motion_val[0][mot_index][0] = s->mv[0][0][0] = mv_predictor[j][0]; s->current_picture.f.motion_val[0][mot_index][1] = s->mv[0][0][1] = mv_predictor[j][1]; if (ref[j] < 0) continue; decode_mb(s, ref[j]); if (mb_x > 0 && fixed[mb_xy - 1]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k * s->linesize - 1] - src[k * s->linesize]); } if (mb_x + 1 < mb_width && fixed[mb_xy + 1]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k * s->linesize + 15] - src[k * s->linesize + 16]); } if (mb_y > 0 && fixed[mb_xy - mb_stride]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k - s->linesize] - src[k]); } if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride]) { int k; for (k = 0; k < 16; k++) score += FFABS(src[k + s->linesize * 15] - src[k + s->linesize * 16]); } if (score <= best_score) { best_score = score; best_pred = j; } } score_sum += best_score; s->mv[0][0][0] = mv_predictor[best_pred][0]; s->mv[0][0][1] = mv_predictor[best_pred][1]; for (i = 0; i < mot_step; i++) for (j = 0; j < mot_step; j++) { s->current_picture.f.motion_val[0][mot_index + i + j * mot_stride][0] = s->mv[0][0][0]; s->current_picture.f.motion_val[0][mot_index + i + j * mot_stride][1] = s->mv[0][0][1]; } decode_mb(s, ref[best_pred]); if (s->mv[0][0][0] != prev_x || s->mv[0][0][1] != prev_y) { fixed[mb_xy] = MV_CHANGED; changed++; } else fixed[mb_xy] = MV_UNCHANGED; } } } if (none_left) goto end; for (i = 0; i < s->mb_num; i++) { int mb_xy = s->mb_index2xy[i]; if (fixed[mb_xy]) fixed[mb_xy] = MV_FROZEN; } } end: av_free(fixed); }
1threat
static abi_long do_accept(int fd, abi_ulong target_addr, abi_ulong target_addrlen_addr) { socklen_t addrlen; void *addr; abi_long ret; if (get_user_u32(addrlen, target_addrlen_addr)) return -TARGET_EFAULT; if (addrlen < 0) return -TARGET_EINVAL; addr = alloca(addrlen); ret = get_errno(accept(fd, addr, &addrlen)); if (!is_error(ret)) { host_to_target_sockaddr(target_addr, addr, addrlen); if (put_user_u32(addrlen, target_addrlen_addr)) ret = -TARGET_EFAULT; } return ret; }
1threat
Where to find some real programming assignments for a beginner webdev? : <p><strong>Hello, folks!</strong></p> <p>So here I am - a total beginner in webdev without any profound education on the topic, but still aiming to get a real webdev job sometime soon. </p> <p>And while the assignments in the courses I've taken employ practical use of the languages(HTML, CSS, PHP, JS, jQuery), they nevertheless lack real-life examples, like something that a real client might want. </p> <p>Googling on programming challenges as to the aforementioned languages gave out mostly the same; I mean yes, there were some interesting things, but they're still far from the real clients' demand, IMO. </p> <p><strong>So the question is:</strong> where can a beginning webdev find some real assignments to perform in order to comprehend the gist of modern webdev through practice and become able to answer the clients' possible demand? Just for the sake of experience, that is, payment is not obligatory. </p> <p>Any links/replies will be greatly appreciated, thanks! </p>
0debug
How to disable IntelliSense in VS Code for Markdown? : <p>I don't want word completion for Markdown files in Visual Studio Code, how do I disable it? Ideally, for Markdown only but in the worst case, even a global switch would be good.</p>
0debug
static void gd_update_caption(GtkDisplayState *s) { const char *status = ""; gchar *title; if (!runstate_is_running()) { status = " [Stopped]"; } if (qemu_name) { title = g_strdup_printf("QEMU (%s)%s", qemu_name, status); } else { title = g_strdup_printf("QEMU%s", status); } gtk_window_set_title(GTK_WINDOW(s->window), title); g_free(title); }
1threat
Google Maps in React-Native (iOS) : <p>My goal is to display a Google Map in React Native. I have seen examples that use the Google Maps SDK with an UIMapView or a MapBox map, but that is not what I am looking for.</p> <p>I currently have no errors. Here is my code:</p> <p>index.ios.js</p> <pre><code>'use strict'; import React, { AppRegistry, Component, StyleSheet, Text, View } from 'react-native'; import GoogleMaps from './ios/GoogleMaps.js'; class RCTGoogleMaps extends Component { constructor(props) { super(props); } render() { return ( &lt;View style={styles.container}&gt; &lt;GoogleMaps style={styles.map}/&gt; &lt;/View&gt; ); } } const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#F5FCFF' }, map: { height: 500, width: 300, marginLeft: 50 } }); AppRegistry.registerComponent('RCTGoogleMaps', () =&gt; RCTGoogleMaps); </code></pre> <p>ios/GoogleMaps.js</p> <pre><code>var {requireNativeComponent} = require('react-native'); module.exports = requireNativeComponent('RCTGoogleMapViewManager', null); </code></pre> <p>ios/RCTGoogleMapViewManager.h</p> <pre><code>#ifndef RCTGoogleMapViewManager_h #define RCTGoogleMapViewManager_h #import &lt;Foundation/Foundation.h&gt; #import "RCTViewManager.h" #import &lt;UIKit/UIKit.h&gt; @interface RCTGoogleMapViewManager : RCTViewManager&lt;UITextViewDelegate&gt; @end #endif /* RCTGoogleMapViewManager_h */ </code></pre> <p>ios/GoogleMapViewManager.m</p> <pre><code>#import &lt;Foundation/Foundation.h&gt; #import "RCTGoogleMapViewManager.h" #import "RCTBridge.h" #import "RCTEventDispatcher.h" #import "UIView+React.h" @import GoogleMaps; @implementation RCTGoogleMapViewManager RCT_EXPORT_MODULE() - (UIView *)view { GMSMapView *mapView_; // Create a GMSCameraPosition that tells the map to display the // coordinate -33.86,151.20 at zoom level 6. GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86 longitude:151.20 zoom:6]; mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera]; mapView_.myLocationEnabled = YES; UIView *newView_ = mapView_; //self.view = mapView_; // Creates a marker in the center of the map. GMSMarker *marker = [[GMSMarker alloc] init]; marker.position = CLLocationCoordinate2DMake(-33.86, 151.20); marker.title = @"Sydney"; marker.snippet = @"Australia"; marker.map = mapView_; return newView_; } RCT_EXPORT_VIEW_PROPERTY(text, NSString) @end </code></pre> <p>There is a red border around the component, but nothing displays inside. I am new to React Native and new to StackOverflow. Unfortunately, they will not let me upload a screenshot until I have more reputation.</p> <p>There is one line I suspect to be off, but have no idea what to change it to. Line #8 in RCTGoogleMapViewManager.h says, "@interface RCTGoogleMapViewManager : RCTViewManager". I have used UITextViewDelegates for other custom components, but this map is not a TextView. That might be it, but I have no clue.</p> <p>Any help at all would be appreciated.</p>
0debug
Error in an array, java.lang.NullPointerException : <p>So, i'm using an array in my program, and it gives me this error:</p> <p><code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException</code></p> <p>The error is in fourth line of this code: </p> <pre><code>int n = numbers.length, numBigger10 = 0; for (int i = 0; i &lt; n; i++) if (numbers[i] &gt; 10) numbersBigger10[i] = numbers[i]; numBigger10++; </code></pre> <p>What can I do to solve?</p> <p>If you want to know more details about the error please feel free to ask.</p>
0debug
static Suite *qfloat_suite(void) { Suite *s; TCase *qfloat_public_tcase; s = suite_create("QFloat test-suite"); qfloat_public_tcase = tcase_create("Public Interface"); suite_add_tcase(s, qfloat_public_tcase); tcase_add_test(qfloat_public_tcase, qfloat_from_double_test); tcase_add_test(qfloat_public_tcase, qfloat_destroy_test); return s; }
1threat
static int cook_decode_close(AVCodecContext *avctx) { int i; COOKContext *q = avctx->priv_data; av_log(NULL,AV_LOG_DEBUG, "Deallocating memory.\n"); av_free(q->mlt_window); av_free(q->mlt_precos); av_free(q->mlt_presin); av_free(q->mlt_postcos); av_free(q->frame_reorder_index); av_free(q->frame_reorder_buffer); av_free(q->decoded_bytes_buffer); ff_fft_end(&q->fft_ctx); for (i=0 ; i<13 ; i++) { free_vlc(&q->envelope_quant_index[i]); } for (i=0 ; i<7 ; i++) { free_vlc(&q->sqvh[i]); } if(q->nb_channels==2 && q->joint_stereo==1 ){ free_vlc(&q->ccpl); } av_log(NULL,AV_LOG_DEBUG,"Memory deallocated.\n"); return 0; }
1threat
Algorithm to find ideal starting spot in a circle : <p>So the problem I have been debating is as such:</p> <p>Your are given an array of integers representing a circle. Then, you have to pick spot in the circle to start. From the place you start, you compare the value at the array to number of steps you took to get there and if the steps are less than or equal to the number, include it in your final set. Find the place to start so that you have the most elements in your set.</p> <pre><code>ex, a=[0, 1, 2] If you start at index=0, then: a[0]=0 &lt; =0 so 0 is included a[1]=1 &lt; =1 so 1 is included a[2]=2 &lt; =2 so 2 is included final set: {0,1,2} If you start at index=1, then: a[1]=1 &gt; 0 so 1 is NOT included a[2]=2 &gt; 1 so 2 is NOT included here we loop back around a[0]=0 &gt; 2 so 0 is included final set: {0} If you start at index=2, then: a[2]=2 &gt; 0 so 2 is NOT included, here we loop back around a[0]=0 &lt; = 1 so 0 is included a[1]=1 &lt; = 2 so 1 is included final set: {0,1} </code></pre> <p>So in this trivial case, starting position index=0 is the best position as it results in the final set with the most elements. Now the brute force method of finding this is obvious, but I am trying to find a more efficient method. My attempts so far have been to examine trying to find the max intersect of viable starting ranges calculated for each element in the array. Also, I feel like dynamic programming can be used in some way to help make the solution but I can't seem to identify exactly how.</p>
0debug
static void scsi_write_complete_noio(SCSIDiskReq *r, int ret) { uint32_t n; assert (r->req.aiocb == NULL); if (r->req.io_canceled) { scsi_req_cancel_complete(&r->req); goto done; } if (ret < 0) { if (scsi_handle_rw_error(r, -ret, false)) { goto done; } } n = r->qiov.size / 512; r->sector += n; r->sector_count -= n; if (r->sector_count == 0) { scsi_write_do_fua(r); return; } else { scsi_init_iovec(r, SCSI_DMA_BUF_SIZE); DPRINTF("Write complete tag=0x%x more=%zd\n", r->req.tag, r->qiov.size); scsi_req_data(&r->req, r->qiov.size); } done: scsi_req_unref(&r->req); }
1threat
Can you use a service worker with a self-signed certificate? : <p>I have developer server that are used for testing. They have SSL self-signed certificates, which allow us to test the web application over HTTPS, but with prominent warnings that the certificates are not verifiable.</p> <p>That's fine, but I have a Service Worker that throws an error with the <code>navigator.serviceWorker.register</code></p> <blockquote> <p>SecurityError: Failed to register a ServiceWorker: An SSL certificate error occurred when fetching the script.</p> </blockquote> <p>How do I use a Service Worker with an intranet testing server which has a self-signed certificate?</p>
0debug
display input text error message as when using the required attribute : <p>I would like to know if you can create a javascript function that allows you to activate and then display an error message around the input text as when you do submit leaving the input blank and you have the required attribute.</p> <p>a message is displayed when a certain condition occurs. is this possible?</p>
0debug
static void qemu_rdma_dump_gid(const char *who, struct rdma_cm_id *id) { char sgid[33]; char dgid[33]; inet_ntop(AF_INET6, &id->route.addr.addr.ibaddr.sgid, sgid, sizeof sgid); inet_ntop(AF_INET6, &id->route.addr.addr.ibaddr.dgid, dgid, sizeof dgid); DPRINTF("%s Source GID: %s, Dest GID: %s\n", who, sgid, dgid); }
1threat
Search form slow show [html] : <p>Anyone can help me create search form like this:</p> <pre><code>http://gledanjefilmova.net/ </code></pre> <p>I know there is some elements in css but I forgot which was...</p>
0debug
Reload current page in Aurelia : <p>I have an <a href="http://www.aurelia.io">Aurelia</a> application where the user can select the company they're currently "working on". Every page in the app is dependent on the currently selected company, and the user can select a new company from a drop-down menu. The drop-down is a component sitting on the nav-bar.</p> <p>What I'd like is to have that component reload the current page on the <code>change.delegate</code> handler without restarting the app. So setting <code>window.location.href</code> is out of the question.</p> <p><strong>Is there a way to force the aurelia <code>Router</code> to reload the current route/page?</strong></p> <p>The alternative would be to use the <code>EventAggregator</code> to signal a company change throughout the app, but that would require either subscribing to that event on every page or having every page inherit from a base class that subscribes to that event, but these are much more involved options.</p>
0debug
How to remove lines from File A that are in File B using Windows powershell : <p><a href="https://stackoverflow.com/questions/19816914/how-to-join-two-text-files-removing-duplicates-in-windows">This other question</a> is excellent for joining two files. I need to do sort of the opposite. I need to remove lines from File A that are in File B, using powershell.</p> <p><em>This</em> question is similar to <a href="https://stackoverflow.com/questions/21580073/delete-lines-from-file-a-that-is-in-file-b">this other question</a>, except that question is for unix and this is for Windows 7 powershell.</p> <p>The files are hosts files. Each one has lines consisting of:</p> <ul> <li><code>127.0.0.1 host.domain.com</code></li> </ul> <p>or</p> <ul> <li><code>0.0.0.0 host.domain.com</code></li> </ul> <p>or</p> <ul> <li><code># this is a comment</code></li> </ul> <p>Files may have up to 200,000 lines. Spaces and tabs may be present.</p> <p>Although I prefer it to be preserved, order does not effect function.</p> <p>Here are some examples of hosts files:</p> <ul> <li><a href="https://adaway.org/hosts.txt" rel="nofollow noreferrer">https://adaway.org/hosts.txt</a></li> <li><a href="https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&amp;showintro=0&amp;mimetype=plaintext" rel="nofollow noreferrer">https://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&amp;showintro=0&amp;mimetype=plaintext</a></li> <li><a href="https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts" rel="nofollow noreferrer">https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts</a></li> <li><a href="https://hosts-file.net/ad_servers.txt" rel="nofollow noreferrer">https://hosts-file.net/ad_servers.txt</a></li> <li><a href="http://winhelp2002.mvps.org/hosts.txt" rel="nofollow noreferrer">http://winhelp2002.mvps.org/hosts.txt</a></li> <li><a href="http://someonewhocares.org/hosts/hosts" rel="nofollow noreferrer">http://someonewhocares.org/hosts/hosts</a></li> </ul> <p>(Don't worry about <code>0.0.0.0</code> vs <code>127.0.0.1</code> for this question.)</p>
0debug
static int libvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { LibvorbisContext *s = avctx->priv_data; ogg_packet op; int ret, duration; if (frame) { const int samples = frame->nb_samples; float **buffer; int c, channels = s->vi.channels; buffer = vorbis_analysis_buffer(&s->vd, samples); for (c = 0; c < channels; c++) { int co = (channels > 8) ? c : ff_vorbis_encoding_channel_layout_offsets[channels - 1][c]; memcpy(buffer[c], frame->extended_data[co], samples * sizeof(*buffer[c])); } if ((ret = vorbis_analysis_wrote(&s->vd, samples)) < 0) { av_log(avctx, AV_LOG_ERROR, "error in vorbis_analysis_wrote()\n"); return vorbis_error_to_averror(ret); } if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) return ret; } else { if (!s->eof) if ((ret = vorbis_analysis_wrote(&s->vd, 0)) < 0) { av_log(avctx, AV_LOG_ERROR, "error in vorbis_analysis_wrote()\n"); return vorbis_error_to_averror(ret); } s->eof = 1; } while ((ret = vorbis_analysis_blockout(&s->vd, &s->vb)) == 1) { if ((ret = vorbis_analysis(&s->vb, NULL)) < 0) break; if ((ret = vorbis_bitrate_addblock(&s->vb)) < 0) break; while ((ret = vorbis_bitrate_flushpacket(&s->vd, &op)) == 1) { if (av_fifo_space(s->pkt_fifo) < sizeof(ogg_packet) + op.bytes) { av_log(avctx, AV_LOG_ERROR, "packet buffer is too small"); return AVERROR_BUG; } av_fifo_generic_write(s->pkt_fifo, &op, sizeof(ogg_packet), NULL); av_fifo_generic_write(s->pkt_fifo, op.packet, op.bytes, NULL); } if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "error getting available packets\n"); break; } } if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "error getting available packets\n"); return vorbis_error_to_averror(ret); } if (av_fifo_size(s->pkt_fifo) < sizeof(ogg_packet)) return 0; av_fifo_generic_read(s->pkt_fifo, &op, sizeof(ogg_packet), NULL); if ((ret = ff_alloc_packet(avpkt, op.bytes))) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n"); return ret; } av_fifo_generic_read(s->pkt_fifo, avpkt->data, op.bytes, NULL); avpkt->pts = ff_samples_to_time_base(avctx, op.granulepos); duration = avpriv_vorbis_parse_frame(&s->vp, avpkt->data, avpkt->size); if (duration > 0) { if (!avctx->delay) { avctx->delay = duration; s->afq.remaining_delay += duration; s->afq.remaining_samples += duration; } ff_af_queue_remove(&s->afq, duration, &avpkt->pts, &avpkt->duration); } *got_packet_ptr = 1; return 0; }
1threat
Python Programming Help- Strings/Parameter : I am very new to python, and I am trying to create a simple function that allows me to return a string reversed. However, when I called the function, the error TypeError: reverseString() takes 1 positional argument but 2 were given comes up. Im more familiar with java, and was wondering what the problem was/if passing a string parameter was the same in python def reverseString(string): return string[:,:,-1]
0debug
static void i386_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) { DisasContext *dc = container_of(dcbase, DisasContext, base); target_ulong pc_next = disas_insn(dc, cpu); if (dc->tf || (dc->base.tb->flags & HF_INHIBIT_IRQ_MASK)) { dc->base.is_jmp = DISAS_TOO_MANY; } else if ((dc->base.tb->cflags & CF_USE_ICOUNT) && ((dc->base.pc_next & TARGET_PAGE_MASK) != ((dc->base.pc_next + TARGET_MAX_INSN_SIZE - 1) & TARGET_PAGE_MASK) || (dc->base.pc_next & ~TARGET_PAGE_MASK) == 0)) { dc->base.is_jmp = DISAS_TOO_MANY; } else if ((pc_next - dc->base.pc_first) >= (TARGET_PAGE_SIZE - 32)) { dc->base.is_jmp = DISAS_TOO_MANY; } dc->base.pc_next = pc_next; }
1threat
How to parse a String like "14px" to get Int value 14 in Swift : <p>I receive from a server API a String like "14px". How to transform this String to Int with value 14 ignoring substring "px"?</p>
0debug
Update TSLint Errors : Could not find implementations for the following rules specified in the configuration : <p>I upgraded my tslint to 4.0.2 and now I get a lot of errors like the following</p> <pre><code>Could not find implementations for the following rules specified in the configuration: directive-selector-name component-selector-name directive-selector-type component-selector-type directive-selector-prefix component-selector-prefix label-undefined no-constructor-vars no-duplicate-key no-unreachable use-strict </code></pre> <p>I believe the issue may be that my tslint.json may be out of date and I need to update it, but I have not found any information on how to do that or even if my assumption is correct.</p> <p><strong>tslint.json</strong></p> <pre><code>{ "rulesDirectory": [ "node_modules/codelyzer" ], "rules": { "directive-selector-name": [true, "camelCase"], "component-selector-name": [true, "kebab-case"], "directive-selector-type": [true, "attribute"], "component-selector-type": [true, "element"], "directive-selector-prefix": [true, "my"], "component-selector-prefix": [true, "my"], "use-input-property-decorator": true, "use-output-property-decorator": true, "use-host-property-decorator": true, "no-attribute-parameter-decorator": true, "no-input-rename": true, "no-output-rename": true, "no-forward-ref" :true, "use-life-cycle-interface": true, "use-pipe-transform-interface": true, "pipe-naming": [true, "camelCase", "my"], "component-class-suffix": true, "directive-class-suffix": true, "ban": [true, ["_", "extend"], ["_", "isNull"], ["_", "isDefined"] ], "class-name": true, "comment-format": [false, "check-space", "check-lowercase" ], "curly": true, "eofline": true, "forin": true, "indent": [true, 2], "interface-name": true, "jsdoc-format": true, "label-position": true, "label-undefined": true, "max-line-length": [false, 140], "member-ordering": [true, "public-before-private", "static-before-instance", "variables-before-functions" ], "no-arg": true, "no-bitwise": true, "no-console": [true, "debug", "info", "time", "timeEnd", "trace" ], "no-construct": true, "no-constructor-vars": false, "no-debugger": true, "no-duplicate-key": true, "no-duplicate-variable": true, "no-empty": true, "no-eval": true, "no-string-literal": true, "no-switch-case-fall-through": true, "trailing-comma": true, "no-trailing-whitespace": true, "no-unused-expression": true, "no-unused-variable": true, "no-unreachable": true, "no-use-before-declare": true, "no-var-requires": true, "one-line": [true, "check-open-brace", "check-catch", "check-else", "check-whitespace" ], "quotemark": [true, "single"], "radix": true, "semicolon": true, "triple-equals": [true, "allow-null-check"], "typedef": [true, "callSignature", "indexSignature", "parameter", "propertySignature", "variableDeclarator" ], "typedef-whitespace": [true, ["callSignature", "noSpace"], ["catchClause", "noSpace"], ["indexSignature", "space"] ], "use-strict": false, "variable-name": false, "whitespace": [true, "check-branch", "check-decl", "check-operator", "check-separator", "check-type" ] } } </code></pre> <p><strong>packages.json</strong></p> <pre><code>{ "dependencies": { "@angular/common": "^2.2.4", "@angular/compiler": "^2.2.4", "@angular/core": "^2.2.4", "@angular/forms": "^2.2.4", "@angular/http": "^2.2.4", "@angular/platform-browser": "^2.2.4", "@angular/platform-browser-dynamic": "^2.2.4", "@angular/router": "^3.2.4", "@ng-bootstrap/ng-bootstrap": "^1.0.0-alpha.14", "ag-grid": "^7.0.0", "angularfire2": "^2.0.0-beta.5", "core-js": "^2.4.1", "firebase": "^3.6.2", "rxjs": "5.0.0-rc.4", "zone.js": "^0.7.2" }, "devDependencies": { "del": "^2.0.2", "gulp": "gulpjs/gulp#4ed9a4a3275559c73a396eff7e1fde3824951ebb", "gulp-hub": "frankwallis/gulp-hub#d461b9c700df9010d0a8694e4af1fb96d9f38bf4", "gulp-filter": "^4.0.0", "gulp-util": "^3.0.7", "gulp-sass": "^2.1.1", "browser-sync": "^2.18.2", "browser-sync-spa": "^1.0.3", "karma": "^1.3.0", "karma-coverage": "^1.1.1", "karma-jasmine": "^1.0.2", "karma-junit-reporter": "^1.1.0", "jasmine": "^2.4.1", "es6-shim": "^0.35.0", "karma-chrome-launcher": "^2.0.0", "babel-plugin-istanbul": "^3.0.0", "karma-webpack": "^1.7.0", "webpack": "2.1.0-beta.20", "html-webpack-plugin": "^2.24.1", "style-loader": "^0.13.0", "css-loader": "^0.26.0", "postcss-loader": "^1.1.1", "autoprefixer": "^6.5.3", "json-loader": "^0.5.4", "extract-text-webpack-plugin": "^2.0.0-beta.3", "html-loader": "^0.4.3", "ts-loader": "^1.2.2", "sass-loader": "^4.0.2", "node-sass": "^3.13.0", "eslint": "^3.11.1", "eslint-config-xo-space": "^0.15.0", "eslint-loader": "^1.6.1", "babel-loader": "^6.2.8", "babel-eslint": "^7.1.1", "eslint-plugin-babel": "^4.0.0", "tslint": "^4.0.2", "typescript": "^2.0.10", "typings": "^2.0.0", "tslint-loader": "^3.2.1", "codelyzer": "^2.0.0-beta.1" }, "scripts": { "build": "gulp", "serve": "gulp serve", "serve:dist": "gulp serve:dist", "test": "gulp test", "test:auto": "gulp test:auto" }, "eslintConfig": { "root": true, "env": { "browser": true, "jasmine": true }, "extends": [ "xo-space/esnext" ] } } </code></pre>
0debug
how to do a smoth scoll down a page with javascript : so im trying to make the for loop increase the height by 1 each loop which will make the screen drop by the height of one. Using a time interval for a very short amount of time I would believe this would make a smooth scroll down the page.
0debug
int qemu_signalfd(const sigset_t *mask) { #if defined(CONFIG_signalfd) int ret; ret = syscall(SYS_signalfd, -1, mask, _NSIG / 8); if (ret != -1) return ret; #endif return qemu_signalfd_compat(mask); }
1threat
How to convert alphabets to numerical values with spaces and retain it back to alphabets using Matlab? : Want to convert the alphabet to numerical values and transform it back to alphabets using some mathematical techniques like fast fourier transform in matlab
0debug
Calling Firebase Analytic's getInstance() every time vs. storing instance as a static variable in Application class : <p>I'm trying decide which of the following is the proper way to do this:</p> <ol> <li>Calling <code>FirebaseAnalytics.getInstance(Context)</code> from every activity, fragment, and service that I'm logging an event from.</li> </ol> <p>or</p> <ol start="2"> <li>Calling <code>FirebaseAnalytics.getInstance(Context)</code> once from <code>Application</code> class and keeping it around as a public static variable. Then, from everywhere I need this I can call `MyAppClass.mFirebaseAnalytics.logEvent()'.</li> </ol> <p>Will any of the above methods have a undesired impact on the events that are automatically collected and/or do either of those have an efficiency gain over the other?</p> <p>Many thanks!</p>
0debug
JavaNullPointer Exception on ArrayList Add Function : <p>Hope you are doing well</p> <p>i am facing issue while adding object to ArrayList i need your kind assistance in solving this problem each time when i am going to add something to selectedContacts ArrayList i got nullPointerException</p> <pre><code>ArrayList&lt;ContactInfo&gt; selectedContacts = new ArrayList&lt;&gt;(); public ArrayList&lt;ContactInfo&gt; getSelectedContacts() { int i = 0; while (contacts.get(i).isCheck()==true) { ContactInfo info = contacts.get(i); if(info != null) selectedContacts.add(info); i++; } return selectedContacts; } </code></pre> <p>ContactInfo.Java</p> <pre><code>public class ContactInfo { String name; String number; String email; boolean check; public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public void setCheck(boolean check) { this.check = check; } public void setName(String name) { this.name = name; } public void setNumber(String number) { this.number = number; } public boolean isCheck() { return check; } public String getName() { return name; } public String getNumber() { return number; } } </code></pre>
0debug
Find time duration between tow times with am pm selecton : I have three dropdown lists for selecting start time and another three for selecting end time .I want asp.net program which will give duration between two time and after i entered start time then end time should be greater than start time .first dropdown list contain 1 to 12 hours ans second contains 0 to 59 minutes and third one is for selecting am/pm.[here is image of that][1] [1]: http://i.stack.imgur.com/E8niL.jpg Give me codebehind for this page..
0debug
Do I need to create a new SQLite database every time an application is updated? : <p>I have a Xamarin Forms application I would like to develop. It will have a SQLite database and I wish to make this available on iOS and Android. The database will be populated with data from a SQL Server database on the cloud with initial seed data. I'm thinking this will be about 500 rows of data with each row about 1Kb.</p> <p>What I don't understand is when and how to populate this. Should I try to put the data into a CSV file and have this populate the database when the application is installed, or when it first starts? What's the normal way to populate seed data other than lines inside of the code with a huge number of insert statements. </p> <p>Any help or advice on how this is normally done (I'm thinking most people do it the same way) would be much appreciated.</p> <p>Thanks</p>
0debug
react-native ios Podfile issue with "use_native_modules!" : <p>In my react-native project (react-native@0.60) in the ios/ dir I run <code>pod install</code> and get this error:</p> <pre><code>[!] Invalid `Podfile` file: no implicit conversion of nil into String. # from /Users/coryrobinson/projects/hhs2/ios/Podfile:37 # ------------------------------------------- # &gt; use_native_modules! # end # ------------------------------------------- </code></pre> <p>I haven't added or changed anything in this Podfile - it's all react-native generated. (I'm not experienced in iOS dev so this might be a simple fix, I just don't know what to look for :-|) Thanks for any help!</p> <p>Here is my Podfile</p> <pre><code>platform :ios, '9.0' require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules' target 'hhs2' do # Pods for hhs2 pod 'React', :path =&gt; '../node_modules/react-native/' pod 'React-Core', :path =&gt; '../node_modules/react-native/React' pod 'React-DevSupport', :path =&gt; '../node_modules/react-native/React' pod 'React-fishhook', :path =&gt; '../node_modules/react-native/Libraries/fishhook' pod 'React-RCTActionSheet', :path =&gt; '../node_modules/react-native/Libraries/ActionSheetIOS' pod 'React-RCTAnimation', :path =&gt; '../node_modules/react-native/Libraries/NativeAnimation' pod 'React-RCTBlob', :path =&gt; '../node_modules/react-native/Libraries/Blob' pod 'React-RCTImage', :path =&gt; '../node_modules/react-native/Libraries/Image' pod 'React-RCTLinking', :path =&gt; '../node_modules/react-native/Libraries/LinkingIOS' pod 'React-RCTNetwork', :path =&gt; '../node_modules/react-native/Libraries/Network' pod 'React-RCTSettings', :path =&gt; '../node_modules/react-native/Libraries/Settings' pod 'React-RCTText', :path =&gt; '../node_modules/react-native/Libraries/Text' pod 'React-RCTVibration', :path =&gt; '../node_modules/react-native/Libraries/Vibration' pod 'React-RCTWebSocket', :path =&gt; '../node_modules/react-native/Libraries/WebSocket' pod 'RNFS', :path =&gt; '../node_modules/react-native-fs' pod 'React-cxxreact', :path =&gt; '../node_modules/react-native/ReactCommon/cxxreact' pod 'React-jsi', :path =&gt; '../node_modules/react-native/ReactCommon/jsi' pod 'React-jsiexecutor', :path =&gt; '../node_modules/react-native/ReactCommon/jsiexecutor' pod 'React-jsinspector', :path =&gt; '../node_modules/react-native/ReactCommon/jsinspector' pod 'yoga', :path =&gt; '../node_modules/react-native/ReactCommon/yoga' pod 'DoubleConversion', :podspec =&gt; '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec' pod 'glog', :podspec =&gt; '../node_modules/react-native/third-party-podspecs/glog.podspec' pod 'Folly', :podspec =&gt; '../node_modules/react-native/third-party-podspecs/Folly.podspec' target 'hhs2Tests' do inherit! :search_paths # Pods for testing end use_native_modules! end target 'hhs2-tvOS' do # Pods for hhs2-tvOS target 'hhs2-tvOSTests' do inherit! :search_paths # Pods for testing end end </code></pre>
0debug
React Router VS Conditional Rendering : <p>I am confused about the core difference (especially regarding performance) between using React Router and regular conditional rendering approach. What I mean "regular conditional rendering approach" is, for example:</p> <p>we can set a state in parent component, and pass it as children component's props, we conditionally update such state depends on requirement, and children component will re-render as different content depends on its props.</p> <p>I think it can achieve the exact same goal of using React Router, so why we still need React router? Is using react Router will bring much better performance experience or something (suppose we don't need history feature)?</p>
0debug
static uint16_t phys_section_add(MemoryRegionSection *section) { if (phys_sections_nb == phys_sections_nb_alloc) { phys_sections_nb_alloc = MAX(phys_sections_nb_alloc * 2, 16); phys_sections = g_renew(MemoryRegionSection, phys_sections, phys_sections_nb_alloc); } phys_sections[phys_sections_nb] = *section; return phys_sections_nb++; }
1threat
static double get_volume(CompandContext *s, double in_lin) { CompandSegment *cs; double in_log, out_log; int i; if (in_lin < s->in_min_lin) return s->out_min_lin; in_log = log(in_lin); for (i = 1;; i++) if (in_log <= s->segments[i + 1].x) break; cs = &s->segments[i]; in_log -= cs->x; out_log = cs->y + in_log * (cs->a * in_log + cs->b); return exp(out_log); }
1threat
Printing a character multiple times in a for loop : <p>I want to use printf and for loop to print a character multiple times per line depending on the input; i.e. if the input is 3 i want to print:</p> <pre><code>a aa aaa </code></pre> <p>this is the loop, which doesn't work at all.</p> <pre><code>for (int i = 0; i &lt; n; i++) { printf("a", i); printf("\n"); } </code></pre> <p>I just don't understand how to print it multiple times on a single line.</p>
0debug
db.execute('SELECT * FROM employees WHERE id = ' + user_input)
1threat
How to pass a class as an argument to another classes constructor? : <p>The problem i get is inside Person.cpp , in the constructor.When i do this ,everything works ok </p> <pre><code>Person::Person(string n,Birthday b) : name(n) , birthday(b) {} </code></pre> <p>when i do this , i get errors...</p> <pre><code>Person::Person(string n,Birthday b) { name = n; birthday = b; } </code></pre> <p>my question is how to pass a class as an argument to another classes constructor?</p> <p>main:</p> <pre><code>#include &lt;iostream&gt; #include "Birthday.h" #include "Person.h" using namespace std; int main() { Birthday birth(13,4,1996); Person bill("Billy Par",birth); bill.printInfo(); return 0; } </code></pre> <p>Person.cpp :</p> <pre><code>#include "Person.h" #include &lt;iostream&gt; using namespace std; Person::Person(string n,Birthday b) : name(n) , birthday(b) {} void Person::printInfo() { cout &lt;&lt; name &lt;&lt; " was born on "; birthday.printDate(); } </code></pre> <p>Birthday.cpp:</p> <pre><code>#include "Birthday.h" #include &lt;iostream&gt; using namespace std; Birthday::Birthday(int d,int m,int y) { day = d; month = m; year = y; } void Birthday::printDate() { cout &lt;&lt; day &lt;&lt; "/" &lt;&lt; month &lt;&lt; "/" &lt;&lt; year &lt;&lt; endl; } </code></pre> <p>Person.h:</p> <pre><code>#ifndef PERSON_H #define PERSON_H #include &lt;string&gt; #include "Birthday.h" using namespace std; class Person { public: Person(string n,Birthday b); void printInfo(); private: string name; Birthday birthday; }; #endif // PERSON_H </code></pre> <p>Birthday.h:</p> <pre><code>#ifndef BIRTHDAY_H #define BIRTHDAY_H class Birthday { public: Birthday(int d,int m,int y); void printDate(); private: int day; int month; int year; }; #endif // BIRTHDAY_H </code></pre>
0debug
static void rv40_v_loop_filter(uint8_t *src, int stride, int dmode, int lim_q1, int lim_p1, int alpha, int beta, int beta2, int chroma, int edge){ rv40_adaptive_loop_filter(src, 1, stride, dmode, lim_q1, lim_p1, alpha, beta, beta2, chroma, edge); }
1threat
Listeners in php : <p>Is there anyway to make a listener for any update happens in database (mysql) using php? for example. if you make any update in database (change an entry or element) it will notify you or make a specific function.</p>
0debug
Move change each element in a string and a coditional if arr[i-1]=='n'.... do : problem take a string move every character in the alphabet 13 times forward for example hello would be **uryyb**, but the trick here is that if there is a vowel in the element before then its 14 spaces so it would be **urzyb**, I got the 14 space but then nothing else happens to the other letters so I keep getting **hezlo**, but if remove the // and use this line of code message[i] = message[i] + key;` then it doesn't do the 14 and only does 13 time can someone explain what I'm doing wrong and how to fix it #include<stdio.h> int main() { char message[100], ch; int i, key; printf("Enter a message to encrypt: "); gets(message); printf("Enter key: "); scanf("%d", &key); for(i = 0; message[i] != '\0'; ++i){ if(message[i] >= 'a' && message[i-1] <= 'z'){ if(message[i-1] == 'e'){ message[i]=message[i] + 14; } //message[i] = message[i] + key; if(message[i] > 'z'){ message[i] = message[i] - 'z' + 'a'-1 ; } message[i] = message[i]; } } printf("Encrypted message: %s", message); return 0; } Output is **hezlo** should be **urzyb**
0debug
Error in is.data.frame(x) : object file name' not found : pls, i dont know why always fail when i save my work #menentukan tempat penyimpanan setwd("C:/Users/Child-PC/Documents/Doc/Kerja/Jakarta Smart City/Data/CRM/CRM (Files) Mei 2019/R Function") #menyimpan data ke csv write.csv(nilai_data, file="nilai_data.csv")
0debug
static gboolean io_watch_poll_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { return g_io_watch_funcs.dispatch(source, callback, user_data); }
1threat
Connection closed by EC2 IP - port 22 : <p>Below is the security group(first one) applied to EC2 instance.</p> <h2><a href="https://i.stack.imgur.com/XCthf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XCthf.png" alt="enter image description here"></a></h2> <p>Rules for this security group is:</p> <h2><a href="https://i.stack.imgur.com/sry4x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sry4x.png" alt="enter image description here"></a></h2> <p>But ssh command give below error:</p> <pre><code>$ ssh -i ./xyz.pem ec2-user@ec2-xx-xx-xx-xx.ca-central-1.compute.amazonaws.com Connection closed by xx.xx.xx.xx port 22 </code></pre> <hr> <p>Why ssh client is unable to connect to ubuntu instance type?</p>
0debug
int ff_h2645_extract_rbsp(const uint8_t *src, int length, H2645NAL *nal) { int i, si, di; uint8_t *dst; nal->skipped_bytes = 0; #define STARTCODE_TEST \ if (i + 2 < length && src[i + 1] == 0 && src[i + 2] <= 3) { \ if (src[i + 2] != 3 && src[i + 2] != 0) { \ \ length = i; \ } \ break; \ } #if HAVE_FAST_UNALIGNED #define FIND_FIRST_ZERO \ if (i > 0 && !src[i]) \ i--; \ while (src[i]) \ i++ #if HAVE_FAST_64BIT for (i = 0; i + 1 < length; i += 9) { if (!((~AV_RN64A(src + i) & (AV_RN64A(src + i) - 0x0100010001000101ULL)) & 0x8000800080008080ULL)) continue; FIND_FIRST_ZERO; STARTCODE_TEST; i -= 7; } #else for (i = 0; i + 1 < length; i += 5) { if (!((~AV_RN32A(src + i) & (AV_RN32A(src + i) - 0x01000101U)) & 0x80008080U)) continue; FIND_FIRST_ZERO; STARTCODE_TEST; i -= 3; } #endif #else for (i = 0; i + 1 < length; i += 2) { if (src[i]) continue; if (i > 0 && src[i - 1] == 0) i--; STARTCODE_TEST; } #endif if (i >= length - 1) { nal->data = nal->raw_data = src; nal->size = nal->raw_size = length; return length; } av_fast_malloc(&nal->rbsp_buffer, &nal->rbsp_buffer_size, length + AV_INPUT_BUFFER_PADDING_SIZE); if (!nal->rbsp_buffer) return AVERROR(ENOMEM); dst = nal->rbsp_buffer; memcpy(dst, src, i); si = di = i; while (si + 2 < length) { if (src[si + 2] > 3) { dst[di++] = src[si++]; dst[di++] = src[si++]; } else if (src[si] == 0 && src[si + 1] == 0 && src[si + 2] != 0) { if (src[si + 2] == 3) { dst[di++] = 0; dst[di++] = 0; si += 3; if (nal->skipped_bytes_pos) { nal->skipped_bytes++; if (nal->skipped_bytes_pos_size < nal->skipped_bytes) { nal->skipped_bytes_pos_size *= 2; av_assert0(nal->skipped_bytes_pos_size >= nal->skipped_bytes); av_reallocp_array(&nal->skipped_bytes_pos, nal->skipped_bytes_pos_size, sizeof(*nal->skipped_bytes_pos)); if (!nal->skipped_bytes_pos) { nal->skipped_bytes_pos_size = 0; return AVERROR(ENOMEM); } } if (nal->skipped_bytes_pos) nal->skipped_bytes_pos[nal->skipped_bytes-1] = di - 1; } continue; } else goto nsc; } dst[di++] = src[si++]; } while (si < length) dst[di++] = src[si++]; nsc: memset(dst + di, 0, AV_INPUT_BUFFER_PADDING_SIZE); nal->data = dst; nal->size = di; nal->raw_data = src; nal->raw_size = si; return si; }
1threat
static av_always_inline int setup_classifs(vorbis_context *vc, vorbis_residue *vr, uint8_t *do_not_decode, unsigned ch_used, int partition_count) { int p, j, i; unsigned c_p_c = vc->codebooks[vr->classbook].dimensions; unsigned inverse_class = ff_inverse[vr->classifications]; unsigned temp, temp2; for (p = 0, j = 0; j < ch_used; ++j) { if (!do_not_decode[j]) { temp = get_vlc2(&vc->gb, vc->codebooks[vr->classbook].vlc.table, vc->codebooks[vr->classbook].nb_bits, 3); av_dlog(NULL, "Classword: %u\n", temp); assert(vr->classifications > 1 && temp <= 65536); for (i = 0; i < c_p_c; ++i) { temp2 = (((uint64_t)temp) * inverse_class) >> 32; if (partition_count + c_p_c - 1 - i < vr->ptns_to_read) vr->classifs[p + partition_count + c_p_c - 1 - i] = temp - temp2 * vr->classifications; temp = temp2; } } p += vr->ptns_to_read; } return 0; }
1threat
status bar disappeared after full screen video in WKWebView only in iOS 12 : <p>As you can see this only happened in iOS 12.</p> <p>iOS 12 &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp; &emsp;&emsp;iOS 11 </p> <p><a href="https://i.stack.imgur.com/XLq2T.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/XLq2T.gif" alt="enter image description here"></a>&emsp;<a href="https://i.stack.imgur.com/C9zt9.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/C9zt9.gif" alt="enter image description here"></a></p> <p>here is my code: </p> <pre><code>import UIKit import WebKit class ViewController: UIViewController { override var preferredStatusBarStyle: UIStatusBarStyle { return .lightContent } override var prefersStatusBarHidden: Bool { return false } var webView: WKWebView! override func viewDidLoad() { super.viewDidLoad() webView = WKWebView(frame: UIScreen.main.bounds) view.addSubview(webView) webView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true webView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true webView.widthAnchor.constraint(equalTo: view.widthAnchor).isActive = true webView.loadHTMLString("&lt;p&gt;&lt;iframe src=\"https://www.youtube.com/embed/HCjNJDNzw8Y\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"\"&gt;&lt;/iframe&gt;&lt;/p&gt;", baseURL: URL(string: "https://www.youtube.com/")) setNeedsStatusBarAppearanceUpdate() } } </code></pre> <p>my info.plist is right below: <a href="https://i.stack.imgur.com/LY1L6.png%60" rel="noreferrer"><img src="https://i.stack.imgur.com/LY1L6.png%60" alt="enter image description here"></a></p> <p>Does anyone know how to solve it? </p> <p>I know that if I set the key <code>View controller-based status bar appearance</code> to <code>YES</code> will help, but In that case it will look like this:</p> <p><a href="https://i.stack.imgur.com/wk7OR.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/wk7OR.gif" alt="enter image description here"></a></p> <p>There are unknown reason for changing status bar from white and black, and as for my real project is in a large scale, so it will be nice to solve in the original setting, rather than make every ViewController inherit from one class which is subclass from UIViewController or add <code>dynamic</code> for overriding <code>prefersStatusBarHidden</code> and <code>preferredStatusBarStyle</code> in extension (here just try to force it show update status bar when <code>View controller-based status bar appearance</code> set to <code>YES</code>)</p> <p>Hope there is a solution for <code>View controller-based status bar appearance</code> set to <code>NO</code>, that will be very helpful thx.</p> <p><strong><a href="https://github.com/andrew54068/WebViewStatusBar" rel="noreferrer" title="demo project">here</a></strong> is the demo project, it was created by Xcode9.4, feel free to try it with.</p>
0debug
Why this R ggplot subscript is not working? : <p>Code where trying to apply <code>g + labs(y=expression(N_{s}))</code> with the following error which does not make sense</p> <pre><code>g &lt;- ggplot(datm, aes(variable, value, fill=gender)) + geom_bar(stat="identity", position = position_dodge()) + facet_grid(male.Nij ~ group) + xlab("Association type") + ggtitle("View") #http://stackoverflow.com/a/17335258/54964 g + labs( y=expression(N_{s}) ) </code></pre> <p>I get</p> <pre><code>Error: unexpected '{' in "g + labs( y=expression(N_{" Execution halted </code></pre> <p>R: 3.3.2 backports<br> OS: Debian 8.5 </p>
0debug
int opt_default(void *optctx, const char *opt, const char *arg) { const AVOption *o; int consumed = 0; char opt_stripped[128]; const char *p; const AVClass *cc = avcodec_get_class(), *fc = avformat_get_class(); const av_unused AVClass *rc_class; const AVClass *sc, *swr_class; if (!strcmp(opt, "debug") || !strcmp(opt, "fdebug")) av_log_set_level(AV_LOG_DEBUG); if (!(p = strchr(opt, ':'))) p = opt + strlen(opt); av_strlcpy(opt_stripped, opt, FFMIN(sizeof(opt_stripped), p - opt + 1)); if ((o = av_opt_find(&cc, opt_stripped, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) || ((opt[0] == 'v' || opt[0] == 'a' || opt[0] == 's') && (o = av_opt_find(&cc, opt + 1, NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)))) { av_dict_set(&codec_opts, opt, arg, FLAGS); consumed = 1; } if ((o = av_opt_find(&fc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ))) { av_dict_set(&format_opts, opt, arg, FLAGS); if(consumed) av_log(NULL, AV_LOG_VERBOSE, "Routing %s to codec and muxer layer\n", opt); consumed = 1; } #if CONFIG_SWSCALE sc = sws_get_class(); if (!consumed && av_opt_find(&sc, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) { int ret = av_opt_set(sws_opts, opt, arg, 0); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); return ret; } consumed = 1; } #endif #if CONFIG_SWRESAMPLE swr_class = swr_get_class(); if (!consumed && av_opt_find(&swr_class, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) { int ret = av_opt_set(swr_opts, opt, arg, 0); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error setting option %s.\n", opt); return ret; } consumed = 1; } #endif #if CONFIG_AVRESAMPLE rc_class = avresample_get_class(); if (av_opt_find(&rc_class, opt, NULL, 0, AV_OPT_SEARCH_CHILDREN | AV_OPT_SEARCH_FAKE_OBJ)) { av_dict_set(&resample_opts, opt, arg, FLAGS); consumed = 1; } #endif if (consumed) return 0; return AVERROR_OPTION_NOT_FOUND; }
1threat
SQL Sever: max of date : Table 1 -------- RefId ----- 1 2 Table 2 -------- RefId Date ----- ----- 1 29/03/2018 07:15 1 29/03/2018 07:30 2 29/03/2018 07:35 2 29/03/2018 07:40 i would like the result to be as follows (Refid and the max(date) from table 2 for that refid) 1 29/03/2018 07:30 2 29/03/2018 07:40
0debug
How to disable auto-quotes and auto-brackets in Jupyter 5.0 : <p>I upgraded Jupyter to the latest vesion, 5.0, and it looks like my front-end configuration stopped working.</p> <p>I don't understand why Jupyter comes with auto closing quotes and brackets by default, which I find pretty annoying. So, at each version I have to change the settings to disable it.</p> <p>It used to work by creating a file <code>~/.jupyter/custom/custom.js</code> and adding the next JavaScript code:</p> <pre><code>require(['notebook/js/codecell'], function (codecell) { codecell.CodeCell.options_default.cm_config.autoCloseBrackets = false; }) </code></pre> <p>I've read that since Jupyter 4 this code could be changed by:</p> <pre><code>IPython.CodeCell.options_default.cm_config.autoCloseBrackets = false; </code></pre> <p>But it looks like in Jupyter 5, the two previous options stopped working.</p> <p>The documentation I found regarding the front-end configuration is not helpful (I'll be happy to improve it once I understand it):</p> <p><a href="http://jupyter-notebook.readthedocs.io/en/latest/frontend_config.html#frontend-config" rel="noreferrer">http://jupyter-notebook.readthedocs.io/en/latest/frontend_config.html#frontend-config</a></p> <p>Can anyone help me understand how to disable auto-brackets and auto-quotes in Jupyter 5 please?</p> <p>This is the exact version I'm running:</p> <p><a href="https://i.stack.imgur.com/M12B4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/M12B4.png" alt="enter image description here"></a></p>
0debug
static void flush_encoders(void) { int i, ret; for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; AVCodecContext *enc = ost->enc_ctx; OutputFile *of = output_files[ost->file_index]; if (!ost->encoding_needed) continue; if (!ost->initialized) { FilterGraph *fg = ost->filter->graph; char error[1024]; av_log(NULL, AV_LOG_WARNING, "Finishing stream %d:%d without any data written to it.\n", ost->file_index, ost->st->index); if (ost->filter && !fg->graph) { int x; for (x = 0; x < fg->nb_inputs; x++) { InputFilter *ifilter = fg->inputs[x]; if (ifilter->format < 0) { AVCodecParameters *par = ifilter->ist->st->codecpar; ifilter->format = par->format; ifilter->sample_rate = par->sample_rate; ifilter->channels = par->channels; ifilter->channel_layout = par->channel_layout; ifilter->width = par->width; ifilter->height = par->height; ifilter->sample_aspect_ratio = par->sample_aspect_ratio; } } if (!ifilter_has_all_input_formats(fg)) continue; ret = configure_filtergraph(fg); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error configuring filter graph\n"); exit_program(1); } finish_output_stream(ost); } ret = init_output_stream(ost, error, sizeof(error)); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d -- %s\n", ost->file_index, ost->index, error); exit_program(1); } } if (enc->codec_type == AVMEDIA_TYPE_AUDIO && enc->frame_size <= 1) continue; #if FF_API_LAVF_FMT_RAWPICTURE if (enc->codec_type == AVMEDIA_TYPE_VIDEO && (of->ctx->oformat->flags & AVFMT_RAWPICTURE) && enc->codec->id == AV_CODEC_ID_RAWVIDEO) continue; #endif if (enc->codec_type != AVMEDIA_TYPE_VIDEO && enc->codec_type != AVMEDIA_TYPE_AUDIO) continue; avcodec_send_frame(enc, NULL); for (;;) { const char *desc = NULL; AVPacket pkt; int pkt_size; switch (enc->codec_type) { case AVMEDIA_TYPE_AUDIO: desc = "audio"; break; case AVMEDIA_TYPE_VIDEO: desc = "video"; break; default: av_assert0(0); } av_init_packet(&pkt); pkt.data = NULL; pkt.size = 0; update_benchmark(NULL); ret = avcodec_receive_packet(enc, &pkt); update_benchmark("flush_%s %d.%d", desc, ost->file_index, ost->index); if (ret < 0 && ret != AVERROR_EOF) { av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n", desc, av_err2str(ret)); exit_program(1); } if (ost->logfile && enc->stats_out) { fprintf(ost->logfile, "%s", enc->stats_out); } if (ret == AVERROR_EOF) { break; } if (ost->finished & MUXER_FINISHED) { av_packet_unref(&pkt); continue; } av_packet_rescale_ts(&pkt, enc->time_base, ost->mux_timebase); pkt_size = pkt.size; output_packet(of, &pkt, ost); if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO && vstats_filename) { do_video_stats(ost, pkt_size); } } } }
1threat
Use module as text in Python : I have a dictionary that contains modules, now I would like to use the string value of the module (see example). Is this possible or am I better of just creating a second dictionary? ```python import module1 import module2 import module3 module_dict = { 'module1' = module1 'module2' = module2 } user_input = input() module_dict[user_input].function() #module3.function requires two strings to work, one of the string happens to be the name of the module module3.function('foo', module_dict[user_input]) ``` This is a really simplified version, forgive me if it looks confussing. I can not use the built-in ```str``` function since it will result in ```module 'modulename' at 'path'``` which is not what I am after.
0debug
static void type_initialize(TypeImpl *ti) { TypeImpl *parent; if (ti->class) { return; } ti->class_size = type_class_get_size(ti); ti->instance_size = type_object_get_size(ti); ti->class = g_malloc0(ti->class_size); parent = type_get_parent(ti); if (parent) { type_initialize(parent); GSList *e; int i; g_assert(parent->class_size <= ti->class_size); memcpy(ti->class, parent->class, parent->class_size); ti->class->interfaces = NULL; for (e = parent->class->interfaces; e; e = e->next) { ObjectClass *iface = e->data; type_initialize_interface(ti, object_class_get_name(iface)); } for (i = 0; i < ti->num_interfaces; i++) { TypeImpl *t = type_get_by_name(ti->interfaces[i].typename); for (e = ti->class->interfaces; e; e = e->next) { TypeImpl *target_type = OBJECT_CLASS(e->data)->type; if (type_is_ancestor(target_type, t)) { break; } } if (e) { continue; } type_initialize_interface(ti, ti->interfaces[i].typename); } } ti->class->type = ti; while (parent) { if (parent->class_base_init) { parent->class_base_init(ti->class, ti->class_data); } parent = type_get_parent(parent); } if (ti->class_init) { ti->class_init(ti->class, ti->class_data); } }
1threat
Gitlab integration with SonarQube : <p>I am pretty new to Development community and specifically to DevOps practices , as a part of project we are trying to integrate SonarQube with Gitlab , did some R&amp; D on SonarQube and Git CI ( Continuous Integration ) and look like plugin is released for Github and SonarQube whereas not for Gitlab. </p> <p>How realistic is it to configure GitLab with SonarQube for inspecting code quality for every pull request and what will be the best practice to integrate these two piece.</p> <p>Thanks </p>
0debug
DeviceState *nand_init(BlockDriverState *bdrv, int manf_id, int chip_id) { DeviceState *dev; if (nand_flash_ids[chip_id].size == 0) { hw_error("%s: Unsupported NAND chip ID.\n", __FUNCTION__); } dev = DEVICE(object_new(TYPE_NAND)); qdev_prop_set_uint8(dev, "manufacturer_id", manf_id); qdev_prop_set_uint8(dev, "chip_id", chip_id); if (bdrv) { qdev_prop_set_drive_nofail(dev, "drive", bdrv); } qdev_init_nofail(dev); return dev; }
1threat
How to group by a single item without including it in the GROUP BY clause? : <p>My desire is to have a sales report grouped by product description that shows the quantity of each item and the price. The problem I am running into is that I only want to group by the product description and not other fields that I have to include because there are aggregate functions in the SELECT clause. I have googled and searched everywhere and have not found a simple solution. </p>
0debug
int index_from_key(const char *key) { int i; for (i = 0; QKeyCode_lookup[i] != NULL; i++) { if (!strcmp(key, QKeyCode_lookup[i])) { break; } } return i; }
1threat
Windows & Android: react native server crashes very often : <pre><code> ERROR EPERM: operation not permitted, lstat '...\.idea\workspace.xml___jb_old___' {"errno":-4048,"code":"EPERM","syscall":"lstat","path":"...\.idea\\workspace.xml___jb_old___"} Error: EPERM: operation not permitted, lstat 'app\.idea\workspace.xml___jb_old___' at Error (native) </code></pre> <p>After that I should again do:</p> <pre><code>npm start </code></pre> <p>How to resolve this quite annoying problem? Thanks</p>
0debug
VBA to export rows in source doc to an existing document and save as new file : 'I am trying to make a vba code to open an existing spreadsheet and populate the first row of that existing spreadsheet with the row of the information from the source spreadsheet then auto save it as the project name listed in a specific cell of the source. Can anyone help me out. I am not a coder, just copying codes that I have found. I am using this code. Sub Button1_Click() Application.DisplayAlerts = False Application.ScreenUpdating = False On Error GoTo PROC_ERROR Dim ThisWorkbook As Workbook, NewBook As Workbook Dim ThisWorksheet As Worksheet, NewWs As Worksheet Dim i As Integer, j As Integer, k As Integer, ExportCount As Integer Set ThisWorkbook = ActiveWorkbook Set ThisWorksheet = ThisWorkbook.Sheets("Sheet1") ExportCount = 0 For i = 2 To Aslong If ThisWorksheet.Cells(i, 1) <> "" Then Set NewBook = Workbooks.Open("F:\DBA\Land Opportunities\Set-Up Templates\FOR SALE TEMPLATE.xlsx") Set NewWs = Existing.Sheets("Project") For j = 2 To 13 If ThisWorksheet.Cells(i, j) <> "" Then NewWs.Cells(1, 1) = ThisWorksheet.Cells(i, j) End If Next j With NewBook .Sheets("Sheet2").Delete .Sheets("Sheet3").Delete .Title = ThisWorksheet.Cells(i, 3) .SaveAs Filename:=ThisWorksheet.Cells(i, 3) & ".csv", FileFormat:=xlCSV, CreateBackup:=False End With ExportCount = ExportCount + 1 End If Next i PROC_ERROR: If Err.Number <> 0 Then MsgBox "This macro has encountered an error and needs to exit. However, some or all of your exported workbooks may still have been saved. Please try again." _ & vbNewLine & vbNewLine & "Error Number: " & Err.Number & vbNewLine & "Error Description: " & Err.Description, vbInformation ExportCount = 0 Application.DisplayAlerts = True Application.ScreenUpdating = True Exit Sub Else MsgBox "Successfully exported " & ExportCount & " workbooks!", vbInformation ExportCount = ExportCount End If Application.DisplayAlerts = True Application.ScreenUpdating = True End Sub
0debug
Navigation Architecture Component - Splash screen : <p>I would like to know how to implement splash screen using Navigation Architecture Component.</p> <p>Till now I have something like this</p> <p><a href="https://i.stack.imgur.com/BovRm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BovRm.png" alt="enter image description here"></a></p> <p>A user has to setup his profile in <code>ProfileFragment</code> for the first time and can edit their profile from <code>ChatFragment</code>. </p> <p>My problem is I don't know how to remove <code>SplashFragment</code> from stack after navigation. I've seen <a href="https://developer.android.com/topic/libraries/architecture/navigation/navigation-conditional" rel="noreferrer">conditional navigation</a> but didn't quite understand. </p>
0debug
static struct omap_lpg_s *omap_lpg_init(MemoryRegion *system_memory, target_phys_addr_t base, omap_clk clk) { struct omap_lpg_s *s = (struct omap_lpg_s *) g_malloc0(sizeof(struct omap_lpg_s)); s->tm = qemu_new_timer_ms(vm_clock, omap_lpg_tick, s); omap_lpg_reset(s); memory_region_init_io(&s->iomem, &omap_lpg_ops, s, "omap-lpg", 0x800); memory_region_add_subregion(system_memory, base, &s->iomem); omap_clk_adduser(clk, qemu_allocate_irqs(omap_lpg_clk_update, s, 1)[0]); return s; }
1threat
How to get the checkbutton to respond to command? : <p>I have a button which adds a movable yellow circle and an off switch when pressed. I want the user to turn off and on the yellow circle, when the checkbutton is checked it will turn the circle to white and when the button is checked it will turn the circle yellow.</p> <pre><code>from tkinter import * root=Tk() root.grid() input_id=0 yco=212 canvas=Canvas(root,height=600,width=600) canvas.grid() def addInput(): global input_id global yco input_id+=1 yco+=50 input_tag="input-%s"%input_id tags=("input",input_tag) canvas.create_oval(200,200,225,225,fill="WHITE",width=5,tag=tags) canvas.tag_bind(input_tag,"&lt;B1-Motion&gt;",lambda event,tag=input_tag:moveInput(event,tag)) def checkStatus(status): if status.get()==0: canvas.delete(tags) canvas.create_oval(200,200,225,225,fill="YELLOW",width=5,tag=tags) canvas.tag_bind(input_tag,"&lt;B1-Motion&gt;",lambda event,tag=input_tag:moveInput(event,tag)) else: canvas.delete(tags) canvas.create_oval(200,200,225,225,fill="WHITE",width=5,tag=tags) canvas.tag_bind(input_tag,"&lt;B1-Motion&gt;",lambda event,tag=input_tag:moveInput(event,tag)) status=IntVar() statusCkbtn=Checkbutton(canvas,text="Off",command=checkStatus(status),variable=status,bg="white") statusCkbtn.var=status statusCkbtn.place(x=200,y=yco) def moveInput(event, tag): x=event.x y=event.y coords=canvas.coords(tag) movex=x-coords[0] movey=y-coords[1] canvas.move(tag, movex, movey) btn=Button(canvas,text="Add Input",command=lambda:addInput()) btn.place(x=100,y=100) root.mainloop() </code></pre>
0debug
Serialization of an object in Java : <p>we have an object as following,</p> <p>[user_id,name,email,password]</p> <p>1- How can we serialize this object?<br> 2- How can we serialize user_id,name,email part only?<br> That means I dnt want serialize password field.</p>
0debug
Is it considered grey/black hat SEO if I modify the sizing of the headings? : <p>The situation is the following:</p> <p>The page's title is H3, the article's title is H2 and some keyword/important sentence is H1 in the article. They have custom css classes on them, so the H3 looks like a H1, and the H1 looks like normal text. Is this considered grey/black hat SEO, or Google doesn't care about their rendered size?</p>
0debug
apt-get installing oracle java 7 stopped working : <p>Recently <code>apt-get install -y oracle-java7-installer</code> stopped working.</p> <p>I know in their roadmap, I think the public version is no longer supported, but it's been working all the way until recently. <a href="http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html" rel="noreferrer">http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html</a></p> <p>Anyone have a work around for this?</p> <pre><code>http://download.oracle.com/otn-pub/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz?AuthParam=1495560077_4041e14adcb5fd7e68827ab0e15dc3b1 Connecting to download.oracle.com (download.oracle.com)|96.6.45.99|:80... connected. HTTP request sent, awaiting response... 404 Not Found 2017-05-23 10:19:17 ERROR 404: Not Found. </code></pre>
0debug
Protobuf3: How to describe map of repeated string? : <p>The <a href="https://developers.google.com/protocol-buffers/docs/proto3#maps" rel="noreferrer" title="Official documentation about map type">Official documentation about map type</a> says:</p> <blockquote> <p><code>map&lt;key_type, value_type&gt; map_field = N;</code></p> <p>...where the key_type can be any integral or string type (so, any scalar type except for floating point types and bytes). The value_type can be <strong>any type</strong>.</p> </blockquote> <p>I want to define a <code>map&lt;string, repeated string&gt;</code> field, but it seems illegal on my <code>libprotoc 3.0.0</code>, which complains <code>Expected "&gt;"</code>. So I wonder if there is any way to put repeated string into map.</p> <p>A Possible workaround could be:</p> <pre><code>message ListOfString { repeated string value = 1; } // Then define: map&lt;string, ListOfString&gt; mapToRepeatedString = 1; </code></pre> <p>But <code>ListOfString</code> here looks redundant. </p>
0debug
static void v9fs_readdir(void *opaque) { int32_t fid; V9fsFidState *fidp; ssize_t retval = 0; size_t offset = 7; int64_t initial_offset; int32_t count, max_count; V9fsPDU *pdu = opaque; V9fsState *s = pdu->s; pdu_unmarshal(pdu, offset, "dqd", &fid, &initial_offset, &max_count); trace_v9fs_readdir(pdu->tag, pdu->id, fid, initial_offset, max_count); fidp = get_fid(pdu, fid); if (fidp == NULL) { retval = -EINVAL; goto out_nofid; } if (!fidp->fs.dir) { retval = -EINVAL; goto out; } if (initial_offset == 0) { v9fs_co_rewinddir(pdu, fidp); } else { v9fs_co_seekdir(pdu, fidp, initial_offset); } count = v9fs_do_readdir(pdu, fidp, max_count); if (count < 0) { retval = count; goto out; } retval = offset; retval += pdu_marshal(pdu, offset, "d", count); retval += count; out: put_fid(pdu, fidp); out_nofid: complete_pdu(s, pdu, retval); }
1threat
Fetching records from database in chunks : <p>My java web application is retrieving a large dataset from the DB (DB2) and displaying the records on a webpage. Since the number of records is very large , the page takes a little time to load (about 15 secs) To improve this , I want to implement pagination on the server side , ie fetch only 50 records at a time and show it on the page. Then when the user clicks on Next , the next 50 records are fetched and displayed.</p> <p>I have already implemented this on the client side ie I am showing the data in chunks of 50 , <strong>but I am still fetching the entire data in one database call</strong>, due to which the page takes time to load.</p> <p>How can I implement the pagination on the server side ie fetch only 50 records at a time ?</p> <p>Thanks in advance.</p>
0debug
Can't center jdialog in jframe [Java] : I can't center my jdialog in my jframe. I've tried to do this but it doesn't work: public Window(String title) { panel = new JPanel(); this.setLocationRelativeTo(Main.instance.frame); this.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); this.setLayout(new GridLayout()); this.setResizable(false); this.setPreferredSize(new Dimension(300, 400)); this.pack(); this.add(panel); this.setTitle(title); } Tell me if you need any more code! Thanks for your help!
0debug
void console_select(unsigned int index) { TextConsole *s; if (index >= MAX_CONSOLES) return; if (active_console) { active_console->g_width = ds_get_width(active_console->ds); active_console->g_height = ds_get_height(active_console->ds); } s = consoles[index]; if (s) { DisplayState *ds = s->ds; if (active_console->cursor_timer) { qemu_del_timer(active_console->cursor_timer); } active_console = s; if (ds_get_bits_per_pixel(s->ds)) { ds->surface = qemu_resize_displaysurface(ds, s->g_width, s->g_height); } else { s->ds->surface->width = s->width; s->ds->surface->height = s->height; } if (s->cursor_timer) { qemu_mod_timer(s->cursor_timer, qemu_get_clock_ms(rt_clock) + CONSOLE_CURSOR_PERIOD / 2); } dpy_resize(s->ds); vga_hw_invalidate(); } }
1threat
What is Renderer2 in angular4? why it is preferred over jquery? : <p>I want to understand what is and why Renderer2 is used in angular for DOM manipulation. Can we use the rich and famous library jQuery in place fo Renderer2 or native javascript? What is advantage of using Renederer2 over jQuery</p>
0debug
def remove_even(l): for i in l: if i % 2 == 0: l.remove(i) return l
0debug
static void versatile_init(ram_addr_t ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model, int board_id) { CPUState *env; ram_addr_t ram_offset; qemu_irq *cpu_pic; qemu_irq pic[32]; qemu_irq sic[32]; DeviceState *dev; PCIBus *pci_bus; NICInfo *nd; int n; int done_smc = 0; if (!cpu_model) cpu_model = "arm926"; env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } ram_offset = qemu_ram_alloc(NULL, "versatile.ram", ram_size); cpu_register_physical_memory(0, ram_size, ram_offset | IO_MEM_RAM); arm_sysctl_init(0x10000000, 0x41007004, 0x02000000); cpu_pic = arm_pic_init_cpu(env); dev = sysbus_create_varargs("pl190", 0x10140000, cpu_pic[0], cpu_pic[1], NULL); for (n = 0; n < 32; n++) { pic[n] = qdev_get_gpio_in(dev, n); } dev = sysbus_create_simple("versatilepb_sic", 0x10003000, NULL); for (n = 0; n < 32; n++) { sysbus_connect_irq(sysbus_from_qdev(dev), n, pic[n]); sic[n] = qdev_get_gpio_in(dev, n); } sysbus_create_simple("pl050_keyboard", 0x10006000, sic[3]); sysbus_create_simple("pl050_mouse", 0x10007000, sic[4]); dev = sysbus_create_varargs("versatile_pci", 0x40000000, sic[27], sic[28], sic[29], sic[30], NULL); pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci"); for(n = 0; n < nb_nics; n++) { nd = &nd_table[n]; if ((!nd->model && !done_smc) || strcmp(nd->model, "smc91c111") == 0) { smc91c111_init(nd, 0x10010000, sic[25]); done_smc = 1; } else { pci_nic_init_nofail(nd, "rtl8139", NULL); } } if (usb_enabled) { usb_ohci_init_pci(pci_bus, -1); } n = drive_get_max_bus(IF_SCSI); while (n >= 0) { pci_create_simple(pci_bus, -1, "lsi53c895a"); n--; } sysbus_create_simple("pl011", 0x101f1000, pic[12]); sysbus_create_simple("pl011", 0x101f2000, pic[13]); sysbus_create_simple("pl011", 0x101f3000, pic[14]); sysbus_create_simple("pl011", 0x10009000, sic[6]); sysbus_create_simple("pl080", 0x10130000, pic[17]); sysbus_create_simple("sp804", 0x101e2000, pic[4]); sysbus_create_simple("sp804", 0x101e3000, pic[5]); sysbus_create_simple("pl110_versatile", 0x10120000, pic[16]); sysbus_create_varargs("pl181", 0x10005000, sic[22], sic[1], NULL); sysbus_create_varargs("pl181", 0x1000b000, sic[23], sic[2], NULL); sysbus_create_simple("pl031", 0x101e8000, pic[10]); versatile_binfo.ram_size = ram_size; versatile_binfo.kernel_filename = kernel_filename; versatile_binfo.kernel_cmdline = kernel_cmdline; versatile_binfo.initrd_filename = initrd_filename; versatile_binfo.board_id = board_id; arm_load_kernel(env, &versatile_binfo); }
1threat
How to use an object outside a method in java? : <pre><code>public class Utilty { public DesiredCapabilities nologs() { DesiredCapabilities dcap= new DesiredCapabilities(); return dcap; } private static WebDriver driver = new FirefoxDriver(dcap) } } </code></pre> <p>i want to use dcap object outside the method nologs but i am unable to do so.how to use dcap object?</p>
0debug
static void pflash_update(pflash_t *pfl, int offset, int size) { int offset_end; if (pfl->bs) { offset_end = offset + size; offset = offset >> 9; offset_end = (offset_end + 511) >> 9; bdrv_write(pfl->bs, offset, pfl->storage + (offset << 9), offset_end - offset); } }
1threat
void usb_ep_combine_input_packets(USBEndpoint *ep) { USBPacket *p, *u, *next, *prev = NULL, *first = NULL; USBPort *port = ep->dev->port; int ret; assert(ep->pipeline); assert(ep->pid == USB_TOKEN_IN); QTAILQ_FOREACH_SAFE(p, &ep->queue, queue, next) { if (ep->halted) { p->result = USB_RET_REMOVE_FROM_QUEUE; port->ops->complete(port, p); continue; } if (p->state == USB_PACKET_ASYNC) { prev = p; continue; } usb_packet_check_state(p, USB_PACKET_QUEUED); if (prev && prev->short_not_ok) { break; } if (first) { if (first->combined == NULL) { USBCombinedPacket *combined = g_new0(USBCombinedPacket, 1); combined->first = first; QTAILQ_INIT(&combined->packets); qemu_iovec_init(&combined->iov, 2); usb_combined_packet_add(combined, first); } usb_combined_packet_add(first->combined, p); } else { first = p; } if ((p->iov.size % ep->max_packet_size) != 0 || !p->short_not_ok || next == NULL) { ret = usb_device_handle_data(ep->dev, first); assert(ret == USB_RET_ASYNC); if (first->combined) { QTAILQ_FOREACH(u, &first->combined->packets, combined_entry) { usb_packet_set_state(u, USB_PACKET_ASYNC); } } else { usb_packet_set_state(first, USB_PACKET_ASYNC); } first = NULL; prev = p; } } }
1threat
How does the linker handle identical template instantiations across translation units? : <p>Suppose I have two translation-units: </p> <p>foo.cpp</p> <pre><code>void foo() { auto v = std::vector&lt;int&gt;(); } </code></pre> <p>bar.cpp</p> <pre><code>void bar() { auto v = std::vector&lt;int&gt;(); } </code></pre> <p>When I compile these translation-units, each will instantiate <code>std::vector&lt;int&gt;</code>. </p> <p>My question is: how does this work at the linking stage? </p> <ul> <li>Do both instantiations have different mangled names? </li> <li>Does the linker remove them as duplicates?</li> </ul>
0debug
static int device_open(AVFormatContext *ctx, uint32_t *capabilities) { struct v4l2_capability cap; int fd; int res, err; int flags = O_RDWR; if (ctx->flags & AVFMT_FLAG_NONBLOCK) { flags |= O_NONBLOCK; } fd = open(ctx->filename, flags, 0); if (fd < 0) { av_log(ctx, AV_LOG_ERROR, "Cannot open video device %s : %s\n", ctx->filename, strerror(errno)); return AVERROR(errno); } res = ioctl(fd, VIDIOC_QUERYCAP, &cap); if (res < 0 && ((err = errno) == 515)) { av_log(ctx, AV_LOG_ERROR, "QUERYCAP not implemented, probably V4L device but " "not supporting V4L2\n"); close(fd); return AVERROR(515); } if (res < 0) { av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_QUERYCAP): %s\n", strerror(errno)); close(fd); return AVERROR(err); } if ((cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) { av_log(ctx, AV_LOG_ERROR, "Not a video capture device\n"); close(fd); return AVERROR(ENODEV); } *capabilities = cap.capabilities; return fd; }
1threat
/dev/kvm permission denied android emulator : <p>hi i install android stdio on Ubuntu 18.0 then i try to start android emulator i got error </p> <blockquote> <p>/dev/kvm permission denied</p> </blockquote> <p>i try some stackoverflow question but its not solve my problem those question links are </p> <p>1.<a href="https://stackoverflow.com/questions/37300811/android-studio-dev-kvm-device-permission-denied">Android Studio: /dev/kvm device permission denied</a></p> <p>2.<a href="https://stackoverflow.com/questions/44635879/kvm-is-required-to-run-this-avd-unknown-error-please-file-a-bug-against-androi">KVM is required to run this AVD. Unknown Error! Please file a bug against Android Studio</a></p> <p>3.<a href="https://askubuntu.com/questions/985142/ubuntu-14-android-studio-3-xrdp-dev-kvm-permission-denied">Ubuntu 14 Android Studio 3 xrdp /dev/kvm permission denied</a></p> <p>t tried all this but its not solve my problem and i give chmod 777 permission also </p> <pre><code>chmod 777 -R /home/halfix/Android/Sdk/emulator/ </code></pre> <p>still i have /de/kvm permission divided </p>
0debug
How to reload a page in angular2 : <p>How to reload a page in angular2.<br> While searching through net, i got a code <code>"this._router.renavigate()"</code> to reload the page but looks like its not working with latest release of angular2.<br> Another way is <code>'window.location.reload()'</code> but this is not the angular way of doing it.</p>
0debug
Change the mat-autocomplete width? : <p>It seems like the <code>&lt;mat-autocomplete&gt;</code> width is always the width of the input we're typing in. Is there no way to make it larger? I have a very small input and can't read the dropdown items. I'm also limited in form space so can't make the input larger.</p> <pre><code>&lt;mat-form-field style="width: 100px;"&gt; &lt;input matInput [matAutocomplete]="auto"&gt; &lt;mat-autocomplete style="width: 500px;" #auto="matAutocomplete"&gt; &lt;mat-option *ngFor="let item of items" [value]="item"&gt; &lt;/mat-option&gt; &lt;/mat-autocomplete&gt; &lt;/mat-form-field&gt; </code></pre>
0debug
how to use an array as Global and access it from all other files in PHP : <p>I have a file called users.php where I am adding usernames in array as below</p> <pre><code>&lt;?php $users = array("alexritz","katrob","diaman","janber","denivar","hamrop","calvik"); ?&gt; </code></pre> <p>everytime I need this array in another php file I use <code>require 'users.php';</code> and do whatever I need with this array. </p> <p>I want to make my array global and use it across all files without using <code>require</code>. I know how to use session and it works for me but I am chasing the global how to make it work. I tried as below</p> <blockquote> <p>users.php</p> </blockquote> <pre><code>&lt;?php $users = array("alexritz","katrob","diaman","janber","denivar","hamrop","calvik"); function globalUsers() { return $GLOBALS['users']; } globalUsers(); ?&gt; </code></pre> <p>then in any other php file I just call <code>globalUsers();</code> but it's not working. </p> <p>Any ideas please ? Thank you.</p>
0debug
static int vmdk_write(BlockDriverState *bs, int64_t sector_num, const uint8_t *buf, int nb_sectors) { BDRVVmdkState *s = bs->opaque; int index_in_cluster, n; uint64_t cluster_offset; static int cid_update = 0; while (nb_sectors > 0) { index_in_cluster = sector_num & (s->cluster_sectors - 1); n = s->cluster_sectors - index_in_cluster; if (n > nb_sectors) n = nb_sectors; cluster_offset = get_cluster_offset(bs, sector_num << 9, 1); if (!cluster_offset) return -1; if (bdrv_pwrite(s->hd, cluster_offset + index_in_cluster * 512, buf, n * 512) != n * 512) return -1; nb_sectors -= n; sector_num += n; buf += n * 512; if (!cid_update) { vmdk_write_cid(bs, time(NULL)); cid_update++; } } return 0; }
1threat
int qed_read_l2_table(BDRVQEDState *s, QEDRequest *request, uint64_t offset) { int ret; qed_unref_l2_cache_entry(request->l2_table); request->l2_table = qed_find_l2_cache_entry(&s->l2_cache, offset); if (request->l2_table) { return 0; } request->l2_table = qed_alloc_l2_cache_entry(&s->l2_cache); request->l2_table->table = qed_alloc_table(s); BLKDBG_EVENT(s->bs->file, BLKDBG_L2_LOAD); ret = qed_read_table(s, offset, request->l2_table->table); qed_acquire(s); if (ret) { qed_unref_l2_cache_entry(request->l2_table); request->l2_table = NULL; } else { request->l2_table->offset = offset; qed_commit_l2_cache_entry(&s->l2_cache, request->l2_table); request->l2_table = qed_find_l2_cache_entry(&s->l2_cache, offset); assert(request->l2_table != NULL); } qed_release(s); return ret; }
1threat
sql qurey for duplicate customers : I want number of customers (count) and duplicate phone_no from a table. I have to remove dashes in phone number and then check the length is equal to 10. Please can any one help in sql query. My query is like below, select COUNT(Cust_ID) cnt,Phone_no from tbl_Customers where Cust_Type = 3 group by Phone_no having COUNT(Cust_ID) > 1 order by cnt desc
0debug
Renaming RStudio project under version control : <p>What's the right way to rename an RStudio project (esp., when that project is under version control)?</p> <p>E.g., I created an RStudio project with version control in "~/myproject". Then I decided I wanted to rename the project to "myproject1". So I </p> <ol> <li>renamed "~/myproject" as "~/myproject1"</li> <li>renamed "myproject.Rproj" as "myproject1.Rproj"</li> <li>committed the "rename" changes with git via RStudio.</li> </ol> <p>Everything seems to be fine. But I have a suspicion I'm missing something and that I'm going to be surprised by some project behavior down the line. </p>
0debug
c# creating a dynamically anonymous types (var) : <p>I need to create a anonymous type (HAS to be a var). Like this:</p> <pre><code>var sizes = new { size = new { Medium = "1", Large = "-3", XL = "10%" } }; </code></pre> <p>It has to be dynamically so the next time this could also happen:</p> <pre><code>var sizes = new { size = new { 3XL = "5", 4XL = "5%", 5XL = "-10%" } }; </code></pre> <p>How do I do this in C# winforms?</p> <p>How do i fill in the var sizes? It has to be in this order!</p>
0debug
Determine if user clicked outside shadow dom : <p>I'm trying to implement a dropdown which you can click outside to close. The dropdown is part of a custom date input and is encapsulated inside the input's shadow DOM.</p> <p>I want to write something like:</p> <pre><code>window.addEventListener('mousedown', function (evt) { if (!componentNode.contains(evt.target)) { closeDropdown(); } }); </code></pre> <p>however, the event is retargeted, so <code>evt.target</code> is <em>always</em> the outside the element. There are multiple shadow boundaries that the event will cross before reaching the window, so there seems to be no way of actually knowing if the user clicked inside my component or not.</p> <p><b>Note:</b> I'm not using polymer anywhere -- I need an answer which applies to generic shadow DOM, not a polymer specific hack.</p>
0debug
int qemu_strtoi64(const char *nptr, const char **endptr, int base, int64_t *result) { char *ep; int err = 0; if (!nptr) { if (endptr) { *endptr = nptr; } err = -EINVAL; } else { errno = 0; *result = strtoll(nptr, &ep, base); err = check_strtox_error(nptr, ep, endptr, errno); } return err; }
1threat
Scala - How to avoid a var here : <p>I wonder if anybody knows how to avoid the var in the following pseudocode:</p> <pre><code>var cnt = theConstant val theSequence = theMap.flapMap{case (theSet, theList) =&gt; if (theSet.isEmpty) { // do something here with theList and return a sequence } else { cnt += 1 // do something here with cnt and theList and return a sequence }} </code></pre>
0debug
static int http_proxy_open(URLContext *h, const char *uri, int flags) { HTTPContext *s = h->priv_data; char hostname[1024], hoststr[1024]; char auth[1024], pathbuf[1024], *path; char lower_url[100]; int port, ret = 0, attempts = 0; HTTPAuthType cur_auth_type; char *authstr; int new_loc; h->is_streamed = 1; av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port, pathbuf, sizeof(pathbuf), uri); ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL); path = pathbuf; if (*path == '/') path++; ff_url_join(lower_url, sizeof(lower_url), "tcp", NULL, hostname, port, NULL); redo: ret = ffurl_open(&s->hd, lower_url, AVIO_FLAG_READ_WRITE, &h->interrupt_callback, NULL); if (ret < 0) return ret; authstr = ff_http_auth_create_response(&s->proxy_auth_state, auth, path, "CONNECT"); snprintf(s->buffer, sizeof(s->buffer), "CONNECT %s HTTP/1.1\r\n" "Host: %s\r\n" "Connection: close\r\n" "%s%s" "\r\n", path, hoststr, authstr ? "Proxy-" : "", authstr ? authstr : ""); av_freep(&authstr); if ((ret = ffurl_write(s->hd, s->buffer, strlen(s->buffer))) < 0) goto fail; s->buf_ptr = s->buffer; s->buf_end = s->buffer; s->line_count = 0; s->filesize = -1; cur_auth_type = s->proxy_auth_state.auth_type; ret = http_read_header(h, &new_loc); if (ret < 0) goto fail; attempts++; if (s->http_code == 407 && (cur_auth_type == HTTP_AUTH_NONE || s->proxy_auth_state.stale) && s->proxy_auth_state.auth_type != HTTP_AUTH_NONE && attempts < 2) { ffurl_closep(&s->hd); goto redo; } if (s->http_code < 400) return 0; ret = AVERROR(EIO); fail: http_proxy_close(h); return ret; }
1threat
RequiresApi vs TargetApi android annotations : <p>Whats the difference between <code>RequiresApi</code> and <code>TargetApi</code>?</p> <p>Sample in kotlin:</p> <pre><code>@RequiresApi(api = Build.VERSION_CODES.M) @TargetApi(Build.VERSION_CODES.M) class FingerprintHandlerM() : FingerprintManager.AuthenticationCallback() </code></pre> <p><em>NOTE: <code>FingerprintManager.AuthenticationCallback</code> requires api <code>M</code></em></p> <p><em>NOTE 2: if I dont use TargetApi lint fail with error <code>class requires api level 23...</code></em></p>
0debug
static int coroutine_fn bdrv_co_do_write_zeroes(BlockDriverState *bs, int64_t sector_num, int nb_sectors, BdrvRequestFlags flags) { BlockDriver *drv = bs->drv; QEMUIOVector qiov; struct iovec iov = {0}; int ret = 0; int max_write_zeroes = bs->bl.max_write_zeroes ? bs->bl.max_write_zeroes : INT_MAX; while (nb_sectors > 0 && !ret) { int num = nb_sectors; if (bs->bl.write_zeroes_alignment && num > bs->bl.write_zeroes_alignment) { if (sector_num % bs->bl.write_zeroes_alignment != 0) { num = bs->bl.write_zeroes_alignment; num -= sector_num % bs->bl.write_zeroes_alignment; } else if ((sector_num + num) % bs->bl.write_zeroes_alignment != 0) { num -= (sector_num + num) % bs->bl.write_zeroes_alignment; } } if (num > max_write_zeroes) { num = max_write_zeroes; } ret = -ENOTSUP; if (drv->bdrv_co_write_zeroes) { ret = drv->bdrv_co_write_zeroes(bs, sector_num, num, flags); } if (ret == -ENOTSUP) { int max_xfer_len = MIN_NON_ZERO(bs->bl.max_transfer_length, MAX_WRITE_ZEROES_BOUNCE_BUFFER); num = MIN(num, max_xfer_len); iov.iov_len = num * BDRV_SECTOR_SIZE; if (iov.iov_base == NULL) { iov.iov_base = qemu_try_blockalign(bs, num * BDRV_SECTOR_SIZE); if (iov.iov_base == NULL) { ret = -ENOMEM; goto fail; } memset(iov.iov_base, 0, num * BDRV_SECTOR_SIZE); } qemu_iovec_init_external(&qiov, &iov, 1); ret = drv->bdrv_co_writev(bs, sector_num, num, &qiov); if (num < max_xfer_len) { qemu_vfree(iov.iov_base); iov.iov_base = NULL; } } sector_num += num; nb_sectors -= num; } fail: qemu_vfree(iov.iov_base); return ret; }
1threat
static sPAPRDIMMState *spapr_recover_pending_dimm_state(sPAPRMachineState *ms, PCDIMMDevice *dimm) { sPAPRDRConnector *drc; PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); MemoryRegion *mr = ddc->get_memory_region(dimm); uint64_t size = memory_region_size(mr); uint32_t nr_lmbs = size / SPAPR_MEMORY_BLOCK_SIZE; uint32_t avail_lmbs = 0; uint64_t addr_start, addr; int i; sPAPRDIMMState *ds; addr_start = object_property_get_int(OBJECT(dimm), PC_DIMM_ADDR_PROP, &error_abort); addr = addr_start; for (i = 0; i < nr_lmbs; i++) { drc = spapr_drc_by_id(TYPE_SPAPR_DRC_LMB, addr / SPAPR_MEMORY_BLOCK_SIZE); g_assert(drc); if (drc->indicator_state != SPAPR_DR_INDICATOR_STATE_INACTIVE) { avail_lmbs++; } addr += SPAPR_MEMORY_BLOCK_SIZE; } ds = g_malloc0(sizeof(sPAPRDIMMState)); ds->nr_lmbs = avail_lmbs; ds->dimm = dimm; spapr_pending_dimm_unplugs_add(ms, ds); return ds; }
1threat
What is the reason I can't execute the code below? : <pre><code>&lt;?php $greeting = 'hi'; echo 'hi' $greeting; ?&gt; </code></pre> <p>I know that the above works when string interpolation is used such as <code>echo "hi $greeting";</code> but if the code works individually as in <code>echo 'hi'</code> and <code>echo $greeting</code> I don't understand why the I get an error when the code is combined to be <code>echo 'hi' $greeting;</code> as I illustrated above.</p>
0debug
int bdrv_create(BlockDriver *drv, const char* filename, QemuOpts *opts, Error **errp) { int ret; Coroutine *co; CreateCo cco = { .drv = drv, .filename = g_strdup(filename), .opts = opts, .ret = NOT_DONE, .err = NULL, }; if (!drv->bdrv_create) { error_setg(errp, "Driver '%s' does not support image creation", drv->format_name); ret = -ENOTSUP; goto out; } if (qemu_in_coroutine()) { bdrv_create_co_entry(&cco); } else { co = qemu_coroutine_create(bdrv_create_co_entry); qemu_coroutine_enter(co, &cco); while (cco.ret == NOT_DONE) { aio_poll(qemu_get_aio_context(), true); } } ret = cco.ret; if (ret < 0) { if (cco.err) { error_propagate(errp, cco.err); } else { error_setg_errno(errp, -ret, "Could not create image"); } } out: g_free(cco.filename); return ret; }
1threat