problem
stringlengths
26
131k
labels
class label
2 classes
How to compare data values in Groovy : I need to compare two data in format `13.07.2017 14:03:51,469000000` using groovy I try to do this, but get error message. Which type of value should I choose for date for compare it? time1 = time1['TIME'] as String assert time1 > time2, 'Error'
0debug
Expanded widgets must be placed inside Flex widgets : <p>New to flutter, can some one tells me whats wrong with below code<a href="https://i.stack.imgur.com/5b5lp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/5b5lp.png" alt="enter image description here"></a></p> <pre><code> class GamePage extends StatelessWidget { int _row; int _column; GamePage(this._row,this._column); @override Widget build(BuildContext context) { return new Material( color: Colors.deepPurpleAccent, child:new Expanded( child:new GridView.count(crossAxisCount: _column,children: new List.generate(_row*_column, (index) { return new Center( child: new CellWidget() ); }),) ) ); } } </code></pre> <p>Attaching error screenshot.</p>
0debug
static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { AMRWBContext *ctx = avctx->priv_data; AMRWBFrame *cf = &ctx->frame; const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; int expected_fr_size, header_size; float *buf_out; float spare_vector[AMRWB_SFR_SIZE]; float fixed_gain_factor; float *synth_fixed_vector; float synth_fixed_gain; float voice_fac, stab_fac; float synth_exc[AMRWB_SFR_SIZE]; float hb_exc[AMRWB_SFR_SIZE_16k]; float hb_samples[AMRWB_SFR_SIZE_16k]; float hb_gain; int sub, i, ret; ctx->avframe.nb_samples = 4 * AMRWB_SFR_SIZE_16k; if ((ret = avctx->get_buffer(avctx, &ctx->avframe)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } buf_out = (float *)ctx->avframe.data[0]; header_size = decode_mime_header(ctx, buf); expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1; if (buf_size < expected_fr_size) { av_log(avctx, AV_LOG_ERROR, "Frame too small (%d bytes). Truncated file?\n", buf_size); *got_frame_ptr = 0; return buf_size; } if (!ctx->fr_quality || ctx->fr_cur_mode > MODE_SID) av_log(avctx, AV_LOG_ERROR, "Encountered a bad or corrupted frame\n"); if (ctx->fr_cur_mode == MODE_SID) av_log_missing_feature(avctx, "SID mode", 1); if (ctx->fr_cur_mode >= MODE_SID) return -1; ff_amr_bit_reorder((uint16_t *) &ctx->frame, sizeof(AMRWBFrame), buf + header_size, amr_bit_orderings_by_mode[ctx->fr_cur_mode]); if (ctx->fr_cur_mode == MODE_6k60) { decode_isf_indices_36b(cf->isp_id, ctx->isf_cur); } else { decode_isf_indices_46b(cf->isp_id, ctx->isf_cur); } isf_add_mean_and_past(ctx->isf_cur, ctx->isf_q_past); ff_set_min_dist_lsf(ctx->isf_cur, MIN_ISF_SPACING, LP_ORDER - 1); stab_fac = stability_factor(ctx->isf_cur, ctx->isf_past_final); ctx->isf_cur[LP_ORDER - 1] *= 2.0; ff_acelp_lsf2lspd(ctx->isp[3], ctx->isf_cur, LP_ORDER); if (ctx->first_frame) { ctx->first_frame = 0; memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(double)); } interpolate_isp(ctx->isp, ctx->isp_sub4_past); for (sub = 0; sub < 4; sub++) ff_amrwb_lsp2lpc(ctx->isp[sub], ctx->lp_coef[sub], LP_ORDER); for (sub = 0; sub < 4; sub++) { const AMRWBSubFrame *cur_subframe = &cf->subframe[sub]; float *sub_buf = buf_out + sub * AMRWB_SFR_SIZE_16k; decode_pitch_vector(ctx, cur_subframe, sub); decode_fixed_vector(ctx->fixed_vector, cur_subframe->pul_ih, cur_subframe->pul_il, ctx->fr_cur_mode); pitch_sharpening(ctx, ctx->fixed_vector); decode_gains(cur_subframe->vq_gain, ctx->fr_cur_mode, &fixed_gain_factor, &ctx->pitch_gain[0]); ctx->fixed_gain[0] = ff_amr_set_fixed_gain(fixed_gain_factor, ff_dot_productf(ctx->fixed_vector, ctx->fixed_vector, AMRWB_SFR_SIZE) / AMRWB_SFR_SIZE, ctx->prediction_error, ENERGY_MEAN, energy_pred_fac); voice_fac = voice_factor(ctx->pitch_vector, ctx->pitch_gain[0], ctx->fixed_vector, ctx->fixed_gain[0]); ctx->tilt_coef = voice_fac * 0.25 + 0.25; for (i = 0; i < AMRWB_SFR_SIZE; i++) { ctx->excitation[i] *= ctx->pitch_gain[0]; ctx->excitation[i] += ctx->fixed_gain[0] * ctx->fixed_vector[i]; ctx->excitation[i] = truncf(ctx->excitation[i]); } synth_fixed_gain = noise_enhancer(ctx->fixed_gain[0], &ctx->prev_tr_gain, voice_fac, stab_fac); synth_fixed_vector = anti_sparseness(ctx, ctx->fixed_vector, spare_vector); pitch_enhancer(synth_fixed_vector, voice_fac); synthesis(ctx, ctx->lp_coef[sub], synth_exc, synth_fixed_gain, synth_fixed_vector, &ctx->samples_az[LP_ORDER]); de_emphasis(&ctx->samples_up[UPS_MEM_SIZE], &ctx->samples_az[LP_ORDER], PREEMPH_FAC, ctx->demph_mem); ff_acelp_apply_order_2_transfer_function(&ctx->samples_up[UPS_MEM_SIZE], &ctx->samples_up[UPS_MEM_SIZE], hpf_zeros, hpf_31_poles, hpf_31_gain, ctx->hpf_31_mem, AMRWB_SFR_SIZE); upsample_5_4(sub_buf, &ctx->samples_up[UPS_FIR_SIZE], AMRWB_SFR_SIZE_16k); ff_acelp_apply_order_2_transfer_function(hb_samples, &ctx->samples_up[UPS_MEM_SIZE], hpf_zeros, hpf_400_poles, hpf_400_gain, ctx->hpf_400_mem, AMRWB_SFR_SIZE); hb_gain = find_hb_gain(ctx, hb_samples, cur_subframe->hb_gain, cf->vad); scaled_hb_excitation(ctx, hb_exc, synth_exc, hb_gain); hb_synthesis(ctx, sub, &ctx->samples_hb[LP_ORDER_16k], hb_exc, ctx->isf_cur, ctx->isf_past_final); hb_fir_filter(hb_samples, bpf_6_7_coef, ctx->bpf_6_7_mem, &ctx->samples_hb[LP_ORDER_16k]); if (ctx->fr_cur_mode == MODE_23k85) hb_fir_filter(hb_samples, lpf_7_coef, ctx->lpf_7_mem, hb_samples); for (i = 0; i < AMRWB_SFR_SIZE_16k; i++) sub_buf[i] = (sub_buf[i] + hb_samples[i]) * (1.0f / (1 << 15)); update_sub_state(ctx); } memcpy(ctx->isp_sub4_past, ctx->isp[3], LP_ORDER * sizeof(ctx->isp[3][0])); memcpy(ctx->isf_past_final, ctx->isf_cur, LP_ORDER * sizeof(float)); *got_frame_ptr = 1; *(AVFrame *)data = ctx->avframe; return expected_fr_size; }
1threat
Error in hist.default(mydata) : 'x' must be numeric : library(data.table) mydata = fread("Kwality.csv",header = FALSE) View(mydata) hist(mydata) I have created my own data set named as Kwality.csv in excel and when I am executing above code I am not able to get Histogram for same and it's throwing me error like this **Error in hist.default(mydata) : 'x' must be numeric**
0debug
Conditional Operation on two int values stored as strings : <p>How can I implement a logic similar to the below mentioned code base ? </p> <pre><code>string a = "1"; string b = "2"; if (a&gt;=b) { Console.WriteLine("Greatest is" + a); } </code></pre> <p>This is a simple dummy that I created to achieve my required implementation but I am stuck without a way to compare these two integer values which are stored as a string . As shown I have two strings which has two int values stored I simply want to be able to check which one of the two strings is greater than the other</p>
0debug
db.execute('SELECT * FROM products WHERE product_id = ' + product_input)
1threat
Only one usage of each socket address (protocol/network address/port) is normally permitted? : <p>I've been looking for a serious solution on google and i only get "Regisrty solutions" kind of stuff which i don't think even relate to my problem.</p> <p>For some reason i get this Error, while i'm only starting the TcpListner once, and when+if fails i stop the server. I really don't get it. Here is my code:</p> <pre><code>class Program { private static string ServerName = ""; private static string UserName = ""; private static string Password = ""; private static string dbConnectionSring = ""; private static X509Certificate adminCertificate; private static byte[] readBuffer = new byte[4096]; static void Main(string[] args) { Console.WriteLine("Please grant SQL Server access to the Admin Server:\n"); Console.Write("Server Name: "); ServerName = Console.ReadLine(); Console.Write("\nUser Name: "); UserName = Console.ReadLine(); Console.Write("\nPassword: "); Password = PasswordMasker.Mask(Password); dbConnectionSring = SQLServerAccess.CreateConnection(ServerName, UserName, Password); adminCertificate = Certificate.GenerateOrImportCertificate("AdminCert.pfx", "randomPassword"); try { Console.WriteLine("Initializing server on the WildCard address on port 443..."); TcpListener listener = new TcpListener(IPAddress.Any, 443); try { Console.WriteLine("Starting to listen at {0}: 443...", IPAddress.Any); //the backlog is set to the maximum integer value, but the underlying network stack will reset this value to its internal maximum value listener.Start(int.MaxValue); Console.WriteLine("Listening... Waiting for a client to connect..."); int ConnectionCount = 0; while (true) { try { listener.BeginAcceptTcpClient(new AsyncCallback(AcceptCallback), listener); ConnectionCount++; Console.WriteLine( " Accepted connection #" + ConnectionCount.ToString()); } catch (SocketException err) { Console.WriteLine("Accept failed: {0}", err.Message); } } } catch (Exception ex) { Console.WriteLine("Listening failed to start."); listener.Stop(); Console.WriteLine(ex.Message); } } catch (Exception ex) { Console.WriteLine("Initialiazing server Failed."); Console.WriteLine(ex.Message); } } </code></pre> <p>I will really appreciate your help!</p>
0debug
Handle "Loading chunk failed" errors with Lazy-loading/Code-splitting : <p>We are developing a Vue.js application based on Vue CLI 3 with Vue Router and Webpack. The <a href="https://router.vuejs.org/guide/advanced/lazy-loading.html" rel="noreferrer">routes are lazy-loaded</a> and the <a href="https://webpack.js.org/guides/caching/" rel="noreferrer">chunk file names contain a hash</a> for cache busting. In general, everything is working fine.</p> <p>However, there is a problem during the deployment. Steps to reproduce are the following.</p> <ul> <li>User opens the application (let's assume route "/"), thus the main chunk file is loaded.</li> <li>We change something in the application and deploy a new version. <ul> <li>Old chunk files are removed</li> <li>New chunk files are being added (i.e. hashes in the chunk file names change)</li> </ul></li> <li>User clicks a link to another route (e.g. "/foo") <ul> <li>An error occurs as the application tries to load a chunk file that has been renamed: <code>Error: "Loading CSS chunk foo failed. (/assets/css/foo.abc123.css)"</code> (this might be CSS or JavaScript)</li> </ul></li> </ul> <p><strong>What is the best way to avoid errors like this?</strong></p> <ul> <li><p>One approach that should work is just to retain old chunk files and delete them at a later time. That, however, complicates the deployment of new versions as you need to keep track of old versions and always also deploy the old chunk files with the new version.</p></li> <li><p>Another (naive) approach is to just reload as soon as such an error is detected (e.g. <a href="https://blog.francium.tech/vue-lazy-routes-loading-chunk-failed-9ee407bbd58" rel="noreferrer">Vue Lazy Routes &amp; loading chunk failed</a>). It somewhat works, but it reloads the <em>old</em> route, not the <em>new</em> one. But at least it ensure that consecutive route changes work again.</p></li> </ul> <p>Any other ideas? Maybe there is something in webpack that could fix this?</p>
0debug
Unable to set default python version to python3 in ubuntu : <p>I was trying to set default python version to <code>python3</code> in <code>Ubuntu 16.04</code>. By default it is <code>python2</code> (2.7). I followed below steps : </p> <pre><code>update-alternatives --remove python /usr/bin/python2 update-alternatives --install /usr/bin/python python /usr/bin/python3 </code></pre> <p>but I'm getting the following error for the second statement, </p> <pre><code>rejeesh@rejeesh-Vostro-1015:~$ update-alternatives --install /usr/bin/python python /usr/bin/python3 update-alternatives: --install needs &lt;link&gt; &lt;name&gt; &lt;path&gt; &lt;priority&gt; Use 'update-alternatives --help' for program usage information. </code></pre> <p>I'm new to Ubuntu and Idon't know what I'm doing wrong.</p>
0debug
unexpected output in recursive function - c++ : I am trying to find the output for fun(5). But I am getting wrong answer, don't know why. My doubt is for n =5 for instance, it would return fun(3) + 3. After that would the return fun(4) + x work or the function fun will be called again? int fun(int n) { static int x = 0; if (n<=0) return 1; if (n>3) { x = n; return fun(n-2) + 3; } return fun(n-1) + x; }
0debug
Why is the compiler-generated enumerator for "yield" not a struct? : <p>The <a href="http://csharpindepth.com/Articles/Chapter6/IteratorBlockImplementation.aspx">compiler-generated implementation</a> of <code>IEnumerator</code> / <code>IEnumerable</code> for <code>yield</code> methods and getters seems to be a class, and is therefore allocated on the heap. However, other .NET types such as <code>List&lt;T&gt;</code> specifically return <code>struct</code> enumerators to avoid useless memory allocation. From a quick overview of the <em>C# In Depth</em> post, I see no reason why that couldn't also be the case here. </p> <p>Am I missing something?</p>
0debug
Avoid for blindly declaring variables in perl : my $scalarVar = ""; my $scalarVar = ''; my $scalarVar = (); my $scalarVar; my @arrayVar = ""; my @arrayVar = ''; my @arrayVar = (); my @arrayVar; my %hashVar = ""; my %hashVar = ''; my %hashVar = (); my $hashVar; Please provide a sample and explanation about this to learn proper declaration of the variables. And it would be appreciate if someone can?
0debug
isInitialized property for lateinit isn't working in companion object : <p>I have a singleton class which i have implemented it in java fashion :</p> <pre><code>companion object { @Volatile private lateinit var instance: TrapBridge fun bridge(): TrapBridge { if (!this::instance.isInitialized) { synchronized(this) { if (!this::instance.isInitialized) { instance = TrapBridge() } } } return instance } } </code></pre> <p>now the problem is i can't use <code>isInitialized</code> property because it throws <code>NoSuchFieldError</code> exception :</p> <pre><code>java.lang.NoSuchFieldError: No field instance of type Lcom/sample/trap/model/TrapBridge; in class Lcom/sample/trap/model/TrapBridge$Companion; or its superclasses (declaration of 'com.sample.trap.model.TrapBridge$Companion' appears in /data/app/com.sample.trapsample-L9D8b2vxEQfiSg9Qep_eNw==/base.apk) </code></pre> <p>and i think it's because <code>instance</code> is class variable and not instance variable so i can't reference it with <code>this</code> keyword :/</p> <p>also i can't check if it's null because it throws <code>UninitializedPropertyAccessException</code> :</p> <pre><code>lateinit property instance has not been initialized </code></pre>
0debug
Why sampling matrix row is very slow? : <p>I tried to do some bootstrapping and calculate <code>colMeans</code>, naturally I chose matrix to store data, however, it is very slow in sampling:</p> <pre><code>m[sample(n,replace=TRUE),] </code></pre> <p>It turns out <code>data.table</code> is the fastest.</p> <pre><code>require(microbenchmark) require(data.table) n = 2000 nc = 8000 m = matrix(1:(n*nc) ,nrow = n) DF = as.data.frame(m) DT = as.data.table(m) s=sample(n, replace=TRUE) microbenchmark(m[s,], DF[s,],DT[s,]) # Unit: milliseconds # expr min lq mean median uq max neval # m[s, ] 371.9271 402.3542 421.7907 420.8446 437.8251 506.1788 100 # DF[s, ] 182.3189 199.0865 218.0746 213.9451 231.1518 409.8625 100 # DT[s, ] 129.8225 139.1977 156.9506 150.4321 164.3104 254.2048 100 </code></pre> <p>Why is sampling matrix much slower than the other two?</p>
0debug
Accessing arrays in objects with PHP : <p>How can I access the TXN_ID in the following object with PHP? Below is a print_r of the object:</p> <pre><code>$txn_object = $txn_params[last_payment]; error_log( print_r($txn_object,true) ); </code></pre> <p>I get this in the error log:</p> <pre><code>EE_Payment Object ( [_props_n_values_provided_in_constructor:protected] =&gt; Array( [PAY_ID] =&gt; 4168 [TXN_ID] =&gt; 746919 [STS_ID] =&gt; PAP [PAY_timestamp] =&gt; 2017-08-29 14:06:26 [PAY_source] =&gt; CART [PAY_amount] =&gt; 24.000 [PMD_ID] =&gt; 11 [PAY_gateway_response] =&gt; submitted_for_settlement [PAY_txn_id_chq_nmbr] =&gt; 96g71gxv [PAY_po_number] =&gt; [PAY_extra_accntng] =&gt; [PAY_details] =&gt; ) ) </code></pre> <p>I've tried a few things, but can't seem to get that value but comes back blank:</p> <pre><code>$txn_object-&gt;_props_n_values_provided_in_constructor[0]-&gt;TXN_ID </code></pre>
0debug
CMS or Framework for my website? : <p>I'm a programmer and for a couple of days I was asking myself: Should I use a CMS or a Framework to build my website?</p> <p>I've learn Laravel (a PHP framework) that I am pretty skilled with it. This said, I tried last week to build a website using a CMS (Wordpress and Drupal) but OH MY I feel like there's no customization possible compared to a framework. I feel like you have some things preset that you can customize and that's it. So I wonder what to take to do a website that will be used to present a company's product and services.</p> <p>Thanks for all the responses! Share your experience programers ;)</p>
0debug
Close parent process if child closed or crashed (C++ , Windows) : I have a Win32 program. This program creates a process with CreateProcess function to run another program. I want to parent process to be closed, if the child process was closed or crashed for any reason. How can I do it? Thanks
0debug
static int vp9_decode_frame(AVCodecContext *avctx, void *frame, int *got_frame, AVPacket *pkt) { const uint8_t *data = pkt->data; int size = pkt->size; VP9Context *s = avctx->priv_data; int ret, i, j, ref; int retain_segmap_ref = s->s.frames[REF_FRAME_SEGMAP].segmentation_map && (!s->s.h.segmentation.enabled || !s->s.h.segmentation.update_map); AVFrame *f; if ((ret = decode_frame_header(avctx, data, size, &ref)) < 0) { return ret; } else if (ret == 0) { if (!s->s.refs[ref].f->buf[0]) { av_log(avctx, AV_LOG_ERROR, "Requested reference %d not available\n", ref); return AVERROR_INVALIDDATA; } if ((ret = av_frame_ref(frame, s->s.refs[ref].f)) < 0) return ret; ((AVFrame *)frame)->pts = pkt->pts; #if FF_API_PKT_PTS FF_DISABLE_DEPRECATION_WARNINGS ((AVFrame *)frame)->pkt_pts = pkt->pts; FF_ENABLE_DEPRECATION_WARNINGS #endif ((AVFrame *)frame)->pkt_dts = pkt->dts; for (i = 0; i < 8; i++) { if (s->next_refs[i].f->buf[0]) ff_thread_release_buffer(avctx, &s->next_refs[i]); if (s->s.refs[i].f->buf[0] && (ret = ff_thread_ref_frame(&s->next_refs[i], &s->s.refs[i])) < 0) return ret; } *got_frame = 1; return pkt->size; } data += ret; size -= ret; if (!retain_segmap_ref || s->s.h.keyframe || s->s.h.intraonly) { if (s->s.frames[REF_FRAME_SEGMAP].tf.f->buf[0]) vp9_frame_unref(avctx, &s->s.frames[REF_FRAME_SEGMAP]); if (!s->s.h.keyframe && !s->s.h.intraonly && !s->s.h.errorres && s->s.frames[CUR_FRAME].tf.f->buf[0] && (ret = vp9_frame_ref(avctx, &s->s.frames[REF_FRAME_SEGMAP], &s->s.frames[CUR_FRAME])) < 0) return ret; } if (s->s.frames[REF_FRAME_MVPAIR].tf.f->buf[0]) vp9_frame_unref(avctx, &s->s.frames[REF_FRAME_MVPAIR]); if (!s->s.h.intraonly && !s->s.h.keyframe && !s->s.h.errorres && s->s.frames[CUR_FRAME].tf.f->buf[0] && (ret = vp9_frame_ref(avctx, &s->s.frames[REF_FRAME_MVPAIR], &s->s.frames[CUR_FRAME])) < 0) return ret; if (s->s.frames[CUR_FRAME].tf.f->buf[0]) vp9_frame_unref(avctx, &s->s.frames[CUR_FRAME]); if ((ret = vp9_frame_alloc(avctx, &s->s.frames[CUR_FRAME])) < 0) return ret; f = s->s.frames[CUR_FRAME].tf.f; f->key_frame = s->s.h.keyframe; f->pict_type = (s->s.h.keyframe || s->s.h.intraonly) ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P; if (s->s.frames[REF_FRAME_SEGMAP].tf.f->buf[0] && (s->s.frames[REF_FRAME_MVPAIR].tf.f->width != s->s.frames[CUR_FRAME].tf.f->width || s->s.frames[REF_FRAME_MVPAIR].tf.f->height != s->s.frames[CUR_FRAME].tf.f->height)) { vp9_frame_unref(avctx, &s->s.frames[REF_FRAME_SEGMAP]); } for (i = 0; i < 8; i++) { if (s->next_refs[i].f->buf[0]) ff_thread_release_buffer(avctx, &s->next_refs[i]); if (s->s.h.refreshrefmask & (1 << i)) { ret = ff_thread_ref_frame(&s->next_refs[i], &s->s.frames[CUR_FRAME].tf); } else if (s->s.refs[i].f->buf[0]) { ret = ff_thread_ref_frame(&s->next_refs[i], &s->s.refs[i]); } if (ret < 0) return ret; } if (avctx->hwaccel) { ret = avctx->hwaccel->start_frame(avctx, NULL, 0); if (ret < 0) return ret; ret = avctx->hwaccel->decode_slice(avctx, pkt->data, pkt->size); if (ret < 0) return ret; ret = avctx->hwaccel->end_frame(avctx); if (ret < 0) return ret; goto finish; } memset(s->above_partition_ctx, 0, s->cols); memset(s->above_skip_ctx, 0, s->cols); if (s->s.h.keyframe || s->s.h.intraonly) { memset(s->above_mode_ctx, DC_PRED, s->cols * 2); } else { memset(s->above_mode_ctx, NEARESTMV, s->cols); } memset(s->above_y_nnz_ctx, 0, s->sb_cols * 16); memset(s->above_uv_nnz_ctx[0], 0, s->sb_cols * 16 >> s->ss_h); memset(s->above_uv_nnz_ctx[1], 0, s->sb_cols * 16 >> s->ss_h); memset(s->above_segpred_ctx, 0, s->cols); s->pass = s->s.frames[CUR_FRAME].uses_2pass = avctx->active_thread_type == FF_THREAD_FRAME && s->s.h.refreshctx && !s->s.h.parallelmode; if ((ret = update_block_buffers(avctx)) < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate block buffers\n"); return ret; } if (s->s.h.refreshctx && s->s.h.parallelmode) { int j, k, l, m; for (i = 0; i < 4; i++) { for (j = 0; j < 2; j++) for (k = 0; k < 2; k++) for (l = 0; l < 6; l++) for (m = 0; m < 6; m++) memcpy(s->prob_ctx[s->s.h.framectxid].coef[i][j][k][l][m], s->prob.coef[i][j][k][l][m], 3); if (s->s.h.txfmmode == i) break; } s->prob_ctx[s->s.h.framectxid].p = s->prob.p; ff_thread_finish_setup(avctx); } else if (!s->s.h.refreshctx) { ff_thread_finish_setup(avctx); } #if HAVE_THREADS if (avctx->active_thread_type & FF_THREAD_SLICE) { for (i = 0; i < s->sb_rows; i++) atomic_store(&s->entries[i], 0); } #endif do { for (i = 0; i < s->active_tile_cols; i++) { s->td[i].b = s->td[i].b_base; s->td[i].block = s->td[i].block_base; s->td[i].uvblock[0] = s->td[i].uvblock_base[0]; s->td[i].uvblock[1] = s->td[i].uvblock_base[1]; s->td[i].eob = s->td[i].eob_base; s->td[i].uveob[0] = s->td[i].uveob_base[0]; s->td[i].uveob[1] = s->td[i].uveob_base[1]; } #if HAVE_THREADS if (avctx->active_thread_type == FF_THREAD_SLICE) { int tile_row, tile_col; av_assert1(!s->pass); for (tile_row = 0; tile_row < s->s.h.tiling.tile_rows; tile_row++) { for (tile_col = 0; tile_col < s->s.h.tiling.tile_cols; tile_col++) { int64_t tile_size; if (tile_col == s->s.h.tiling.tile_cols - 1 && tile_row == s->s.h.tiling.tile_rows - 1) { tile_size = size; } else { tile_size = AV_RB32(data); data += 4; size -= 4; } if (tile_size > size) return AVERROR_INVALIDDATA; ret = ff_vp56_init_range_decoder(&s->td[tile_col].c_b[tile_row], data, tile_size); if (ret < 0) return ret; if (vp56_rac_get_prob_branchy(&s->td[tile_col].c_b[tile_row], 128)) return AVERROR_INVALIDDATA; data += tile_size; size -= tile_size; } } ff_slice_thread_execute_with_mainfunc(avctx, decode_tiles_mt, loopfilter_proc, s->td, NULL, s->s.h.tiling.tile_cols); } else #endif { ret = decode_tiles(avctx, data, size); if (ret < 0) return ret; } if (avctx->active_thread_type == FF_THREAD_SLICE) for (i = 1; i < s->s.h.tiling.tile_cols; i++) for (j = 0; j < sizeof(s->td[i].counts) / sizeof(unsigned); j++) ((unsigned *)&s->td[0].counts)[j] += ((unsigned *)&s->td[i].counts)[j]; if (s->pass < 2 && s->s.h.refreshctx && !s->s.h.parallelmode) { ff_vp9_adapt_probs(s); ff_thread_finish_setup(avctx); } } while (s->pass++ == 1); ff_thread_report_progress(&s->s.frames[CUR_FRAME].tf, INT_MAX, 0); finish: for (i = 0; i < 8; i++) { if (s->s.refs[i].f->buf[0]) ff_thread_release_buffer(avctx, &s->s.refs[i]); if (s->next_refs[i].f->buf[0] && (ret = ff_thread_ref_frame(&s->s.refs[i], &s->next_refs[i])) < 0) return ret; } if (!s->s.h.invisible) { if ((ret = av_frame_ref(frame, s->s.frames[CUR_FRAME].tf.f)) < 0) return ret; *got_frame = 1; } return pkt->size; }
1threat
Why output differs if i erase "else" from the function? : <p>I am trying to write a GCD function to calculate gcd of two integers using euclids algorithm. In the function if i erase "else" it outputs 3 which is incorrect . But if i use "else" it outputs 1 which is the correct output. i assume if i don't use "else" the function is still correct. Why am i getting two different outputs.</p> <p>Here is my code, </p> <pre><code> #include &lt;iostream&gt; using namespace std; int euclidGcd(int x , int y){ if(x%y!=0) euclidGcd(y , x%y ); else return y; } int main(){ cout&lt;&lt;euclidGcd(2,3)&lt;&lt;"\n"; return 0; } </code></pre>
0debug
How to modify textbox value in new thread : <p>I've got this Sub:</p> <pre><code>Public Sub obtenerValorDeFichero() Dim ruta As String ruta = "file.txt" Dim myFile As New FileInfo(ruta) Dim sizeInBytes As Long = myFile.Length While (Convert.ToInt32(sizeInBytes.ToString) &lt; 4) myFile.Refresh() sizeInBytes = myFile.Length End While Threading.Thread.Sleep(500) Me.TextBox3.Text = File.ReadAllText(ruta).Trim End Sub </code></pre> <p>And I'm calling it in the New code by this way:</p> <pre><code>Dim myThread As System.Threading.Thread myThread = New System.Threading.Thread(Sub() obtenerValorDeFichero()) myThread.Start() </code></pre> <p>But it crashes when try's to change the Me.Textbox3.Text value, how can i do it?</p>
0debug
what different between fixed rate and fixed delay in schedule spring? : <p>I am implementing scheduled tasks using spring and i see have 2 type config time that scheduled works again from latest. What different between 2 type this config.</p> <pre><code> @Scheduled(fixedDelay = 5000) public void doJobDelay() { // do anything } @Scheduled(fixedRate = 5000) public void doJobRate() { // do anything } </code></pre>
0debug
static inline int wv_unpack_stereo(WavpackFrameContext *s, GetBitContext *gb, void *dst_l, void *dst_r, const int type) { int i, j, count = 0; int last, t; int A, B, L, L2, R, R2; int pos = s->pos; uint32_t crc = s->sc.crc; uint32_t crc_extra_bits = s->extra_sc.crc; int16_t *dst16_l = dst_l; int16_t *dst16_r = dst_r; int32_t *dst32_l = dst_l; int32_t *dst32_r = dst_r; float *dstfl_l = dst_l; float *dstfl_r = dst_r; s->one = s->zero = s->zeroes = 0; do { L = wv_get_value(s, gb, 0, &last); if (last) break; R = wv_get_value(s, gb, 1, &last); if (last) break; for (i = 0; i < s->terms; i++) { t = s->decorr[i].value; if (t > 0) { if (t > 8) { if (t & 1) { A = 2 * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1]; B = 2 * s->decorr[i].samplesB[0] - s->decorr[i].samplesB[1]; } else { A = (3 * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1]) >> 1; B = (3 * s->decorr[i].samplesB[0] - s->decorr[i].samplesB[1]) >> 1; s->decorr[i].samplesA[1] = s->decorr[i].samplesA[0]; s->decorr[i].samplesB[1] = s->decorr[i].samplesB[0]; j = 0; } else { A = s->decorr[i].samplesA[pos]; B = s->decorr[i].samplesB[pos]; j = (pos + t) & 7; if (type != AV_SAMPLE_FMT_S16P) { L2 = L + ((s->decorr[i].weightA * (int64_t)A + 512) >> 10); R2 = R + ((s->decorr[i].weightB * (int64_t)B + 512) >> 10); } else { L2 = L + ((s->decorr[i].weightA * A + 512) >> 10); R2 = R + ((s->decorr[i].weightB * B + 512) >> 10); if (A && L) s->decorr[i].weightA -= ((((L ^ A) >> 30) & 2) - 1) * s->decorr[i].delta; if (B && R) s->decorr[i].weightB -= ((((R ^ B) >> 30) & 2) - 1) * s->decorr[i].delta; s->decorr[i].samplesA[j] = L = L2; s->decorr[i].samplesB[j] = R = R2; } else if (t == -1) { if (type != AV_SAMPLE_FMT_S16P) L2 = L + ((s->decorr[i].weightA * (int64_t)s->decorr[i].samplesA[0] + 512) >> 10); else L2 = L + ((s->decorr[i].weightA * s->decorr[i].samplesA[0] + 512) >> 10); UPDATE_WEIGHT_CLIP(s->decorr[i].weightA, s->decorr[i].delta, s->decorr[i].samplesA[0], L); L = L2; if (type != AV_SAMPLE_FMT_S16P) R2 = R + ((s->decorr[i].weightB * (int64_t)L2 + 512) >> 10); else R2 = R + ((s->decorr[i].weightB * L2 + 512) >> 10); UPDATE_WEIGHT_CLIP(s->decorr[i].weightB, s->decorr[i].delta, L2, R); R = R2; s->decorr[i].samplesA[0] = R; } else { if (type != AV_SAMPLE_FMT_S16P) R2 = R + ((s->decorr[i].weightB * (int64_t)s->decorr[i].samplesB[0] + 512) >> 10); else R2 = R + ((s->decorr[i].weightB * s->decorr[i].samplesB[0] + 512) >> 10); UPDATE_WEIGHT_CLIP(s->decorr[i].weightB, s->decorr[i].delta, s->decorr[i].samplesB[0], R); R = R2; if (t == -3) { R2 = s->decorr[i].samplesA[0]; s->decorr[i].samplesA[0] = R; if (type != AV_SAMPLE_FMT_S16P) L2 = L + ((s->decorr[i].weightA * (int64_t)R2 + 512) >> 10); else L2 = L + ((s->decorr[i].weightA * R2 + 512) >> 10); UPDATE_WEIGHT_CLIP(s->decorr[i].weightA, s->decorr[i].delta, R2, L); L = L2; s->decorr[i].samplesB[0] = L; pos = (pos + 1) & 7; if (s->joint) L += (R -= (L >> 1)); crc = (crc * 3 + L) * 3 + R; if (type == AV_SAMPLE_FMT_FLTP) { *dstfl_l++ = wv_get_value_float(s, &crc_extra_bits, L); *dstfl_r++ = wv_get_value_float(s, &crc_extra_bits, R); } else if (type == AV_SAMPLE_FMT_S32P) { *dst32_l++ = wv_get_value_integer(s, &crc_extra_bits, L); *dst32_r++ = wv_get_value_integer(s, &crc_extra_bits, R); } else { *dst16_l++ = wv_get_value_integer(s, &crc_extra_bits, L); *dst16_r++ = wv_get_value_integer(s, &crc_extra_bits, R); count++; } while (!last && count < s->samples); wv_reset_saved_context(s); if ((s->avctx->err_recognition & AV_EF_CRCCHECK) && wv_check_crc(s, crc, crc_extra_bits)) return AVERROR_INVALIDDATA; return 0;
1threat
yuv2mono_1_c_template(SwsContext *c, const uint16_t *buf0, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, enum PixelFormat dstFormat, int flags, int y, enum PixelFormat target) { const uint8_t * const d128 = dither_8x8_220[y & 7]; uint8_t *g = c->table_gU[128] + c->table_gV[128]; int i; for (i = 0; i < dstW - 7; i += 8) { int acc = g[(buf0[i ] >> 7) + d128[0]]; acc += acc + g[(buf0[i + 1] >> 7) + d128[1]]; acc += acc + g[(buf0[i + 2] >> 7) + d128[2]]; acc += acc + g[(buf0[i + 3] >> 7) + d128[3]]; acc += acc + g[(buf0[i + 4] >> 7) + d128[4]]; acc += acc + g[(buf0[i + 5] >> 7) + d128[5]]; acc += acc + g[(buf0[i + 6] >> 7) + d128[6]]; acc += acc + g[(buf0[i + 7] >> 7) + d128[7]]; output_pixel(*dest++, acc); } }
1threat
static int mov_read_custom_2plus(MOVContext *c, AVIOContext *pb, int size) { int64_t end = avio_tell(pb) + size; uint8_t *key = NULL, *val = NULL; int i; AVStream *st; MOVStreamContext *sc; if (c->fc->nb_streams < 1) return 0; st = c->fc->streams[c->fc->nb_streams-1]; sc = st->priv_data; for (i = 0; i < 2; i++) { uint8_t **p; uint32_t len, tag; if (end - avio_tell(pb) <= 12) break; len = avio_rb32(pb); tag = avio_rl32(pb); avio_skip(pb, 4); if (len < 12 || len - 12 > end - avio_tell(pb)) break; len -= 12; if (tag == MKTAG('n', 'a', 'm', 'e')) p = &key; else if (tag == MKTAG('d', 'a', 't', 'a') && len > 4) { avio_skip(pb, 4); len -= 4; p = &val; } else break; *p = av_malloc(len + 1); if (!*p) break; avio_read(pb, *p, len); (*p)[len] = 0; } if (key && val) { if (strcmp(key, "iTunSMPB") == 0) { int priming, remainder, samples; if(sscanf(val, "%*X %X %X %X", &priming, &remainder, &samples) == 3){ if(priming>0 && priming<16384) sc->start_pad = priming; } } if (strcmp(key, "cdec") != 0) { av_dict_set(&c->fc->metadata, key, val, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); key = val = NULL; } } avio_seek(pb, end, SEEK_SET); av_freep(&key); av_freep(&val); return 0; }
1threat
Django 1.9 JSONField order_by : <p>I have the following django model that contains JSONField:</p> <pre><code>class RatebookDataEntry(models.Model): data = JSONField(blank=True, default=[]) last_update = models.DateTimeField(auto_now=True) class Meta: verbose_name_plural = 'Ratebook data entries' </code></pre> <p>And <strong>data</strong> field contains this json:</p> <pre><code>{ "annual_mileage": 15000, "description": "LEON DIESEL SPORT COUPE", "body_style": "Coupe", "range_name": "LEON", "co2_gkm_max": 122, "manufacturer_name": "SEAT" } </code></pre> <p>Can I sort queryset by one of the data fields? This query doesn't work.</p> <pre><code>RatebookDataEntry.objects.all().order_by("data__manufacturer_name") </code></pre>
0debug
static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc *band, IVITile *tile, AVCodecContext *avctx) { int x, y, mv_x, mv_y, mv_delta, offs, mb_offset, mv_scale, blks_per_mb; IVIMbInfo *mb, *ref_mb; int row_offset = band->mb_size * band->pitch; mb = tile->mbs; ref_mb = tile->ref_mbs; offs = tile->ypos * band->pitch + tile->xpos; if (!ref_mb && ((band->qdelta_present && band->inherit_qdelta) || band->inherit_mv)) return AVERROR_INVALIDDATA; if (tile->num_MBs != IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)) { av_log(avctx, AV_LOG_ERROR, "Allocated tile size %d mismatches parameters %d\n", tile->num_MBs, IVI_MBs_PER_TILE(tile->width, tile->height, band->mb_size)); return AVERROR_INVALIDDATA; } mv_scale = (ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3); mv_x = mv_y = 0; for (y = tile->ypos; y < (tile->ypos + tile->height); y += band->mb_size) { mb_offset = offs; for (x = tile->xpos; x < (tile->xpos + tile->width); x += band->mb_size) { mb->xpos = x; mb->ypos = y; mb->buf_offs = mb_offset; if (get_bits1(&ctx->gb)) { if (ctx->frame_type == FRAMETYPE_INTRA) { av_log(avctx, AV_LOG_ERROR, "Empty macroblock in an INTRA picture!\n"); return -1; } mb->type = 1; mb->cbp = 0; mb->q_delta = 0; if (!band->plane && !band->band_num && (ctx->frame_flags & 8)) { mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table, IVI_VLC_BITS, 1); mb->q_delta = IVI_TOSIGNED(mb->q_delta); } mb->mv_x = mb->mv_y = 0; if (band->inherit_mv){ if (mv_scale) { mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale); mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale); } else { mb->mv_x = ref_mb->mv_x; mb->mv_y = ref_mb->mv_y; } } } else { if (band->inherit_mv) { mb->type = ref_mb->type; } else if (ctx->frame_type == FRAMETYPE_INTRA) { mb->type = 0; } else { mb->type = get_bits1(&ctx->gb); } blks_per_mb = band->mb_size != band->blk_size ? 4 : 1; mb->cbp = get_bits(&ctx->gb, blks_per_mb); mb->q_delta = 0; if (band->qdelta_present) { if (band->inherit_qdelta) { if (ref_mb) mb->q_delta = ref_mb->q_delta; } else if (mb->cbp || (!band->plane && !band->band_num && (ctx->frame_flags & 8))) { mb->q_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table, IVI_VLC_BITS, 1); mb->q_delta = IVI_TOSIGNED(mb->q_delta); } } if (!mb->type) { mb->mv_x = mb->mv_y = 0; } else { if (band->inherit_mv){ if (mv_scale) { mb->mv_x = ivi_scale_mv(ref_mb->mv_x, mv_scale); mb->mv_y = ivi_scale_mv(ref_mb->mv_y, mv_scale); } else { mb->mv_x = ref_mb->mv_x; mb->mv_y = ref_mb->mv_y; } } else { mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table, IVI_VLC_BITS, 1); mv_y += IVI_TOSIGNED(mv_delta); mv_delta = get_vlc2(&ctx->gb, ctx->mb_vlc.tab->table, IVI_VLC_BITS, 1); mv_x += IVI_TOSIGNED(mv_delta); mb->mv_x = mv_x; mb->mv_y = mv_y; if (mv_x < 0 || mv_y < 0) { av_log(avctx, AV_LOG_ERROR, "Invalid MV %d %d\n", mv_x, mv_y); mb->mv_x = mb->mv_y = 0; return AVERROR_INVALIDDATA; } } } } mb++; if (ref_mb) ref_mb++; mb_offset += band->mb_size; } offs += row_offset; } align_get_bits(&ctx->gb); return 0; }
1threat
Is Firebase's latency low enough to be used for realtime MMOG instead of socket? : <p>I wonder if Firebase's performance (latency, throughput) is good enough to be used real-time MMO games online.</p> <p>Could someone with enough knowledge share their opinions on this?</p> <p>Can Firebase be used instead of socket for real time games?</p>
0debug
document.write('<script src="evil.js"></script>');
1threat
Changing DateTime format to dd/mmmm/yyyy : <p>I have a DateTime object in the format of <code>6/07/2016</code>, and I want to change it to be in the format of <code>6th July 2016</code>.</p> <p>How can I do this in C#? Been looking around but only seem to find ways to turn strings into DateTime in this format. What if I already have a DateTime object? Convert to string first?</p> <p>Thanks</p>
0debug
How do i keep the header cell moving with the tableview cells in Swift 2.0 : <p>I am trying to create a tableview which starts the header in the middle of the tableview and then can be scrolled up with the added tableView Cells to the top then stops, and then the tableview cells can just scroll "under" it. I got the header to be in the middle of the tableview, but the tableView Cells just scroll on top of it, and the header doesnt really scroll to the top. it just stay where it is. I want to be able to let the header move as you scroll the list, and then stops when it reaches the top of the list, and then its just the tableView Cells that are moving afterwards.</p> <p>I am using the latest version of XCode</p>
0debug
Set up Rmonkey API key, secret, client id,redirect uri...still not working : <p>I followed the directions on this page to set up my Mashery Survey Monkey account. I set my API key and secret options using their values on the app. I used my client ID, which I assume is my "display name" to set sm_client_id. I then used smlogin(), and was directed to a page with the following error:</p> <p>SurveyMonkey</p> <p>The authorization request failed: Invalid client_id and/or redirect_uri</p> <p>What else could I be doing wrong?</p> <p>BTW, I tried this setting the app both as Public and Private. Same problem each time.</p>
0debug
How does Docker run a Linux kernel under macOS host? : <p>I installed Docker on my macOS Sierra as follows. Note I don't have VirtualBox installed.</p> <pre><code>brew cask uninstall virtualbox brew cask install docker </code></pre> <p>My macOS details.</p> <pre><code>$ uname -a Darwin m-C02QG7TRG8WN.local 16.5.0 Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64 x86_64 $ docker version Client: Version: 17.03.1-ce API version: 1.27 Go version: go1.7.5 Git commit: c6d412e Built: Tue Mar 28 00:40:02 2017 OS/Arch: darwin/amd64 Server: Version: 17.03.1-ce API version: 1.27 (minimum version 1.12) Go version: go1.7.5 Git commit: c6d412e Built: Fri Mar 24 00:00:50 2017 OS/Arch: linux/amd64 Experimental: true </code></pre> <p>Once I run Docker from launchpad, I am able to run Docker containers.</p> <pre><code>$ docker run -it ubuntu root@2351d4222a4e:/# uname -a Linux 2351d4222a4e 4.9.13-moby #1 SMP Sat Mar 25 02:48:44 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux </code></pre> <p>My question is how does Docker manage to run a Linux kernel within macOS? I thought Docker would at least require boot2docker or some other such Linux kernel running so that it can create the Ubuntu's filesystem with the help of it. But the above output seems to indicate that it is not so. Where does the Linux kernel come from then?</p>
0debug
Visual Studio Code: How to Disable Drag to Edit Text? : <p>In VS Code how can I disable Drag to Edit Text? </p> <p>When editing in Visual Studio Code, often when I attempt to select an area of text, I accidentally select a few characters. When I drag, the characters are moved. Seems I'm inept at using a mouse.</p> <p>How can I disable drag to edit? I searched online and in keyboard shortcuts. No luck.</p>
0debug
Laravel 5 - Remove Parameter From All Request Objects at Controller Level : <p>I have URLs that look like:</p> <pre><code>http://example.com/api/user?id=45&amp;name=mike&amp;api_token=2348283 http://example.com/api/project?id=5&amp;description=first&amp;api_token=2348283 etc... </code></pre> <p>In my controllers, I have functions that look like:</p> <pre><code>public function user_get_endpoint(Request $request){ $request = $request-&gt;toArray(); return UserModel::where($request)-&gt;get()-&gt;toArray(); } </code></pre> <p>The above will currently break since the <code>$request</code> object contains a property called <code>api_token</code> which does not exist in the <code>user</code> table. I am using the <code>api_token</code> in a middleware to check for authentication.</p> <p>I can manually unset the <code>api_token</code> property in each of my API functions by using <code>unset($request['api_token']</code>, but I'd like to avoid that if possible.</p> <p>Is there anyway to do this application wide or at a class or controller level?</p>
0debug
static void gdb_read_byte(GDBState *s, int ch) { CPUState *env = s->env; int i, csum; uint8_t reply; #ifndef CONFIG_USER_ONLY if (s->last_packet_len) { if (ch == '-') { #ifdef DEBUG_GDB printf("Got NACK, retransmitting\n"); #endif put_buffer(s, (uint8_t *)s->last_packet, s->last_packet_len); } #ifdef DEBUG_GDB else if (ch == '+') printf("Got ACK\n"); else printf("Got '%c' when expecting ACK/NACK\n", ch); #endif if (ch == '+' || ch == '$') s->last_packet_len = 0; if (ch != '$') return; } if (vm_running) { vm_stop(EXCP_INTERRUPT); } else #endif { switch(s->state) { case RS_IDLE: if (ch == '$') { s->line_buf_index = 0; s->state = RS_GETLINE; } break; case RS_GETLINE: if (ch == '#') { s->state = RS_CHKSUM1; } else if (s->line_buf_index >= sizeof(s->line_buf) - 1) { s->state = RS_IDLE; } else { s->line_buf[s->line_buf_index++] = ch; } break; case RS_CHKSUM1: s->line_buf[s->line_buf_index] = '\0'; s->line_csum = fromhex(ch) << 4; s->state = RS_CHKSUM2; break; case RS_CHKSUM2: s->line_csum |= fromhex(ch); csum = 0; for(i = 0; i < s->line_buf_index; i++) { csum += s->line_buf[i]; } if (s->line_csum != (csum & 0xff)) { reply = '-'; put_buffer(s, &reply, 1); s->state = RS_IDLE; } else { reply = '+'; put_buffer(s, &reply, 1); s->state = gdb_handle_packet(s, env, s->line_buf); } break; default: abort(); } } }
1threat
How can I copy 1 specific commit to another branch ? : <p>I have 2 branches : </p> <ul> <li>branchA</li> <li>branchB</li> </ul> <p>I checkout <code>branchB</code>, and fix a small thing while I am on that branch.</p> <pre><code>commit f2c88cad3d7648cad9c12e724d09db0952abec63 Author: Name &lt;email&gt; Date: Fri Mar 18 09:10:22 2016 -0400 Fix small bug on dashboard </code></pre> <p>Then, I do <code>git push origin branchB</code> Which I should have did </p> <p><code>git push origin branchA branchB</code> </p> <p>Now, in branchB I have </p> <pre><code>commit f2c88cad3d7648cad9c12e724d09db0952abec63 </code></pre> <p>but I don't have it on branchA</p> <p>How do I copy that <strong>1</strong> commit <code>f2c88ca</code> into my branchA as well ? </p> <p>Any hints on this will be much appreciated ! </p>
0debug
Check two button click same time in Android : Is a any way to check two buttons click only same time ? I wrote switch in button click listeners,but I can't check when these buttons clicked same time Here is a my source @Override public void onClick(View v) { switch (v.getId()) { case R.id.button1: Log.d("MR.bool", "Button1 was clicked "); break; case R.id.button2: Log.d("MR.bool", "Button2 was clicked "); break; default: break; } }
0debug
Is JAX-RS built on top of Servlet API? How? : <p>I've been reading that the JAX-RS is built on top of servlets. Is this literally true, or it just mean that it is a higher level component? If it is, how does that work? Does JAX-RS create a servlet which parses the request and manually initializes <code>@Path</code> annotated classes and passes the modified parameters to them? The JSR does not seem to specify this, and none of the books that mention it go into any details.</p> <p>note: I don't have trouble deploying JAX or servlets, I am just curious about the details, as it would provide a better understanding of how the web container works.</p>
0debug
def max_length(list1): max_length = max(len(x) for x in list1 ) max_list = max((x) for x in list1) return(max_length, max_list)
0debug
static ssize_t local_readlink(FsContext *ctx, const char *path, char *buf, size_t bufsz) { return readlink(rpath(ctx, path), buf, bufsz); }
1threat
Name of application in the facebook login screen : I want to change my application name that displayed on the facebook login screen [enter image description here][1] [1]: https://i.stack.imgur.com/R7Gpp.jpg How can I do it?
0debug
Why am I getting in expected T_variable? : <pre><code>&lt;?php $date = new datetime; echo $date-&gt;format('m-d-y'); ?&gt; </code></pre> <p>Can someone see something I can't? I keep getting unexpected $date on the 2 line. (I'm very new when it comes to php. Any help appreciated.)</p>
0debug
Why the Time Complexity of my python code O(N**2) : <p>I am having a tough time understanding how time complexity is calculated for a python code. Why is the time complexity of the below code O(N**2) ?</p> <pre><code>from itertools import permutations indices = list(permutations(range(len(A)),2)) indices = list(filter(lambda x: x[0] &lt; x[1], indices)) Y = [(A[i], A[j]) for i,j in indices] count = sum(x&gt;y for x,y in Y) if count &gt;= 1000000000: count = -1 return count </code></pre>
0debug
Combine search engine and machine learning : <p>I'm pretty new on search engines and pretty newbie on machine learning. But I wanted to know if there is a way to combine functionalities of search engines like elasticsearch or Apache Solr and machine learning project like Apache Mahout, H2O or PredictionIO.</p> <p>For exemple, if you work on a travel website where you can search for a destination. You start type "au", so the first suggestions are "AUstria", "AUstralia", "mAUrice island", "mAUritania"... etc... This is typically what elasticsearch can do.</p> <p>But you know that this user has already travelled on Mauritania three times, so you want that Mauritania goes on the first place of suggestions. And I guess that's typically what machine learning can do.</p> <p>Is there bridges between this two type of technologies ? Can machine learning ensure the work of search engine efficiently ?</p> <p>I'm open to all answers, regardless of the technologies used. If you have ever experienced this type of problems, my ears are wide open :-)</p> <p>Thank you</p>
0debug
How to read txt file and save as a single string in java in order to split it by a certain character : <p>I'm new to to java language &amp; am finding trouble finding to:</p> <pre><code>1. read a txt file 2. save entire txt file as single string 3. once I have the txt file content as a string, break the string (by a certain character such as a new line) into an array of strings that I can work with. </code></pre> <p>If you may include the import statements that are required, that would be helpful as well as a new java programmer.</p> <p>I was working with the <code>BufferedReader</code> but I believe that only gives me the current line to work with.</p> <p>I did see that <code>BufferedReader</code> had a <code>lines()</code> method which returns a stream of <code>Stream&lt;String&gt;</code>.</p>
0debug
static int add_metadata_from_side_data(AVCodecContext *avctx, AVFrame *frame) { int size, ret = 0; const uint8_t *side_metadata; const uint8_t *end; side_metadata = av_packet_get_side_data(avctx->pkt, AV_PKT_DATA_STRINGS_METADATA, &size); if (!side_metadata) goto end; end = side_metadata + size; while (side_metadata < end) { const uint8_t *key = side_metadata; const uint8_t *val = side_metadata + strlen(key) + 1; int ret = av_dict_set(avpriv_frame_get_metadatap(frame), key, val, 0); if (ret < 0) break; side_metadata = val + strlen(val) + 1; } end: return ret; }
1threat
Where can I download Java Mission Control(7) (OpenJDK11 or higher)? : <p>Java Mission Control(JMC) was announced to be handed over from Oracle to the open source community from JDK 11 onwards. However JMC is not bundled with the <a href="https://jdk.java.net/11/" rel="noreferrer">OpenJDK11 releases</a>.</p> <p>I read that JMC will be provided as separate <a href="https://jdk.java.net/jmc/" rel="noreferrer">download here</a>, but there are no builds to download. Also Oracle no longer provides a download on <a href="https://www.oracle.com/technetwork/java/javaseproducts/mission-control/java-mission-control-1998576.html" rel="noreferrer">their page about JMC</a>. And I can no longer find it in the <a href="https://www.oracle.com/technetwork/java/javase/downloads/index.html" rel="noreferrer">Oracle JDK</a>.</p> <p>The source is mirrored on <a href="https://github.com/JDKMissionControl/jmc" rel="noreferrer">GitHub</a> but there are also no build releases to download.</p> <p>Where can I download the most recent open source licensed version of Java Mission Control?</p>
0debug
Accept No space in this textbox, please provide me the regular expression and where to add it : this is my password validation code. other than space i wanted to accept everything in this textbox so help me out and this is my validation code. $("#clientPassWord").on("change", function () { var clientPassWord=$("#clientPassWord").val().length; var clientPassWord1=$("#clientPassWord").val(); if(clientPassWord==null || clientPassWord<=0){ $("#passmsg").show(); $("#passmsg").html("This is a required field. You can’t leave it empty."); } else{ if(clientPassWord>=8 ) { $("#passmsg").hide(); $("#joinbtn").removeAttr('disabled'); if (clientPassWord1.toLowerCase().match("paperindex") || clientPassWord1.toUpperCase().match("PAPERINDEX") || clientPassWord1.toLowerCase().match("paperindexcom") || clientPassWord1.toUpperCase().match("PAPERINDEXCOM") ) { $("#passmsg").show(); $("#passmsg").html("&quot;PaperIndex&quot; and variations of this word are not allowed here"); } else{ $("#passmsg").hide(); $("#joinbtn").removeAttr('disabled'); } } else { $("#passmsg").show(); $("#passmsg").html("Short passwords are easy to guess. Enter at least 8 characters."); $("#joinbtn").attr('disabled', 'disabled'); } } });
0debug
' ' was not declared in this scope : <p>I was trying to implement this dynamic array thing and I ran into some problems When I try to compile it, the compiler tells me that bunch of my functions are not declared in this scope</p> <p>here are the files</p> <p><em>dynamicArray.h</em></p> <pre><code>#ifndef DYNAMICARRAY_H #define DYNAMICARRAY_H #include &lt;ctime&gt; #include&lt;iostream&gt; class dynamicArray{ public: dynamicArray(); int * array_constructor(int * &amp;intPtr, int &amp;size ); int * array_resize(int * &amp;intPtr, int&amp; currSize, int&amp; newSize); void array_destructor(int * &amp;intPtr); void array_set(int* &amp;intPtr, int &amp;size); }; #endif // DYNAMICARRAY_H </code></pre> <p><em>dynamicArray.cpp</em></p> <pre><code>#include "dynamicArray.h" #include &lt;iostream&gt; #include &lt;ctime&gt; #include &lt;cstdlib&gt; using namespace std; int * array_constructor(int * &amp;intPtr, int &amp;size ){ if(intPtr != NULL){ delete [] intPtr; } intPtr = new int[size]; for (int i = 0; i &lt; size; i++){ intPtr[i] = i*i; } return intPtr; } int * array_resize(int * &amp;intPtr, int&amp; currSize, int&amp; newSize){ if(newSize == 0){ delete [] intPtr; return NULL; }else if((newSize == currSize) || (newSize &lt; 0)){ return intPtr; } int * array = new int[newSize]; for (int i = 0; i &lt; newSize; i++){ array[i] = i*i; } return array; } void array_destructor(int * &amp;intPtr){ delete [] intPtr; intPtr = NULL; } void array_set(int*&amp; intPtr, int&amp; size){ srand(time(0)); for (int i = 0; i &lt; size; i++){ intPtr[i] = rand(); } } </code></pre> <p><em>main.cpp</em></p> <pre><code>#include "dynamicArray.h" #include &lt;array&gt; #include &lt;iostream&gt; using namespace std; void print(int array[], int size){ if(array == NULL){ cout &lt;&lt; "array is empty" &lt;&lt; endl; return; } for(int i = 0; i &lt; size; i++){ cout &lt;&lt; "array[" &lt;&lt; i &lt;&lt; "] = " &lt;&lt; array[i] &lt;&lt; endl; } cout &lt;&lt; endl; return; } int main() { int *myArray = NULL; int size = 8; int newSize1 = 10; int newSize2 = 5; int newSize3 = -1; int finalSize = 1; myArray = array_constructor(myArray, size); print(myArray, size); myArray = array_resize(myArray, size, newSize1); print(myArray, newSize1); myArray = array_resize(myArray, newSize1, newSize2); print(myArray, newSize2); myArray = array_resize(myArray, newSize2, newSize3); print(myArray, newSize2); array_set(myArray, newSize2); print(myArray, newSize2); array_destructor(myArray); print(myArray, finalSize); return 0; } </code></pre> <p>I tried putting int * dynamicArray::array_constructor(int * &amp;intPtr, int &amp;size ) instead, but no luck Did I do something wrong with the header file or in dynamicArray.cpp? This worked before, but I forgot how to do it.</p>
0debug
Why does the code below return an empty string (''")? : <p>I don't understand when you input the word "pandemonium", how does it return an empty string (""). Can someone explain why that is. </p> <pre><code>def mystery(text): result = "" for x in text: if x == "p": result += "pop" elif x == "m": result = "" else: result += x return result </code></pre>
0debug
static void pcnet_transmit(PCNetState *s) { hwaddr xmit_cxda = 0; int count = CSR_XMTRL(s)-1; int add_crc = 0; int bcnt; s->xmit_pos = -1; if (!CSR_TXON(s)) { s->csr[0] &= ~0x0008; return; } s->tx_busy = 1; txagain: if (pcnet_tdte_poll(s)) { struct pcnet_TMD tmd; TMDLOAD(&tmd, PHYSADDR(s,CSR_CXDA(s))); #ifdef PCNET_DEBUG_TMD printf(" TMDLOAD 0x%08x\n", PHYSADDR(s,CSR_CXDA(s))); PRINT_TMD(&tmd); #endif if (GET_FIELD(tmd.status, TMDS, STP)) { s->xmit_pos = 0; xmit_cxda = PHYSADDR(s,CSR_CXDA(s)); if (BCR_SWSTYLE(s) != 1) add_crc = GET_FIELD(tmd.status, TMDS, ADDFCS); } if (s->lnkst == 0 && (!CSR_LOOP(s) || (!CSR_INTL(s) && !BCR_TMAULOOP(s)))) { SET_FIELD(&tmd.misc, TMDM, LCAR, 1); SET_FIELD(&tmd.status, TMDS, ERR, 1); SET_FIELD(&tmd.status, TMDS, OWN, 0); s->csr[0] |= 0xa000; s->xmit_pos = -1; goto txdone; } if (s->xmit_pos < 0) { goto txdone; } bcnt = 4096 - GET_FIELD(tmd.length, TMDL, BCNT); if (s->xmit_pos + bcnt > sizeof(s->buffer)) { s->xmit_pos = -1; goto txdone; } s->phys_mem_read(s->dma_opaque, PHYSADDR(s, tmd.tbadr), s->buffer + s->xmit_pos, bcnt, CSR_BSWP(s)); s->xmit_pos += bcnt; if (!GET_FIELD(tmd.status, TMDS, ENP)) { goto txdone; } #ifdef PCNET_DEBUG printf("pcnet_transmit size=%d\n", s->xmit_pos); #endif if (CSR_LOOP(s)) { if (BCR_SWSTYLE(s) == 1) add_crc = !GET_FIELD(tmd.status, TMDS, NOFCS); s->looptest = add_crc ? PCNET_LOOPTEST_CRC : PCNET_LOOPTEST_NOCRC; pcnet_receive(qemu_get_queue(s->nic), s->buffer, s->xmit_pos); s->looptest = 0; } else { if (s->nic) { qemu_send_packet(qemu_get_queue(s->nic), s->buffer, s->xmit_pos); } } s->csr[0] &= ~0x0008; s->csr[4] |= 0x0004; s->xmit_pos = -1; txdone: SET_FIELD(&tmd.status, TMDS, OWN, 0); TMDSTORE(&tmd, PHYSADDR(s,CSR_CXDA(s))); if (!CSR_TOKINTD(s) || (CSR_LTINTEN(s) && GET_FIELD(tmd.status, TMDS, LTINT))) s->csr[0] |= 0x0200; if (CSR_XMTRC(s)<=1) CSR_XMTRC(s) = CSR_XMTRL(s); else CSR_XMTRC(s)--; if (count--) goto txagain; } else if (s->xmit_pos >= 0) { struct pcnet_TMD tmd; TMDLOAD(&tmd, xmit_cxda); SET_FIELD(&tmd.misc, TMDM, BUFF, 1); SET_FIELD(&tmd.misc, TMDM, UFLO, 1); SET_FIELD(&tmd.status, TMDS, ERR, 1); SET_FIELD(&tmd.status, TMDS, OWN, 0); TMDSTORE(&tmd, xmit_cxda); s->csr[0] |= 0x0200; if (!CSR_DXSUFLO(s)) { s->csr[0] &= ~0x0010; } else if (count--) goto txagain; } s->tx_busy = 0; }
1threat
static int dvvideo_decode_frame(AVCodecContext *avctx, void *data, int *data_size, UINT8 *buf, int buf_size) { DVVideoDecodeContext *s = avctx->priv_data; int sct, dsf, apt, ds, nb_dif_segs, vs, width, height, i, packet_size; unsigned size; UINT8 *buf_ptr; const UINT16 *mb_pos_ptr; AVPicture *picture; init_get_bits(&s->gb, buf, buf_size); sct = get_bits(&s->gb, 3); if (sct != 0) return -1; skip_bits(&s->gb, 5); get_bits(&s->gb, 4); get_bits(&s->gb, 1); skip_bits(&s->gb, 3); get_bits(&s->gb, 8); dsf = get_bits(&s->gb, 1); if (get_bits(&s->gb, 1) != 0) return -1; skip_bits(&s->gb, 11); apt = get_bits(&s->gb, 3); get_bits(&s->gb, 1); skip_bits(&s->gb, 4); get_bits(&s->gb, 3); get_bits(&s->gb, 1); skip_bits(&s->gb, 4); get_bits(&s->gb, 3); get_bits(&s->gb, 1); skip_bits(&s->gb, 4); get_bits(&s->gb, 3); width = 720; if (dsf) { avctx->frame_rate = 25 * FRAME_RATE_BASE; packet_size = PAL_FRAME_SIZE; height = 576; nb_dif_segs = 12; } else { avctx->frame_rate = 30 * FRAME_RATE_BASE; packet_size = NTSC_FRAME_SIZE; height = 480; nb_dif_segs = 10; } if (buf_size < packet_size) return -1; s->sampling_411 = !dsf; if (s->sampling_411) { mb_pos_ptr = dv_place_411; avctx->pix_fmt = PIX_FMT_YUV411P; } else { mb_pos_ptr = dv_place_420; avctx->pix_fmt = PIX_FMT_YUV420P; } avctx->width = width; avctx->height = height; if (avctx->flags & CODEC_FLAG_DR1 && avctx->get_buffer_callback) { s->width = -1; avctx->dr_buffer[0] = avctx->dr_buffer[1] = avctx->dr_buffer[2] = 0; if(avctx->get_buffer_callback(avctx, width, height, I_TYPE) < 0){ fprintf(stderr, "get_buffer() failed\n"); return -1; } } if (s->width != width || s->height != height) { if (!(avctx->flags & CODEC_FLAG_DR1)) for(i=0;i<3;i++) { if (avctx->dr_buffer[i] != s->current_picture[i]) av_freep(&s->current_picture[i]); avctx->dr_buffer[i] = 0; } for(i=0;i<3;i++) { if (avctx->dr_buffer[i]) { s->current_picture[i] = avctx->dr_buffer[i]; s->linesize[i] = (i == 0) ? avctx->dr_stride : avctx->dr_uvstride; } else { size = width * height; s->linesize[i] = width; if (i >= 1) { size >>= 2; s->linesize[i] >>= s->sampling_411 ? 2 : 1; } s->current_picture[i] = av_malloc(size); } if (!s->current_picture[i]) return -1; } s->width = width; s->height = height; } buf_ptr = buf; for (ds = 0; ds < nb_dif_segs; ds++) { buf_ptr += 6 * 80; for(vs = 0; vs < 27; vs++) { if ((vs % 3) == 0) { buf_ptr += 80; } dv_decode_video_segment(s, buf_ptr, mb_pos_ptr); buf_ptr += 5 * 80; mb_pos_ptr += 5; } } emms_c(); *data_size = sizeof(AVPicture); picture = data; for(i=0;i<3;i++) { picture->data[i] = s->current_picture[i]; picture->linesize[i] = s->linesize[i]; } return packet_size; }
1threat
Batch or Powershell script to clean up the files older than 6 hours? : <p>I wonder if .bat support to delete files older than N hours? I have a script that removes files older than N days but couldn't find command to remove based on hours. If the .bat file doesn't have the hourly function, can we do this using PowerShell script? I am trying to clean up all the files in C:\temp (Windows Server) that are older than 6 hours. </p>
0debug
static void h264_h_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta) { h264_loop_filter_luma_intra_c(pix, 1, stride, alpha, beta); }
1threat
int64_t qmp_guest_get_time(Error **errp) { int ret; qemu_timeval tq; int64_t time_ns; ret = qemu_gettimeofday(&tq); if (ret < 0) { error_setg_errno(errp, errno, "Failed to get time"); return -1; } time_ns = tq.tv_sec * 1000000000LL + tq.tv_usec * 1000; return time_ns; }
1threat
static int ast_write_header(AVFormatContext *s) { ASTMuxContext *ast = s->priv_data; AVIOContext *pb = s->pb; AVCodecContext *enc; unsigned int codec_tag; if (s->nb_streams == 1) { enc = s->streams[0]->codec; } else { av_log(s, AV_LOG_ERROR, "only one stream is supported\n"); return AVERROR(EINVAL); } if (enc->codec_id == AV_CODEC_ID_ADPCM_AFC) { av_log(s, AV_LOG_ERROR, "muxing ADPCM AFC is not implemented\n"); return AVERROR_PATCHWELCOME; } codec_tag = ff_codec_get_tag(ff_codec_ast_tags, enc->codec_id); if (!codec_tag) { av_log(s, AV_LOG_ERROR, "unsupported codec\n"); return AVERROR(EINVAL); } if (ast->loopstart && ast->loopend && ast->loopstart >= ast->loopend) { av_log(s, AV_LOG_ERROR, "loopend can't be less or equal to loopstart\n"); return AVERROR(EINVAL); } CHECK_LOOP(start) CHECK_LOOP(end) ffio_wfourcc(pb, "STRM"); ast->size = avio_tell(pb); avio_wb32(pb, 0); avio_wb16(pb, codec_tag); avio_wb16(pb, 16); avio_wb16(pb, enc->channels); avio_wb16(pb, 0xFFFF); avio_wb32(pb, enc->sample_rate); ast->samples = avio_tell(pb); avio_wb32(pb, 0); avio_wb32(pb, 0); avio_wb32(pb, 0); avio_wb32(pb, 0); avio_wb32(pb, 0); avio_wl32(pb, 0x7F); avio_wb64(pb, 0); avio_wb64(pb, 0); avio_wb32(pb, 0); avio_flush(pb); return 0; }
1threat
How can I use PHP in HTML? do I need to include a tag? : <p>I am trying to do something basic with PHP and HTML first before I get into something big. However, my html page doesn't seem to be processing PHP correctly.</p> <p>I have the following php code in my html:</p> <pre><code>&lt;?php echo '&lt;p&gt;Hello World&lt;/p&gt;'; ?&gt; </code></pre> <p>However, the output on the html page is: 'Hello World' on one line but:</p> <p>'; ?> follows hello world How can I fix this so I get 'hello world'?</p>
0debug
How can I determine which server I'm connected to? : I'm a rookie so I'm not really acquainted with how this really works. I've downloaded SQL Server 2016 and once I log onto the Management Studio, it asks me to connect to a particular server. Now I've no idea which server I'm connected to. I've tried everything. Turned the firewall off, used cmd commands, (tells me that my access has been denied), registered a new server from within the studio (but I feel as if I'm not connected to any as nothing shows up) I'm really confused
0debug
How to code in php to store a one to many relation in mysql database ? (MySQL) : <p>I have two tables. 1) School 2) Student Each School shall have more than one student. One student can only belong to one school. </p> <p>I am noob. I don't know the proper php/ajax code to store a new records in mysql database. I am using 2 select boxes. If I am going to choose school in 1st select box then 2nd select box only show the student who enrolled in designated school..</p>
0debug
"type" object is not subscriptable python selenium : im a newbie to python selenium environment. this is my piece of code. from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait import unittest class LoginTest(unittest.TestCase): def setUp(self): self.driver= webdriver.Firefox() self.driver.get("https://www.facebook.com/") def test_Login(self): driver=self.driver facebookUsername ="somoe@gmail.com" facebookPassword ="basabasa" emailFieldID = "email" passFieldID = "pass" loginButtonXpath = "//input[@value= 'Log In']" fbLogoXpath = "(//a[contains(href , 'logo')])[1]" emailFieldElement = WebDriverWait[driver, 10].until(lambda driver:driver.find_element_by_id(emailFieldID)) passwordFieldElement = WebDriverWait[driver, 10].until(lambda driver:driver.find_element_by_id(passFieldID)) loginButtonElement = WebDriverWait[driver, 10].until(lambda driver:driver.find_element_by_xpath(loginButtonXpath)) emailFieldElement.clear() emailFieldElement.send_keys(facebookUsername) passFieldElement.clear() passFieldElement.send_keys(facebookPassword) loginButtonElement.click() loginButtonElement=WebDriverWait[driver, 10].until(lambda driver : driver.find_element_by_xpath(fbLogoXpath)) def tearDown(self): self.driver.quit() if __name__=='__main__': unittest.main() this code loads facebook when it runs but does not autofill the email and password area and returns with the error mentioned above. i need urgent help in this if possible. thank you.
0debug
How to convert a cell type in Google colab notebook using keyboard shortcuts : <p>Are there any shortcuts to convert the current cell (where my cursor is) from one type to other (code cell -> Text Cell) or vice versa?</p>
0debug
Facebook (#32) Page request limited reached : <p>I am getting the following error while I am trying to access my page using Facebook Graph API.</p> <pre><code>{ error: { message: "(#32) Page request limited reached", type: "OAuthException", code: 32, fbtrace_id: "F6d20m1iihx" </code></pre> <p>} }</p> <p>Could not find anything in Facebook API Documentation. Is this related to my API or page?</p>
0debug
Would you prefer a public or a private Blockchain for managing identities and the authentification in organisations? : <p>I am working on a blockchain implementation and I'm stucked for weeks now at the decision whether I should use a public or a private Blockchain. It's so difficult to decide. I want to manage the identities across organisations (organisations which working together) in one blockchain so that they can authenticate themselfs with just the one and same identifier on every web service (web services across the organizations). My first idea was to use a private one because personal data should be private. But at one side if i use the private i would loose the benefits of the original blockchain technology. Also if i use a private i would have again a centralization because someone must manage the access to it? so it would be like a normal database? what would be the benefit then? on the other side if i use a public blockchain i cant control the users who have got access to it and everybody could see the personal data of each employee. </p> <p>What would you prefer? And also which framework is the best for a quick prototype implementation? I'm thinking about using hyperledger. I'm greatful for every opinion/recommendation</p>
0debug
Cannot get histogram to show separated bins with vertical lines : <p>Annoying strange problem and I have not been able to find a solution on this site yet (although the question has popped up)</p> <p>I am trying to make a histogram where the bins have the 'bar style' where vertical lines separate each bin but no matter what I change the histtype constructor to I get a step filled histogram. </p> <p>Here is my code. Note I am using jupyter notebook installed via anaconda with python version 2.7.6</p> <pre><code>import numpy as np import matplotlib.pyplot as plt x = np.random.rand((100)) bins = np.linspace(0, 2, 40) plt.title('Relative Amplitude',fontsize=30) plt.xlabel('Random Histogram') plt.ylabel('Frequency',fontsize=30) plt.hist(x, bins, alpha=0.5, histtype='bar') plt.legend(loc='upper right',fontsize=30) plt.xticks(fontsize = 20) plt.yticks(fontsize = 20) plt.show() </code></pre> <p>Thats it and I get a step filled diagram with no vertical lines separating the bars. What is annoying is that I didn't have this problem awhile ago, something clearly has changed and I don't know what.I have tried histype='barstacked' as well. Thank you kindly for your help</p> <p><a href="https://i.stack.imgur.com/yh3AI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/yh3AI.png" alt="enter image description here"></a> </p>
0debug
int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info) { int handle = 0; int n; if (arch_info->exception == 1) { if (arch_info->dr6 & (1 << 14)) { if (cpu_single_env->singlestep_enabled) handle = 1; } else { for (n = 0; n < 4; n++) if (arch_info->dr6 & (1 << n)) switch ((arch_info->dr7 >> (16 + n*4)) & 0x3) { case 0x0: handle = 1; break; case 0x1: handle = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_WRITE; break; case 0x3: handle = 1; cpu_single_env->watchpoint_hit = &hw_watchpoint; hw_watchpoint.vaddr = hw_breakpoint[n].addr; hw_watchpoint.flags = BP_MEM_ACCESS; break; } } } else if (kvm_find_sw_breakpoint(cpu_single_env, arch_info->pc)) handle = 1; if (!handle) { cpu_synchronize_state(cpu_single_env); assert(cpu_single_env->exception_injected == -1); cpu_single_env->exception_injected = arch_info->exception; cpu_single_env->has_error_code = 0; } return handle; }
1threat
Error checking TLS connection: Error checking and/or regenerating the certs : <p>After I restarted my windows i cannot connect to docker machine running in Oracle Virtual Box. When i start Docker QuickStart Terminal every thing looks fine, it's coming up OK and it gives me this message:</p> <pre><code>docker is configured to use the default machine with IP 192.168.99.100 For help getting started, check out the docs at https://docs.docker.com </code></pre> <p>but when i do:</p> <pre><code>$ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default - virtualbox Timeout </code></pre> <p>and:</p> <pre><code>λ docker images An error occurred trying to connect: Get http://localhost:2375/v1.21/images/json: dial tcp 127.0.0.1:2375: ConnectEx tcp: No connection could be made because the target machine actively refused it. </code></pre> <p>also when i try to reinitialize my env., i get:</p> <pre><code>λ docker-machine env default Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.100:2376": dial tcp 192.168.99.100:2376: i/o timeout You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'. Be advised that this will trigger a Docker daemon restart which will stop running containers. </code></pre> <p>BTW, Regenerating certs also not helping. Any idea?</p> <p>Thanks.</p>
0debug
"Post Image data using POSTMAN" : <p>I am trying to POST data to my API. I have a model with an <code>image</code> field where:</p> <pre><code>image = models.ImageField() </code></pre> <p>I have an image on my local box, which I am trying to send. Am I sending it correctly?</p> <pre><code>{ "id": "3", "uid":"273a0d69", "uuid": "90", "image": "@/home/user/Downloads/tt.jpeg" } </code></pre>
0debug
Can we test the methods written in Kotlin with Mockito? : <p>Can we test the Mobile Application methods written in Kotlin with Mockito tool?</p> <p>Have a mobile application which uses the library written in kotlin. Can Mockito supports to test these library methods.</p>
0debug
Using Hash Table to count the frequencies : Can we use hash table for the following problems, if i am allowing extra storage O(N)? 1. Count the frequencies of all elements in an array ? 2. Count the number of occurences in an array ? 3. Finding which number is repeating maximum times in an array ?
0debug
Pandas...how to get top 5 most occurring names in a column : My Dataframe looks something like this. [enter image description here][1] [1]: https://i.stack.imgur.com/8OuCu.png I need to find top 5 most occurring names in Name column of this table
0debug
static void update_irq(struct xlx_pic *p) { uint32_t i; if (p->regs[R_MER] & 2) { p->regs[R_ISR] |= p->irq_pin_state & ~p->c_kind_of_intr; } p->regs[R_IPR] = p->regs[R_ISR] & p->regs[R_IER]; for (i = 0; i < 32; i++) { if (p->regs[R_IPR] & (1 << i)) break; } if (i == 32) i = ~0; p->regs[R_IVR] = i; qemu_set_irq(p->parent_irq, (p->regs[R_MER] & 1) && p->regs[R_IPR]); }
1threat
I am new to Java (or for simplicity sake for any programming language) and this is what I wrote; : 1 2 3 public class Sample { 4 public static void main(String args[]){ 5 int month = Integer.parseInt(args[0]); 6 if (month == 12 || month == 1 || month==2){ 7 System.out.println("The season is Winter"); 8 } 9 elseif (month==3||month==4||month==5); 10 { 11 System.out.println("The season is Spring"); 12 } 13 elseif (month==6||month==7||month==8); 14 { 15 System.out.println("The season is Summer"); 16 } 17 elseif (month==9||month==10||month==11); 18 { 19 System.out.println("The season is Autmn"); 20 } 21 else{ 22 System.out.println("Wrong input entered"); 23 } 24 25 } 26 } **This code results in following error;** Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0 at Sample.main(Sample.java:5) > can someone help what error i am making here causing it to throw the error?
0debug
C++ I'm confused about declaring and using characters - for instance in this sscanf example : The following example works fine: char rc[20]="1,150"; char command[1]; int data1 = 0; int data2 = 0; int data3 = 0; int count = sscanf(rc, "%c,%d,%d,%d", command, &data1, &data2, &data3); It gives: count = 2; command[0] = 1; data1 = 150 But I don't know how to make this work if command is defined as: char command; or char * command.
0debug
Python Syntax error ("") : <p>Here is my code for my program but I'm having problems with a syntax error I cant figure out what the problem is. The Error I'm getting is in <code>print "employee / supervisor id :" ,k.get_id()," Date joined :" ,k.get_date()</code>The Syntax error has to do with the "" in that line of code. </p> <pre><code> `import datetime #this will import the formatting for date and tiem class employee: """docstring for employee""" def __init__(self, empid,loc,enttime): self.empid = empid self.enttime = enttime self.exitime = None self.date = None self.loc = loc def exittime(self,exitime): self.exitime = exitime def setdate(self,date): self.date = date def get_id(self): return self.empid def get_date(self): return self.date class supervisor(object): """docstring for supervisor""" def __init__(self, supid,loc,enttime): self.supid = supid self.deptid =loc self.enttime =enttime self.exitime =None self.date = None def exittime(self,exitime): self.exitime = exitime def setdate(self,date): self.date = date def get_id(self): return self.supid def get_date(self): return self.date def printbydate(l): l.sort(key=lambda x: x.date, reverse=True) for k in l: print "employee / supervisor id :" ,k.get_id()," Date joined :" ,k.get_date() date1 = datetime.date(2015, 11, 20) date2 = datetime.date(2017, 11, 27) a = employee("e112","abc",12) b = supervisor("s341","abc",14) a.setdate(date1) b.setdate(date2) a.exittime(19) b.exittime(19) pil =[] pil.append(a) pil.append(b) printbydate(pil)' </code></pre>
0debug
i want to convert json to java object i created class and i wrote code like this .i am getting exception o/p:Unexpected character (c) at position 0 : i m getting the json data from client .but when i try to convert json to java i m getting error ClientConfig clientConfig = new DefaultClientConfig(); clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE); Client client = Client.create(clientConfig); WebResource webResource = client .resource("my url"); String name = "adn"; String password = "12"; String authString = name + ":" + password; String authStringEnc = new BASE64Encoder().encode(authString .getBytes()); // System.out.println("Base64 encoded auth string: " + // authStringEnc); ClientResponse response = webResource.accept("application/json") .header("Authorization", "Basic " + authStringEnc) .get(ClientResponse.class); String output = response.getEntity(String.class); output = output.substring(13, output.length() - 1); System.out.println(output); JSONParser parse = new JSONParser(); counts count=new counts(); JSONObject jobj = (JSONObject)parse.parse(output); JSONArray jsonarr_1 = (JSONArray) jobj.get("Counts"); // System.out.println(jsonarr_1.get(1)); JSONArray array = new JSONArray(); //Get data for Results array for(int i=0;i<jsonarr_1.length();i++) { //Store the JSON objects in an array //Get the index of the JSON object and print the values as per the index JSONObject jsonobj_1 = (JSONObject)jsonarr_1.get(i); System.out.println("Elements under results array"); System.out.println("\nPlace id: " +jsonobj_1.get("college_name")); System.out.println("Types: " +jsonobj_1.get("college_epass_id")); } i am getting the json data from client .i want to convert tht json to java objet .i created pojo(counts) class also .i am getting the json data like this o/p:college_name":"GPT n, Kakda","college_epass_id":128},{"college_name":"GT, am","college_epass_id":2946}.Unexpected character (c) at position 0. when i was trying to convert json data to java i am getting erro like Unexpected character (c) at position 0.
0debug
Default message in custom exception - Python : <p>I want to create a custom exception in Python, that when raised without any arguments, it will print a default message.</p> <p>Case Example:</p> <pre><code>&gt;&gt;&gt; class CustomException(Exception): # some code here &gt;&gt;&gt; raise CustomException </code></pre> <p>and get the below output:</p> <pre><code>Traceback (most recent call last): File "&lt;stdin&gt;", line 1, in &lt;module&gt; __main__.CustomException: This is a default message! </code></pre>
0debug
document.write('<script src="evil.js"></script>');
1threat
ren *.xml *.xsig works in cmd but not in .bat : <p>I have a very simple batch file, I want it to change the extension of all the .xml into .xsig files in the folder of the batch file. The only line that is in the batch file is:</p> <pre><code>ren *.xml *.xsig </code></pre> <p>The command works fine in cmd, but not by double clicking the batch file, it always reports the next message:</p> <pre><code>The system could not find the file specified </code></pre> <p>What am I doing wrong? I've tested this in windows 7.</p>
0debug
Error with new intent ANDROID STUDIO : <pre><code> package com.example.alex.askii; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.graphics.Color; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; import java.sql.DriverManager; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; //Alex Levin public class Login extends AppCompatActivity { Button login; Button signUp; EditText userNameET; EditText passWordET; DatabaseHelper helper = new DatabaseHelper(this); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); login = (Button)findViewById(R.id.Login); signUp = (Button)findViewById(R.id.signUp); userNameET = (EditText)findViewById(R.id.username); passWordET = (EditText)findViewById(R.id.password); login.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v){ //get text valiues String userName = userNameET.getText().toString(); String passWord = passWordET.getText().toString(); //Query in java the username String actualPassword = helper.searchPass(userName); //If Correct if(passWord.equals(actualPassword)){ Toast.makeText(getApplicationContext(), "Redirecting...", Toast.LENGTH_SHORT).show(); /* Intent i = new Intent(mainActivity.this, display.class); i.putExtra("UserName", str); startActivity(i) Example code to go to next activity ^^ */ }else{ Toast.makeText(getApplicationContext(), "Invalid Username Or Password", Toast.LENGTH_SHORT).show(); } } }); signUp.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Login.this, signUP.class); startActivity(i); } }); } } &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;android.support.constraint.ConstraintLayout 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:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.alex.askii.Login"&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Askii Login" android:textSize = "30dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintVertical_bias="0.033" tools:layout_constraintRight_creator="1" tools:layout_constraintLeft_creator="1" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text= "Username:" android:textSize="20dp" app:layout_constraintRight_toLeftOf="@+id/username" tools:layout_constraintRight_creator="1" tools:layout_constraintBottom_creator="1" app:layout_constraintBottom_toBottomOf="@+id/username" android:layout_marginEnd="7dp" android:layout_marginBottom="4dp" android:layout_marginRight="7dp" /&gt; &lt;TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text= "Password:" android:textSize="20dp" android:id="@+id/textView" tools:layout_constraintBottom_creator="1" android:layout_marginStart="16dp" app:layout_constraintBottom_toBottomOf="parent" tools:layout_constraintLeft_creator="1" android:layout_marginBottom="169dp" app:layout_constraintLeft_toLeftOf="parent" android:layout_marginLeft="16dp" /&gt; &lt;Button xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/Login" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Login" android:onClick="login" tools:layout_constraintRight_creator="1" tools:layout_constraintBottom_creator="1" app:layout_constraintBottom_toBottomOf="parent" android:layout_marginEnd="84dp" app:layout_constraintRight_toRightOf="parent" android:layout_marginBottom="88dp" android:layout_marginRight="130dp" /&gt; &lt;EditText android:id="@+id/password" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="10" android:inputType="textPassword" tools:layout_constraintRight_creator="1" app:layout_constraintRight_toRightOf="@+id/username" app:layout_constraintBaseline_toBaselineOf="@+id/textView" tools:layout_constraintBaseline_creator="1" tools:layout_constraintLeft_creator="1" app:layout_constraintLeft_toLeftOf="@+id/username" /&gt; &lt;EditText android:id="@+id/username" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ems="10" android:inputType="textPersonName" android:text="Enter Username" tools:layout_constraintBottom_creator="1" app:layout_constraintBottom_toTopOf="@+id/password" android:layout_marginStart="11dp" tools:layout_constraintLeft_creator="1" android:layout_marginBottom="20dp" app:layout_constraintLeft_toRightOf="@+id/textView" android:layout_marginLeft="11dp" /&gt; &lt;Button xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/signUp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Sign Up" tools:layout_constraintRight_creator="1" tools:layout_constraintBottom_creator="1" app:layout_constraintBottom_toBottomOf="parent" android:layout_marginEnd="84dp" app:layout_constraintRight_toRightOf="parent" android:layout_marginRight="216dp" android:layout_marginBottom="47dp" /&gt; &lt;/android.support.constraint.ConstraintLayout&gt; package com.example.alex.askii; import android.app.Activity; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; /** * Created by Alex on 12/30/2017. */ public class signUP extends AppCompatActivity{ @Override protected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.signup); } Button signUpOnPage = (Button)findViewById(R.id.signUpOnPage); public void onSignUpOnPage(View v){ if(v.getId() == R.id.signUpOnPage){ EditText userName = (EditText)findViewById(R.id.newUserName); EditText passWord = (EditText)findViewById(R.id.newPassWord); EditText confPassword = (EditText)findViewById(R.id.newUserName); String userNameString = userName.getText().toString(); String passWordString = passWord.getText().toString(); String confPasswordString = confPassword.getText().toString(); if(!passWordString.equals(confPasswordString)){ Toast check = Toast.makeText(signUP.this, "Passwords Don't Match", Toast.LENGTH_SHORT); check.show(); } } } } </code></pre> <p>For some reason I am getting the following error</p> <pre><code>12-30 02:39:59.308 1969-1969/com.example.alex.askii E/AndroidRuntime: FATAL EXCEPTION: main java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.alex.askii/com.example.alex.askii.signUP}: java.lang.NullPointerException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981) at android.app.ActivityThread.access$600(ActivityThread.java:123) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4424) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NullPointerException at android.support.v7.app.AppCompatDelegateImplBase.&lt;init&gt;(AppCompatDelegateImplBase.java:118) at android.support.v7.app.AppCompatDelegateImplV9.&lt;init&gt;(AppCompatDelegateImplV9.java:152) at android.support.v7.app.AppCompatDelegateImplV11.&lt;init&gt;(AppCompatDelegateImplV11.java:29) at android.support.v7.app.AppCompatDelegateImplV14.&lt;init&gt;(AppCompatDelegateImplV14.java:53) at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:204) at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:184) at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:518) at android.support.v7.app.AppCompatActivity.findViewById(AppCompatActivity.java:189) at com.example.alex.askii.signUP.&lt;init&gt;(signUP.java:16) at java.lang.Class.newInstanceImpl(Native Method) at java.lang.Class.newInstance(Class.java:1319) at android.app.Instrumentation.newActivity(Instrumentation.java:1023) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)  at android.app.ActivityThread.access$600(ActivityThread.java:123)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)  at android.os.Handler.dispatchMessage(Handler.java:99)  at android.os.Looper.loop(Looper.java:137)  at android.app.ActivityThread.main(ActivityThread.java:4424)  at java.lang.reflect.Method.invokeNative(Native Method)  at java.lang.reflect.Method.invoke(Method.java:511)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)  at dalvik.system.NativeStart.main(Native Method)  </code></pre> <p>I am really unsure why this is happening maybe it is something wrong with my manifests but I doubt it because the manifest was autogenerated. Please help I can't find the answer online because it seems like I followed everything online correctly this is the last place I came to for help I am so frustrated right now!</p>
0debug
iscsi_co_generic_cb(struct iscsi_context *iscsi, int status, void *command_data, void *opaque) { struct IscsiTask *iTask = opaque; struct scsi_task *task = command_data; iTask->status = status; iTask->do_retry = 0; iTask->task = task; if (status != SCSI_STATUS_GOOD) { if (iTask->retries++ < ISCSI_CMD_RETRIES) { if (status == SCSI_STATUS_CHECK_CONDITION && task->sense.key == SCSI_SENSE_UNIT_ATTENTION) { error_report("iSCSI CheckCondition: %s", iscsi_get_error(iscsi)); iTask->do_retry = 1; goto out; } if (status == SCSI_STATUS_BUSY || status == SCSI_STATUS_TIMEOUT || status == SCSI_STATUS_TASK_SET_FULL) { unsigned retry_time = exp_random(iscsi_retry_times[iTask->retries - 1]); if (status == SCSI_STATUS_TIMEOUT) { retry_time = EVENT_INTERVAL * 2; iTask->iscsilun->request_timed_out = true; } error_report("iSCSI Busy/TaskSetFull/TimeOut" " (retry #%u in %u ms): %s", iTask->retries, retry_time, iscsi_get_error(iscsi)); aio_timer_init(iTask->iscsilun->aio_context, &iTask->retry_timer, QEMU_CLOCK_REALTIME, SCALE_MS, iscsi_retry_timer_expired, iTask); timer_mod(&iTask->retry_timer, qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + retry_time); iTask->do_retry = 1; return; } } iTask->err_code = iscsi_translate_sense(&task->sense); error_report("iSCSI Failure: %s", iscsi_get_error(iscsi)); } else { iTask->iscsilun->force_next_flush |= iTask->force_next_flush; } out: if (iTask->co) { iTask->bh = aio_bh_new(iTask->iscsilun->aio_context, iscsi_co_generic_bh_cb, iTask); qemu_bh_schedule(iTask->bh); } else { iTask->complete = 1; } }
1threat
static void intra_predict_mad_cow_dc_l0t_8x8_msa(uint8_t *src, int32_t stride) { uint8_t lp_cnt; uint32_t src0, src1, src2 = 0; uint32_t out0, out1, out2; v16u8 src_top; v8u16 add; v4u32 sum; src_top = LD_UB(src - stride); add = __msa_hadd_u_h(src_top, src_top); sum = __msa_hadd_u_w(add, add); src0 = __msa_copy_u_w((v4i32) sum, 0); src1 = __msa_copy_u_w((v4i32) sum, 1); for (lp_cnt = 0; lp_cnt < 4; lp_cnt++) { src2 += src[lp_cnt * stride - 1]; } src2 = (src0 + src2 + 4) >> 3; src0 = (src0 + 2) >> 2; src1 = (src1 + 2) >> 2; out0 = src0 * 0x01010101; out1 = src1 * 0x01010101; out2 = src2 * 0x01010101; for (lp_cnt = 4; lp_cnt--;) { SW(out2, src); SW(out1, src + 4); SW(out0, src + stride * 4); SW(out1, src + stride * 4 + 4); src += stride; } }
1threat
How to get the url parameters in the same order as they are sent? (Java) : I have a use case in which multiple parameters are to be sent from a web page to servlet. The name given to the parameters are in alphanumeric form, for example: 01h, 02h... etc. I had used different Java functions such as Collections.sort() etc., but when there are more than 10 parameters the values are misplaced. For example, the 10th parameter will have the name as 10h, thus after retrieving the parameters using Collections.sort(), the order becomes 01h, 10h, 02h... Instead, it should be 01h, 02h, 03h, .... , 10h Please advise.
0debug
static void sdhci_do_adma(SDHCIState *s) { unsigned int n, begin, length; const uint16_t block_size = s->blksize & 0x0fff; ADMADescr dscr; int i; for (i = 0; i < SDHC_ADMA_DESCS_PER_DELAY; ++i) { s->admaerr &= ~SDHC_ADMAERR_LENGTH_MISMATCH; get_adma_description(s, &dscr); DPRINT_L2("ADMA loop: addr=" TARGET_FMT_plx ", len=%d, attr=%x\n", dscr.addr, dscr.length, dscr.attr); if ((dscr.attr & SDHC_ADMA_ATTR_VALID) == 0) { s->admaerr &= ~SDHC_ADMAERR_STATE_MASK; s->admaerr |= SDHC_ADMAERR_STATE_ST_FDS; if (s->errintstsen & SDHC_EISEN_ADMAERR) { s->errintsts |= SDHC_EIS_ADMAERR; s->norintsts |= SDHC_NIS_ERR; } sdhci_update_irq(s); return; } length = dscr.length ? dscr.length : 65536; switch (dscr.attr & SDHC_ADMA_ATTR_ACT_MASK) { case SDHC_ADMA_ATTR_ACT_TRAN: if (s->trnmod & SDHC_TRNS_READ) { while (length) { if (s->data_count == 0) { for (n = 0; n < block_size; n++) { s->fifo_buffer[n] = sdbus_read_data(&s->sdbus); } } begin = s->data_count; if ((length + begin) < block_size) { s->data_count = length + begin; length = 0; } else { s->data_count = block_size; length -= block_size - begin; } dma_memory_write(&address_space_memory, dscr.addr, &s->fifo_buffer[begin], s->data_count - begin); dscr.addr += s->data_count - begin; if (s->data_count == block_size) { s->data_count = 0; if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) { s->blkcnt--; if (s->blkcnt == 0) { break; } } } } } else { while (length) { begin = s->data_count; if ((length + begin) < block_size) { s->data_count = length + begin; length = 0; } else { s->data_count = block_size; length -= block_size - begin; } dma_memory_read(&address_space_memory, dscr.addr, &s->fifo_buffer[begin], s->data_count - begin); dscr.addr += s->data_count - begin; if (s->data_count == block_size) { for (n = 0; n < block_size; n++) { sdbus_write_data(&s->sdbus, s->fifo_buffer[n]); } s->data_count = 0; if (s->trnmod & SDHC_TRNS_BLK_CNT_EN) { s->blkcnt--; if (s->blkcnt == 0) { break; } } } } } s->admasysaddr += dscr.incr; break; case SDHC_ADMA_ATTR_ACT_LINK: s->admasysaddr = dscr.addr; DPRINT_L1("ADMA link: admasysaddr=0x%" PRIx64 "\n", s->admasysaddr); break; default: s->admasysaddr += dscr.incr; break; } if (dscr.attr & SDHC_ADMA_ATTR_INT) { DPRINT_L1("ADMA interrupt: admasysaddr=0x%" PRIx64 "\n", s->admasysaddr); if (s->norintstsen & SDHC_NISEN_DMA) { s->norintsts |= SDHC_NIS_DMA; } sdhci_update_irq(s); } if (((s->trnmod & SDHC_TRNS_BLK_CNT_EN) && (s->blkcnt == 0)) || (dscr.attr & SDHC_ADMA_ATTR_END)) { DPRINT_L2("ADMA transfer completed\n"); if (length || ((dscr.attr & SDHC_ADMA_ATTR_END) && (s->trnmod & SDHC_TRNS_BLK_CNT_EN) && s->blkcnt != 0)) { ERRPRINT("SD/MMC host ADMA length mismatch\n"); s->admaerr |= SDHC_ADMAERR_LENGTH_MISMATCH | SDHC_ADMAERR_STATE_ST_TFR; if (s->errintstsen & SDHC_EISEN_ADMAERR) { ERRPRINT("Set ADMA error flag\n"); s->errintsts |= SDHC_EIS_ADMAERR; s->norintsts |= SDHC_NIS_ERR; } sdhci_update_irq(s); } sdhci_end_transfer(s); return; } } timer_mod(s->transfer_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + SDHC_TRANSFER_DELAY); }
1threat
ios13 tls certificates issue - connection error : <p>Since the release of ios13 I have a strange problem in my iOS app due to tls connection error to my backend. If I try to connect to the backend via the simulator (iOS 13) it works fine, if I install the app on the physical device (iOS 13.1) I can't connect anymore due to:</p> <pre><code>2019-10-01 13:24:12.862510+0200 CopApp[1830:506662] [] tcp_input [C1.1:3] flags=[R.] seq=2608024828, ack=2612553500, win=28408 state=ESTABLISHED rcv_nxt=2608024828, snd_una=2612553500 2019-10-01 13:24:12.869115+0200 CopApp[1830:506662] Connection 1: received failure notification 2019-10-01 13:24:12.869360+0200 CopApp[1830:506662] Connection 1: received ECONNRESET with incomplete TLS handshake - generating errSSLClosedNoNotify 2019-10-01 13:24:12.869526+0200 CopApp[1830:506662] Connection 1: failed to connect 3:-9816, reason -1 2019-10-01 13:24:12.869684+0200 CopApp[1830:506662] Connection 1: encountered error(3:-9816) 2019-10-01 13:24:28.124012+0200 CopApp[1830:506782] [] tcp_input [C2.1:3] flags=[R.] seq=3652579464, ack=755757394, win=28408 state=ESTABLISHED rcv_nxt=3652579464, snd_una=755757394 2019-10-01 13:24:28.128402+0200 CopApp[1830:506782] Connection 2: received failure notification 2019-10-01 13:24:28.128627+0200 CopApp[1830:506782] Connection 2: received ECONNRESET with incomplete TLS handshake - generating errSSLClosedNoNotify 2019-10-01 13:24:28.128793+0200 CopApp[1830:506782] Connection 2: failed to connect 3:-9816, reason -1 2019-10-01 13:24:28.128949+0200 CopApp[1830:506782] Connection 2: encountered error(3:-9816) 2019-10-01 13:24:43.584026+0200 CopApp[1830:506831] [] tcp_input [C3.1:3] flags=[R.] seq=984907791, ack=487743401, win=28408 state=ESTABLISHED rcv_nxt=984907791, snd_una=487743401 2019-10-01 13:24:43.587452+0200 CopApp[1830:506831] Connection 3: received failure notification 2019-10-01 13:24:43.587674+0200 CopApp[1830:506831] Connection 3: received ECONNRESET with incomplete TLS handshake - generating errSSLClosedNoNotify 2019-10-01 13:24:43.587839+0200 CopApp[1830:506831] Connection 3: failed to connect 3:-9816, reason -1 2019-10-01 13:24:43.588047+0200 CopApp[1830:506831] Connection 3: encountered error(3:-9816) 2019-10-01 13:24:43.594292+0200 CopApp[1830:506831] Task &lt;DAEFF7C7-DF2E-4DCB-9BF9-2A7825D56AF2&gt;.&lt;1&gt; HTTP load failed, 0/0 bytes (error code: -1200 [3:-9816]) Si è verificato un errore SSL ed è impossibile effettuare una connessione sicura con il server. </code></pre> <p>Obviously the backend is the same and it's covered by an aws certificate created by aws certificate manager. I think the problem is not the certificate because I think it is compliant to the new apple's certificates policy but I can't understand where the problem is.</p> <p>Could you please help me?</p> <p>Thanks</p>
0debug
Rotate and resize rectangle drawn in canvas in android : In my android application i have drawn rectangle in canvas ,how can i rotate rectangle and resize the rectangle on touch events. canvas.drawRect(300,300,500,500,paint); This code is used to draw the rectangle.
0debug
How to use CORS to implement JavaScript Google Places API request : <p>I really do NOT understand how I'm supposed to make this work:</p> <pre><code>var requestURL = 'https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4&amp;key=AIzaSyAW4CQp3KxwYkrHFZERfcGSl--rFce4tNw'; console.log(requestURL); $.getJSON( requestURL, function( data ) { // data console.log(data); }); </code></pre> <p>and my HTML file:</p> <pre><code> &lt;body&gt; &lt;script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"&gt;&lt;/script&gt; &lt;script src="main.js" charset="utf-8"&gt;&lt;/script&gt; &lt;/body&gt; </code></pre> <p>I always get the <strong>No 'Access-Control-Allow-Origin' header is present on the requested resource.</strong> message... even though if I go to <a href="https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4&amp;key=AIzaSyAW4CQp3KxwYkrHFZERfcGSl--rFce4tNw" rel="noreferrer">https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJN1t_tDeuEmsRUsoyG83frY4&amp;key=AIzaSyAW4CQp3KxwYkrHFZERfcGSl--rFce4tNw</a> in my browser I get the proper JSON returned. </p> <p>I am lead to believe that CORS can help me here. I don't understand CORS. Please, can anyone help me in plain simple terms? What should I change to make this work?? </p> <p>Thanks </p>
0debug
R: How to get the average in a dataframe up to each observation? : I want to get the average score by Name going up to the date. Here is an example dataframe Date Name Score 1/1/16 Bill 5 1/1/16 Hank 5 1/1/16 Aaron 10 1/2/16 Hank 15 1/2/16 Bill 10 1/3/16 Bill 20 1/3/16 Aaron 20 1/4/16 Aaron 20 How can I add this column? Date Name Score Average_to_date 1/1/16 Bill 5 NA 1/1/16 Hank 5 NA 1/1/16 Aaron 10 NA 1/2/16 Hank 15 5 1/2/16 Bill 10 5 1/3/16 Bill 20 7.5 1/3/16 Aaron 20 10 1/4/16 Aaron 20 15
0debug
Log all queries in the official Postgres docker image : <p>I have a docker container based on Postgres's official docker image. I want to see the incoming queries when I look at the logs of the docker container using <code>docker logs -f</code>. This is my Dockerfile:</p> <pre><code>FROM postgres:11.1-alpine COPY mock_data.sql /docker-entrypoint-initdb.d/mock_data.sql ENV PGDATA=/data </code></pre> <p>and this is the part of my docker-compose.yml file related to this service:</p> <pre><code>version: '3' services: mock_data: image: mock_data container_name: mock_data ports: - 5434:5432/tcp </code></pre> <p>What is the eaasiest way to include the incoming queries in docker logs?</p>
0debug
How to give user a default password only once after he installed the app? : I created an app where the user has to login with a password and he can change the password later after he logged in. But of course he can not have a password when he just installed the app. Is there a way where I can give the user a default password (e.g. "0000) that he can only type in once?
0debug
Add HTML breaker with PHP if statement : I have a PHP loop listing results from a database: foreach($_SESSION['all'] as $result) { echo $result; } What I have done is write an if statement in PHP so that every time 4 results have been outputted, execute a line of code. In order to do this I have declared '`$i = 0;`' outside of this loop and then inside the loop I have '`$i++;`'. I then say: if ($i %4 == 0) { //execute code inside this if statement } I then put a breaker inside this loop so that every 4 results, there would be a breaker ('`<br />`'). It looks like this: if ($i %4 == 0){ echo "<br />"; echo $i; } When I look at the source code of the site the '`<br />`' is there but it doesn't move the rest of the information to another line. When I add a different line of code it shows, for example, if I print '`<p>Hello</p>`', it outputs 'Hello'. It just seems to be the '`<br />`' that doesn't work. This results in all the results after the first 4 being off the end of the screen. Here is the whole page and a screenshot of the output: <?php session_start(); ?> <section class="hero is-dark is-halfheight is-bold"> <div class="hero-head"> </div> <div class="hero-body"> <div class="container has-text-centered"> <div class="columns"> <?php $i = 0; foreach($_SESSION['all'] as $result) { echo '<div class="column is-3">'; echo '<a href="#">'; echo '<div class="box has-text-centered">'; echo $result; echo '</div>'; echo '</a>'; echo '</div>'; $i++; if ($i %4 == 0){ echo "<br />"; echo $i; } } ?> </div> </div> </div> <div class="hero-foot"> <?php echo $i; ?> <div class="container has-text-centered"> <a class="button is-light is-small" href="add.php"> Add Client </a> </div> <br> </div> </section> And... [Screenshot of output in browser][1] [1]: https://i.stack.imgur.com/5hu2M.png Thanks in advance for any answers. Help will be greatly appreciated!
0debug
static void lm32_uclinux_init(MachineState *machine) { const char *cpu_model = machine->cpu_model; const char *kernel_filename = machine->kernel_filename; const char *kernel_cmdline = machine->kernel_cmdline; const char *initrd_filename = machine->initrd_filename; LM32CPU *cpu; CPULM32State *env; DriveInfo *dinfo; MemoryRegion *address_space_mem = get_system_memory(); MemoryRegion *phys_ram = g_new(MemoryRegion, 1); qemu_irq irq[32]; HWSetup *hw; ResetInfo *reset_info; int i; hwaddr flash_base = 0x04000000; size_t flash_sector_size = 256 * 1024; size_t flash_size = 32 * 1024 * 1024; hwaddr ram_base = 0x08000000; size_t ram_size = 64 * 1024 * 1024; hwaddr uart0_base = 0x80000000; hwaddr timer0_base = 0x80002000; hwaddr timer1_base = 0x80010000; hwaddr timer2_base = 0x80012000; int uart0_irq = 0; int timer0_irq = 1; int timer1_irq = 20; int timer2_irq = 21; hwaddr hwsetup_base = 0x0bffe000; hwaddr cmdline_base = 0x0bfff000; hwaddr initrd_base = 0x08400000; size_t initrd_max = 0x01000000; reset_info = g_malloc0(sizeof(ResetInfo)); if (cpu_model == NULL) { cpu_model = "lm32-full"; } cpu = LM32_CPU(cpu_generic_init(TYPE_LM32_CPU, cpu_model)); if (cpu == NULL) { fprintf(stderr, "qemu: unable to find CPU '%s'\n", cpu_model); exit(1); } env = &cpu->env; reset_info->cpu = cpu; reset_info->flash_base = flash_base; memory_region_allocate_system_memory(phys_ram, NULL, "lm32_uclinux.sdram", ram_size); memory_region_add_subregion(address_space_mem, ram_base, phys_ram); dinfo = drive_get(IF_PFLASH, 0, 0); pflash_cfi02_register(flash_base, NULL, "lm32_uclinux.flash", flash_size, dinfo ? blk_by_legacy_dinfo(dinfo) : NULL, flash_sector_size, flash_size / flash_sector_size, 1, 2, 0x01, 0x7e, 0x43, 0x00, 0x555, 0x2aa, 1); env->pic_state = lm32_pic_init(qemu_allocate_irq(cpu_irq_handler, env, 0)); for (i = 0; i < 32; i++) { irq[i] = qdev_get_gpio_in(env->pic_state, i); } lm32_uart_create(uart0_base, irq[uart0_irq], serial_hds[0]); sysbus_create_simple("lm32-timer", timer0_base, irq[timer0_irq]); sysbus_create_simple("lm32-timer", timer1_base, irq[timer1_irq]); sysbus_create_simple("lm32-timer", timer2_base, irq[timer2_irq]); env->juart_state = lm32_juart_init(serial_hds[1]); reset_info->bootstrap_pc = flash_base; if (kernel_filename) { uint64_t entry; int kernel_size; kernel_size = load_elf(kernel_filename, NULL, NULL, &entry, NULL, NULL, 1, EM_LATTICEMICO32, 0, 0); reset_info->bootstrap_pc = entry; if (kernel_size < 0) { kernel_size = load_image_targphys(kernel_filename, ram_base, ram_size); reset_info->bootstrap_pc = ram_base; } if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } } hw = hwsetup_init(); hwsetup_add_cpu(hw, "LM32", 75000000); hwsetup_add_flash(hw, "flash", flash_base, flash_size); hwsetup_add_ddr_sdram(hw, "ddr_sdram", ram_base, ram_size); hwsetup_add_timer(hw, "timer0", timer0_base, timer0_irq); hwsetup_add_timer(hw, "timer1_dev_only", timer1_base, timer1_irq); hwsetup_add_timer(hw, "timer2_dev_only", timer2_base, timer2_irq); hwsetup_add_uart(hw, "uart", uart0_base, uart0_irq); hwsetup_add_trailer(hw); hwsetup_create_rom(hw, hwsetup_base); hwsetup_free(hw); reset_info->hwsetup_base = hwsetup_base; if (kernel_cmdline && strlen(kernel_cmdline)) { pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, kernel_cmdline); reset_info->cmdline_base = cmdline_base; } if (initrd_filename) { size_t initrd_size; initrd_size = load_image_targphys(initrd_filename, initrd_base, initrd_max); reset_info->initrd_base = initrd_base; reset_info->initrd_size = initrd_size; } qemu_register_reset(main_cpu_reset, reset_info); }
1threat
How does WorkManager schedule GET requests to REST API? : <p>I've had a look at the codelab for WorkManager plus some examples on here, but everything in code I have seen is either related to doing work locally on the device or work uploading to the server, not downloading data and responding to the data received. In the developer guidelines it even says, "For example, an app might need to download new resources from the network from time to time," so I thought it would be perfect for this task. My question is if WorkManager can handle the following scenario and if not, what is the proper tool for handling it:</p> <ol> <li>Schedule a job that runs once a day in background</li> <li>The job is to do a data fetch from the REST API (and post it to a LiveData object if possible).</li> <li>When the data returns, check that it is newer than local data.</li> <li>Notify the user that new data is available.</li> </ol> <p>My worker class looks something like this:</p> <pre><code>public class MyWorker extends Worker { @NonNull @Override public WorkerResult doWork() { lookForNewData(); return WorkerResult.SUCCESS; } public void lookForNewData() { MutableLiveData&lt;MyObject&gt; liveData = new MutableLiveData&lt;&gt;(); liveData.observe(lifeCycleOwner, results -&gt; { notifyOnNewData(results); }) APILayer.getInstance().fetchData(searchParams, liveData) } </code></pre> <p>My issue is of course that the LiveData object can't observe because there is no activity or fragment that can be its LifecycleOwner. But even if I used a callback from the API to respond to the data arriving, my worker would already have posted that it was successful and it probably would not proceed with the callback, right? So I kind of know this approach is totally wrong, but I can't see any code for getting data with WorkManager</p> <p>Please help with a proper solution and some example code or some links, either with WorkManager if it can handle this kind of work or something else if it is more appropriate.</p>
0debug
Beginner Java: Program Crashed when submitted (multiple methods) : My program crashed for some reason when I submitted it. I can't seem to figure out why. Our assignments are turned into hypergrade. That is where it crashed. Also how can I get it to display menu again after it displays "invalid selection" >Here is my code import java.util.Scanner; import java.text.DecimalFormat; public class Homework8bbb { //create main public static void main(String[]args) {//open main method int selection; double meters; Scanner keyboard = new Scanner(System.in); DecimalFormat format = new DecimalFormat("##.00"); //call showMenu method //DISPLAY showMenu method do { showMenu(); //get user [selection] selection = keyboard.nextInt(); //validate selection do { if (selection < 1 || selection > 4) { System.out.print("Invalid selection\n"); selection = keyboard.nextInt(); } }while(selection < 1 || selection > 4); //get [meters] System.out.print("How many meters?\n"); meters = keyboard.nextInt(); //validate meters: do not allow negative meters while (meters < 0) { System.out.print("Invalid Selection. Please enter a positive number:\n"); meters = keyboard.nextInt(); } switch (selection) { case 1: calcKilometers(meters); break; case 2: calcInches(meters); break; case 3: calcFeet(meters); break; case 4: break; } }while(selection != 4); } public static void showMenu() { System.out.print("\n" + "METER CONVERSION\n" + " 1) Convert to Kilometers\n" + " 2) Convert to Inches\n" + " 3) Convert to Feet\n" + " 4) Quit the Program\n" + " Please make a selection:\n"); } //calcKilometers method public static double calcKilometers(double meters) { double kilometers; kilometers = meters * 0.001; System.out.println(meters + " meters is " + kilometers + " kilometers."); return kilometers; } //calcInches method public static double calcInches(double meters) { double inches; inches = meters * 39.37; System.out.println(meters + " meters is " + inches + " inches."); return inches; } //calcFeet method public static double calcFeet(double meters) { double feet; feet = meters * 3.281; System.out.println(meters + " meters is " + feet + " feet."); return feet; } }//close class
0debug
When I want to access sms this error appear please help me : I tried to retrive sms and then added to the firebase realtime database and change the balance of specific account but this error is appear when I want to change the balance : > E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.nouraalqahtani.debrah2, PID: 4500 java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.trim()' on a null object reference at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1838) at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110) at java.lang.Double.parseDouble(Double.java:539) at com.example.nouraalqahtani.debrah2.accesssms$3.onDataChange(accesssms.java:304) at com.google.firebase.database.core.ValueEventRegistration.fireEvent(com.google.firebase:firebase-database@@16.0.6:75) at com.google.firebase.database.core.view.DataEvent.fire(com.google.firebase:firebase-database@@16.0.6:63) at com.google.firebase.database.core.view.EventRaiser$1.run(com.google.firebase:firebase-database@@16.0.6:55) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6494) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) and this accesssms class package com.example.nouraalqahtani.debrah2; import android.content.ContentResolver; import android.content.pm.PackageManager; import android.database.Cursor; import android.net.Uri; import android.os.Bundle; import android.support.annotation.NonNull; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.Toast; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; import com.google.firebase.database.ValueEventListener; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.Locale; public class accesssms extends AppCompatActivity { private static accesssms inst; ArrayList<String> smsMessagesList = new ArrayList<String>(); ListView smsListView; ArrayAdapter arrayAdapter; DatabaseReference myRef; String day; String updatebalance; String accounting; String accountnumber; String smsbody; int count; int childrencount; double balance; double amount; int childrencountinflow; String type; String bank; String amountstr; public static accesssms instance() { return inst; } @Override public void onStart() { super.onStart(); inst = this; } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_accesssms); myRef= FirebaseDatabase.getInstance().getReference("user_account").child(" . (username)").child("bank_accounts"); day = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(new Date()); smsListView = (ListView) findViewById(R.id.SMSList); arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, smsMessagesList); smsListView.setAdapter(arrayAdapter); // Add SMS Read Permision At Runtime // Todo : If Permission Is Not GRANTED if(ContextCompat.checkSelfPermission(getBaseContext(),"android.permission.READ_SMS") ==PackageManager.PERMISSION_GRANTED) { // Todo : If Permission Granted Then Show SMS refreshSmsInbox(); } else { // Todo : Then Set Permission final int REQUEST_CODE_ASK_PERMISSIONS = 123; ActivityCompat.requestPermissions(accesssms.this, new String[] {"android.permission.READ_SMS"}, REQUEST_CODE_ASK_PERMISSIONS); } } public void refreshSmsInbox() { ContentResolver contentResolver = getContentResolver(); Cursor smsInboxCursor = contentResolver.query(Uri.parse("content://sms/inbox"), null, null, null, null); int indexBody = smsInboxCursor.getColumnIndex("body"); int indexAddress = smsInboxCursor.getColumnIndex("address"); if (indexBody < 0 || !smsInboxCursor.moveToFirst()) return; arrayAdapter.clear(); do { String str = "SMS From: " + smsInboxCursor.getString(indexAddress) + "\n" + smsInboxCursor.getString(indexBody) + "\n"; arrayAdapter.add(str); //if it samba bank if (smsInboxCursor.getString(indexAddress).equals(".Samba")) { smsbody = smsInboxCursor.getString(indexBody); int ende = smsbody.indexOf(' '); final String transaction = smsbody.substring(0, ende); //to check if it outflow or inflow //if it outflow if (transaction.equals("دفع")) { type = "outflow"; myRef.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot dataSnapshot) { //Take last three number card number int accountnumberstart = smsbody.lastIndexOf("."); count = accountnumberstart +5; accountnumber = smsbody.substring(accountnumberstart+2 , count); for (DataSnapshot ds : dataSnapshot.getChildren()) { String dataaccountOUT = ds.child("account_no").getValue(String.class); if (Integer.parseInt(accountnumber)==Integer.parseInt(dataaccountOUT)) { childrencount=(int)ds.child("outflow").getChildrenCount(); bank=ds.getKey(); addoutflow(); } } } @Override public void onCancelled(@NonNull DatabaseError databaseError) { }}); } else if (transaction.equals("تم")) { type = "inflow"; //take account number myRef.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot dataSnapshot) { //Take the last four numbers of account number int accountnumberstart = smsbody.indexOf("حساب"); count = accountnumberstart+15 ; accountnumber = smsbody.substring(accountnumberstart +11, count); for (DataSnapshot ds : dataSnapshot.getChildren()) { String dataaccount = ds.child("fourfirstdigit").getValue(String.class); if (Integer.parseInt(accountnumber)==Integer.parseInt(dataaccount)){ childrencountinflow=(int)ds.child("inflow").getChildrenCount(); bank=ds.getKey(); addinflow(); } }} @Override public void onCancelled(@NonNull DatabaseError databaseError) { } }); } }} while (smsInboxCursor.moveToNext()); blanacechange(); } public void updateList(final String smsMessage) { arrayAdapter.insert(smsMessage, 0); arrayAdapter.notifyDataSetChanged(); } public void toastMessage(String message){ Toast.makeText(this,message,Toast.LENGTH_SHORT).show(); } public void addoutflow(){ // counter=counter+1; // String co=Integer.toString(counter); int accounttotalstart = smsbody.lastIndexOf("بقيمة"); int accounttotalend = smsbody.lastIndexOf("ريال"); accounting = smsbody.substring(accounttotalstart + 6, accounttotalend); amountstr=arabicToenglish(accounting); myRef.child(bank).child("outflow").child("6").child("amount").setValue(amountstr); //change the balance //take vendor name int vendorstart = smsbody.lastIndexOf("*", count + 1); int vendorend = smsbody.lastIndexOf(","); String vendor = smsbody.substring(vendorstart + 3, vendorend); //add vendor name to database myRef.child(bank).child("outflow").child("6").child("vendor").setValue(vendor); //add current time int timstart = smsbody.lastIndexOf(","); int timend = smsbody.lastIndexOf("/"); String date = smsbody.substring(timstart + 1, timend + 4); myRef.child(bank).child("outflow").child("6").child("date").setValue(arabicToenglish(date)); int ti = smsbody.lastIndexOf(" "); String time = smsbody.substring(timend + 4, ti); // myRef.child(bank).child("outflow").child("6").child("time").setValue(arabicToenglish(time)); //to check if it AM OR PM String AMorPM = smsbody.substring(ti + 1); if (AMorPM.equals("صباحاً")) { myRef.child(bank).child("outflow").child("6").child("time").setValue(arabicToenglish(time) + " AM"); } else myRef.child(bank).child("outflow").child("6").child("time").setValue(arabicToenglish(time) + " PM"); } public void addinflow(){ int accounttotalstart = smsbody.lastIndexOf("مبلغ"); int accounttotalend = smsbody.indexOf(" "); accounting = smsbody.substring(accounttotalstart + 4, accounttotalend); amountstr=arabicToenglish(accounting); myRef.child(bank).child("inflow").child("2").child("amount") .setValue(amountstr); //change the balance int timstart = smsbody.lastIndexOf("في"); int timend = smsbody.lastIndexOf("-"); String date = smsbody.substring(timstart + 2, timend + 5); myRef.child(bank).child("inflow").child("2").child("date").setValue(arabicToenglish(date)); int ti = smsbody.lastIndexOf(" "); String time = smsbody.substring(timend + 4, ti); myRef.child(bank).child("inflow").child("2").child("time").setValue(arabicToenglish(time)); //to check if it AM OR PM String AMorPM = smsbody.substring(ti + 1); if (AMorPM.equals("صباحاً")) { myRef.child(bank).child("inflow").child("2").child("time").setValue(time + " AM"); } else myRef.child(bank).child("inflow").child("2").child("time").setValue(time + " PM"); } private static String arabicToenglish(String number) { char[] chars = new char[number.length()]; for(int i=0;i<number.length();i++) { char ch = number.charAt(i); if (ch >= 0x0660 && ch <= 0x0669) ch -= 0x0660 - '0'; else if (ch >= 0x06f0 && ch <= 0x06F9) ch -= 0x06f0 - '0'; chars[i] = ch; } return new String(chars); } public void blanacechange() { myRef.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot dataSnapshot) { String databa = dataSnapshot.child(bank).child("balance").getValue(String.class); String am = dataSnapshot.child(bank).child("6").child("amount").getValue(String.class); balance=Double.parseDouble(databa); amount=Double.parseDouble(am); if (type.equals("outflow")){ balance = balance - amount; myRef.child(bank).child("balance").setValue(Double.toString(balance));} if (type.equals("inflow")){ balance=balance+amount; myRef.child(bank).child("balance").setValue(Double.toString(balance)); } } @Override public void onCancelled(@NonNull DatabaseError databaseError) { } }); } } And this my database [enter image description here][1] [1]: https://i.stack.imgur.com/Gu7lL.png
0debug
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
How to double click on an item from grid using selenium webdriver : I need to select any specific grid from the calendar provided. I will attach the screenshot below. [enter image description here][1] [1]: https://i.stack.imgur.com/Io7Nk.png
0debug
void qmp_blockdev_change_medium(const char *device, const char *filename, bool has_format, const char *format, bool has_read_only, BlockdevChangeReadOnlyMode read_only, Error **errp) { BlockBackend *blk; BlockDriverState *medium_bs = NULL; int bdrv_flags, ret; QDict *options = NULL; Error *err = NULL; blk = blk_by_name(device); if (!blk) { error_set(errp, ERROR_CLASS_DEVICE_NOT_FOUND, "Device '%s' not found", device); goto fail; } if (blk_bs(blk)) { blk_update_root_state(blk); } bdrv_flags = blk_get_open_flags_from_root_state(blk); if (!has_read_only) { read_only = BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN; } switch (read_only) { case BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN: break; case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_ONLY: bdrv_flags &= ~BDRV_O_RDWR; break; case BLOCKDEV_CHANGE_READ_ONLY_MODE_READ_WRITE: bdrv_flags |= BDRV_O_RDWR; break; default: abort(); } if (has_format) { options = qdict_new(); qdict_put(options, "driver", qstring_from_str(format)); } assert(!medium_bs); ret = bdrv_open(&medium_bs, filename, NULL, options, bdrv_flags, errp); if (ret < 0) { goto fail; } blk_apply_root_state(blk, medium_bs); bdrv_add_key(medium_bs, NULL, &err); if (err) { error_propagate(errp, err); goto fail; } qmp_blockdev_open_tray(device, false, false, &err); if (err) { error_propagate(errp, err); goto fail; } qmp_x_blockdev_remove_medium(device, &err); if (err) { error_propagate(errp, err); goto fail; } qmp_blockdev_insert_anon_medium(device, medium_bs, &err); if (err) { error_propagate(errp, err); goto fail; } qmp_blockdev_close_tray(device, errp); fail: bdrv_unref(medium_bs); }
1threat
How to be able to set up breakpoints correctly when using VS Code to debug a TypeScript app run using ts-node in a Docker container? : <p>Our app is written in TypeScript and uses Docker, and to avoid round-tripping through .js files, we're running it with <a href="https://github.com/TypeStrong/ts-node" rel="noreferrer">ts-node</a> to load the .ts files directly.</p> <p>Unfortunately this seems to make VSCode confused as to where valid lines of code are for setting breakpoints.</p> <p>This problem manifests with the following setup:</p> <h1>/package.json</h1> <pre class="lang-json prettyprint-override"><code>{ "scripts": { "start": "node --inspect=0.0.0.0 --require ts-node/register src/index.ts" }, "dependencies": { "@types/node": "^10.1.2", "ts-node": "^6.0.3", "typescript": "^2.8.3" } } </code></pre> <h1>/tsconfig.json</h1> <pre class="lang-json prettyprint-override"><code>{ "compilerOptions": { "target": "ES2017", "module": "commonjs", "outDir": "./dist", "rootDir": "./src", "esModuleInterop": true } } </code></pre> <h1>/Dockerfile</h1> <pre><code>FROM node RUN mkdir /home/node/app WORKDIR /home/node/app COPY package.json /home/node/app RUN npm install &amp;&amp; npm cache clean --force COPY . /home/node/app CMD [ "npm", "start" ] </code></pre> <h1>/docker-compose.yml</h1> <pre class="lang-yaml prettyprint-override"><code>version: "3.4" services: http: build: . ports: - "8000:8000" - "9229:9229" </code></pre> <h1>/.vscode/launch.json</h1> <pre class="lang-json prettyprint-override"><code>{ "version": "0.2.0", "configurations": [ { "type": "node", "request": "attach", "name": "Attach", "address": "localhost", "port": 9229, "protocol": "inspector", "localRoot": "${workspaceFolder}/src", "remoteRoot": "/home/node/app/src" } ] } </code></pre> <h1>/src/index.ts</h1> <pre><code>import {createServer} from "http"; const server = createServer((msg, res) =&gt; { res.writeHead(200, {'Content-Type': 'text/plain'}) res.end(msg.url) debugger }) server.listen(8000) </code></pre> <p>(The blank lines are significant for reasons I'll show later, about ten of them does the job.)</p> <p>You can also fetch the whole thing here: <a href="https://github.com/millimoose/ts-node-breakpoints" rel="noreferrer">https://github.com/millimoose/ts-node-breakpoints</a></p> <p>I run this with <code>docker-compose --up</code>, then attach to that with the debugger using the above launch configuration. When I try to set breakpoints in <code>/src/index.ts</code> on any of the lines inside the <code>createServer()</code> call, they're reported as invalid; while I can set breakpoints in the blank lines. This is presumably because TypeScript compilation strips the blank lines, and for some reason, VSCode will only recognize line numbers from the generated JS as valid:</p> <p><a href="https://i.stack.imgur.com/g4YWo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/g4YWo.png" alt="line number mismatch between TS and JS"></a></p> <p>This is a contrived example for ease of reproduction, but in general there'll be a mismatch between where I think I'm setting breakpoints, and where they're actually set.</p> <p>However, when I break on the <code>debugger</code> statement, VSCode fetches the TypeScript file (the tab says something along the lines of "read-only inlined from sourcemap" when newly opened) from the server, and I can then set breakpoints correctly in it:</p> <p><a href="https://i.stack.imgur.com/rRDu9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rRDu9.png" alt="breakpoints in local vs. remote file"></a></p> <p>This is an unsatisfying situation for reasons I shouldn't have to explain: juggling a local file I can edit and a remote file where breakpoints work is a hassle, and adding <code>debugger</code> statements would involve reloading the app everytime I need a new breakpoint.</p> <p>I've searched around for the issue, but the keywords give me at least ten lengthy GitHub issues ranging as far as years back. Since I'm not intimately familiar with the internals of ts-node, transpilation, and sourcemaps, I'm having a hard time reasoning through what's going on here, much less how to fix it. From what I understand, what happens is that ts-node compiles TS to JS and generates sourcemaps in temporary files inside the Docker container where VSCode can't access them. (This is why I've no idea how to set e.g. <code>outFiles</code>.) There were also some allusions to my scenario being already supported if set up correctly in closed issues, but no clue as to how to do it.</p> <p>Is there a way to get this working so that I can actually set a breakpoint in my local sources when remote-debugging, and have them hit in said files, without having to revert to precompiling TS to JS and sourcemaps so I have the latter available locally?</p>
0debug
Regex to match numeric and special chatacters : I need regex which matches as per below values: 1. abc123 - Do not match 2. 123 - Match 3. a123bc - Do not match 4. a#b%c - Match 5. 13&ab12% - Match 6. আফ্রিকার - Do not match In short, it matches with only numeric string and any string with special character(#,&,%). Also it do not match with any other language string. I tried this regex but it didn't work for me. "^[\\D][^#&%]+$"
0debug
int msi_init(struct PCIDevice *dev, uint8_t offset, unsigned int nr_vectors, bool msi64bit, bool msi_per_vector_mask) { unsigned int vectors_order; uint16_t flags; uint8_t cap_size; int config_offset; if (!msi_supported) { return -ENOTSUP; } MSI_DEV_PRINTF(dev, "init offset: 0x%"PRIx8" vector: %"PRId8 " 64bit %d mask %d\n", offset, nr_vectors, msi64bit, msi_per_vector_mask); assert(!(nr_vectors & (nr_vectors - 1))); assert(nr_vectors > 0); assert(nr_vectors <= PCI_MSI_VECTORS_MAX); vectors_order = ffs(nr_vectors) - 1; flags = vectors_order << (ffs(PCI_MSI_FLAGS_QMASK) - 1); if (msi64bit) { flags |= PCI_MSI_FLAGS_64BIT; } if (msi_per_vector_mask) { flags |= PCI_MSI_FLAGS_MASKBIT; } cap_size = msi_cap_sizeof(flags); config_offset = pci_add_capability(dev, PCI_CAP_ID_MSI, offset, cap_size); if (config_offset < 0) { return config_offset; } dev->msi_cap = config_offset; dev->cap_present |= QEMU_PCI_CAP_MSI; pci_set_word(dev->config + msi_flags_off(dev), flags); pci_set_word(dev->wmask + msi_flags_off(dev), PCI_MSI_FLAGS_QSIZE | PCI_MSI_FLAGS_ENABLE); pci_set_long(dev->wmask + msi_address_lo_off(dev), PCI_MSI_ADDRESS_LO_MASK); if (msi64bit) { pci_set_long(dev->wmask + msi_address_hi_off(dev), 0xffffffff); } pci_set_word(dev->wmask + msi_data_off(dev, msi64bit), 0xffff); if (msi_per_vector_mask) { pci_set_long(dev->wmask + msi_mask_off(dev, msi64bit), 0xffffffff >> (PCI_MSI_VECTORS_MAX - nr_vectors)); } return config_offset; }
1threat