problem
stringlengths
26
131k
labels
class label
2 classes
int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base, int64_t sector_num, int nb_sectors, int *pnum) { BlockDriverState *intermediate; int ret, n = nb_sectors; intermediate = top; while (intermediate && intermediate != base) { int pnum_inter; ret = bdrv_is_allocated(intermediate, sector_num, nb_sectors, &pnum_inter); if (ret < 0) { return ret; } else if (ret) { *pnum = pnum_inter; return 1; } if (n > pnum_inter && (intermediate == top || sector_num + pnum_inter < intermediate->total_sectors)) { n = pnum_inter; } intermediate = intermediate->backing_hd; } *pnum = n; return 0; }
1threat
static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPacket *avpkt) { JvContext *s = avctx->priv_data; const uint8_t *buf = avpkt->data; const uint8_t *buf_end = buf + avpkt->size; int video_size, video_type, i, j; video_size = AV_RL32(buf); video_type = buf[4]; buf += 5; if (video_size) { if (video_size < 0 || video_size > avpkt->size - 5) { av_log(avctx, AV_LOG_ERROR, "video size %d invalid\n", video_size); return AVERROR_INVALIDDATA; } if (avctx->reget_buffer(avctx, &s->frame) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; } if (video_type == 0 || video_type == 1) { GetBitContext gb; init_get_bits(&gb, buf, 8 * video_size); for (j = 0; j < avctx->height; j += 8) for (i = 0; i < avctx->width; i += 8) decode8x8(&gb, s->frame.data[0] + j*s->frame.linesize[0] + i, s->frame.linesize[0], &s->dsp); buf += video_size; } else if (video_type == 2) { if (buf + 1 <= buf_end) { int v = *buf++; for (j = 0; j < avctx->height; j++) memset(s->frame.data[0] + j*s->frame.linesize[0], v, avctx->width); } } else { av_log(avctx, AV_LOG_WARNING, "unsupported frame type %i\n", video_type); return AVERROR_INVALIDDATA; } } if (buf_end - buf >= AVPALETTE_COUNT * 3) { for (i = 0; i < AVPALETTE_COUNT; i++) { uint32_t pal = AV_RB24(buf); s->palette[i] = 0xFF << 24 | pal << 2 | ((pal >> 4) & 0x30303); buf += 3; } s->palette_has_changed = 1; } if (video_size) { s->frame.key_frame = 1; s->frame.pict_type = AV_PICTURE_TYPE_I; s->frame.palette_has_changed = s->palette_has_changed; s->palette_has_changed = 0; memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); *data_size = sizeof(AVFrame); *(AVFrame*)data = s->frame; } return avpkt->size; }
1threat
How to redirect to html error page when error 403 occurs on Google Cloud Plateform? : I'm looking for a way to redirect 403 errors to a html error page on Google Cloud Plateform.
0debug
unsigned int qemu_get_be32(QEMUFile *f) { unsigned int v; v = qemu_get_byte(f) << 24; v |= qemu_get_byte(f) << 16; v |= qemu_get_byte(f) << 8; v |= qemu_get_byte(f); return v; }
1threat
How can I click a button while a textarea is focused with jquery? : I'm using jquery's focus() to alter a textarea when focused. However, I need to click a submit button outside of the focused area. The submit button currently only worked after the textarea is un-focus. Here's my code <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#post").focus(function(){ $(this).css({'border-color':'green', 'height':'120px'}); }); $("#post").blur(function(){ $(this).css({'border-color':'#bfbfbf', 'height':'50px'}); }); }); function submit(){ //Do Something $('#post').val(''); } </script> <style> textarea{ border-radius: 3px; resize: none; width: 300px; height: 50px; font-size: 20px; padding: 10px; border: 2px solid #bfbfbf; } </style> </head> <body> <textarea name="post" cols="52" id="post" placeholder="Post.." onclick="focusasd()"></textarea> <br> <input type="button" name="submit" value="Submit" id="submit" onclick="submit()"/> </body> </html> Here is a [jsfiddle][1]. How can I make the submit button work even when the textarea is focused. Thanks. [1]: https://jsfiddle.net/0ug2e5s4/2/
0debug
React method binding explained : <p>Hope this will help newcomers to understand the purpose of method binding in react. There's a good explanation [here][1] and [here][2], but this will be more to the point and crux of the problem.</p>
0debug
static int vc1_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) { VC1Context *v = avctx->priv_data; MpegEncContext *s = &v->s; AVFrame *pict = data; uint8_t *buf2 = NULL; if (buf_size == 0) { if (s->low_delay==0 && s->next_picture_ptr) { *pict= *(AVFrame*)s->next_picture_ptr; s->next_picture_ptr= NULL; *data_size = sizeof(AVFrame); } return 0; } if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){ int i= ff_find_unused_picture(s, 0); s->current_picture_ptr= &s->picture[i]; } if (avctx->codec_id == CODEC_ID_VC1) { int buf_size2 = 0; buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); if(IS_MARKER(AV_RB32(buf))){ const uint8_t *start, *end, *next; int size; next = buf; for(start = buf, end = buf + buf_size; next < end; start = next){ next = find_next_marker(start + 4, end); size = next - start - 4; if(size <= 0) continue; switch(AV_RB32(start)){ case VC1_CODE_FRAME: buf_size2 = vc1_unescape_buffer(start + 4, size, buf2); break; case VC1_CODE_ENTRYPOINT: buf_size2 = vc1_unescape_buffer(start + 4, size, buf2); init_get_bits(&s->gb, buf2, buf_size2*8); decode_entry_point(avctx, &s->gb); break; case VC1_CODE_SLICE: av_log(avctx, AV_LOG_ERROR, "Sliced decoding is not implemented (yet)\n"); return -1; } } }else if(v->interlace && ((buf[0] & 0xC0) == 0xC0)){ const uint8_t *divider; divider = find_next_marker(buf, buf + buf_size); if((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD){ av_log(avctx, AV_LOG_ERROR, "Error in WVC1 interlaced frame\n"); return -1; } buf_size2 = vc1_unescape_buffer(buf, divider - buf, buf2); av_free(buf2);return -1; }else{ buf_size2 = vc1_unescape_buffer(buf, buf_size, buf2); } init_get_bits(&s->gb, buf2, buf_size2*8); } else init_get_bits(&s->gb, buf, buf_size*8); if(v->profile < PROFILE_ADVANCED) { if(vc1_parse_frame_header(v, &s->gb) == -1) { return -1; } } else { if(vc1_parse_frame_header_adv(v, &s->gb) == -1) { return -1; } } if(s->pict_type != FF_I_TYPE && !v->res_rtm_flag){ return -1; } s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == FF_I_TYPE; if(s->last_picture_ptr==NULL && (s->pict_type==FF_B_TYPE || s->dropable)){ return -1; } if(avctx->hurry_up && s->pict_type==FF_B_TYPE) return -1; if( (avctx->skip_frame >= AVDISCARD_NONREF && s->pict_type==FF_B_TYPE) || (avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=FF_I_TYPE) || avctx->skip_frame >= AVDISCARD_ALL) { return buf_size; } if(avctx->hurry_up>=5) { return -1; } if(s->next_p_frame_damaged){ if(s->pict_type==FF_B_TYPE) return buf_size; else s->next_p_frame_damaged=0; } if(MPV_frame_start(s, avctx) < 0) { return -1; } s->me.qpel_put= s->dsp.put_qpel_pixels_tab; s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab; ff_er_frame_start(s); v->bits = buf_size * 8; vc1_decode_blocks(v); ff_er_frame_end(s); MPV_frame_end(s); assert(s->current_picture.pict_type == s->current_picture_ptr->pict_type); assert(s->current_picture.pict_type == s->pict_type); if (s->pict_type == FF_B_TYPE || s->low_delay) { *pict= *(AVFrame*)s->current_picture_ptr; } else if (s->last_picture_ptr != NULL) { *pict= *(AVFrame*)s->last_picture_ptr; } if(s->last_picture_ptr || s->low_delay){ *data_size = sizeof(AVFrame); ff_print_debug_info(s, pict); } avctx->frame_number = s->picture_number - 1; return buf_size; }
1threat
how I could use each index for print index of each element in ruby? : I have an array array = ["mm,GATO,nIn","mm,GATO,nn","mm,PERRO,nIn","mm,PERRO,nn","mm,LOBO,nIn","mm,LOBO,nn"] I need to use each_index for obtain array = ["mm,GATO,nn1","mm,GATO,nn2","mm,PERRO,nn1","mm,PERRO,nn2","mm,LOBO,nn1","mm,LOBO,nn2"] PLease help me with this
0debug
from itertools import combinations def find_combinations(test_list): res = [(b1 + a1, b2 + a2) for (a1, a2), (b1, b2) in combinations(test_list, 2)] return (res)
0debug
static int decode_display_orientation(H264Context *h) { h->sei_display_orientation_present = !get_bits1(&h->gb); if (h->sei_display_orientation_present) { h->sei_hflip = get_bits1(&h->gb); h->sei_vflip = get_bits1(&h->gb); h->sei_anticlockwise_rotation = get_bits(&h->gb, 16); get_ue_golomb(&h->gb); skip_bits1(&h->gb); } return 0; }
1threat
select TOP designated employees per department IN A SINGLE qUERY : I HAVE A TABLE AND VALUES HOW TO FINED TOP designated employees per department. TAHNKS IN ADVANCED OUT PUT SHOULD BE emp_id dept_name emp_name desig 1 IT JAFFERY DIRECTOR 12 QA GEORGE MANAGER 13 ADMIN EMILLY MANAGER 15 DEVELOPMENT ABDUL MANAGER 16 DATA PATRICK CLERK CREATE TABLE [dbo].[#deptartment] ( [emp_id] [INT] IDENTITY(1, 1) NOT NULL, [dept_name] [VARCHAR](100) NULL, [emp_name] [VARCHAR](50) NULL , [desig] [VARCHAR](100) NULL ) ON [PRIMARY] GO INSERT INTO #deptartment VALUES ('IT','JAFFERY','DIRECTOR') INSERT INTO #deptartment VALUES ('DEVELOPMENT','CORBIT','PROGRAMMER') INSERT INTO #deptartment VALUES ('DEVELOPMENT','CHANDRA','DBA') INSERT INTO #deptartment VALUES ('IT','KEVIN','MANAGER') INSERT INTO #deptartment VALUES ('IT','ROBERT','SUPERVISOR') INSERT INTO #deptartment VALUES ('QA','NOMAN','ANALYST') INSERT INTO #deptartment VALUES ('ADMIN','CORE','RECEPTIONIST') INSERT INTO #deptartment VALUES ('QA','MADDEN','ANALYST') INSERT INTO #deptartment VALUES ('IT','NORRIS','TECHNICIAN') INSERT INTO #deptartment VALUES ('ADMIN','PATRICK','CLERK') INSERT INTO #deptartment VALUES ('DATA','SONJA','SUPERVISOR') INSERT INTO #deptartment VALUES ('QA','GEORGE','MANAGER') INSERT INTO #deptartment VALUES ('ADMIN','EMILLY','MANAGER') INSERT INTO #deptartment VALUES ('QA','PATRICK','TESTER') INSERT INTO #deptartment VALUES ('DEVELOPMENT','ABDUL','MANAGER') INSERT INTO #deptartment VALUES ('DATA','PATRICK','CLERK') INSERT INTO #deptartment VALUES ('ADMIN','GEORGE','CLERK') INSERT INTO #deptartment VALUES ('DEVELOPMENT','YURIY','SUPERVISOR') INSERT INTO #deptartment VALUES ('DATA','GRAHAM','OPERATOR')
0debug
int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, int *frame_size_ptr, uint8_t *buf, int buf_size) { int ret; if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){ if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){ av_log(avctx, AV_LOG_ERROR, "buffer smaller than AVCODEC_MAX_AUDIO_FRAME_SIZE\n"); return -1; } if(*frame_size_ptr < FF_MIN_BUFFER_SIZE || *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t) || *frame_size_ptr < buf_size){ av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr); return -1; } ret = avctx->codec->decode(avctx, samples, frame_size_ptr, buf, buf_size); avctx->frame_number++; }else{ ret= 0; *frame_size_ptr=0; } return ret; }
1threat
static int decode_b_mbs(VC9Context *v) { MpegEncContext *s = &v->s; GetBitContext *gb = &v->s.gb; int current_mb = 0, i ; int b_mv_type = BMV_TYPE_BACKWARD; int mquant, mqdiff; int ttmb; static const int size_table[6] = { 0, 2, 3, 4, 5, 8 }, offset_table[6] = { 0, 1, 3, 7, 15, 31 }; int mb_has_coeffs = 1; int dmv1_x, dmv1_y, dmv2_x, dmv2_y; int k_x, k_y; int hpel_flag; int index, index1; int val, sign; switch (v->mvrange) { case 1: k_x = 10; k_y = 9; break; case 2: k_x = 12; k_y = 10; break; case 3: k_x = 13; k_y = 11; break; default: k_x = 9; k_y = 8; break; } hpel_flag = v->mv_mode & 1; k_x -= hpel_flag; k_y -= hpel_flag; if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0]; else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1]; else v->ttmb_vlc = &vc9_ttmb_vlc[2]; for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++) { for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++) { if (v->direct_mb_plane.is_raw) v->direct_mb_plane.data[current_mb] = get_bits(gb, 1); if (v->skip_mb_plane.is_raw) v->skip_mb_plane.data[current_mb] = get_bits(gb, 1); if (!v->direct_mb_plane.data[current_mb]) { if (v->skip_mb_plane.data[current_mb]) { b_mv_type = decode012(gb); if (v->bfraction > 420 && b_mv_type < 3) b_mv_type = 1-b_mv_type; } else { GET_MVDATA(dmv1_x, dmv1_y); if (!s->mb_intra ) { b_mv_type = decode012(gb); if (v->bfraction > 420 && b_mv_type < 3) b_mv_type = 1-b_mv_type; } } } if (!v->skip_mb_plane.data[current_mb]) { if (mb_has_coeffs ) { GET_MQUANT(); if (s->mb_intra ) s->ac_pred = get_bits(gb, 1); } else { if (b_mv_type == BMV_TYPE_INTERPOLATED) { GET_MVDATA(dmv2_x, dmv2_y); } if (mb_has_coeffs ) { if (s->mb_intra ) s->ac_pred = get_bits(gb, 1); GET_MQUANT(); } } } if (v->ttmbf) ttmb = get_vlc2(gb, v->ttmb_vlc->table, VC9_TTMB_VLC_BITS, 12); for (i=0; i<6; i++) { } current_mb++; } } return 0; }
1threat
static int context_init(H264Context *h){ MpegEncContext * const s = &h->s; CHECKED_ALLOCZ(h->top_borders[0], h->s.mb_width * (16+8+8) * sizeof(uint8_t)) CHECKED_ALLOCZ(h->top_borders[1], h->s.mb_width * (16+8+8) * sizeof(uint8_t)) CHECKED_ALLOCZ(s->allocated_edge_emu_buffer, (s->width+64)*2*21*2); s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*21; return 0; fail: return -1; }
1threat
How can I Handle Socket.IO rooms with cluster? : <p>I have a server working with cluster and to make that work with socke.IO I am using sticky-session, but I have a problem with my rooms (I don't know if the way I did is the best option): The cluster is instantiating processes and each process has a specific number of rooms. </p> <ul> <li>Server <ul> <li>Process 1 <ul> <li>Room1 </li> <li>Room2</li> <li>Room N</li> </ul></li> <li>Process 2 <ul> <li>Room1 </li> <li>Room2</li> <li>Room N</li> </ul></li> </ul></li> </ul> <p>The way I did to connect some user to the rooms (with only one process) is using the route, where the user access a page and when he tries to make a connection with Socket.io I check the URL and with that information I insert him in a room.</p> <p>My problem is implementing this server with cluster I can not insert the user in specific rooms because there is some rooms that only exist in specific processes and sticky session put him in another process. How can I put an user in a room that is in another process ? Also The use can only to see the routes of the process he is in the server and I would like to show every rooms in the page.</p> <p>I already has read about Redis-Adapter but I didn't find solutions on github using Socket.io + Cluster(Sticky-session + redis-adapter) + rooms.</p> <p>Follow my code to share what I have done:</p> <pre><code>//Cluster.Master with simplified Code if (cluster.isMaster) { var workers = []; // Spawn workers. for (var i = 0; i &lt; num_processes; i++) { spawn(i); } // Create the outside facing server listening on our port. var server = net.createServer({ pauseOnConnect: true }, function(connection) { // We received a connection and need to pass it to the appropriate // worker. Get the worker for this connection's source IP and pass // it the connection. var worker = workers[worker_index(connection.remoteAddress, num_processes)]; worker.send('sticky-session:connection', connection); }).listen(process.env.PORT); } else { console.log('I am worker #' + cluster.worker.id); var app = new express(); //view engine app.set('views', './views'); app.set('view engine', 'pug'); //statics app.use(express.static(path.join(__dirname, 'public'))); //rooms app.use('/', rooms); var server = app.listen(0, 'localhost'), io = sio(server); io.adapter(sio_redis({ host: 'localhost', port: 6379 })); //This File has the socket events (socket.on('messageX', function(){})) // And there I am var realtime = require('./realtime/socketIOEvents.js')(io); // Listen to messages sent from the master. Ignore everything else. process.on('message', function(message, connection) { if (message !== 'sticky-session:connection') { return; } // Emulate a connection event on the server by emitting the // event with the connection the master sent us. server.emit('connection', connection); connection.resume(); }); } </code></pre>
0debug
Ionic **Build Failed** Code signing is required for product type 'Application' in SDK 'iOS 10.1' : <p>When I am running <code>ionic run ios --device </code> the build is failing, It was working fine few days ago and now I am getting this error, How to solve it, I have searched the solution but none worked for me.</p> <p>Below is the error</p> <pre><code> === BUILD TARGET SoftApp OF PROJECT SoftApp WITH CONFIGURATION Debug === Check dependencies Signing for "SoftApp" requires a development team. Select a development team in the project editor. Code signing is required for product type 'Application' in SDK 'iOS 10.1' ** BUILD FAILED ** The following build commands failed: Check dependencies (1 failure) Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/amitabhs/Projects/SoftApp/SoftAppcc/Mobile/SoftAppIonic_cc/platforms/ios/cordova/build-debug.xcconfig,-project,SoftApp.xcodeproj,ARCHS=armv7 arm64,-target,SoftApp,-configuration,Debug,-sdk,iphoneos,build,VALID_ARCHS=armv7 arm64,CONFIGURATION_BUILD_DIR=/Users/amitabhs/Projects/SoftApp/SoftAppcc/Mobile/SoftAppIonic_cc/platforms/ios/build/device,SHARED_PRECOMPS_DIR=/Users/amitabhs/Projects/SoftApp/SoftAppcc/Mobile/SoftAppIonic_cc/platforms/ios/build/sharedpch </code></pre> <p>I have tried un-installing and reinstalling IOS, cordova and ionic, nothing helped</p> <p>Here is my config:</p> <pre><code> Your system information: Cordova CLI: 6.3.1 Ionic Framework Version: 1.3.1 Ionic CLI Version: 2.0.0 Ionic App Lib Version: 2.0.0-beta.20 ios-deploy version: 1.8.6 ios-sim version: 5.0.8 OS: Mac OS X El Capitan Node Version: v4.5.0 Xcode version: Xcode 8.1 Build version 8B62 </code></pre>
0debug
static int decode_slice_thread(AVCodecContext *avctx, void *arg, int jobnr, int threadnr) { ProresContext *ctx = avctx->priv_data; SliceContext *slice = &ctx->slices[jobnr]; const uint8_t *buf = slice->data; AVFrame *pic = ctx->frame; int i, hdr_size, qscale, log2_chroma_blocks_per_mb; int luma_stride, chroma_stride; int y_data_size, u_data_size, v_data_size, a_data_size; uint8_t *dest_y, *dest_u, *dest_v, *dest_a; int16_t qmat_luma_scaled[64]; int16_t qmat_chroma_scaled[64]; int mb_x_shift; slice->ret = -1; hdr_size = buf[0] >> 3; qscale = av_clip(buf[1], 1, 224); qscale = qscale > 128 ? qscale - 96 << 2: qscale; y_data_size = AV_RB16(buf + 2); u_data_size = AV_RB16(buf + 4); v_data_size = slice->data_size - y_data_size - u_data_size - hdr_size; if (hdr_size > 7) v_data_size = AV_RB16(buf + 6); a_data_size = slice->data_size - y_data_size - u_data_size - v_data_size - hdr_size; if (y_data_size < 0 || u_data_size < 0 || v_data_size < 0 || hdr_size+y_data_size+u_data_size+v_data_size > slice->data_size){ av_log(avctx, AV_LOG_ERROR, "invalid plane data size\n"); return -1; } buf += hdr_size; for (i = 0; i < 64; i++) { qmat_luma_scaled [i] = ctx->qmat_luma [i] * qscale; qmat_chroma_scaled[i] = ctx->qmat_chroma[i] * qscale; } if (ctx->frame_type == 0) { luma_stride = pic->linesize[0]; chroma_stride = pic->linesize[1]; } else { luma_stride = pic->linesize[0] << 1; chroma_stride = pic->linesize[1] << 1; } if (avctx->pix_fmt == AV_PIX_FMT_YUV444P10 || avctx->pix_fmt == AV_PIX_FMT_YUVA444P10) { mb_x_shift = 5; log2_chroma_blocks_per_mb = 2; } else { mb_x_shift = 4; log2_chroma_blocks_per_mb = 1; } dest_y = pic->data[0] + (slice->mb_y << 4) * luma_stride + (slice->mb_x << 5); dest_u = pic->data[1] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift); dest_v = pic->data[2] + (slice->mb_y << 4) * chroma_stride + (slice->mb_x << mb_x_shift); dest_a = pic->data[3] + (slice->mb_y << 4) * luma_stride + (slice->mb_x << 5); if (ctx->frame_type && ctx->first_field ^ ctx->frame->top_field_first) { dest_y += pic->linesize[0]; dest_u += pic->linesize[1]; dest_v += pic->linesize[2]; dest_a += pic->linesize[3]; } decode_slice_luma(avctx, slice, (uint16_t*)dest_y, luma_stride, buf, y_data_size, qmat_luma_scaled); if (!(avctx->flags & CODEC_FLAG_GRAY)) { decode_slice_chroma(avctx, slice, (uint16_t*)dest_u, chroma_stride, buf + y_data_size, u_data_size, qmat_chroma_scaled, log2_chroma_blocks_per_mb); decode_slice_chroma(avctx, slice, (uint16_t*)dest_v, chroma_stride, buf + y_data_size + u_data_size, v_data_size, qmat_chroma_scaled, log2_chroma_blocks_per_mb); } if (ctx->alpha_info && dest_a && a_data_size) decode_slice_alpha(ctx, (uint16_t*)dest_a, luma_stride, buf + y_data_size + u_data_size + v_data_size, a_data_size, slice->mb_count); slice->ret = 0; return 0; }
1threat
Send newsletter - best pratic - order by email host or not : for a newsletter mailing, about 50,000 users, using pear, is it convenient to order the list by mail provider or leave it all randomly?
0debug
static void kvmppc_pivot_hpt_cpu(CPUState *cs, run_on_cpu_data arg) { target_ulong sdr1 = arg.target_ptr; PowerPCCPU *cpu = POWERPC_CPU(cs); CPUPPCState *env = &cpu->env; cpu_synchronize_state(cs); env->spr[SPR_SDR1] = sdr1; if (kvmppc_put_books_sregs(cpu) < 0) { error_report("Unable to update SDR1 in KVM"); exit(1); } }
1threat
clk_setup_cb cpu_ppc_tb_init (CPUState *env, uint32_t freq) { ppc_tb_t *tb_env; tb_env = qemu_mallocz(sizeof(ppc_tb_t)); if (tb_env == NULL) return NULL; env->tb_env = tb_env; tb_env->decr_timer = qemu_new_timer(vm_clock, &cpu_ppc_decr_cb, env); #if defined(TARGET_PPC64H) tb_env->hdecr_timer = qemu_new_timer(vm_clock, &cpu_ppc_hdecr_cb, env); #endif cpu_ppc_set_tb_clk(env, freq); return &cpu_ppc_set_tb_clk; }
1threat
reshape data based on column name : How can one reshape data based on column name x1 x2 x3 x4 1 1 5 6 1 2 3 5 2 1 6 1 2 2 2 4 to x1 1 x1 1 x1 2 x1 2 x2 1 . . . I have read many posts but I could not figure this out
0debug
static void test_visitor_out_native_list_int16(TestOutputVisitorData *data, const void *unused) { test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S16); }
1threat
error 1005 laravel because of migrations pariorities : i have some tables that are connected to each other. i should declare foreign key for those. when i doing this by migrations, the error 1005 appear. I know that this error due to migrations priorities. now i dont know how to solve this problem. this is one of my migrations: [![categories migration][1]][1] and this is another one: [![colors migration][2]][2] And finally, the most important migration is: [![products migration][3]][3] [1]: https://i.stack.imgur.com/wZ9F5.png [2]: https://i.stack.imgur.com/mqjFc.png [3]: https://i.stack.imgur.com/qRbnm.png and i don't know how to declare foreign keys in another migration. thanks for your helping.
0debug
Compiler Linker error? : <p>I'm programming for Arduino and since I'm a beginner when I get this error message I'm unable to interpret it in order to solve it.</p> <p>"<em>C:\Users\VITOR~1.NUN\AppData\Local\Temp\ccmmwX2d.ltrans0.ltrans.o: In function <code>setup': ccmmwX2d.ltrans0.o:(.text+0x16a): undefined reference to</code>registrador_nivel' C:\Users\VITOR~1.NUN\AppData\Local\Temp\ccmmwX2d.ltrans4.ltrans.o: In function <code>AutoCampLib::Registrador::debug(char*)': ccmmwX2d.ltrans4.o:(.text+0xae0): undefined reference to</code>registrador_nivel' collect2.exe: error: ld returned 1 exit status</em>"</p> <p><strong>This is my lib :</strong> </p> <pre><code> #ifndef LIBAC_H #define LIBAC_H #define DEBUG /***************************************************/ /********************Bibliotecas********************/ /***************************************************/ /* Biblioteca padrão do Arduino */ #include &lt;Arduino.h&gt; /* Bibliotecas de data/hora para módulo DS1307 RTC */ #include &lt;Wire.h&gt; #include &lt;RTClib.h&gt; #include &lt;Time.h&gt; #include &lt;TimeLib.h&gt; #include &lt;TimeAlarms.h&gt; /* Bibliotecas de leitura e escrita para módulo SD */ #include &lt;SD.h&gt; #include &lt;SPI.h&gt; /* Biblioteca do módulo ultrassônico HC-SR04 */ #include &lt;Ultrasonic.h&gt; /* Biblioteca de Lista Encadeada */ #include &lt;LinkedList.h&gt; /* Biblioteca de Threads */ #include "Thread.h" #include "ThreadController.h" /* Biblioteca de HashMap */ #include &lt;HashMap.h&gt; /***************************************************/ /******************Mapa da Pinagem******************/ /***************************************************/ #define PINO_SD_CS 53 #define setor_1 23 #define setor_2 25 #define setor_3 42 #define setor_4 43 #define setor_5 44 #define setor_6 45 #define setor_7 12 #define setor_8 13 #define setor_9 22 #define setor_10 24 #define setor_11 26 #define setor_12 28 #define setor_13 30 #define setor_14 32 #define setor_15 34 #define DesligaBombaCaptacao 31 #define LigaBombaCaptacao 33 #define DesligaBombaInjec 35 #define LigaBombaInjec 37 #define valvulaDescarte 46 #define DesligaPaMistura 39 #define LigaPaMistura 41 #define silo_1 10 #define silo_2 11 #define valvulaL2 29 #define contraLavagem 27 #define segundosUmaSemana 604800 #define TEMPO_OCIOSO 300 #define pinoInterruptTanque 0 // corresponde ao pino 2 #define pinoInterruptSilo 1 // corresponde ao pino 3 #define pinoInterruptInjec 2 // corresponde ao pino 4 #define pinoSensorTanque 6 #define pinoSensorSilo 5 #define pinoSensorInjec 8 #define boiaInferior 7 #define boiaSuperior 9 #define VOLUME_PURGA 100 // em Litros #define ULTIMA_MENSAGEM "Ultima.msg" #define SILOS_PRODUTOS "Silos.cfg" #define PROGRAMACAO "Ferti.cal" #define CONFIGURACAO "Start.cfg" #define RETROLAVAGEM "Retrolavagem.cal" #define DADOS "AutoCamp.nfo" #define LOG "AutoCamp.log" #define BACKUP "Backup.log" namespace AutoCampLib { class Mensageiro { public: Mensageiro(); void lerSerial(); void enviar1099(); private: bool guardarMensagem(char mensagem[]); bool tratarMensagem(); void tratar2001(); void tratar2002(); void tratar2003(); void tratar2101(); void tratar2901(); void tratar2902(); void tratar2903(); void tratar2904(); void tratar2905(); void tratar2999(); void enviar1001(); void enviar1002(); void enviar1003(); void enviar1004(); void enviar1005(); void lerArquivo(String nome); void escreverArquivo(String nome, int identificacao); bool verificaLetra(char caracter); }; class Registrador { public: static void debug(char mensagem[]); static void info(char mensagem[]); static void warn(char mensagem[]); static void error(char mensagem[]); private: static void escreverRegistro(char mensagem[],char tipo[]); static void verificarTamanho(); static String buscarDataHora(); }; class Fertilizantes { public : void setSilo(char *s); void setVol(float volumeFert); char *getSilo(); float getVol(); void setPortaSilo(int portasilo); int getPortaSilo(); private : char _silo[8]; float volumeF; int _portasilo; }; class Eventos { public : Eventos(); void setSetor(int setor); void setDuracao(int duracao); void setSequencial(int sequencial); void setVolumeH2O(float volumeAgua); void setPorta(int porta); int getPorta(); int getSetor(); int getDuracao(); int getSequencial(); float getVolumeH2O(); //void setFertilizantes(LinkedList&lt;Fertilizantes*&gt;); //LinkedList&lt;Fertilizantes*&gt; getFertilizantes(); Fertilizantes* getFertilizante(int posicao); void addFertilizante(Fertilizantes* fertilizante); int sizeFertilizantes(); private : int _setor; int _porta; float _duracao; int _sequencial; float _volumeH2O; LinkedList&lt;Fertilizantes*&gt; _fertilizantes; }; class Agendamentos { public: Agendamentos(); void setDia(int dia); void setHora(int hora); void setMinuto(int minuto); void setSegundo(int segundo); int getDia(); int getHora(); int getMinuto(); int getSegundo(); //LinkedList&lt;Eventos*&gt; getEventos(); Eventos* getEvento(int posicao); void addEvento(Eventos* evento); int sizeEventos(); private : int _dia; int _hora; int _minuto; int _segundo; int posicao; LinkedList&lt;Eventos*&gt; _eventos; }; class Start { public : void setPressurizacao (int pressurizacao); void setTroca (int troca); void setInjecao(int injecao); void setAtraso( int atraso); void setOrdem(int ordem); void setBase(float base); void setTopo(float topo); void setAltura(float altura); void setSiloSTART(char *p); void setPino(int pino); void openReadStart(Start *start); void leCaracter(char c, File file); int getPressurizacao(); int getTroca(); int getInjecao(); int getAtraso(); int getOrdem(); float getBase(); float getTopo(); float getAltura(); char *getSiloSTART(); int getPino(); private : Start *start; File startcfg; int pr; int troca; int inj; int atraso; int seq; int pino; float base; float topo; float altura; char charLido; int _pressurizacao; int _troca; int _injecao; int _atraso; int _ordem; float _base; float _topo; float _altura; char _silostart[8]; int _pino; }; class Util { public : static double calculaVolume(byte sensorInterrupt,byte sensorPin, float volumeDesejado); static void contadorPulso(); }; class SensorNivel: public Thread { public : bool shouldRun(long time); void run(); private : int estado; }; class Programas: public Thread { public : bool shouldRun(long time); void run(); private : unsigned long tempo; DateTime now ; }; class RecuperaIrriga: public Thread { public : bool shouldRun(long time); void run(); void fecharTodoSetor(); void verificarSetores(int numSetor); private : long horaFim; long horaAtual; long horaAgendamento; int numeroEvento; DateTime now; Agendamentos *agendamento; }; class VolumeAgua: public Thread { public : bool shouldRun(long time); void run(); static void contadorPulso(); double calculaVolume(byte sensorInterrupt,byte sensorPin, float volumeDesejado); private : volatile byte contaPulso; int numeroFert; int numeroEvento; float taxaFluxo; float fatorCalibrador; unsigned int fluxoL; unsigned long totalL; unsigned long oldTime; }; class VolumeSilo: public Thread { public : bool shouldRun(long time); void run(); static void contadorPulso(); double calculaVolume(byte sensorInterrupt,byte sensorPin, float volumeDesejado); private : float fatorCalibrador; volatile byte contaPulso; int numeroEvento; int numeroFert; float taxaFluxo; unsigned int fluxoL; unsigned long totalL; unsigned long oldTime; }; class RecuperaFerti: public Thread { public : void verificarSetores(int numSetor); void run(); bool shouldRun(long time); private : long horaAtual; long inicio; int encherTanque; long horaAgendamento; int encherSilo; int numeroFert; int numeroEvento; DateTime now; Agendamentos *agendamento; }; class RecuperaSilos: public Thread { public : bool shouldRun(long time); void run(); private : int numeroFert; int numeroEvento; }; class Injecao: public Thread { public : bool shouldRun(long time); void run(); private : int numeroFert; int numeroEvento; int estado; }; class NivelInjec: public Thread { private : int estado; public : bool shouldRun(long time); void run(); }; class Purga: public Thread { public : void run(); bool shouldRun(long time); static void contadorPulso(); double calculaVolume(byte sensorInterrupt,byte sensorPin, float volumeDesejado); }; class NivelPurga: public Thread { private : int estado; DateTime now; int numeroEvento; long horaAtual; long horaAgendamento; Agendamentos *agendamento; public : bool shouldRun(long time); void run(); fecharTodoSetor(); }; } using namespace AutoCampLib; #endif </code></pre>
0debug
Why isn't "export default" recommended in Angular? : <p>According to the <a href="https://www.typescriptlang.org/docs/handbook/modules.html" rel="noreferrer">Typescript documentation (section "Guidance for structuring modules")</a>:</p> <blockquote> <p><em>If you’re only exporting a single class or function, use export default</em></p> <p>Just as “exporting near the top-level” reduces friction on your module’s consumers, so does introducing a default export. If a module’s primary purpose is to house one specific export, then you should consider exporting it as a default export. This makes both importing and actually using the import a little easier.</p> </blockquote> <p>Example:</p> <pre><code>export default class SomeType { constructor() { ... } } </code></pre> <p>In the <a href="https://angular.io/guide/architecture#components" rel="noreferrer">Angular documentation for components</a> (for example) one sees this:</p> <pre><code>export class HeroListComponent implements OnInit { heroes: Hero[]; selectedHero: Hero; constructor(private service: HeroService) { } ngOnInit() { this.heroes = this.service.getHeroes(); } selectHero(hero: Hero) { this.selectedHero = hero; } } </code></pre> <p>Generally, a component's or module's primary purpose is to house one specific export. So, is there a reason why Angular does not use or recommend using <code>export default</code>?</p>
0debug
ERB Comparison signs ( less than, less than equal to, etc) : I'm wondering how to test if a variable is between two values such as 1 and 10. For example I have the following: <% bullet_hit = rand(1..10) %> <% if 1 < bullet_hit < 10 %> <%= bullet_hit %> <% end %> It seems pretty straight, but I think I have the wrong syntax. Any help would be appreciated. Thank you.
0debug
sever receive message and convert from lower case to upper case : code to receive message like " hi i am man" and convert it to upper case "HI I AM MAN" n = read( newsockfd,buffer,255 ); printf("Here is the message: %s\n",buffer);
0debug
Using a Progress Bar while Seeding a database in Laravel : <p>I have to seed quite a lot of data into a database and I want to be able to show the user a progress bar while this happens. I know this is documented:</p> <ul> <li><a href="https://laravel.com/docs/master/artisan#registering-commands" rel="noreferrer">https://laravel.com/docs/master/artisan#registering-commands</a> (just above)</li> <li><a href="http://symfony.com/doc/2.7/components/console/helpers/progressbar.html" rel="noreferrer">http://symfony.com/doc/2.7/components/console/helpers/progressbar.html</a></li> </ul> <p>but I'm having problems including it in my seeder.</p> <pre><code>&lt;?php use Illuminate\Database\Seeder; class SubDivisionRangeSeeder extends Seeder { public function run() { $this-&gt;output-&gt;createProgressBar(10); for ($i = 0; $i &lt; 10; $i++) { sleep(1); $this-&gt;output-&gt;advance(); } $this-&gt;output-&gt;finish(); } } </code></pre> <p>or</p> <pre><code>&lt;?php use Illuminate\Database\Seeder; class SubDivisionRangeSeeder extends Seeder { public function run() { $this-&gt;output-&gt;progressStart(10); for ($i = 0; $i &lt; 10; $i++) { sleep(1); $this-&gt;output-&gt;progressAdvance(); } $this-&gt;output-&gt;progressFinish(); } } </code></pre> <p>from <a href="https://mattstauffer.co/blog/advanced-input-output-with-artisan-commands-tables-and-progress-bars-in-laravel-5.1" rel="noreferrer">https://mattstauffer.co/blog/advanced-input-output-with-artisan-commands-tables-and-progress-bars-in-laravel-5.1</a></p> <p>Any ideas?</p>
0debug
Rails 4 - JS for dependent fields with simple form : <p>I am trying to make an app in Rails 4.</p> <p>I am using simple form for forms and have just tried to use gem 'dependent-fields-rails' to hide or show subset questions based on the form field of a primary question.</p> <p>I'm getting stuck.</p> <p>I have added gems to my gem file for:</p> <pre><code>gem 'dependent-fields-rails' gem 'underscore-rails' </code></pre> <p>I have updated my application.js to:</p> <pre><code>//= require dependent-fields //= require underscore </code></pre> <p>I have a form which has:</p> <pre><code>&lt;%= f.simple_fields_for :project_date do |pdf| %&gt; &lt;%= pdf.error_notification %&gt; &lt;div class="form-inputs"&gt; &lt;%= pdf.input :student_project, as: :radio_buttons, :label =&gt; "Is this a project in which students may participate?", autofocus: true %&gt; &lt;div class="js-dependent-fields" data-radio-name="project_date[student_project]" data-radio-value="true"&gt; &lt;%= pdf.input :course_project, as: :radio_buttons, :label =&gt; "Is this a project students complete for credit towards course assessment?" %&gt; &lt;%= pdf.input :recurring_project, as: :radio_buttons, :label =&gt; "Is this project offered on a recurring basis?" %&gt; &lt;%= pdf.input :frequency, :label =&gt; "How often is this project repeated?", :collection =&gt; ["No current plans to repeat this project", "Each semester", "Each year"] %&gt; &lt;/div&gt; &lt;div class='row'&gt; &lt;div class="col-md-4"&gt; &lt;%= pdf.input :start_date, :as =&gt; :date_picker, :label =&gt; "When do you want to get started?" %&gt; &lt;/div&gt; &lt;div class="col-md-4"&gt; &lt;%= pdf.input :completion_date, :as =&gt; :date_picker, :label =&gt; "When do you expect to finish?" %&gt; &lt;/div&gt; &lt;div class="col-md-4"&gt; &lt;%= pdf.input :eoi, :as =&gt; :date_picker, :label =&gt; 'When are expressions of interest due?' %&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;% end %&gt; &lt;script type="text/javascript"&gt; $('.datetimepicker').datetimepicker(); &lt;/script&gt; &lt;script&gt; $(document).ready(function() { DependentFields.bind() }); &lt;/script&gt; </code></pre> <p>I don't know much about javascript. </p> <p>I"m not sure if the final script paragraph is necessary or if the gem puts that into the code for you. I'm not sure if it's supposed to be expressed inside script tags and I also don't know how to give effect to this requirement (which is set out on the gem page for dependent-fields):</p> <pre><code>"Be sure to include underscorejs and jquery in your page." </code></pre> <p>How do you include underscorejs and jQuery in a page? I have them in my gem file. Is that enough or is something else required to make this work?</p> <p>Currently, when I try this form, nothing is hidden. I have tried swapping the true value to 'yes' but that doesnt make any difference either.</p> <pre><code>&lt;div class="js-dependent-fields" data-radio-name="project_date[student_project]" data-radio-value="true"&gt; &lt;div class="js-dependent-fields" data-radio-name="project_date[student_project]" data-radio-value="yes"&gt; </code></pre> <p>Can anyone see where I've gone wrong? </p>
0debug
int av_get_packet(AVIOContext *s, AVPacket *pkt, int size) { int ret; size= ffio_limit(s, size); ret= av_new_packet(pkt, size); if(ret<0) return ret; pkt->pos= avio_tell(s); ret= avio_read(s, pkt->data, size); if(ret<=0) av_free_packet(pkt); else av_shrink_packet(pkt, ret); if (pkt->size < orig_size) pkt->flags |= AV_PKT_FLAG_CORRUPT; return ret; }
1threat
ReactJS APP in Heroku "Invalid Host header" HOST configuration? : <p>I am trying to put my <a href="https://github.com/gitlwh/MembershipSample/tree/master/client" rel="noreferrer">React app</a> on the Heroku. The whole project include one API (express) and one client (ReactJS). I have put my API on heroku. But when I put my client on Heroku, it shows build succeeded. But when I <a href="https://shielded-temple-31393.herokuapp.com/" rel="noreferrer">open</a> it, it shows <code>Invalid Host header</code>. </p> <p>I google this problem and many people tell me to configure the <a href="https://github.com/facebook/create-react-app/issues/2271" rel="noreferrer">HOST</a>. But they are using webpack. I build this with <code>create-react-app</code> and I run it by <code>npm start</code>. I want to know how to solve this problem in most easy way. Thanks.</p>
0debug
static uint64_t bw_conf1_read(void *opaque, target_phys_addr_t addr, unsigned size) { PCIBus *b = opaque; return pci_data_read(b, addr, size); }
1threat
Spring Boot & Swagger UI. Set JWT token : <p>I have a Swagger config like this</p> <pre><code>@EnableSwagger2 @Configuration public class SwaggerConfig { @Bean public Docket api() { List&lt;SecurityScheme&gt; schemeList = new ArrayList&lt;&gt;(); schemeList.add(new ApiKey(HttpHeaders.AUTHORIZATION, "JWT", "header")); return new Docket(DocumentationType.SWAGGER_2) .produces(Collections.singleton("application/json")) .consumes(Collections.singleton("application/json")) .ignoredParameterTypes(Authentication.class) .securitySchemes(schemeList) .useDefaultResponseMessages(false) .select() .apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot"))) .paths(PathSelectors.any()) .build(); } } </code></pre> <p>In the Swagger UI when I click on the Authorize button I enter my JWT token in the value field <code>eyJhbGc..nN84qrBg</code>. Now I expect that any request I do through the Swagger UI will contain the JWT in the header. However, that is not the case. No request contains a Authorization header.</p> <p>What am I missing?</p>
0debug
NLTK download SSL: Certificate verify failed : <p>I get the following error when trying to install Punkt for nltk:</p> <pre><code>nltk.download('punkt') [nltk_data] Error loading Punkt: &lt;urlopen error [SSL: [nltk_data] CERTIFICATE_VERIFY_FAILED] certificate verify failed [nltk_data] (_ssl.c:590)&gt; False </code></pre>
0debug
<androidx.fragment.app.FragmentContainerView> vs <fragment> as a view for a NavHost : <p>When using <code>androidx.fragment.app.FragmentContainerView</code> as a navHost instead of a regular <code>fragment</code> app is not able to navigate to a destination after orientation change.</p> <p>I get a following error: <code>java.lang.IllegalStateException: no current navigation node</code></p> <p>Is there a gotcha that I should know about to use it properly or is my way of using nav components is incorrect? </p> <p>Simple activity xml with a view:</p> <pre><code> ... &lt;androidx.fragment.app.FragmentContainerView android:id="@+id/nav_host_fragment" android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="match_parent" app:defaultNavHost="true" app:layout_behavior="@string/appbar_scrolling_view_behavior" app:navGraph="@navigation/nav_simple" /&gt; ... </code></pre> <p>Navigation code:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;navigation xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/nav_legislator.xml" app:startDestination="@id/initialFragment"&gt; &lt;fragment android:id="@+id/initialFragment" android:name="com.example.fragmenttag.InitialFragment" android:label="Initial Fragment" tools:layout="@layout/initial_fragment"&gt; &lt;action android:id="@+id/action_initialFragment_to_destinationFragment" app:destination="@id/destinationFragment" /&gt; &lt;/fragment&gt; &lt;fragment android:id="@+id/destinationFragment" android:name="com.example.fragmenttag.DestinationFragment" android:label="Destination Fragment" tools:layout="@layout/destination_fragment" /&gt; &lt;/navigation&gt; </code></pre> <p>Here is a github repo where you can easily reproduce a bug: <a href="https://github.com/dmytroKarataiev/navHostBug" rel="noreferrer">https://github.com/dmytroKarataiev/navHostBug</a></p>
0debug
How i get the file name when i upload anyfile from my fileupload control : <p>I want the file name in description. When user submit the anyfile from frontend, the file name will show in separate div. i am using asp.net mvc framework so, can anyone help me in it.</p>
0debug
Kotlin with-statement as an expression : <p>We can do</p> <pre><code>val obj = Obj() with (obj) { objMethod1() objMethod2() } </code></pre> <p>But is there a way to do this?</p> <pre><code>val obj = with(Obj()) { objMethod1() objMethod2() } </code></pre> <p>To solve a common case where you create an object and call a few methods on it to initialise its state.</p>
0debug
How to add field to NSMutableDictionary Swift : <p>Here is what I've tried </p> <pre><code>var villages = [NSDictionary]() var bars = [NSMutableDictionary]() var allBars = [NSMutableDictionary]() (bars[2]).setObject(distanceInMiles, forKey: "Distance" as NSCopying) //And this bars[2]["Distance"] = distanceInMiles </code></pre> <p>There is no distance field in my dictionary currently but I'd like to add it to the dictionary and set the value for it. </p> <p>I keep getting this error:</p> <p>Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFDictionary setObject:forKey:]: mutating method sent to immutable object'</p> <p>Here is how my dictionary is laid out:</p> <pre><code>[{ Latitude = "40.719629"; Longitude = "-74.003939"; Name = "Macao Trading Co"; ObjectID = ayORtpic7H; PlaceID = ChIJA9S9jIpZwokRZTF0bHWwXYU; }, { Latitude = "40.717304"; Longitude = "-74.008571"; Name = "Bar Cyrk"; ObjectID = z7NV2uOmgH; PlaceID = ChIJaWlspR9awokRvrKEAoUz3eM; }, { Latitude = "40.720721"; Longitude = "-74.005489"; Name = "AOA Bar &amp; Grill"; ObjectID = GIst3BLb5X; PlaceID = ChIJBYvf3IpZwokRJXbThVSI4jU; }] </code></pre> <p>I'm not sure what I'm doing wrong. My bars dictionary is mutable so why do I keep getting the mutating method sent to immutable object error?</p>
0debug
static void cpu_exec_nocache(CPUState *cpu, int max_cycles, TranslationBlock *orig_tb) { TranslationBlock *tb; if (max_cycles > CF_COUNT_MASK) max_cycles = CF_COUNT_MASK; tb = tb_gen_code(cpu, orig_tb->pc, orig_tb->cs_base, orig_tb->flags, max_cycles | CF_NOCACHE); tb->orig_tb = tcg_ctx.tb_ctx.tb_invalidated_flag ? NULL : orig_tb; cpu->current_tb = tb; trace_exec_tb_nocache(tb, tb->pc); cpu_tb_exec(cpu, tb->tc_ptr); cpu->current_tb = NULL; tb_phys_invalidate(tb, -1); tb_free(tb); }
1threat
TypeOf and CType code equivalent in C# : <p>Can someone help me the equivalent code to C#</p> <pre><code>Public Sub ClearTextBox(ByVal root As Control) For Each ctrl As Control In root.Controls ClearTextBox(ctrl) If TypeOf ctrl Is TextBox Then CType(ctrl, TextBox).Text = String.Empty End If Next ctrl End Sub </code></pre>
0debug
BigDecimal Round to 2 decimal places and then to one significant figure : <p>How do i round a BigDecimal to 2 decimal places and then to one significant figure?</p> <p>Thanks</p>
0debug
static void vtd_iotlb_page_invalidate_notify(IntelIOMMUState *s, uint16_t domain_id, hwaddr addr, uint8_t am) { IntelIOMMUNotifierNode *node; VTDContextEntry ce; int ret; QLIST_FOREACH(node, &(s->notifiers_list), next) { VTDAddressSpace *vtd_as = node->vtd_as; ret = vtd_dev_to_context_entry(s, pci_bus_num(vtd_as->bus), vtd_as->devfn, &ce); if (!ret && domain_id == VTD_CONTEXT_ENTRY_DID(ce.hi)) { vtd_page_walk(&ce, addr, addr + (1 << am) * VTD_PAGE_SIZE, vtd_page_invalidate_notify_hook, (void *)&vtd_as->iommu, true); } } }
1threat
int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt, int padtop, int padbottom, int padleft, int padright, int *color) { uint8_t *optr, *iptr; int y_shift; int x_shift; int yheight; int i, y; if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB || !is_yuv_planar(&pix_fmt_info[pix_fmt])) return -1; for (i = 0; i < 3; i++) { x_shift = i ? pix_fmt_info[pix_fmt].x_chroma_shift : 0; y_shift = i ? pix_fmt_info[pix_fmt].y_chroma_shift : 0; if (padtop || padleft) { memset(dst->data[i], color[i], dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift)); } if (padleft || padright || src) { if (src) { iptr = src->data[i]; optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift); memcpy(optr, iptr, src->linesize[i]); iptr += src->linesize[i]; } optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + (dst->linesize[i] - (padright >> x_shift)); yheight = (height - 1 - (padtop + padbottom)) >> y_shift; for (y = 0; y < yheight; y++) { memset(optr, color[i], (padleft + padright) >> x_shift); if (src) { memcpy(optr + ((padleft + padright) >> x_shift), iptr, src->linesize[i]); iptr += src->linesize[i]; } optr += dst->linesize[i]; } } if (padbottom || padright) { optr = dst->data[i] + dst->linesize[i] * ((height - padbottom) >> y_shift) - (padright >> x_shift); memset(optr, color[i],dst->linesize[i] * (padbottom >> y_shift) + (padright >> x_shift)); } } return 0; }
1threat
Average of first and last variable : <p><a href="https://i.stack.imgur.com/TEkoN.png" rel="nofollow noreferrer">Sample Data</a></p> <p>The highlighted color is the first and the last of each customer ID how do I use R code to do this and below is the answer expected</p> <p><a href="https://i.stack.imgur.com/quZLQ.png" rel="nofollow noreferrer">Answer expected</a></p>
0debug
c# save program output to a (.txt) file : My program namespace trim2 { class Program { static void Main(string[] args) { //ask user to start, if yes then continue, else then close DataConversion() } public static void DataConversion() { string lines = File.ReadAllText(@"d:\trim1.txt"); string result; result = lines.Replace("- - ",string.Empty).Replace("+"string.Empty)..... \\process goes here \\process goes here \\process goes here } } } What i expected is after the file goes thru the data conversion process it would save into a new text file (which is the processed one).. how can i achieve this? Also i tried this line, seems wont work File.WriteAllText("C:\Users\Cleaned.txt", new string(ShiftLine)); Thanks for your reply
0debug
bool qemu_co_queue_next(CoQueue *queue) { Coroutine *next; next = QTAILQ_FIRST(&queue->entries); if (next) { QTAILQ_REMOVE(&queue->entries, next, co_queue_next); QTAILQ_INSERT_TAIL(&unlock_bh_queue, next, co_queue_next); trace_qemu_co_queue_next(next); qemu_bh_schedule(unlock_bh); } return (next != NULL); }
1threat
Docker in Docker : <p>We have app and which will spin the short term (short span) docker containers. Right now, it runs in Ubunut16.04 server (VM) and we installed docker, and nodejs in same server. We have nodejs app which runs in same server so whenever a request comes in, then the nodejs app will spin up a docker container and execute a user input inside the docker container. Once after the docker finish its job or if it runs out of admin defined resources then the docker container will be forcefully killed (docker kill) and removed (docker rm). </p> <p>Now my question is, is it best practices to run the Ubunte16.04 docker container and run nodjes app and the short term docker containers inside the Ubunuter16.04 docker container. </p> <p>In short run a docker inside other docker container.</p> <p><a href="https://i.stack.imgur.com/qCxL5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qCxL5.jpg" alt="enter image description here"></a></p>
0debug
MalformedPolicyDocument error when creating policy via terraform : <p>I am getting the following error when running terraform:</p> <pre><code>* aws_iam_role_policy.rds_policy: Error putting IAM role policy my-rds-policy: MalformedPolicyDocument: The policy failed legacy parsing </code></pre> <p>Here is my definition of the resource:</p> <pre><code>resource "aws_iam_role_policy" "rds_policy" { name = "my-rds-policy" role = "${aws_iam_role.rds_role.id}" policy = &lt;&lt;EOF { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:ListBucket", "s3:GetBucketLocation" ], "Resource": [ "arn:aws:s3:::my-bucket" ] }, { "Effect": "Allow", "Action": [ "s3:GetObjectMetaData", "s3:GetObject", "s3:PutObject", "s3:ListMultipartUploadParts", "s3:AbortMultipartUpload" ], "Resource": [ "arn:aws:s3:::my-bucket/backups/*" ] } ] } EOF } </code></pre> <p>The JSON policy doc is well formed, and I can't see anything obvious. </p>
0debug
Set date() to midnight in users timezone with moment.js : <p>I use moment.js to display a UTC date in the users local timezone:</p> <pre><code>var date = new Date(Date.UTC(2016,03,30,0,0,0)); var now = new Date(); var diff = (date.getTime()/1000) - (now.getTime()/1000); var textnode = document.createTextNode(moment(date).format('dddd, DD.MM.YYYY') + ' a las ' + moment(date).format('HH:mm A')); document.getElementsByClassName("date")[0].appendChild(textnode.cloneNode(true)); </code></pre> <p>I later use the <code>diff</code> variable to show a countdown timer.</p> <p>I would like to show a different countdown timer to everyone in their local time zone. (Using the difference till its midnight in their time zone, not in UTC)</p> <p>But I am struggeling to get it work. Instead of using <code>var date = new Date(Date.UTC(2016,03,30,0,0,0));</code> I probably need to use some function of moment.js that gives me till midnight in the users time zone.</p> <p>The best example would be new years eve. If I use UTC everyone would have the same counter (9 hours left) but in different parts of the world this wouldn't make sense. For someone in australia it should be 2 hours left, and for someone in the US 14 hours.</p>
0debug
static int block_crypto_create_generic(QCryptoBlockFormat format, const char *filename, QemuOpts *opts, Error **errp) { int ret = -EINVAL; QCryptoBlockCreateOptions *create_opts = NULL; QCryptoBlock *crypto = NULL; struct BlockCryptoCreateData data = { .size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE), .opts = opts, .filename = filename, }; create_opts = block_crypto_create_opts_init(format, opts, errp); if (!create_opts) { return -1; } crypto = qcrypto_block_create(create_opts, block_crypto_init_func, block_crypto_write_func, &data, errp); if (!crypto) { ret = -EIO; goto cleanup; } ret = 0; cleanup: qcrypto_block_free(crypto); blk_unref(data.blk); qapi_free_QCryptoBlockCreateOptions(create_opts); return ret; }
1threat
React.js - using property initializers for all component methods : <p>I am working on a React Native project and I'm using ES6 classes for React components.</p> <p>Since React components defined via ES6 classes don't have autobinding, the React team <a href="https://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#autobinding">recommends</a> combining ES7 property initializers with arrow functions to create the same effect.</p> <p>In order to be consistent and prevent confusion with this-binding, I am using ES7 property initializers for all component methods:</p> <pre><code>class Foo extends React.Component { constructor(props) { super(props); ... } componentDidMount = () =&gt; { ... }; bar = () =&gt; { ... }; render = () =&gt; { ... }; } </code></pre> <p>I was wondering -- are there any serious performance caveats to be aware of? In particular, I'm wondering about the render() method.</p> <p>Overall, does this seem like a good approach?</p>
0debug
expression must be a modifiable lvalue (for array) : <p>I have this program I'm working on, and one part of it is a linked list which I am working on making. I got this far, but at this point in the code it tells me (on the 3rd to last line) that inst must be a modifiable lvalue. I'm not sure what I'm doing wrong here. </p> <pre><code>#include &lt;iostream&gt; using namespace std; struct node{ float color[3]; float v[2*3]; node *next; }; class TriangleList { private: node *head; private: node * tail; public: TriangleList() { head = NULL; tail = NULL; } void add(float vertices[], float colors[]) { node *inst = new node; inst-&gt;v = vertices; } }; </code></pre>
0debug
def swap_List(newList): size = len(newList) temp = newList[0] newList[0] = newList[size - 1] newList[size - 1] = temp return newList
0debug
How to find first non-zero item of an Array? : Is there a way to grab the first non-zero item from an array of numbers? I have an Array with many zeros at the beginning and I need only the first item that is not a zero. For example `Array = [0,0,0,0,25,53,21,77]` Return: "25"
0debug
static void ref405ep_init(MachineState *machine) { ram_addr_t ram_size = machine->ram_size; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; char *filename; ppc4xx_bd_info_t bd; CPUPPCState *env; qemu_irq *pic; MemoryRegion *bios; MemoryRegion *sram = g_new(MemoryRegion, 1); ram_addr_t bdloc; MemoryRegion *ram_memories = g_malloc(2 * sizeof(*ram_memories)); hwaddr ram_bases[2], ram_sizes[2]; target_ulong sram_size; long bios_size; target_ulong kernel_base, initrd_base; long kernel_size, initrd_size; int linux_boot; int fl_idx, fl_sectors, len; DriveInfo *dinfo; MemoryRegion *sysmem = get_system_memory(); memory_region_allocate_system_memory(&ram_memories[0], NULL, "ef405ep.ram", 0x08000000); ram_bases[0] = 0; ram_sizes[0] = 0x08000000; memory_region_init(&ram_memories[1], NULL, "ef405ep.ram1", 0); ram_bases[1] = 0x00000000; ram_sizes[1] = 0x00000000; ram_size = 128 * 1024 * 1024; #ifdef DEBUG_BOARD_INIT printf("%s: register cpu\n", __func__); #endif env = ppc405ep_init(sysmem, ram_memories, ram_bases, ram_sizes, 33333333, &pic, kernel_filename == NULL ? 0 : 1); sram_size = 512 * 1024; memory_region_init_ram(sram, NULL, "ef405ep.sram", sram_size, &error_abort); vmstate_register_ram_global(sram); memory_region_add_subregion(sysmem, 0xFFF00000, sram); #ifdef DEBUG_BOARD_INIT printf("%s: register BIOS\n", __func__); #endif fl_idx = 0; #ifdef USE_FLASH_BIOS dinfo = drive_get(IF_PFLASH, 0, fl_idx); if (dinfo) { BlockBackend *blk = blk_by_legacy_dinfo(dinfo); bios_size = blk_getlength(blk); fl_sectors = (bios_size + 65535) >> 16; #ifdef DEBUG_BOARD_INIT printf("Register parallel flash %d size %lx" " at addr %lx '%s' %d\n", fl_idx, bios_size, -bios_size, blk_name(blk), fl_sectors); #endif pflash_cfi02_register((uint32_t)(-bios_size), NULL, "ef405ep.bios", bios_size, blk, 65536, fl_sectors, 1, 2, 0x0001, 0x22DA, 0x0000, 0x0000, 0x555, 0x2AA, 1); fl_idx++; } else #endif { #ifdef DEBUG_BOARD_INIT printf("Load BIOS from file\n"); #endif bios = g_new(MemoryRegion, 1); memory_region_init_ram(bios, NULL, "ef405ep.bios", BIOS_SIZE, &error_abort); vmstate_register_ram_global(bios); if (bios_name == NULL) bios_name = BIOS_FILENAME; filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); if (filename) { bios_size = load_image(filename, memory_region_get_ram_ptr(bios)); g_free(filename); if (bios_size < 0 || bios_size > BIOS_SIZE) { error_report("Could not load PowerPC BIOS '%s'", bios_name); exit(1); } bios_size = (bios_size + 0xfff) & ~0xfff; memory_region_add_subregion(sysmem, (uint32_t)(-bios_size), bios); } else if (!qtest_enabled() || kernel_filename != NULL) { error_report("Could not load PowerPC BIOS '%s'", bios_name); exit(1); } else { bios_size = -1; } memory_region_set_readonly(bios, true); } #ifdef DEBUG_BOARD_INIT printf("%s: register FPGA\n", __func__); #endif ref405ep_fpga_init(sysmem, 0xF0300000); #ifdef DEBUG_BOARD_INIT printf("%s: register NVRAM\n", __func__); #endif m48t59_init(NULL, 0xF0000000, 0, 8192, 1968, 8); linux_boot = (kernel_filename != NULL); if (linux_boot) { #ifdef DEBUG_BOARD_INIT printf("%s: load kernel\n", __func__); #endif memset(&bd, 0, sizeof(bd)); bd.bi_memstart = 0x00000000; bd.bi_memsize = ram_size; bd.bi_flashstart = -bios_size; bd.bi_flashsize = -bios_size; bd.bi_flashoffset = 0; bd.bi_sramstart = 0xFFF00000; bd.bi_sramsize = sram_size; bd.bi_bootflags = 0; bd.bi_intfreq = 133333333; bd.bi_busfreq = 33333333; bd.bi_baudrate = 115200; bd.bi_s_version[0] = 'Q'; bd.bi_s_version[1] = 'M'; bd.bi_s_version[2] = 'U'; bd.bi_s_version[3] = '\0'; bd.bi_r_version[0] = 'Q'; bd.bi_r_version[1] = 'E'; bd.bi_r_version[2] = 'M'; bd.bi_r_version[3] = 'U'; bd.bi_r_version[4] = '\0'; bd.bi_procfreq = 133333333; bd.bi_plb_busfreq = 33333333; bd.bi_pci_busfreq = 33333333; bd.bi_opbfreq = 33333333; bdloc = ppc405_set_bootinfo(env, &bd, 0x00000001); env->gpr[3] = bdloc; kernel_base = KERNEL_LOAD_ADDR; kernel_size = load_image_targphys(kernel_filename, kernel_base, ram_size - kernel_base); if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } printf("Load kernel size %ld at " TARGET_FMT_lx, kernel_size, kernel_base); if (initrd_filename) { initrd_base = INITRD_LOAD_ADDR; initrd_size = load_image_targphys(initrd_filename, initrd_base, ram_size - initrd_base); if (initrd_size < 0) { fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", initrd_filename); exit(1); } } else { initrd_base = 0; initrd_size = 0; } env->gpr[4] = initrd_base; env->gpr[5] = initrd_size; if (kernel_cmdline != NULL) { len = strlen(kernel_cmdline); bdloc -= ((len + 255) & ~255); cpu_physical_memory_write(bdloc, kernel_cmdline, len + 1); env->gpr[6] = bdloc; env->gpr[7] = bdloc + len; } else { env->gpr[6] = 0; env->gpr[7] = 0; } env->nip = KERNEL_LOAD_ADDR; } else { kernel_base = 0; kernel_size = 0; initrd_base = 0; initrd_size = 0; bdloc = 0; } #ifdef DEBUG_BOARD_INIT printf("bdloc " RAM_ADDR_FMT "\n", bdloc); printf("%s: Done\n", __func__); #endif }
1threat
void pc_init_pci64_hole(PcPciInfo *pci_info, uint64_t pci_hole64_start, uint64_t pci_hole64_size) { if ((sizeof(hwaddr) == 4) || (!pci_hole64_size)) { return; } pci_info->w64.begin = ROUND_UP(pci_hole64_start, 0x1ULL << 30); pci_info->w64.end = pci_info->w64.begin + pci_hole64_size; assert(pci_info->w64.begin <= pci_info->w64.end); }
1threat
How to declare factory constructor in abstract classes? : <p>I want to declare, but not define a factory constructor in an abstract class.</p> <p>In my case, I want to create a method that accepts any class that implements a <code>String toJson()</code> method as well as a <code>fromJson(Map&lt;String, dynamic&gt; data)</code> factory constructor.</p> <p>Is there any way to achieve that in Dart? I'm looking for something like the following, which is not valid Dart code:</p> <pre class="lang-dart prettyprint-override"><code>abstract class JsonSerializable { factory fromJson(Map&lt;String, dynamic&gt; data); String toJson(); } </code></pre>
0debug
jQuery count elements Start from 0? : <p>I'm trying to count the elements on page BUT i need the numbers to start from 0 as opposed to 1.</p> <p>I know I can simply do <code>var tadada = $('.clickableDiv').length;</code></p> <p>but this will return the numbers from 1.</p> <p>is this possible using jquery or javascript?</p>
0debug
c# constructor calling toString : <p>I have an object that overrides iComparable and that also overrides toString().</p> <p>When the constructor is called it is also calling toString(), but not hitting any break points in the toString() method.</p> <p>The toString() is also called when each line of the constructor is executed, and as soon as the DataSource property is updated it gets the data from the database and puts in unexpected results.</p> <p>I have proven this with the logging of environment.stacktrace for each call.</p> <p>Is this expected behaviour, and is there anyway to only call the toString() when I explicitly call it rather than automatically.</p> <p>Code for the class is below</p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Business.Data; namespace PfWToEpayfactGIF { class PsPayChangeDetails : IComparable&lt;PsPayChangeDetails&gt; { public DateTime EffectiveDate { get; set; } public String Code { get; set; } public string ChangeType { get; set; } public int DataSourceX { get; set; } private string gradeID; private string gradeSubCode; private string gradePercentage; private string IDField; private string salary; private string maxOTRateType; private string lWeightType; private string onTempPromotion; private string RTIHoursInd; private string paygroupID; private string classification; private string hoursPayable; private string workingPatternID; private string OSPSchemeNo; private string milestoneDate; private string employeeNo; public PsPayChangeDetails(string code, DateTime effectiveDate, string changeType, int groupSource) { EffectiveDate = effectiveDate; Code = code; ChangeType = changeType; DataSourceX = groupSource; } public void ReadLine(string[] line) { employeeNo = line[0] != string.Empty ? line[0] : employeeNo; try { if (Code == "E420") { gradeID = line[4] != string.Empty ? line[4] : gradeID; gradeSubCode = line[5] != string.Empty ? line[5] : gradeSubCode; gradePercentage = line[6] != string.Empty ? line[6] : gradePercentage; IDField = line[7] != string.Empty ? line[7] : IDField; salary = line[8] != string.Empty ? line[8] : salary; maxOTRateType = line[9] != string.Empty ? line[9] : maxOTRateType; lWeightType = line[10] != string.Empty ? line[10] : lWeightType; onTempPromotion = line[11] != string.Empty ? line[11] : onTempPromotion; RTIHoursInd = line[12] != string.Empty ? line[12] : RTIHoursInd; } else { paygroupID = line[4] != string.Empty ? line[4] : paygroupID; classification = line[5] != string.Empty ? line[5] : classification; hoursPayable = line[6] != string.Empty ? line[6] : hoursPayable; workingPatternID = line[7] != string.Empty ? line[7] : workingPatternID; OSPSchemeNo = line[8] != string.Empty ? line[8] : OSPSchemeNo; milestoneDate = line[9] != string.Empty ? line[9] : milestoneDate; } } catch (IndexOutOfRangeException) { //ignore the exception as its telling us we dont have all the fields which is fine. } } public override string ToString() { using (System.IO.StreamWriter write = new System.IO.StreamWriter(@"c:\temp\test.txt", true)) { write.WriteLine(Environment.StackTrace); } string output = $"{employeeNo},{Code},{EffectiveDate.ToString("dd/MMM/yyyy")},{ChangeType},"; if (Code == "E420") { output += $"{gradeID},{gradeSubCode},{gradePercentage},{IDField},{salary},{maxOTRateType},{lWeightType},{onTempPromotion},{RTIHoursInd}"; } else { using (DataEntities db = new DataEntities(DataSourceX)) { if (paygroupID == null) { string partTime = workingPatternID == "PT" ? "Y" : "N"; paygroupID = db.PayGroupEESetting.Where(pge =&gt; pge.PartTimeInd == partTime &amp;&amp; pge.EnteredDate == db.PayGroupEESetting.Where(pg =&gt; pg.PayGroup == pge.PayGroup &amp;&amp; pg.EnteredDate &lt;= EffectiveDate).Max(pg =&gt; pg.EnteredDate)).OrderBy(pge =&gt; pge.PayGroup).FirstOrDefault().PayGroup; } workingPatternID = workingPatternID == null ? "FT" : "PT"; if (OSPSchemeNo == null) { OSPSchemeNo = db.OSPScheme.Min(o =&gt; o.SchemeNo).ToString(); } } output += $"{paygroupID},{classification},{hoursPayable},{workingPatternID},{OSPSchemeNo},{milestoneDate}"; } return output; } public int CompareTo(PsPayChangeDetails other) { if (this.Code == other.Code) { return this.EffectiveDate.CompareTo(other.EffectiveDate); } else { return this.Code.CompareTo(other.Code); } } } } </code></pre> <p>Thanks for any help.</p> <p>Ben</p>
0debug
Setting android:extractNativeLibs=false to reduce app size : <p>I am not sure, if I got this right. It seems it is doing the oposite. If I keep the flag <a href="https://developer.android.com/reference/android/R.attr.html#extractNativeLibs" rel="noreferrer">android:extractNativeLibs</a> set to true, the app is taking about 70MB of user's space (yeah...) but if I set this flag to false, the size of the app installed on the device jumps to about 95MB. So I am not sure if user would appreciate this.</p>
0debug
How to switch a branch using GitHub Shell. : I am having an issue with my GitLab Repository. Somehow there is a conflict between my local repo and the remote one. GitHub Desktop says `Commit is not successful because there is a conflict and refer to Shell`. When I open the GitHub Shell to find out which file is causing the issue, it appears that I am in `Master` branch and I am sure enough that I shouldn't be in the Master branch. So how can I come to my own branch and how can I find out which file is causing the conflict? [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/DRNAq.jpg
0debug
Google maps polyline not rendering perfectly : <p>I am drawing polyline using latest google maps API for iOS. I am constructing polyline point by point but it is not rendering properly as when i zoom out the polyline vanishes(not in literal terms) from the map and when i zoom in it simply shows the line.</p> <p><a href="https://i.stack.imgur.com/wO637.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/wO637.jpg" alt="Zoomed in view"></a> This is how polyline appears when zoomed in </p> <p><a href="https://i.stack.imgur.com/cBJrm.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/cBJrm.jpg" alt="Zoomed out view"></a> This is how it appears when zoomed out </p> <p>here is my function for drawing polyline</p> <pre><code>RCPolyline *polyline = [[RCPolyline alloc] init]; [polyline drawPolylineFromPoint:self.selectedEmployee.location toPoint:location]; </code></pre> <p>i have override <code>init:</code> for RCPolyline to be something like this</p> <pre><code>- (instancetype)init { self = [super init]; if (self) { self.strokeWidth = 5.0f; self.strokeColor = UIColor.redColor; self.geodesic = YES; self.map = [RCMapView sharedMapView]; } return self;} </code></pre> <p>and <code>drawPolylineFromPoint:toPoint:</code> does this</p> <pre><code> - (void)drawPolylineFromPoint:(CLLocation *)pointX toPoint:(CLLocation *)pointY { GMSMutablePath *path = [GMSMutablePath path]; [path addCoordinate:pointX.coordinate]; [path addCoordinate:pointY.coordinate]; self.path = path;} </code></pre>
0debug
static int handle_hypercall(S390CPU *cpu, struct kvm_run *run) { CPUS390XState *env = &cpu->env; cpu_synchronize_state(CPU(cpu)); env->regs[2] = s390_virtio_hypercall(env); return 0; }
1threat
static void coroutine_fn v9fs_lcreate(void *opaque) { int32_t dfid, flags, mode; gid_t gid; ssize_t err = 0; ssize_t offset = 7; V9fsString name; V9fsFidState *fidp; struct stat stbuf; V9fsQID qid; int32_t iounit; V9fsPDU *pdu = opaque; v9fs_string_init(&name); err = pdu_unmarshal(pdu, offset, "dsddd", &dfid, &name, &flags, &mode, &gid); if (err < 0) { goto out_nofid; trace_v9fs_lcreate(pdu->tag, pdu->id, dfid, flags, mode, gid); if (name_is_illegal(name.data)) { err = -ENOENT; goto out_nofid; if (!strcmp(".", name.data) || !strcmp("..", name.data)) { err = -EEXIST; goto out_nofid; fidp = get_fid(pdu, dfid); if (fidp == NULL) { err = -ENOENT; goto out_nofid; flags = get_dotl_openflags(pdu->s, flags); err = v9fs_co_open2(pdu, fidp, &name, gid, flags | O_CREAT, mode, &stbuf); if (err < 0) { fidp->fid_type = P9_FID_FILE; fidp->open_flags = flags; if (flags & O_EXCL) { fidp->flags |= FID_NON_RECLAIMABLE; iounit = get_iounit(pdu, &fidp->path); stat_to_qid(&stbuf, &qid); err = pdu_marshal(pdu, offset, "Qd", &qid, iounit); if (err < 0) { err += offset; trace_v9fs_lcreate_return(pdu->tag, pdu->id, qid.type, qid.version, qid.path, iounit); out: put_fid(pdu, fidp); out_nofid: pdu_complete(pdu, err); v9fs_string_free(&name);
1threat
How do I add Lua to a C++ Project : <p>1) How do I add Lua to a C++ project in microsoft visual studio 2017. I have downloaded all the Lua files but I need to Add Lua to the project properties. 2) Whats the main difference between C++ and C 3) Which language is best to create a GUI, Lua, C, C# or C++. Thanks in advance </p>
0debug
static int revert_channel_correlation(ALSDecContext *ctx, ALSBlockData *bd, ALSChannelData **cd, int *reverted, unsigned int offset, int c) { ALSChannelData *ch = cd[c]; unsigned int dep = 0; unsigned int channels = ctx->avctx->channels; if (reverted[c]) return 0; reverted[c] = 1; while (dep < channels && !ch[dep].stop_flag) { revert_channel_correlation(ctx, bd, cd, reverted, offset, ch[dep].master_channel); dep++; } if (dep == channels) { av_log(ctx->avctx, AV_LOG_WARNING, "Invalid channel correlation.\n"); return AVERROR_INVALIDDATA; } bd->const_block = ctx->const_block + c; bd->shift_lsbs = ctx->shift_lsbs + c; bd->opt_order = ctx->opt_order + c; bd->store_prev_samples = ctx->store_prev_samples + c; bd->use_ltp = ctx->use_ltp + c; bd->ltp_lag = ctx->ltp_lag + c; bd->ltp_gain = ctx->ltp_gain[c]; bd->lpc_cof = ctx->lpc_cof[c]; bd->quant_cof = ctx->quant_cof[c]; bd->raw_samples = ctx->raw_samples[c] + offset; dep = 0; while (!ch[dep].stop_flag) { unsigned int smp; unsigned int begin = 1; unsigned int end = bd->block_length - 1; int64_t y; int32_t *master = ctx->raw_samples[ch[dep].master_channel] + offset; if (ch[dep].time_diff_flag) { int t = ch[dep].time_diff_index; if (ch[dep].time_diff_sign) { t = -t; begin -= t; } else { end -= t; } for (smp = begin; smp < end; smp++) { y = (1 << 6) + MUL64(ch[dep].weighting[0], master[smp - 1 ]) + MUL64(ch[dep].weighting[1], master[smp ]) + MUL64(ch[dep].weighting[2], master[smp + 1 ]) + MUL64(ch[dep].weighting[3], master[smp - 1 + t]) + MUL64(ch[dep].weighting[4], master[smp + t]) + MUL64(ch[dep].weighting[5], master[smp + 1 + t]); bd->raw_samples[smp] += y >> 7; } } else { for (smp = begin; smp < end; smp++) { y = (1 << 6) + MUL64(ch[dep].weighting[0], master[smp - 1]) + MUL64(ch[dep].weighting[1], master[smp ]) + MUL64(ch[dep].weighting[2], master[smp + 1]); bd->raw_samples[smp] += y >> 7; } } dep++; } return 0; }
1threat
How do I make a batch web browser? : <p>I am trying to make a batch web browser for my own mini os. I have tried using the type command but that won't work. How do I embed websites into batch files? Here is what I have so far:</p> <pre><code> @echo off set /p website=What site do you want to read? type %website% pause </code></pre>
0debug
static int cow_create(const char *filename, QemuOpts *opts, Error **errp) { struct cow_header_v2 cow_header; struct stat st; int64_t image_sectors = 0; char *image_filename = NULL; Error *local_err = NULL; int ret; BlockDriverState *cow_bs = NULL; image_sectors = DIV_ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), BDRV_SECTOR_SIZE); image_filename = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE); ret = bdrv_create_file(filename, opts, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; } ret = bdrv_open(&cow_bs, filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, NULL, &local_err); if (ret < 0) { error_propagate(errp, local_err); goto exit; } memset(&cow_header, 0, sizeof(cow_header)); cow_header.magic = cpu_to_be32(COW_MAGIC); cow_header.version = cpu_to_be32(COW_VERSION); if (image_filename) { cow_header.mtime = cpu_to_be32(0); if (stat(image_filename, &st) != 0) { goto mtime_fail; } cow_header.mtime = cpu_to_be32(st.st_mtime); mtime_fail: pstrcpy(cow_header.backing_file, sizeof(cow_header.backing_file), image_filename); } cow_header.sectorsize = cpu_to_be32(512); cow_header.size = cpu_to_be64(image_sectors * 512); ret = bdrv_pwrite(cow_bs, 0, &cow_header, sizeof(cow_header)); if (ret < 0) { goto exit; } ret = bdrv_truncate(cow_bs, sizeof(cow_header) + ((image_sectors + 7) >> 3)); if (ret < 0) { goto exit; } exit: g_free(image_filename); if (cow_bs) { bdrv_unref(cow_bs); } return ret; }
1threat
docker base image with solaris operating system : <p>Does anybody know from where i can get docker base image with Solaris OS in it?</p> <p>I tried finding it on Dockerhub but couldn't find one.</p> <p>Please provide me the detail 'dockerhost/namespace/imagename:tag'</p>
0debug
SQLSERVER 2014:- Invalid length parameter passed to the LEFT or SUBSTRING function : I am getting the following error while trying to execute the below query in sql server 2014 . I have data customers chat data and I want to replace the customers with "Customer" and Agent name with "Agent" Error :- Invalid length parameter passed to the LEFT or SUBSTRING function. Data format : - 11:35:41 Daniella Sichtman : I don't mind. It's ok 11:35:55 Daniella Sichtman : Did you understand my problem? 11:36:09 Madan : Yes, I got your issue. 11:36:20 Madan : Please stay connected while I check what best I can do for you. 11:37:01 Daniella Sichtman : OK. If I may suggest. Mail the hotel that we need 2 nights. I have their contact information if you need that. 11:37:21 Daniella Sichtman : The room are availible they told us 11:37:41 Daniella Sichtman : Just need an ok 11:37:43 Madan : Have you visited the hotel reception to extend your stay ? 11:38:01 Daniella Sichtman : Yes. They told us you need to give the ok 11:39:14 Madan : Nico, I would like to Inform you that we have already authorized to the hotel to extend the stay for our guests. 11:39:46 Daniella Sichtman : They don't know about that or did you told them this morning? Note:- I have seen many post but did't get the desire output. I would request to all of you , could you help me. Regards Anand XX:XX:XX Agent : I do understand what you are saying but I am afraid, but any instrument larger than XXcm x XXXcm x XXcm like a double bass or harp can’t be taken on board the aircraft as cabin baggage. XX:XX:XX Customer : Hello, it's a GUITAR. it is just X cm bigger, the case is Xcm thicker. XX:XX:XX Customer : it's a soft case that can be pushed to fit your dimensions XX:XX:XX Agent : I do understand what you are saying but even it is X cm then also they will ask you to put it on hold and we do understanbd that you are worried if it gets damaged but there won't be any case and you can get the fragile tag from the Airport so that it will be taken care.<br /> XX:XX:XX Customer : What if I take it on board (priority boarding) and it fits within their dimensions exactly and can go in an overhead locker?
0debug
static int inc_refcounts(BlockDriverState *bs, uint16_t *refcount_table, int refcount_table_size, int64_t offset, int64_t size) { BDRVQcowState *s = bs->opaque; int64_t start, last, cluster_offset; int k; int errors = 0; if (size <= 0) return 0; start = offset & ~(s->cluster_size - 1); last = (offset + size - 1) & ~(s->cluster_size - 1); for(cluster_offset = start; cluster_offset <= last; cluster_offset += s->cluster_size) { k = cluster_offset >> s->cluster_bits; if (k < 0 || k >= refcount_table_size) { fprintf(stderr, "ERROR: invalid cluster offset=0x%" PRIx64 "\n", cluster_offset); errors++; } else { if (++refcount_table[k] == 0) { fprintf(stderr, "ERROR: overflow cluster offset=0x%" PRIx64 "\n", cluster_offset); errors++; } } } return errors; }
1threat
Gradle - equivalent of test {} configuration block for android : <p>Gradle has the test configuration block </p> <p><a href="https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html" rel="noreferrer">https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html</a></p> <p>```</p> <pre><code>apply plugin: 'java' // adds 'test' task test { // enable TestNG support (default is JUnit) useTestNG() // set a system property for the test JVM(s) systemProperty 'some.prop', 'value' // explicitly include or exclude tests include 'org/foo/**' exclude 'org/boo/**' // show standard out and standard error of the test JVM(s) on the console testLogging.showStandardStreams = true // set heap size for the test JVM(s) minHeapSize = "128m" maxHeapSize = "512m" // set JVM arguments for the test JVM(s) jvmArgs '-XX:MaxPermSize=256m' // listen to events in the test execution lifecycle beforeTest { descriptor -&gt; logger.lifecycle("Running test: " + descriptor) } // listen to standard out and standard error of the test JVM(s) onOutput { descriptor, event -&gt; logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message ) } } </code></pre> <p>where one can set all sorts of test configuration (I am mostly interested in the heap size). Is there something similar for android projects?</p>
0debug
Equivalent of InterlockedExchangeAdd for Linux using Delphi 10.2) : <p>Delphi 10.2 (having support for Linux) has a cross Platform function AtomicExchange which is equivalent to Windows InterlocekdEchange. So far so good...</p> <p>I have to port Win32 code making use of InterlockedExchangeAdd which has no AtomicExchangeAdd equivalent.</p> <p>My question is: what can I use to replace InterlockedExchangeAdd when compiling for Linux ?</p>
0debug
Parse error: syntax error, unexpected 'if' (T_IF) in D:\Xampp\htdocs\profile\new\view.php on line 29 : <p>I am getting parse error unexpected IF (T_IF). please help me correcting my code i have session_start() before tag and using session username for selecting row from database. please help me my code is not working properly</p> <p><strong>PHP CODE</strong></p> <pre><code>&lt;?php // connect to the database include('connect-db.php'); $username = $_SESSION['username'] // get the records from the database if ($result = $mysqli-&gt;query("SELECT * FROM user WHERE username = '$username'")) { // display records if there are records to display if ($result-&gt;num_rows &gt; 0) { // display records in a table echo "&lt;table border='1' cellpadding='10'&gt;"; // set table headers echo "&lt;tr&gt;&lt;th&gt;ID&lt;/th&gt;&lt;th&gt;First Name&lt;/th&gt;&lt;th&gt;Last Name&lt;/th&gt;&lt;th&gt;&lt;/th&gt;&lt;th&gt;&lt;/th&gt;&lt;/tr&gt;"; while ($row = $result-&gt;fetch_object()) { // set up a row for each record echo "&lt;tr&gt;"; echo "&lt;td&gt;" . $row-&gt;id . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row-&gt;firstname . "&lt;/td&gt;"; echo "&lt;td&gt;" . $row-&gt;lastname . "&lt;/td&gt;"; echo "&lt;td&gt;&lt;a href='records.php?id=" . $row-&gt;id . "'&gt;Edit&lt;/a&gt;&lt;/td&gt;"; echo "&lt;td&gt;&lt;a href='delete.php?id=" . $row-&gt;id . "'&gt;Delete&lt;/a&gt;&lt;/td&gt;"; echo "&lt;/tr&gt;"; } echo "&lt;/table&gt;"; } // if there are no records in the database, display an alert message else { echo "No results to display!"; } } // show an error if there is an issue with the database query else { echo "Error: " . $mysqli-&gt;error; } // close database connection $mysqli-&gt;close(); ?&gt; </code></pre>
0debug
Not a statement error with objects : <p>I am getting a "not a statement" error in my code and i have no idea why here is the code </p> <pre><code> for (int i = 0; i &lt; Champ.length; i++) { for (int j = 0; j &lt; Champ[i].length; j++) { if (Champ[i][j].getLegume() != null) { Champ[i][j].getNbJoursMatLegume() - jour; //HERE IS THE ERROR .... System.out.print(Champ[i][j].getNbJoursMatLegume() + " "); } } System.out.println(""); } </code></pre> <p>All my variables are initialized and work fine, but i dont know why i can't do that operation</p>
0debug
How to deploy Java stadnalone application on JBOSS along with other web applications : I am writing a Java program which will keep on listening to JMS/ActiveM queue for any messages. When there is a message posted on the queue, this program will pick up the message and process it. this program has a main method. Now I want to deploy this program in JBOSS/wildfly. already there are some web application deployed on JBOSS. I want to deploy this program also on JBOSS to avoid manual start ups. Whenever the JBOSS server starts, this program also should run and listen to queue. If main method cannot be used, Need some advise on alternative solution to this requirement.
0debug
Micro web-framework for Kotlin : <p>I would like to develop a very simple web-application. Is there something similar to Flask from Python world for Kotlin?</p> <p>I know there is for instance Kara framework, but it looks abandoned.</p>
0debug
static void rtc_realizefn(DeviceState *dev, Error **errp) { ISADevice *isadev = ISA_DEVICE(dev); RTCState *s = MC146818_RTC(dev); int base = 0x70; s->cmos_data[RTC_REG_A] = 0x26; s->cmos_data[RTC_REG_B] = 0x02; s->cmos_data[RTC_REG_C] = 0x00; s->cmos_data[RTC_REG_D] = 0x80; if (s->base_year == 2000) { s->base_year = 0; } rtc_set_date_from_host(isadev); #ifdef TARGET_I386 switch (s->lost_tick_policy) { case LOST_TICK_POLICY_SLEW: s->coalesced_timer = timer_new_ns(rtc_clock, rtc_coalesced_timer, s); break; case LOST_TICK_POLICY_DISCARD: break; default: error_setg(errp, "Invalid lost tick policy."); return; } #endif s->periodic_timer = timer_new_ns(rtc_clock, rtc_periodic_timer, s); s->update_timer = timer_new_ns(rtc_clock, rtc_update_timer, s); check_update_timer(s); s->clock_reset_notifier.notify = rtc_notify_clock_reset; qemu_clock_register_reset_notifier(rtc_clock, &s->clock_reset_notifier); s->suspend_notifier.notify = rtc_notify_suspend; qemu_register_suspend_notifier(&s->suspend_notifier); memory_region_init_io(&s->io, OBJECT(s), &cmos_ops, s, "rtc", 2); isa_register_ioport(isadev, &s->io, base); qdev_set_legacy_instance_id(dev, base, 3); qemu_register_reset(rtc_reset, s); object_property_add(OBJECT(s), "date", "struct tm", rtc_get_date, NULL, NULL, s, NULL); object_property_add_alias(qdev_get_machine(), "rtc-time", OBJECT(s), "date", NULL); }
1threat
Cpp/C++ - Is this an alternative to tolower? : I was solving a very easy problem to convert a character in a string to lowercase, I obviously used tolower(). However, I saw someone use this and it was an accepted solution. **Is this an alternative to tolower() function in cpp? If so, why?** Reference to the problem: https://atcoder.jp/contests/abc126/tasks/abc126_a #include <iostream> using namespace std; int main(int argc, char const *argv[]) { // We want to convert "ABC" to "aBC" string S = "ABC"; S[0] += 0x20; // Returns "aBC" cout << S << endl; return 0; }
0debug
uint64_t helper_addqv (uint64_t op1, uint64_t op2) { uint64_t tmp = op1; op1 += op2; if (unlikely((tmp ^ op2 ^ (-1ULL)) & (tmp ^ op1) & (1ULL << 63))) { arith_excp(env, GETPC(), EXC_M_IOV, 0); } return op1; }
1threat
How to get a versionName in react-native app on Android? : <p>I've made a timestamped versionName in build.gradle like 20150707.1125. I want to show the version of the package in react-native app in about window. How I could get versionName in code?</p>
0debug
int ff_amf_get_field_value(const uint8_t *data, const uint8_t *data_end, const uint8_t *name, uint8_t *dst, int dst_size) { int namelen = strlen(name); int len; while (*data != AMF_DATA_TYPE_OBJECT && data < data_end) { len = ff_amf_tag_size(data, data_end); if (len < 0) len = data_end - data; data += len; } if (data_end - data < 3) return -1; data++; for (;;) { int size = bytestream_get_be16(&data); if (!size) break; if (data + size >= data_end || data + size < data) return -1; data += size; if (size == namelen && !memcmp(data-size, name, namelen)) { switch (*data++) { case AMF_DATA_TYPE_NUMBER: snprintf(dst, dst_size, "%g", av_int2double(AV_RB64(data))); break; case AMF_DATA_TYPE_BOOL: snprintf(dst, dst_size, "%s", *data ? "true" : "false"); break; case AMF_DATA_TYPE_STRING: len = bytestream_get_be16(&data); av_strlcpy(dst, data, FFMIN(len+1, dst_size)); break; default: return -1; } return 0; } len = ff_amf_tag_size(data, data_end); if (len < 0 || data + len >= data_end || data + len < data) return -1; data += len; } return -1; }
1threat
What determines how much RAM texture takes? : Does this depend on the physical size of the texture? Let's say I have two empty textures: Texture1 - 1kb, 1024x024 and Texture2 - 1kb, 32x32. Will they take up a single amount of RAM?
0debug
Why is my result varying if I am performing division with a Global constant vs local variable? : I have been working on a C code. I have declared few constants using #define. However I have observed that while I am performing division of a local variable with a constant(defined using #define) I am numerically getting a wrong answer. I have tried changing the constant defined(using #define) to a local variable and then performing division. Now I am getting correct answer. The problem is I have many constants, whose values are to be used throughout various functions. I want to know how I van solve this problem. These are the results I am getting when used #define "0.106883 is q2, 28.348689 is D2 ,1.508116 is q2/D2" These are the results I am getting when used as a local variable. "0.106883 is q2, 28.348689 is D2 ,0.003770 is q2/D2" Any help is appreciated.I am using GCC 8.3.0_2.
0debug
static int read_uncompressed_sgi(const SGIInfo *si, AVPicture *pict, ByteIOContext *f) { int x, y, z, chan_offset, ret = 0; uint8_t *dest_row, *tmp_row = NULL; tmp_row = av_malloc(si->xsize); url_fseek(f, SGI_HEADER_SIZE, SEEK_SET); pict->linesize[0] = si->xsize; for (z = 0; z < si->zsize; z++) { #ifndef WORDS_BIGENDIAN if (si->zsize == 4 && z != 3) chan_offset = 2 - z; else #endif chan_offset = z; for (y = si->ysize - 1; y >= 0; y--) { dest_row = pict->data[0] + (y * si->xsize * si->zsize); if (!get_buffer(f, tmp_row, si->xsize)) { ret = -1; goto cleanup; } for (x = 0; x < si->xsize; x++) { dest_row[chan_offset] = tmp_row[x]; dest_row += si->zsize; } } } cleanup: av_free(tmp_row); return ret; }
1threat
aio_read_done(void *opaque, int ret) { struct aio_ctx *ctx = opaque; struct timeval t2; gettimeofday(&t2, NULL); if (ret < 0) { printf("readv failed: %s\n", strerror(-ret)); return; } if (ctx->Pflag) { void *cmp_buf = malloc(ctx->qiov.size); memset(cmp_buf, ctx->pattern, ctx->qiov.size); if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) { printf("Pattern verification failed at offset %lld, " "%zd bytes\n", (long long) ctx->offset, ctx->qiov.size); } free(cmp_buf); } if (ctx->qflag) { return; } if (ctx->vflag) { dump_buffer(ctx->buf, ctx->offset, ctx->qiov.size); } t2 = tsub(t2, ctx->t1); print_report("read", &t2, ctx->offset, ctx->qiov.size, ctx->qiov.size, 1, ctx->Cflag); qemu_io_free(ctx->buf); free(ctx); }
1threat
Broken code in company contact form : <p>The contact form on my employer's website doesn't work so they asked me to fix it. I examined the code and found some issues. The "form method" was incorrect so I changed that. Also, the email address in the send_form_email.php was wrong so I fixed that as well but the form still doesn't work. Can anybody see what I'm missing here?</p> <pre><code> &lt;form action="send_form_email.php" method="post" class="fieldbox2"&gt; &lt;table width="344" border="0" cellspacing="0" cellpadding="0"&gt; &lt;tr&gt; &lt;td width="169" align="right" valign="middle"&gt;&lt;span class="fieldbox1"&gt; &lt;input name="first_name" type="text" id="first_name" value="First Name"/&gt; &lt;/span&gt;&lt;/td&gt; &lt;td width="7" align="right" valign="middle"&gt;&amp;nbsp;&lt;/td&gt; &lt;td width="168" align="left" valign="middle"&gt;&lt;span class="fieldbox1"&gt; &lt;input name="last_name" type="text" id="last_name" value="Last Name"/&gt; &lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right" valign="middle"&gt;&lt;span class="fieldbox1"&gt; &lt;input name="email" type="text" id="email" value="Email"/&gt; &lt;/span&gt;&lt;/td&gt; &lt;td align="right" valign="middle"&gt;&amp;nbsp;&lt;/td&gt; &lt;td align="left" valign="middle"&gt;&lt;span class="fieldbox1"&gt; &lt;input name="city" type="text" id="city" value="City"/&gt; &lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align="right" valign="middle"&gt;&lt;span class="fieldbox1"&gt; &lt;input name="telephone" type="text" id="telephone" value="Phone Number"/&gt; &lt;/span&gt;&lt;/td&gt; &lt;td align="right" valign="middle"&gt;&amp;nbsp;&lt;/td&gt; &lt;td align="left" valign="middle"&gt;&lt;span class="fieldbox1"&gt; &lt;input name="company" type="text" id="company" value="Company"/&gt; &lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" align="center" valign="middle"&gt;&lt;textarea name="textarea2" cols="45" id="textarea2"&gt;Write Comments&lt;/textarea&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="3" align="center" valign="middle"&gt;&lt;p&gt; &lt;input name="sendbutton" type="button" id="sendbutton" value="Submit Query"/&gt; &lt;/p&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;?php if(isset($_POST['email'])) { $email_to = "#"; $email_subject = "Quote Requested"; function died($error) { echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.&lt;br /&gt;&lt;br /&gt;"; echo $error."&lt;br /&gt;&lt;br /&gt;"; echo "Please go back and fix these errors.&lt;br /&gt;&lt;br /&gt;"; die(); } if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['city']) || !isset($_POST['telephone']) || !isset($_POST['company']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $city = $_POST['city']; // required $telephone = $_POST['phone_number']; // not required $company = $_POST['company']; // not required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.&lt;br /&gt;'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.&lt;br /&gt;'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.&lt;br /&gt;'; } if(!preg_match($string_exp,$city)) { $error_message .= 'The City you entered does not appear to be valid.&lt;br /&gt;'; } if(strlen($comments) &lt; 2) { $error_message .= 'The Comments you entered do not appear to be valid.&lt;br /&gt;'; } if(strlen($error_message) &gt; 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Company: ".clean_string($company)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?&gt; Thank you for contacting us. We will be in touch with you very soon. &lt;?php } ?&gt; </code></pre>
0debug
SCSIDevice *scsi_bus_legacy_add_drive(SCSIBus *bus, BlockBackend *blk, int unit, bool removable, int bootindex, const char *serial, Error **errp) { const char *driver; char *name; DeviceState *dev; Error *err = NULL; driver = blk_is_sg(blk) ? "scsi-generic" : "scsi-disk"; dev = qdev_create(&bus->qbus, driver); name = g_strdup_printf("legacy[%d]", unit); object_property_add_child(OBJECT(bus), name, OBJECT(dev), NULL); g_free(name); qdev_prop_set_uint32(dev, "scsi-id", unit); if (bootindex >= 0) { object_property_set_int(OBJECT(dev), bootindex, "bootindex", &error_abort); } if (object_property_find(OBJECT(dev), "removable", NULL)) { qdev_prop_set_bit(dev, "removable", removable); } if (serial && object_property_find(OBJECT(dev), "serial", NULL)) { qdev_prop_set_string(dev, "serial", serial); } qdev_prop_set_drive(dev, "drive", blk, &err); if (err) { qerror_report_err(err); error_free(err); error_setg(errp, "Setting drive property failed"); object_unparent(OBJECT(dev)); return NULL; } object_property_set_bool(OBJECT(dev), true, "realized", &err); if (err != NULL) { error_propagate(errp, err); object_unparent(OBJECT(dev)); return NULL; } return SCSI_DEVICE(dev); }
1threat
Sort a list according to a property java : <p>I have a list of Strings </p> <pre><code>ArrayList&lt;String&gt; titles = t1,t1,t2,t2,t3,t3,t3 </code></pre> <p>I want a sublist with the unique values ie. <code>titles2 = t1,t2,t3</code></p> <p>How can I do this? Any help is appreciated</p>
0debug
static int blkverify_open(BlockDriverState *bs, const char *filename, int flags) { BDRVBlkverifyState *s = bs->opaque; int ret; char *raw, *c; if (strncmp(filename, "blkverify:", strlen("blkverify:"))) { return -EINVAL; } filename += strlen("blkverify:"); c = strchr(filename, ':'); if (c == NULL) { return -EINVAL; } raw = strdup(filename); raw[c - filename] = '\0'; ret = bdrv_file_open(&bs->file, raw, flags); free(raw); if (ret < 0) { return ret; } filename = c + 1; s->test_file = bdrv_new(""); ret = bdrv_open(s->test_file, filename, flags, NULL); if (ret < 0) { bdrv_delete(s->test_file); s->test_file = NULL; return ret; } return 0; }
1threat
static int parse_meter(DBEContext *s) { if (s->meter_size) skip_input(s, s->key_present + s->meter_size + 1); return 0; }
1threat
simple java error i don't know how to fix : <p>I am new to Java. I wrote this program and when I run it, it always gives me that the answer is <strong>0.0</strong> </p> <p>Can you tell me what I did wrong?</p> <pre><code>import java.util.Scanner; public class Learnclass { public static void main(String[] args) { Double fnum, snum; Double ans = 0.0; String opr; Scanner getIn = new Scanner(System.in); System.out.print("Enter your first number: "); fnum = getIn.nextDouble(); System.out.print("Enter your second number: "); snum = getIn.nextDouble(); System.out.print("Enter the operation: "); opr = getIn.next(); if(opr == "add") { ans = fnum + snum; } System.out.print("Answer is " + ans); } } </code></pre>
0debug
Parsing Json array and object : <p>Can someone give me a good link or help explain the workings of parsing json. I have a array of objects like so........ [{}{}{}]. Im trying to get the value of for example {"name" :"John"....} do I call .get (name) to get value John.or .getString (name) to get value John. </p> <p>Another thing I came across is on same object there is [{"name":"John", "Eta":"5"}....] I tried to call getstring (ETA) and there was an error can't .getstring (Eta) on object. Could it have something to do with the fact that some of the json has something like /"Time":"(0004253200)"/</p>
0debug
static void mirror_write_complete(void *opaque, int ret) { MirrorOp *op = opaque; MirrorBlockJob *s = op->s; if (ret < 0) { BlockDriverState *source = s->common.bs; BlockErrorAction action; bdrv_set_dirty(source, op->sector_num, op->nb_sectors); action = mirror_error_action(s, false, -ret); if (action == BLOCK_ERROR_ACTION_REPORT && s->ret >= 0) { s->ret = ret; } } mirror_iteration_done(op, ret); }
1threat
How to train using neural network in python? : <p>I am in my final year Project. In my project,I will collect data from a specific road. I have choosen 5 points in that road.From each point i will collect data from GPS about which day of the week,time of the day and time Taken to reach from previous point to that point.</p> <p>I want to train neural network using this data. So,the input is which day of the week,time,source and destination &amp; output will be the time needed to reach the destination point from the source point.</p> <p>What will be easiest to complete this job in python? which library should i choose?</p>
0debug
Convert String obtained from edittext to Integer in Kotlin language : <p>I am trying to make a simple Android application using Kotlin language. I have one EditText, I am getting its value in String but I want to convert that value into an integer. How can I convert this string to integer in <strong>Kotlin language</strong>?.</p>
0debug
int qemu_mutex_trylock(QemuMutex *mutex) { int owned; owned = TryEnterCriticalSection(&mutex->lock); if (owned) { assert(mutex->owner == 0); mutex->owner = GetCurrentThreadId(); } return !owned; }
1threat
static inline void chroma_4mv_motion_lowres(MpegEncContext *s, uint8_t *dest_cb, uint8_t *dest_cr, uint8_t **ref_picture, h264_chroma_mc_func * pix_op, int mx, int my) { const int lowres = s->avctx->lowres; const int op_index = FFMIN(lowres, 2); const int block_s = 8 >> lowres; const int s_mask = (2 << lowres) - 1; const int h_edge_pos = s->h_edge_pos >> lowres + 1; const int v_edge_pos = s->v_edge_pos >> lowres + 1; int emu = 0, src_x, src_y, offset, sx, sy; uint8_t *ptr; if (s->quarter_sample) { mx /= 2; my /= 2; } mx = ff_h263_round_chroma(mx); my = ff_h263_round_chroma(my); sx = mx & s_mask; sy = my & s_mask; src_x = s->mb_x * block_s + (mx >> lowres + 1); src_y = s->mb_y * block_s + (my >> lowres + 1); offset = src_y * s->uvlinesize + src_x; ptr = ref_picture[1] + offset; if (s->flags & CODEC_FLAG_EMU_EDGE) { if ((unsigned) src_x > h_edge_pos - (!!sx) - block_s || (unsigned) src_y > v_edge_pos - (!!sy) - block_s) { s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos); ptr = s->edge_emu_buffer; emu = 1; } } sx = (sx << 2) >> lowres; sy = (sy << 2) >> lowres; pix_op[op_index](dest_cb, ptr, s->uvlinesize, block_s, sx, sy); ptr = ref_picture[2] + offset; if (emu) { s->dsp.emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos); ptr = s->edge_emu_buffer; } pix_op[op_index](dest_cr, ptr, s->uvlinesize, block_s, sx, sy); }
1threat
SUM AND GROUPING JSON OUTPOUT : I have a json output on php like: [{"Title":"Message","count":"180","Number":"200"},{"Title":"Message","count":"200","Number":"400"}] how can obtain result like: [{"Title":"Message","count":"380","Number":"600"}] thank you very much
0debug
Google Play App Review doesn't show App Version code or name : <p>I have released an app on play store, and have received some reviews. In google play developer console, I could not see the version of app in few of the reviews. This is what I found under the APPLICATION heading.</p> <p><code>Version code — Version name —</code></p> <p>I tried searching around, but could not find any explanation for these to be absent. What may be the possible reasons?</p>
0debug