problem
stringlengths
26
131k
labels
class label
2 classes
static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, int n, const uint8_t *scantable, const uint32_t *qmul, int max_coeff){ MpegEncContext * const s = &h->s; static const int coeff_token_table_index[17]= {0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3}; int level[16]; int zeros_left, coeff_num, coeff_token, total_coeff, i, j, trailing_ones, run_before; if(n == CHROMA_DC_BLOCK_INDEX){ coeff_token= get_vlc2(gb, chroma_dc_coeff_token_vlc.table, CHROMA_DC_COEFF_TOKEN_VLC_BITS, 1); total_coeff= coeff_token>>2; }else{ if(n == LUMA_DC_BLOCK_INDEX){ total_coeff= pred_non_zero_count(h, 0); coeff_token= get_vlc2(gb, coeff_token_vlc[ coeff_token_table_index[total_coeff] ].table, COEFF_TOKEN_VLC_BITS, 2); total_coeff= coeff_token>>2; }else{ total_coeff= pred_non_zero_count(h, n); coeff_token= get_vlc2(gb, coeff_token_vlc[ coeff_token_table_index[total_coeff] ].table, COEFF_TOKEN_VLC_BITS, 2); total_coeff= coeff_token>>2; h->non_zero_count_cache[ scan8[n] ]= total_coeff; } } if(total_coeff==0) return 0; if(total_coeff > (unsigned)max_coeff) { av_log(h->s.avctx, AV_LOG_ERROR, "corrupted macroblock %d %d (total_coeff=%d)\n", s->mb_x, s->mb_y, total_coeff); return -1; } trailing_ones= coeff_token&3; tprintf(h->s.avctx, "trailing:%d, total:%d\n", trailing_ones, total_coeff); assert(total_coeff<=16); i = show_bits(gb, 3); skip_bits(gb, trailing_ones); level[0] = 1-((i&4)>>1); level[1] = 1-((i&2) ); level[2] = 1-((i&1)<<1); if(trailing_ones<total_coeff) { int mask, prefix; int suffix_length = total_coeff > 10 & trailing_ones < 3; int bitsi= show_bits(gb, LEVEL_TAB_BITS); int level_code= cavlc_level_tab[suffix_length][bitsi][0]; skip_bits(gb, cavlc_level_tab[suffix_length][bitsi][1]); if(level_code >= 100){ prefix= level_code - 100; if(prefix == LEVEL_TAB_BITS) prefix += get_level_prefix(gb); if(prefix<14){ if(suffix_length) level_code= (prefix<<1) + get_bits1(gb); else level_code= prefix; }else if(prefix==14){ if(suffix_length) level_code= (prefix<<1) + get_bits1(gb); else level_code= prefix + get_bits(gb, 4); }else{ level_code= 30 + get_bits(gb, prefix-3); if(prefix>=16) level_code += (1<<(prefix-3))-4096; } if(trailing_ones < 3) level_code += 2; suffix_length = 2; mask= -(level_code&1); level[trailing_ones]= (((2+level_code)>>1) ^ mask) - mask; }else{ level_code += ((level_code>>31)|1) & -(trailing_ones < 3); suffix_length = 1 + (level_code + 3U > 6U); level[trailing_ones]= level_code; } for(i=trailing_ones+1;i<total_coeff;i++) { static const unsigned int suffix_limit[7] = {0,3,6,12,24,48,INT_MAX }; int bitsi= show_bits(gb, LEVEL_TAB_BITS); level_code= cavlc_level_tab[suffix_length][bitsi][0]; skip_bits(gb, cavlc_level_tab[suffix_length][bitsi][1]); if(level_code >= 100){ prefix= level_code - 100; if(prefix == LEVEL_TAB_BITS){ prefix += get_level_prefix(gb); } if(prefix<15){ level_code = (prefix<<suffix_length) + get_bits(gb, suffix_length); }else{ level_code = (15<<suffix_length) + get_bits(gb, prefix-3); if(prefix>=16) level_code += (1<<(prefix-3))-4096; } mask= -(level_code&1); level_code= (((2+level_code)>>1) ^ mask) - mask; } level[i]= level_code; suffix_length+= suffix_limit[suffix_length] + level_code > 2U*suffix_limit[suffix_length]; } } if(total_coeff == max_coeff) zeros_left=0; else{ if(n == CHROMA_DC_BLOCK_INDEX) zeros_left= get_vlc2(gb, (chroma_dc_total_zeros_vlc-1)[ total_coeff ].table, CHROMA_DC_TOTAL_ZEROS_VLC_BITS, 1); else zeros_left= get_vlc2(gb, (total_zeros_vlc-1)[ total_coeff ].table, TOTAL_ZEROS_VLC_BITS, 1); } coeff_num = zeros_left + total_coeff - 1; j = scantable[coeff_num]; if(n > 24){ block[j] = level[0]; for(i=1;i<total_coeff;i++) { if(zeros_left <= 0) run_before = 0; else if(zeros_left < 7){ run_before= get_vlc2(gb, (run_vlc-1)[zeros_left].table, RUN_VLC_BITS, 1); }else{ run_before= get_vlc2(gb, run7_vlc.table, RUN7_VLC_BITS, 2); } zeros_left -= run_before; coeff_num -= 1 + run_before; j= scantable[ coeff_num ]; block[j]= level[i]; } }else{ block[j] = (level[0] * qmul[j] + 32)>>6; for(i=1;i<total_coeff;i++) { if(zeros_left <= 0) run_before = 0; else if(zeros_left < 7){ run_before= get_vlc2(gb, (run_vlc-1)[zeros_left].table, RUN_VLC_BITS, 1); }else{ run_before= get_vlc2(gb, run7_vlc.table, RUN7_VLC_BITS, 2); } zeros_left -= run_before; coeff_num -= 1 + run_before; j= scantable[ coeff_num ]; block[j]= (level[i] * qmul[j] + 32)>>6; } } if(zeros_left<0){ av_log(h->s.avctx, AV_LOG_ERROR, "negative number of zero coeffs at %d %d\n", s->mb_x, s->mb_y); return -1; } return 0; }
1threat
Make request POST angular 1.x using 'Content-Type': 'application/json' : Previously I used the following type of headers in my function to make the request from the application: ###Html <label class="item item-input"> <i class="icon ion-person placeholder-icon"></i> <input type="text" placeholder="Usuario" ng-model="usuariotxt"> </label> <label class="item item-input"> <i class="icon ion-key placeholder-icon"></i> <input type="password" placeholder="Contraseña" ng-model="passwordtxt"> </label> ###Data Login datos = { Usuario: $scope.usuariotxt, Password: $scope.passwordtxt }; `'Content-Type': 'application/x-www-form-urlencoded'` ###function function Autenticacion(datos) { var url = 'http://API_URL'; return $http.post(url, $httpParamSerializer(datos), { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } }); }; Now the content-type must be different from how you submitted the request in advance `'Content-Type': 'application/json'` function Autenticacion(datos) { //var url = 'API_URL'; return $http.post(url, $httpParamSerializer(datos), { headers: { 'Content-Type': 'application/json' } }); }; But using the ARC tool, the request works perfectly [![Image Link][1]][1] The server is in Azure, this the information Cache-Control: no-cache Pragma: no-cache Content-Length: 270 Content-Type: application/json; charset=utf-8 Expires: -1 Server: Microsoft-IIS/8.0 X-Aspnet-Version: 4.0.30319 X-Powered-By: ASP.NET Set-Cookie: ARRAffinity=0a3517ba6ed8bb14ffe517099672a3eb4ea3c4b710ad8c6e0edaa70c2d244335;Path=/;Domain=apipedroupc20170125045931.azurewebsites.net Date: Tue, 28 Feb 2017 20:53:09 GMT The following errors em appear in the chrome console OPTIONS http://API_URL 405 (Method Not Allowed) XMLHttpRequest cannot load http://API_URL. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://192.168.1.9:8100' is therefore not allowed access. The response had HTTP status code 405. [1]: https://i.stack.imgur.com/0lWZh.png
0debug
static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size, AVSubtitle *sub) { DVBSubContext *ctx = avctx->priv_data; DVBSubDisplayDefinition *display_def = ctx->display_definition; DVBSubRegion *region; DVBSubRegionDisplay *display; AVSubtitleRect *rect; DVBSubCLUT *clut; uint32_t *clut_table; int i; int offset_x=0, offset_y=0; sub->rects = NULL; sub->start_display_time = 0; sub->end_display_time = ctx->time_out * 1000; sub->format = 0; if (display_def) { offset_x = display_def->x; offset_y = display_def->y; } sub->num_rects = ctx->display_list_size; if (sub->num_rects <= 0) return AVERROR_INVALIDDATA; sub->rects = av_mallocz_array(sub->num_rects * sub->num_rects, sizeof(*sub->rects)); if (!sub->rects) return AVERROR(ENOMEM); i = 0; for (display = ctx->display_list; display; display = display->next) { region = get_region(ctx, display->region_id); rect = sub->rects[i]; if (!region) continue; rect->x = display->x_pos + offset_x; rect->y = display->y_pos + offset_y; rect->w = region->width; rect->h = region->height; rect->nb_colors = 16; rect->type = SUBTITLE_BITMAP; rect->linesize[0] = region->width; clut = get_clut(ctx, region->clut); if (!clut) clut = &default_clut; switch (region->depth) { case 2: clut_table = clut->clut4; break; case 8: clut_table = clut->clut256; break; case 4: default: clut_table = clut->clut16; break; } rect->data[1] = av_mallocz(AVPALETTE_SIZE); if (!rect->data[1]) { av_free(sub->rects); return AVERROR(ENOMEM); } memcpy(rect->data[1], clut_table, (1 << region->depth) * sizeof(uint32_t)); rect->data[0] = av_malloc(region->buf_size); if (!rect->data[0]) { av_free(rect->data[1]); av_free(sub->rects); return AVERROR(ENOMEM); } memcpy(rect->data[0], region->pbuf, region->buf_size); #if FF_API_AVPICTURE FF_DISABLE_DEPRECATION_WARNINGS { int j; for (j = 0; j < 4; j++) { rect->pict.data[j] = rect->data[j]; rect->pict.linesize[j] = rect->linesize[j]; } } FF_ENABLE_DEPRECATION_WARNINGS #endif i++; } sub->num_rects = i; #ifdef DEBUG save_display_set(ctx); #endif return 1; }
1threat
def maximum_product(nums): import heapq a, b = heapq.nlargest(3, nums), heapq.nsmallest(2, nums) return max(a[0] * a[1] * a[2], a[0] * b[0] * b[1])
0debug
PPC_OP(addc) { T2 = T0; T0 += T1; if (T0 < T2) { xer_ca = 1; } else { xer_ca = 0; } RETURN(); }
1threat
static int alsa_init_in (HWVoiceIn *hw, audsettings_t *as) { ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw; struct alsa_params_req req; struct alsa_params_obt obt; snd_pcm_t *handle; audsettings_t obt_as; req.fmt = aud_to_alsafmt (as->fmt); req.freq = as->freq; req.nchannels = as->nchannels; req.period_size = conf.period_size_in; req.buffer_size = conf.buffer_size_in; req.size_in_usec = conf.size_in_usec_in; req.override_mask = !!conf.period_size_in_overridden | (!!conf.buffer_size_in_overridden << 1); if (alsa_open (1, &req, &obt, &handle)) { return -1; } obt_as.freq = obt.freq; obt_as.nchannels = obt.nchannels; obt_as.fmt = obt.fmt; obt_as.endianness = obt.endianness; audio_pcm_init_info (&hw->info, &obt_as); hw->samples = obt.samples; alsa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift); if (!alsa->pcm_buf) { dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n", hw->samples, 1 << hw->info.shift); alsa_anal_close (&handle); return -1; } alsa->handle = handle; return 0; }
1threat
simple PHP signup form wont POST to MySQL Database : <p>I'm very new to this, I made a php to test the connection with the database and it seems fine, but writing information to a table isn't working.</p> <p>Heres the index.php (where the signup form is)</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Title of the document&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="style.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="signup.php" method="POST"&gt; &lt;input type="text" name="firstname" placeholder="Firstname"&gt;&lt;br&gt; &lt;input type="text" name="lastname" placeholder="Lastname"&gt;&lt;br&gt; &lt;input type="text" name="uid" placeholder="Username"&gt;&lt;br&gt; &lt;input type="text" name="pwd" placeholder="Password"&gt;&lt;br&gt; &lt;input type="submit"&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</code></pre> </div> </div> </p> <p>Heres the signup.php (which is what i think might be broken)</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php include 'dbh.php'; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $uid = $_POST['uid']; $pwd = $_POST['pwd']; $sql = "INSERT INTO useraccounts (firstname, lastname, uid, pwd) VALUES ('$firstname', '$lastname', '$uid', '$pwd')"; $result = mysqli_query($conn, $sql); header("Location: index.php"); ?&gt;</code></pre> </div> </div> </p> <p>and heres the dbh.php which connects to mysql</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php $conn = mysql_connect("hostname", "username", "password", "databasename"); if (!$conn) { die("Connection failed: ".mysql_connect_error()); } ?&gt;</code></pre> </div> </div> </p> <p>I'm sure there's already a load of questions like mine out there but I'm so new to this I'm finding it hard to learn from the answers I've come across</p>
0debug
static void s390_cpu_initial_reset(CPUState *s) { S390CPU *cpu = S390_CPU(s); CPUS390XState *env = &cpu->env; int i; s390_cpu_reset(s); memset(&env->start_initial_reset_fields, 0, offsetof(CPUS390XState, end_reset_fields) - offsetof(CPUS390XState, start_initial_reset_fields)); env->cregs[0] = CR0_RESET; env->cregs[14] = CR14_RESET; env->gbea = 1; env->pfault_token = -1UL; env->ext_index = -1; for (i = 0; i < ARRAY_SIZE(env->io_index); i++) { env->io_index[i] = -1; } env->mchk_index = -1; set_float_detect_tininess(float_tininess_before_rounding, &env->fpu_status); if (kvm_enabled()) { kvm_s390_reset_vcpu(cpu); } }
1threat
Border bottom animation : <p>How can I make the bottom border animations like <a href="http://htmlcoder.me/preview/the_project/v.1.1/template/index-construction.html" rel="nofollow">here</a> ? In main header.</p>
0debug
AWS S3 integration yields undefined method `match' : <p>I'm working on a simple project using Paperclip to upload images. Everything has been working just fine until I attempted to integrate S3 with Paperclip. Upon 'uploading' a user's image I get a <code>NoMethodError (undefined method 'match' for nil:NilClass):</code> error. This only happens when I have my S3 configuration running - if I comment it out the file uploads perfectly. </p> <p>My configuration:</p> <pre><code>development.rb: .... .... config.paperclip_defaults = { :storage =&gt; :s3, :s3_credentials =&gt; { :bucket =&gt; ENV['AWS_BUCKET_ID'], :access_key_id =&gt; ENV['AWS_ACCESS_KEY_ID'], :secret_access_key =&gt; ENV['AWS_SECRET_ACCESS_KEY'] } } </code></pre> <p>My Model:</p> <pre><code> class User &lt; ActiveRecord::Base has_attached_file :image_file, default_url: "/myapp/images/:style/missing.png" validates_attachment_file_name :image_file, matches: [/png\Z/, /jpeg\Z/, /tiff\Z/, /bmp\Z/, /jpg\Z/] </code></pre> <p>entire error output from console:</p> <pre><code>NoMethodError (undefined method `match' for nil:NilClass): app/controllers/images_controller.rb:33:in `block in create' app/controllers/images_controller.rb:32:in `create' </code></pre> <p>Things I tried:</p> <ul> <li><p>I added the AWS keys and bucket name directly into the code instead of as an environmental variable.</p></li> <li><p>As mentioned above, I commented out the AWS configuration in my environment file and it seemed to work perfectly.</p></li> </ul> <p>It's probably worth mentioning that I installed the <code>fog</code> gem earlier to start configuring for Google Cloud Storage, but decided to stick with S3 instead. I used <code>gem uninstall fog</code> to remove the gem but it appears some dependencies stayed behind. </p>
0debug
static ssize_t qsb_grow(QEMUSizedBuffer *qsb, size_t new_size) { size_t needed_chunks, i; if (qsb->size < new_size) { struct iovec *new_iov; size_t size_diff = new_size - qsb->size; size_t chunk_size = (size_diff > QSB_MAX_CHUNK_SIZE) ? QSB_MAX_CHUNK_SIZE : QSB_CHUNK_SIZE; needed_chunks = DIV_ROUND_UP(size_diff, chunk_size); new_iov = g_try_new(struct iovec, qsb->n_iov + needed_chunks); if (new_iov == NULL) { return -ENOMEM; } for (i = qsb->n_iov; i < qsb->n_iov + needed_chunks; i++) { new_iov[i].iov_base = g_try_malloc0(chunk_size); new_iov[i].iov_len = chunk_size; if (!new_iov[i].iov_base) { size_t j; for (j = qsb->n_iov; j < i; j++) { g_free(new_iov[j].iov_base); } g_free(new_iov); return -ENOMEM; } } for (i = 0; i < qsb->n_iov; i++) { new_iov[i] = qsb->iov[i]; } qsb->n_iov += needed_chunks; g_free(qsb->iov); qsb->iov = new_iov; qsb->size += (needed_chunks * chunk_size); } return qsb->size; }
1threat
How does spring dependency injection work? : <p>I want to know when are the dependencies injected in a spring bean. I have the following code :</p> <pre><code>import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Component public class TestClass { @Autowired Environment env; // throws Null Pointer Here. String prop = env.getProperty("some.property"); public void test() { // works here String prop = env.getProperty("some.property"); } } </code></pre> <p>Why does spring throws NPE when I try to get Environment variable. What happens when the class constructor is called? Does spring only looks for bean availability in the context at construction time and not inject it then and there? Please explain the full flow of bean creation. Are the dependencies only injected after the object is constructed and added to the context? Does spring look for dependencies only after an instance of the class is created or does it look for them when the constructor is called?</p>
0debug
static int film_read_close(AVFormatContext *s) { FilmDemuxContext *film = s->priv_data; av_free(film->sample_table); av_free(film->stereo_buffer); return 0; }
1threat
Change name of a cell in data frame in R : <p>I have a data set:</p> <pre><code> x y z 1 apple a 4 2 orange d 3 3 banana b 2 4 strawberry c 1 </code></pre> <p>How can I change the name "banana" to "grape"? I want to get:</p> <pre><code> x y z 1 apple a 4 2 orange d 3 3 grape b 2 4 strawberry c 1 </code></pre> <p>Reproducible code:</p> <pre><code>example&lt;-data.frame( x = c("apple", "orange", "banana", "strawberry"), y = c("a", "d", "b", "c"), z = c(4:1) ) </code></pre>
0debug
Can't compile a g++ file using OpenGL library on Mac OS using Xcode and Terminal : I am trying to compile this simple program: [enter image description here][1] But every time I try to do it using Xcode or terminal they give me the following warnings and the following errors: [enter image description here][2] Thanks ! Hope you guys can help me! [1]: http://i.stack.imgur.com/LYYLi.png [2]: http://i.stack.imgur.com/gpQh0.png
0debug
static int decode_mb_info(IVI5DecContext *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; 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; } } } mb++; if (ref_mb) ref_mb++; mb_offset += band->mb_size; } offs += row_offset; } align_get_bits(&ctx->gb); return 0; }
1threat
Regular expressions doubts : <p>I have a few doubts that I have not managed to clear up by research and am hoping for some help.</p> <p>1) What does the <code>m</code> do, and what do the <code>/ /</code> before the m and at the end do? $var =~ m/[^0-9]+/</p> <p>2) <code>/[^0-9]+/</code> Which of the following lines does this regex match?</p> <pre><code> A) `123` B) `4` C) `I see 5 dogs` D) `I see five dogs` </code></pre> <p>My answer to 2): It matches <code>C</code> and <code>D</code>, and not <code>A</code> and <code>B</code> because there is no character or wold that does not contain <code>0-9</code>.</p>
0debug
Display the same data and summation in mysql : I want to ask and hopefully the readers can help. I have a case showing data details based on order number. the following data. + order number | item | total kg<br> 1. 99684 | CF Rice Pandan Wangi 10 kg | 50.0 kg<br> 2. 99684 | CF Rice Rojolele 10 kg | 100.0 kg<br> 3. JK14020 | CF Rice Pandan Wangi 10 kg | 20.0 kg I would like if if there is the same name it only appears 1x and its total kg increases also according to the total details per each of them, is there any solution for this? I just use looping without any condition, do not know how.
0debug
static AVCodec *AVCodecInitialize(enum AVCodecID codec_id) { AVCodec *res; avcodec_register_all(); av_log_set_level(AV_LOG_PANIC); res = avcodec_find_decoder(codec_id); if (!res) error("Failed to find decoder"); return res; }
1threat
How to display a button when there is no network and make it disappear when connection is available in Android App Development? : <p>I am creating an Android app and want to disappear retry button when there is network and it should be visible when there is no network, so the user can retry to load.</p>
0debug
Jquery select multiply of 3 : Hi in my Ul li i want to select only muliply of 3 other wise it will show alert msg. How i achive this <ul> <li><input type="checkbox" />a</li> <li><input type="checkbox"/>b</li> <li><input type="checkbox"/>c</li> <li><input type="checkbox"/>d</li> <li><input type="checkbox" />e</li> <li><input type="checkbox"/>f</li> </ul>
0debug
static int init_input(AVFormatContext *s, const char *filename) { int ret; AVProbeData pd = {filename, NULL, 0}; if (s->pb) { s->flags |= AVFMT_FLAG_CUSTOM_IO; if (!s->iformat) return av_probe_input_buffer(s->pb, &s->iformat, filename, s, 0, 0); else if (s->iformat->flags & AVFMT_NOFILE) av_log(s, AV_LOG_WARNING, "Custom AVIOContext makes no sense and " "will be ignored with AVFMT_NOFILE format.\n"); } if ( (s->iformat && s->iformat->flags & AVFMT_NOFILE) || (!s->iformat && (s->iformat = av_probe_input_format(&pd, 0)))) if ((ret = avio_open(&s->pb, filename, AVIO_FLAG_READ)) < 0) return ret; if (s->iformat) return av_probe_input_buffer(s->pb, &s->iformat, filename, s, 0, 0); }
1threat
npm install hangs on loadIdealTree:loadAllDepsIntoIdealTree: sill install loadIdealTree : <p>I have a Node.js application. When I try to run <code>npm install</code> it hangs with this:</p> <pre><code>loadIdealTree:loadAllDepsIntoIdealTree: sill install loadIdealTree </code></pre> <p><code>npm install --verbose</code> gives me a little extra info:</p> <pre><code>npm info it worked if it ends with ok npm verb cli [ '/usr/local/bin/node', npm verb cli '/usr/local/bin/npm', npm verb cli 'install', npm verb cli '--verbose', npm verb cli 'aws-sdk-js' ] npm info using npm@5.8.0 npm info using node@v8.9.2 npm verb npm-session ea38310110279de7 npm http fetch GET 404 https://registry.npmjs.org/aws-sdk-js 2211ms npm verb stack Error: 404 Not Found: aws-sdk-js@latest npm verb stack at fetch.then.res (/usr/local/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/fetch.js:42:19) npm verb stack at tryCatcher (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23) npm verb stack at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31) npm verb stack at Promise._settlePromise (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18) npm verb stack at Promise._settlePromise0 (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10) npm verb stack at Promise._settlePromises (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18) npm verb stack at Async._drainQueue (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16) npm verb stack at Async._drainQueues (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10) npm verb stack at Immediate.Async.drainQueues (/usr/local/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14) npm verb stack at runCallback (timers.js:789:20) npm verb stack at tryOnImmediate (timers.js:751:5) npm verb stack at processImmediate [as _immediateCallback] (timers.js:722:5) npm verb cwd /Users/me/git/aws-sdk-js-perf npm verb Darwin 17.5.0 npm verb argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--verbose" "aws-sdk-js" npm verb node v8.9.2 npm verb npm v5.8.0 npm ERR! code E404 npm ERR! 404 Not Found: aws-sdk-js@latest npm verb exit [ 1, true ] npm ERR! A complete log of this run can be found in: npm ERR! /Users/me/.npm/_logs/2018-05-24T10_30_55_688Z-debug.log </code></pre> <p>I came across instances where other people experienced this but the below seemed to resolve their issue. It doesn't fix mine:</p> <pre><code>npm set registry http://registry.npmjs.org/ </code></pre> <p>Does anybody know what might be wrong?</p>
0debug
Count how many rows you have in your db with PHP : <p>Hellow, </p> <p>I want to count how many rows i have in a table. I got a table (workstations) in my mysql database (phpmyadmin). I want to print it out, so ik can see how many workstations their are "active" in my environment</p> <p>I've read many blogs about this, but all the things they propose are not working for me.</p> <p>Thanks in advance!</p>
0debug
static inline void RENAME(yuv2packedX)(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize, const int16_t **alpSrc, uint8_t *dest, long dstW, long dstY) { #if COMPILE_TEMPLATE_MMX x86_reg dummy=0; x86_reg dstW_reg = dstW; if(!(c->flags & SWS_BITEXACT)) { if (c->flags & SWS_ACCURATE_RND) { switch(c->dstFormat) { case PIX_FMT_RGB32: if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX "movq %%mm2, "U_TEMP"(%0) \n\t" "movq %%mm4, "V_TEMP"(%0) \n\t" "movq %%mm5, "Y_TEMP"(%0) \n\t" YSCALEYUV2PACKEDX_ACCURATE_YA(ALP_MMX_FILTER_OFFSET) "movq "Y_TEMP"(%0), %%mm5 \n\t" "psraw $3, %%mm1 \n\t" "psraw $3, %%mm7 \n\t" "packuswb %%mm7, %%mm1 \n\t" WRITEBGR32(%4, %5, %%REGa, %%mm3, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm2, %%mm6) YSCALEYUV2PACKEDX_END } else { YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX "pcmpeqd %%mm7, %%mm7 \n\t" WRITEBGR32(%4, %5, %%REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) YSCALEYUV2PACKEDX_END } return; case PIX_FMT_BGR24: YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_c"\n\t" "add %4, %%"REG_c" \n\t" WRITEBGR24(%%REGc, %5, %%REGa) :: "r" (&c->redDither), "m" (dummy), "m" (dummy), "m" (dummy), "r" (dest), "m" (dstW_reg) : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S ); return; case PIX_FMT_RGB555: YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX "pxor %%mm7, %%mm7 \n\t" #ifdef DITHER1XBPP "paddusb "BLUE_DITHER"(%0), %%mm2\n\t" "paddusb "GREEN_DITHER"(%0), %%mm4\n\t" "paddusb "RED_DITHER"(%0), %%mm5\n\t" #endif WRITERGB15(%4, %5, %%REGa) YSCALEYUV2PACKEDX_END return; case PIX_FMT_RGB565: YSCALEYUV2PACKEDX_ACCURATE YSCALEYUV2RGBX "pxor %%mm7, %%mm7 \n\t" #ifdef DITHER1XBPP "paddusb "BLUE_DITHER"(%0), %%mm2\n\t" "paddusb "GREEN_DITHER"(%0), %%mm4\n\t" "paddusb "RED_DITHER"(%0), %%mm5\n\t" #endif WRITERGB16(%4, %5, %%REGa) YSCALEYUV2PACKEDX_END return; case PIX_FMT_YUYV422: YSCALEYUV2PACKEDX_ACCURATE "psraw $3, %%mm3 \n\t" "psraw $3, %%mm4 \n\t" "psraw $3, %%mm1 \n\t" "psraw $3, %%mm7 \n\t" WRITEYUY2(%4, %5, %%REGa) YSCALEYUV2PACKEDX_END return; } } else { switch(c->dstFormat) { case PIX_FMT_RGB32: if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf) { YSCALEYUV2PACKEDX YSCALEYUV2RGBX YSCALEYUV2PACKEDX_YA(ALP_MMX_FILTER_OFFSET, %%mm0, %%mm3, %%mm6, %%mm1, %%mm7) "psraw $3, %%mm1 \n\t" "psraw $3, %%mm7 \n\t" "packuswb %%mm7, %%mm1 \n\t" WRITEBGR32(%4, %5, %%REGa, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6) YSCALEYUV2PACKEDX_END } else { YSCALEYUV2PACKEDX YSCALEYUV2RGBX "pcmpeqd %%mm7, %%mm7 \n\t" WRITEBGR32(%4, %5, %%REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6) YSCALEYUV2PACKEDX_END } return; case PIX_FMT_BGR24: YSCALEYUV2PACKEDX YSCALEYUV2RGBX "pxor %%mm7, %%mm7 \n\t" "lea (%%"REG_a", %%"REG_a", 2), %%"REG_c" \n\t" "add %4, %%"REG_c" \n\t" WRITEBGR24(%%REGc, %5, %%REGa) :: "r" (&c->redDither), "m" (dummy), "m" (dummy), "m" (dummy), "r" (dest), "m" (dstW_reg) : "%"REG_a, "%"REG_c, "%"REG_d, "%"REG_S ); return; case PIX_FMT_RGB555: YSCALEYUV2PACKEDX YSCALEYUV2RGBX "pxor %%mm7, %%mm7 \n\t" #ifdef DITHER1XBPP "paddusb "BLUE_DITHER"(%0), %%mm2 \n\t" "paddusb "GREEN_DITHER"(%0), %%mm4 \n\t" "paddusb "RED_DITHER"(%0), %%mm5 \n\t" #endif WRITERGB15(%4, %5, %%REGa) YSCALEYUV2PACKEDX_END return; case PIX_FMT_RGB565: YSCALEYUV2PACKEDX YSCALEYUV2RGBX "pxor %%mm7, %%mm7 \n\t" #ifdef DITHER1XBPP "paddusb "BLUE_DITHER"(%0), %%mm2 \n\t" "paddusb "GREEN_DITHER"(%0), %%mm4 \n\t" "paddusb "RED_DITHER"(%0), %%mm5 \n\t" #endif WRITERGB16(%4, %5, %%REGa) YSCALEYUV2PACKEDX_END return; case PIX_FMT_YUYV422: YSCALEYUV2PACKEDX "psraw $3, %%mm3 \n\t" "psraw $3, %%mm4 \n\t" "psraw $3, %%mm1 \n\t" "psraw $3, %%mm7 \n\t" WRITEYUY2(%4, %5, %%REGa) YSCALEYUV2PACKEDX_END return; } } } #endif #if COMPILE_TEMPLATE_ALTIVEC if (!(c->flags & SWS_BITEXACT) && !c->alpPixBuf && (c->dstFormat==PIX_FMT_ABGR || c->dstFormat==PIX_FMT_BGRA || c->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB24 || c->dstFormat==PIX_FMT_RGBA || c->dstFormat==PIX_FMT_ARGB)) ff_yuv2packedX_altivec(c, lumFilter, lumSrc, lumFilterSize, chrFilter, chrSrc, chrFilterSize, dest, dstW, dstY); else #endif yuv2packedXinC(c, lumFilter, lumSrc, lumFilterSize, chrFilter, chrSrc, chrFilterSize, alpSrc, dest, dstW, dstY); }
1threat
static int init_image(TiffContext *s) { int i, ret; uint32_t *pal; switch (s->bpp * 10 + s->bppcount) { case 11: if (!s->palette_is_set) { s->avctx->pix_fmt = AV_PIX_FMT_MONOBLACK; break; } case 21: case 41: case 81: s->avctx->pix_fmt = AV_PIX_FMT_PAL8; break; case 243: s->avctx->pix_fmt = AV_PIX_FMT_RGB24; break; case 161: s->avctx->pix_fmt = s->le ? AV_PIX_FMT_GRAY16LE : AV_PIX_FMT_GRAY16BE; break; case 162: s->avctx->pix_fmt = AV_PIX_FMT_GRAY8A; break; case 324: s->avctx->pix_fmt = AV_PIX_FMT_RGBA; break; case 483: s->avctx->pix_fmt = s->le ? AV_PIX_FMT_RGB48LE : AV_PIX_FMT_RGB48BE; break; case 644: s->avctx->pix_fmt = s->le ? AV_PIX_FMT_RGBA64LE : AV_PIX_FMT_RGBA64BE; break; default: av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, bppcount=%d)\n", s->bpp, s->bppcount); return AVERROR_INVALIDDATA; } if (s->width != s->avctx->width || s->height != s->avctx->height) { if ((ret = av_image_check_size(s->width, s->height, 0, s->avctx)) < 0) return ret; avcodec_set_dimensions(s->avctx, s->width, s->height); } if (s->picture.data[0]) s->avctx->release_buffer(s->avctx, &s->picture); if ((ret = s->avctx->get_buffer(s->avctx, &s->picture)) < 0) { av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return ret; } if (s->avctx->pix_fmt == AV_PIX_FMT_PAL8) { if (s->palette_is_set) { memcpy(s->picture.data[1], s->palette, sizeof(s->palette)); } else { pal = (uint32_t *) s->picture.data[1]; for (i = 0; i < 1<<s->bpp; i++) pal[i] = 0xFF << 24 | i * 255 / ((1<<s->bpp) - 1) * 0x010101; } } return 0; }
1threat
static inline void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int direct, int mvtype) { MpegEncContext *s = &v->s; int xy, wrap, off = 0; int16_t *A, *B, *C; int px, py; int sum; int r_x, r_y; const uint8_t *is_intra = v->mb_type[0]; r_x = v->range_x; r_y = v->range_y; dmv_x[0] <<= 1 - s->quarter_sample; dmv_y[0] <<= 1 - s->quarter_sample; dmv_x[1] <<= 1 - s->quarter_sample; dmv_y[1] <<= 1 - s->quarter_sample; wrap = s->b8_stride; xy = s->block_index[0]; if (s->mb_intra) { s->current_picture.motion_val[0][xy + v->blocks_off][0] = s->current_picture.motion_val[0][xy + v->blocks_off][1] = s->current_picture.motion_val[1][xy + v->blocks_off][0] = s->current_picture.motion_val[1][xy + v->blocks_off][1] = 0; return; } if (!v->field_mode) { s->mv[0][0][0] = scale_mv(s->next_picture.motion_val[1][xy][0], v->bfraction, 0, s->quarter_sample); s->mv[0][0][1] = scale_mv(s->next_picture.motion_val[1][xy][1], v->bfraction, 0, s->quarter_sample); s->mv[1][0][0] = scale_mv(s->next_picture.motion_val[1][xy][0], v->bfraction, 1, s->quarter_sample); s->mv[1][0][1] = scale_mv(s->next_picture.motion_val[1][xy][1], v->bfraction, 1, s->quarter_sample); s->mv[0][0][0] = av_clip(s->mv[0][0][0], -60 - (s->mb_x << 6), (s->mb_width << 6) - 4 - (s->mb_x << 6)); s->mv[0][0][1] = av_clip(s->mv[0][0][1], -60 - (s->mb_y << 6), (s->mb_height << 6) - 4 - (s->mb_y << 6)); s->mv[1][0][0] = av_clip(s->mv[1][0][0], -60 - (s->mb_x << 6), (s->mb_width << 6) - 4 - (s->mb_x << 6)); s->mv[1][0][1] = av_clip(s->mv[1][0][1], -60 - (s->mb_y << 6), (s->mb_height << 6) - 4 - (s->mb_y << 6)); } if (direct) { s->current_picture.motion_val[0][xy + v->blocks_off][0] = s->mv[0][0][0]; s->current_picture.motion_val[0][xy + v->blocks_off][1] = s->mv[0][0][1]; s->current_picture.motion_val[1][xy + v->blocks_off][0] = s->mv[1][0][0]; s->current_picture.motion_val[1][xy + v->blocks_off][1] = s->mv[1][0][1]; return; } if ((mvtype == BMV_TYPE_FORWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) { C = s->current_picture.motion_val[0][xy - 2]; A = s->current_picture.motion_val[0][xy - wrap * 2]; off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2; B = s->current_picture.motion_val[0][xy - wrap * 2 + off]; if (!s->mb_x) C[0] = C[1] = 0; if (!s->first_slice_line) { if (s->mb_width == 1) { px = A[0]; py = A[1]; } else { px = mid_pred(A[0], B[0], C[0]); py = mid_pred(A[1], B[1], C[1]); } } else if (s->mb_x) { px = C[0]; py = C[1]; } else { px = py = 0; } { int qx, qy, X, Y; if (v->profile < PROFILE_ADVANCED) { qx = (s->mb_x << 5); qy = (s->mb_y << 5); X = (s->mb_width << 5) - 4; Y = (s->mb_height << 5) - 4; if (qx + px < -28) px = -28 - qx; if (qy + py < -28) py = -28 - qy; if (qx + px > X) px = X - qx; if (qy + py > Y) py = Y - qy; } else { qx = (s->mb_x << 6); qy = (s->mb_y << 6); X = (s->mb_width << 6) - 4; Y = (s->mb_height << 6) - 4; if (qx + px < -60) px = -60 - qx; if (qy + py < -60) py = -60 - qy; if (qx + px > X) px = X - qx; if (qy + py > Y) py = Y - qy; } } if (0 && !s->first_slice_line && s->mb_x) { if (is_intra[xy - wrap]) sum = FFABS(px) + FFABS(py); else sum = FFABS(px - A[0]) + FFABS(py - A[1]); if (sum > 32) { if (get_bits1(&s->gb)) { px = A[0]; py = A[1]; } else { px = C[0]; py = C[1]; } } else { if (is_intra[xy - 2]) sum = FFABS(px) + FFABS(py); else sum = FFABS(px - C[0]) + FFABS(py - C[1]); if (sum > 32) { if (get_bits1(&s->gb)) { px = A[0]; py = A[1]; } else { px = C[0]; py = C[1]; } } } } s->mv[0][0][0] = ((px + dmv_x[0] + r_x) & ((r_x << 1) - 1)) - r_x; s->mv[0][0][1] = ((py + dmv_y[0] + r_y) & ((r_y << 1) - 1)) - r_y; } if ((mvtype == BMV_TYPE_BACKWARD) || (mvtype == BMV_TYPE_INTERPOLATED)) { C = s->current_picture.motion_val[1][xy - 2]; A = s->current_picture.motion_val[1][xy - wrap * 2]; off = (s->mb_x == (s->mb_width - 1)) ? -2 : 2; B = s->current_picture.motion_val[1][xy - wrap * 2 + off]; if (!s->mb_x) C[0] = C[1] = 0; if (!s->first_slice_line) { if (s->mb_width == 1) { px = A[0]; py = A[1]; } else { px = mid_pred(A[0], B[0], C[0]); py = mid_pred(A[1], B[1], C[1]); } } else if (s->mb_x) { px = C[0]; py = C[1]; } else { px = py = 0; } { int qx, qy, X, Y; if (v->profile < PROFILE_ADVANCED) { qx = (s->mb_x << 5); qy = (s->mb_y << 5); X = (s->mb_width << 5) - 4; Y = (s->mb_height << 5) - 4; if (qx + px < -28) px = -28 - qx; if (qy + py < -28) py = -28 - qy; if (qx + px > X) px = X - qx; if (qy + py > Y) py = Y - qy; } else { qx = (s->mb_x << 6); qy = (s->mb_y << 6); X = (s->mb_width << 6) - 4; Y = (s->mb_height << 6) - 4; if (qx + px < -60) px = -60 - qx; if (qy + py < -60) py = -60 - qy; if (qx + px > X) px = X - qx; if (qy + py > Y) py = Y - qy; } } if (0 && !s->first_slice_line && s->mb_x) { if (is_intra[xy - wrap]) sum = FFABS(px) + FFABS(py); else sum = FFABS(px - A[0]) + FFABS(py - A[1]); if (sum > 32) { if (get_bits1(&s->gb)) { px = A[0]; py = A[1]; } else { px = C[0]; py = C[1]; } } else { if (is_intra[xy - 2]) sum = FFABS(px) + FFABS(py); else sum = FFABS(px - C[0]) + FFABS(py - C[1]); if (sum > 32) { if (get_bits1(&s->gb)) { px = A[0]; py = A[1]; } else { px = C[0]; py = C[1]; } } } } s->mv[1][0][0] = ((px + dmv_x[1] + r_x) & ((r_x << 1) - 1)) - r_x; s->mv[1][0][1] = ((py + dmv_y[1] + r_y) & ((r_y << 1) - 1)) - r_y; } s->current_picture.motion_val[0][xy][0] = s->mv[0][0][0]; s->current_picture.motion_val[0][xy][1] = s->mv[0][0][1]; s->current_picture.motion_val[1][xy][0] = s->mv[1][0][0]; s->current_picture.motion_val[1][xy][1] = s->mv[1][0][1]; }
1threat
Keras - using activation function with a parameter : <p>How is it possible to use leaky ReLUs in the newest version of keras? Function relu() accepts an optional parameter 'alpha', that is responsible for the negative slope, but I cannot figure out how to pass ths paramtere when constructing a layer. </p> <p>This line is how I tried to do it,</p> <pre><code>model.add(Activation(relu(alpha=0.1)) </code></pre> <p>but then I get the error</p> <pre><code>TypeError: relu() missing 1 required positional argument: 'x' </code></pre> <p>How can I use a leaky ReLU, or any other activation function with some parameter?</p>
0debug
static int dxva2_h264_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size) { const H264Context *h = avctx->priv_data; AVDXVAContext *ctx = avctx->hwaccel_context; struct dxva2_picture_context *ctx_pic = h->cur_pic_ptr->hwaccel_picture_private; if (DXVA_CONTEXT_DECODER(avctx, ctx) == NULL || DXVA_CONTEXT_CFG(avctx, ctx) == NULL || DXVA_CONTEXT_COUNT(avctx, ctx) <= 0) return -1; assert(ctx_pic); fill_picture_parameters(avctx, ctx, h, &ctx_pic->pp); fill_scaling_lists(avctx, ctx, h, &ctx_pic->qm); ctx_pic->slice_count = 0; ctx_pic->bitstream_size = 0; ctx_pic->bitstream = NULL; return 0; }
1threat
Is it safe to link gcc 6, gcc 7, and gcc 8 objects? : <p><a href="https://stackoverflow.com/q/46746878/2069064">Is it safe to link C++17, C++14, and C++11 objects</a> asks about linking objects compiled with different language standards, and Jonathan Wakely's excellent answer on that question explains the ABI stability promises that gcc/libstdc++ make to enusure that this works.</p> <p>There's one more thing that can change between gcc versions though - the language ABI via <a href="https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html" rel="noreferrer"><code>-fabi-version</code></a>. Let's say, for simplicity, I have three object files:</p> <ul> <li><code>foo.o</code>, compiled with gcc 6.5 c++14</li> <li><code>bar.o</code>, compiled with gcc 7.4 c++14</li> <li><code>quux.o</code>, compiled with gcc 8.3 c++17</li> </ul> <p>All with the respective default language ABIs (i.e. 10, 11, and 13). Linking these objects together is safe from the library perspective per the linked answer. But are there things that could go wrong from a language ABI perspective? Is there anything I should be watching out for? Most of the language ABI changes seem like they wouldn't cause issues, but the calling convention change for empty class types in 12 might?</p>
0debug
rollup.JS and "'this' keyword is equivalent to 'undefined' : <p>I'm trying to bundle Angular2 modules using Rollup.js. this is my rollup.config.vendor.js file:</p> <pre><code>import typescript from 'rollup-plugin-typescript2'; import resolve from 'rollup-plugin-node-resolve'; import commonjs from 'rollup-plugin-commonjs'; export default { entry: 'vendor.ts', dest: './Bundle/vendor.js', format: 'iife', moduleName: 'vendor', plugins: [ typescript(), resolve({ jsnext: true, main: true, browser: true }), commonjs({ include: 'node_modules/rxjs/**', }), ] } </code></pre> <p>It creates a bundled js, but in the process it keeps printing this kind of message:</p> <pre><code>The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined node_modules\@angular\forms\@angular\forms.es5.js (1:25) 1: var __extends = (this &amp;&amp; this.__extends) || function (d, b) { ^ 2: for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; 3: function __() { this.constructor = d; } </code></pre> <p>What does it mean?<br> Am I doing something wrong or is it the way it's supposed to be?</p>
0debug
static int read_sl_header(PESContext *pes, SLConfigDescr *sl, const uint8_t *buf, int buf_size) { GetBitContext gb; int au_start_flag = 0, au_end_flag = 0, ocr_flag = 0, idle_flag = 0; int padding_flag = 0, padding_bits = 0, inst_bitrate_flag = 0; int dts_flag = -1, cts_flag = -1; int64_t dts = AV_NOPTS_VALUE, cts = AV_NOPTS_VALUE; init_get_bits(&gb, buf, buf_size*8); if (sl->use_au_start) au_start_flag = get_bits1(&gb); if (sl->use_au_end) au_end_flag = get_bits1(&gb); if (!sl->use_au_start && !sl->use_au_end) au_start_flag = au_end_flag = 1; if (sl->ocr_len > 0) ocr_flag = get_bits1(&gb); if (sl->use_idle) idle_flag = get_bits1(&gb); if (sl->use_padding) padding_flag = get_bits1(&gb); if (padding_flag) padding_bits = get_bits(&gb, 3); if (!idle_flag && (!padding_flag || padding_bits != 0)) { if (sl->packet_seq_num_len) skip_bits_long(&gb, sl->packet_seq_num_len); if (sl->degr_prior_len) if (get_bits1(&gb)) skip_bits(&gb, sl->degr_prior_len); if (ocr_flag) skip_bits_long(&gb, sl->ocr_len); if (au_start_flag) { if (sl->use_rand_acc_pt) get_bits1(&gb); if (sl->au_seq_num_len > 0) skip_bits_long(&gb, sl->au_seq_num_len); if (sl->use_timestamps) { dts_flag = get_bits1(&gb); cts_flag = get_bits1(&gb); } } if (sl->inst_bitrate_len) inst_bitrate_flag = get_bits1(&gb); if (dts_flag == 1) dts = get_bits64(&gb, sl->timestamp_len); if (cts_flag == 1) cts = get_bits64(&gb, sl->timestamp_len); if (sl->au_len > 0) skip_bits_long(&gb, sl->au_len); if (inst_bitrate_flag) skip_bits_long(&gb, sl->inst_bitrate_len); } if (dts != AV_NOPTS_VALUE) pes->dts = dts; if (cts != AV_NOPTS_VALUE) pes->pts = cts; avpriv_set_pts_info(pes->st, sl->timestamp_len, 1, sl->timestamp_res); return (get_bits_count(&gb) + 7) >> 3; }
1threat
In C++ how can I extract members from an array and return an array of the member's type? : <pre><code>namespace detail { template &lt;typename T, typename U&gt; Array&lt;U&gt; extract_(const Array&lt;T&gt;&amp; array, std::function&lt;U(const T&amp;)&gt; member) { Array&lt;U&gt; extracted; for (auto&amp; item : array) extracted += member(item); return extracted; } } #define extract(container, member) detail::extract_(container, \ std::function&lt; typeof(typeof(container)::Type::element_type::member) (const typeof(container)::Type&amp;)&gt;( \ [&amp;](const typeof(container)::Type&amp; item){ return item-&gt;member; })) </code></pre> <p>So that's the algorithm I want to use to extract members from arrays. <code>Array&lt;T&gt;</code> is my homegrown array type, it handles bidness.</p> <p>If you're allergic to macros, sorry, but it makes user code very clean.</p> <p>What I want to do is if I have <code>Array&lt;Size&gt; sizeArray</code> with member <code>double Array&lt;Size&gt;::Length</code>, to be able to say <code>auto lengths = extract(sizeArray, Length);</code> and have <code>lengths</code> be of type <code>Array&lt;double&gt;</code>.</p> <p>I already do something similar with</p> <pre><code>namespace detail { template &lt;typename T&gt; Array&lt;T&gt; filter_(const Array&lt;T&gt;&amp; array, std::function&lt;bool(const T&amp;)&gt; condition) { Array&lt;T&gt; filtered; for (auto&amp; item : array) if (condition(item)) filtered += item; return filtered; } } // this macro creates a capturing lambda, the item to check is called 'item' #define filter(container, condition) detail::filter_(container, \ std::function&lt;bool(const typeof(container)::Type&amp;)&gt;( \ [&amp;](const typeof(container)::Type&amp; item){ return condition; })) </code></pre> <p>I can do <code>auto turnedOff = filter(objects, !item-&gt;IsTurnedOn);</code> and it works really well, but it's returning the same type, so it's an easier task to solve.</p>
0debug
How can i convert an array into an object of key-value pairs, where keys are previous value in array? : I am trying to convert an array like this into an object: [ "a", "11993", "b", "18486", "c", "13240388" ] by grouping by 2 where first item is key and second is value: Here is the desired outcome: { "a"=>"11993", "b"=>"18486", "c"=>"13240388" }
0debug
static void nic_receive(void *opaque, const uint8_t * buf, size_t size) { EEPRO100State *s = opaque; uint16_t rfd_status = 0xa000; static const uint8_t broadcast_macaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; assert(!(s->configuration[20] & BIT(6))); if (s->configuration[8] & 0x80) { logout("%p received while CSMA is disabled\n", s); return; } else if (size < 64 && (s->configuration[7] & 1)) { logout("%p received short frame (%d byte)\n", s, size); s->statistics.rx_short_frame_errors++; } else if ((size > MAX_ETH_FRAME_SIZE + 4) && !(s->configuration[18] & 8)) { logout("%p received long frame (%d byte), ignored\n", s, size); return; } else if (memcmp(buf, s->macaddr, 6) == 0) { logout("%p received frame for me, len=%d\n", s, size); } else if (memcmp(buf, broadcast_macaddr, 6) == 0) { logout("%p received broadcast, len=%d\n", s, size); rfd_status |= 0x0002; } else if (buf[0] & 0x01) { logout("%p received multicast, len=%d\n", s, size); assert(!(s->configuration[21] & BIT(3))); int mcast_idx = compute_mcast_idx(buf); if (!(s->mult[mcast_idx >> 3] & (1 << (mcast_idx & 7)))) { return; } rfd_status |= 0x0002; } else if (s->configuration[15] & 1) { logout("%p received frame in promiscuous mode, len=%d\n", s, size); rfd_status |= 0x0004; } else { logout("%p received frame, ignored, len=%d,%s\n", s, size, nic_dump(buf, size)); return; } if (get_ru_state(s) != ru_ready) { logout("no ressources, state=%u\n", get_ru_state(s)); s->statistics.rx_resource_errors++; return; } eepro100_rx_t rx; cpu_physical_memory_read(s->ru_base + s->ru_offset, (uint8_t *) & rx, offsetof(eepro100_rx_t, packet)); uint16_t rfd_command = le16_to_cpu(rx.command); uint16_t rfd_size = le16_to_cpu(rx.size); assert(size <= rfd_size); if (size < 64) { rfd_status |= 0x0080; } logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u\n", rfd_command, rx.link, rx.rx_buf_addr, rfd_size); stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, status), rfd_status); stw_phys(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, count), size); assert(!(s->configuration[18] & 4)); cpu_physical_memory_write(s->ru_base + s->ru_offset + offsetof(eepro100_rx_t, packet), buf, size); s->statistics.rx_good_frames++; eepro100_fr_interrupt(s); s->ru_offset = le32_to_cpu(rx.link); if (rfd_command & 0x8000) { assert(0); } if (rfd_command & 0x4000) { set_ru_state(s, ru_suspended); } }
1threat
Exception in thread "main" java.lang.NullPointerException while performing selection sort? : <p>I was writing some code to create a selection sort algorithm that sorted objects of the distance class. However, when I ran the program, the program returned the error:</p> <pre><code>&gt; Exception in thread "main" java.lang.NullPointerException &gt; at Distance.compareTo(Distance.java:28) &gt; at Distance.compareTo(Distance.java:1) &gt; at Driver05.findMax(Driver05.java:54) &gt; at Driver05.sort(Driver05.java:43) &gt; at Driver05.input(Driver05.java:26) &gt; at Driver05.main(Driver05.java:7) </code></pre> <p>What is this error and What can I do to fix it?</p> <p>The File that makes data(generates data randomly in feet and inches):</p> <pre><code>import java.io.*; public class MakeDataFile { public static void main(String[] args) throws Exception { System.setOut(new PrintStream(new FileOutputStream("data.txt"))); int numitems = (int)(Math.random() * 25 + 50); System.out.println(numitems); for(int k = 0; k &lt; numitems; k++) { System.out.println((int)(Math.random() * 100)); System.out.println((int)(Math.random() * 12)); } } } </code></pre> <p>The Distance Class: </p> <pre><code>public class Distance implements Comparable&lt;Distance&gt; { private int myFeet, myInches; public Distance() { myFeet = myInches = 0; } public Distance(int x, int y) { myFeet = x; myInches = y; } public int getFeet() { return myFeet; } public int getInches() { return myInches; } public void setFeet(int x) { myFeet = x; } public void setInches(int x) { myInches = x; } public int compareTo( Distance d) { int myTotal = myFeet * 12 + myInches; int dTotal = d.getFeet() * 12 + d.getInches(); return myTotal - dTotal; } public boolean equals(Distance arg) { return compareTo(arg) == 0; } public String toString() { return myFeet + " ft. " + myInches + " in. "; } } </code></pre> <p>The Distance class serves the purpose of allowing me to more easily compare distances. </p> <p>The Actual Driver:</p> <pre><code>import java.io.*; //the File class import java.util.*; //the Scanner class public class Driver05 { public static void main(String[] args) throws Exception { Comparable[] array = input("data.txt"); sort(array); output(array, "output.txt"); } public static Comparable[] input(String filename) throws Exception { Scanner infile = new Scanner( new File(filename) ); int numitems = infile.nextInt(); Comparable[] array = new Distance[numitems]; int x = 0; for(int k = 1; k &lt; numitems; k = k+2) { int feetNum = infile.nextInt(); int inchNum = infile.nextInt(); array[x] = new Distance(feetNum, inchNum); } infile.close(); sort(array); output(array, "output.txt"); return array; } public static void output(Object[]array, String filename) throws Exception { System.setOut(new PrintStream(new FileOutputStream(filename))); for(int k = 0; k &lt; array.length; k++) System.out.println(array[k].toString()); } public static void sort(Comparable[] array) { int maxPos; for(int k = 0; k &lt; array.length; k++) { maxPos = findMax(array, array.length - k); swap(array, maxPos, array.length - k - 1); } } private static int findMax(Comparable[] enterArray, int endIndex) { int max = 0; for(int x = 0; x &lt; endIndex; x++) { if (enterArray[max].compareTo(enterArray[x]) &lt; 0) { max = x; } } return max; } private static void swap(Comparable[] enterArray,int maxIndex,int lastIndex) { Comparable temp; temp = enterArray[maxIndex]; enterArray[maxIndex] = enterArray[lastIndex]; enterArray[lastIndex] = temp; } } </code></pre> <p>The driver contains the selection sort algorithm that sorts the data obtained from the output of the MakeData file. </p> <p>It would be very helpful if someone could explain this error and how to correct it. </p>
0debug
static int scsi_cd_initfn(SCSIDevice *dev) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, dev); s->qdev.blocksize = 2048; s->qdev.type = TYPE_ROM; s->features |= 1 << SCSI_DISK_F_REMOVABLE; if (!s->product) { s->product = g_strdup("QEMU CD-ROM"); } return scsi_initfn(&s->qdev); }
1threat
static void omap_sysctl_write8(void *opaque, target_phys_addr_t addr, uint32_t value) { struct omap_sysctl_s *s = (struct omap_sysctl_s *) opaque; int pad_offset, byte_offset; int prev_value; switch (addr) { case 0x030 ... 0x140: pad_offset = (addr - 0x30) >> 2; byte_offset = (addr - 0x30) & (4 - 1); prev_value = s->padconf[pad_offset]; prev_value &= ~(0xff << (byte_offset * 8)); prev_value |= ((value & 0x1f1f1f1f) << (byte_offset * 8)) & 0x1f1f1f1f; s->padconf[pad_offset] = prev_value; break; default: OMAP_BAD_REG(addr); break; } }
1threat
static void virt_acpi_get_cpu_info(VirtAcpiCpuInfo *cpuinfo) { CPUState *cpu; memset(cpuinfo->found_cpus, 0, sizeof cpuinfo->found_cpus); CPU_FOREACH(cpu) { set_bit(cpu->cpu_index, cpuinfo->found_cpus); } }
1threat
Does chnaging v4l2 default settings improves usb camera performance? : I'm have USB ELP camera. I'm using v4l2 driver to capture images from that USB camera. I've found that we can change v4l2 default parameters like brightness, contrast, gamma, exposure, resolution. Can we able to increase the speed of camera access time so that it can captures images at less time by changing these parameters to optimum values ? Thanks for advice.
0debug
static int16_t g726_decode(G726Context* c, int I) { int dq, re_signal, pk0, fa1, i, tr, ylint, ylfrac, thr2, al, dq0; Float11 f; int I_sig= I >> (c->code_size - 1); dq = inverse_quant(c, I); ylint = (c->yl >> 15); ylfrac = (c->yl >> 10) & 0x1f; thr2 = (ylint > 9) ? 0x1f << 10 : (0x20 + ylfrac) << ylint; tr= (c->td == 1 && dq > ((3*thr2)>>2)); if (I_sig) dq = -dq; re_signal = (int16_t)(c->se + dq); pk0 = (c->sez + dq) ? sgn(c->sez + dq) : 0; dq0 = dq ? sgn(dq) : 0; if (tr) { c->a[0] = 0; c->a[1] = 0; for (i=0; i<6; i++) c->b[i] = 0; } else { fa1 = av_clip_intp2((-c->a[0]*c->pk[0]*pk0)>>5, 8); c->a[1] += 128*pk0*c->pk[1] + fa1 - (c->a[1]>>7); c->a[1] = av_clip(c->a[1], -12288, 12288); c->a[0] += 64*3*pk0*c->pk[0] - (c->a[0] >> 8); c->a[0] = av_clip(c->a[0], -(15360 - c->a[1]), 15360 - c->a[1]); for (i=0; i<6; i++) c->b[i] += 128*dq0*sgn(-c->dq[i].sign) - (c->b[i]>>8); } c->pk[1] = c->pk[0]; c->pk[0] = pk0 ? pk0 : 1; c->sr[1] = c->sr[0]; i2f(re_signal, &c->sr[0]); for (i=5; i>0; i--) c->dq[i] = c->dq[i-1]; i2f(dq, &c->dq[0]); c->dq[0].sign = I_sig; c->td = c->a[1] < -11776; c->dms += (c->tbls.F[I]<<4) + ((- c->dms) >> 5); c->dml += (c->tbls.F[I]<<4) + ((- c->dml) >> 7); if (tr) c->ap = 256; else { c->ap += (-c->ap) >> 4; if (c->y <= 1535 || c->td || abs((c->dms << 2) - c->dml) >= (c->dml >> 3)) c->ap += 0x20; } c->yu = av_clip(c->y + c->tbls.W[I] + ((-c->y)>>5), 544, 5120); c->yl += c->yu + ((-c->yl)>>6); al = (c->ap >= 256) ? 1<<6 : c->ap >> 2; c->y = (c->yl + (c->yu - (c->yl>>6))*al) >> 6; c->se = 0; for (i=0; i<6; i++) c->se += mult(i2f(c->b[i] >> 2, &f), &c->dq[i]); c->sez = c->se >> 1; for (i=0; i<2; i++) c->se += mult(i2f(c->a[i] >> 2, &f), &c->sr[i]); c->se >>= 1; return av_clip(re_signal << 2, -0xffff, 0xffff); }
1threat
static void put_pixels_clamped4_c(const DCTELEM *block, uint8_t *restrict pixels, int line_size) { int i; uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; for(i=0;i<4;i++) { pixels[0] = cm[block[0]]; pixels[1] = cm[block[1]]; pixels[2] = cm[block[2]]; pixels[3] = cm[block[3]]; pixels += line_size; block += 8; } }
1threat
Using IIS Server instead of IIS Express in Visual Studio 2015 : <p>How can we configure our already developed ASP.Net website to use IIS Server instead of using IIS Express in VS2015?</p> <p>IIS Express is the default server in Visual Studio 2015. My website runs fine with ASP.NET web Development server in Visual studio 2012 but when i run it in VS2015 , it does not loads the css and images .</p> <p>So, i want to run it with IIS Server and not IIS Express in VS2015. Can anyone help me out ?</p>
0debug
static int pix_sum_altivec(uint8_t *pix, int line_size) { int i, s; const vector unsigned int zero = (const vector unsigned int) vec_splat_u32(0); vector unsigned int sad = (vector unsigned int) vec_splat_u32(0); vector signed int sumdiffs; for (i = 0; i < 16; i++) { vector unsigned char t1 = vec_vsx_ld(0, pix); sad = vec_sum4s(t1, sad); pix += line_size; } sumdiffs = vec_sums((vector signed int) sad, (vector signed int) zero); sumdiffs = vec_splat(sumdiffs, 3); vec_vsx_st(sumdiffs, 0, &s); return s; }
1threat
Insert JSON file in SQL tables using C# : <p>Can someone please provide example How to Insert JSON file in SQL tables using C#.</p>
0debug
How to add an image in an SQL database? : I'm currently working in Microsoft Visual studio and I am doing a project for school where I have to make an app that lets you book seats at a cinema and see the description of the movie you have selected as well as leave/read a review. In my app I have decided that I want to include pictures (basically a poster for each of the movies); I have made my "Movies" table and have "idf" as my primary key. I have added a "poster" column in my table definition and I have set its type to image; my question is, how do I assign a certain image to a movie, so as to have access to it and to be able to display it later using a query of some sort?
0debug
static int test_vector_dmul_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, const double *v1, double scale) { LOCAL_ALIGNED(32, double, cdst, [LEN]); LOCAL_ALIGNED(32, double, odst, [LEN]); int ret; cdsp->vector_dmul_scalar(cdst, v1, scale, LEN); fdsp->vector_dmul_scalar(odst, v1, scale, LEN); if (ret = compare_doubles(cdst, odst, LEN, DBL_EPSILON)) av_log(NULL, AV_LOG_ERROR, "vector_dmul_scalar failed\n"); return ret; }
1threat
Eslint errorring importing jsx without extension : <p>I am trying, in es6, to import jsx files without requiring the .jsx extension:</p> <pre><code>import LoginErrorDialog from './LoginErrorDialogView'; </code></pre> <p>Not:</p> <pre><code>import LoginErrorDialog from './LoginErrorDialogView.jsx'; </code></pre> <p>While I have got webpack to import in this fashion successfully:</p> <pre><code>export default { entry: './src/ui/js/app.js', output: { publicPath: '/', filename: 'bundle.js' }, resolve: { extensions: ['.js', '.jsx'], </code></pre> <p>Eslint (<code>esw webpack.config.* ./ --color --ext .js --ext .jsx</code>) is still errorring.</p> <p><code>Unable to resolve path to module './LoginView' import/no-unresolved</code></p> <p>Any ideas?</p>
0debug
Can link prefetch be used to cache a JSON API response for a later XHR request? : <p>Given a JSON API endpoint <code>/api/config</code>, we're trying to use <code>&lt;link rel="prefetch" href="/api/config"&gt;</code> in the head of an HTML document. Chrome downloads the data as expected when it hits the link tag in the HTML, but requests it again via XHR from our script about a second later.</p> <p>The server is configured to allow caching, and is responding with <code>Cache-Control: "max-age=3600, must-revalidate"</code> in the header. When Chrome requests the data again, the server responds correctly with a 304 Not Modified status.</p> <p>The use case is this: the config endpoint will always be requested from the Javascript in our single page application using XHR (an AngularJS resolve, in case it's relevant). However, our scripts are very large and take a long time to parse, so the JSON config will not be requested until the parsing is finished. Prefetching would allow us to use some of that parsing time to fetch and cache responses from API endpoints that would otherwise have to wait for the scripts to load.</p>
0debug
connection.query('SELECT * FROM users WHERE username = ' + input_string)
1threat
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.'Admin')' : <p>When I Try to add value of role in DB it shows me this error , You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.'Admin')' at line 1,</p> <pre><code>&lt;? $pin=$_POST['pin']; $password=$_POST['password']; $name=$_POST['name']; $email=$_POST['email']; $role=$_POST['role']; echo $pin; echo $role; If($pin=="1233") { mysqli_query($conn, "INSERT INTO admin(pin,name,email,password,role) VALUES('$pin','$name','$email','$password'.'$role')") or die(mysqli_error($conn)); header('location:index1.php'); } ?&gt; &lt;form class="form-horizontal" method="post" action="process.php"&gt; enter code here &lt;label for="name" class="cols-sm-2 control-label"&gt;Pin Number :&lt;/label&gt; &lt;input type="text" name="pin" placeholder="Enter Pin"&gt; &lt;label for="name" class="cols-sm-2 control-label"&gt;Your Name :&lt;/label&gt; &lt;input type="text" name="name" placeholder="Enter your Name"/&gt; &lt;label for="email" class="cols-sm-2 control-label"&gt;Your Email :&lt;/label&gt; &lt;input type="text" name="email" placeholder="Enter your Email"/&gt; &lt;input type="text" name="phone" placeholder="Enter your Phone Number"/&gt; &lt;label for="password" class="cols-sm-2 control-label"&gt;Password :&lt;/label&gt; &lt;input type="password" name="password" placeholder="Enter your Password"/&gt; &lt;label &gt;Role :&lt;/label&gt; &lt;select name="role" &gt; &lt;option value="Admin"&gt;Teacher&lt;/option&gt; &lt;option value="Teacher"&gt;Admin&lt;/option&gt; &lt;/select&gt; &lt;input type="submit" class="btn-success" value="Sign up" style="border-radius: 07px;padding: 3px;background: green" name="register"&gt; &lt;/form&gt; </code></pre>
0debug
Sorting aray using BubbleSort fails : Following algorithm works pretty fine in C# <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> public int[] Sortieren(int[] array, int decide) { bool sortiert; int temp; for (int i = 0; i < array.Length; i++) { do { sortiert = true; for (int j = 0; j < array.Length - 1; j++) { if (decide == 1) { if (array[j] < array[j + 1]) { temp = array[j]; array[j] = array[j + 1]; array[j + 1] = temp; sortiert = false; } }else if (decide == 0) { if (array[j] > array[j + 1]) { temp = array[j]; array[j] = array[j + 1]; array[j + 1] = temp; sortiert = false; } } else { Console.WriteLine("Inkorrekter Sortierungsparameter!"); break; } } } while (!sortiert); } return array; } <!-- end snippet --> Same thing in C fails. I will only get first three numbers of array being sorted. Rest of numbers are same. So, this code also seems to change array instead of only sorting it. Any ideas, where is Bug? <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> int main() { int zufallszahlen[MAX],temp,Array_length; bool sortiert; srand(time(NULL)); for(int i=0;i<=MAX;i++){ zufallszahlen[i]=rand()%1000; } Array_length=sizeof(zufallszahlen) / sizeof(int); printf("Liste der Zahlen(unsortiert):\n"); for(int i=0;i<MAX;i++){ if(i==MAX-1) printf("%i",zufallszahlen[i]); else printf("%i,",zufallszahlen[i]); } //Searching algorithm for(int i=0;i<Array_length;i++){ do{ sortiert=true; for(int j=0;j<Array_length-1;j++){ if(zufallszahlen[j]>zufallszahlen[j+1]){ temp=zufallszahlen[j]; zufallszahlen[j]==zufallszahlen[j+1]; zufallszahlen[j+1]=temp; sortiert=false; } } }while(!sortiert); } printf("\nListe der Zahlen(sortiert):\n"); for(int i=0;i<Array_length;i++){ if(i==Array_length-1) printf("%i",zufallszahlen[i]); else printf("%i,",zufallszahlen[i]); } } <!-- end snippet --> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
0debug
static int bayer_to_rgb24_wrapper(SwsContext *c, const uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]) { uint8_t *dstPtr= dst[0]; const uint8_t *srcPtr= src[0]; int i; void (*copy) (const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width); void (*interpolate)(const uint8_t *src, int src_stride, uint8_t *dst, int dst_stride, int width); switch(c->srcFormat) { #define CASE(pixfmt, prefix) \ case pixfmt: copy = bayer_##prefix##_to_rgb24_copy; \ interpolate = bayer_##prefix##_to_rgb24_interpolate; \ break; CASE(AV_PIX_FMT_BAYER_BGGR8, bggr8) CASE(AV_PIX_FMT_BAYER_BGGR16LE, bggr16le) CASE(AV_PIX_FMT_BAYER_BGGR16BE, bggr16be) CASE(AV_PIX_FMT_BAYER_RGGB8, rggb8) CASE(AV_PIX_FMT_BAYER_RGGB16LE, rggb16le) CASE(AV_PIX_FMT_BAYER_RGGB16BE, rggb16be) CASE(AV_PIX_FMT_BAYER_GBRG8, gbrg8) CASE(AV_PIX_FMT_BAYER_GBRG16LE, gbrg16le) CASE(AV_PIX_FMT_BAYER_GBRG16BE, gbrg16be) CASE(AV_PIX_FMT_BAYER_GRBG8, grbg8) CASE(AV_PIX_FMT_BAYER_GRBG16LE, grbg16le) CASE(AV_PIX_FMT_BAYER_GRBG16BE, grbg16be) #undef CASE default: return 0; } copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->srcW); srcPtr += 2 * srcStride[0]; dstPtr += 2 * dstStride[0]; for (i = 2; i < srcSliceH - 2; i += 2) { interpolate(srcPtr, srcStride[0], dstPtr, dstStride[0], c->srcW); srcPtr += 2 * srcStride[0]; dstPtr += 2 * dstStride[0]; } copy(srcPtr, srcStride[0], dstPtr, dstStride[0], c->srcW); return srcSliceH; }
1threat
Looping different div using V-for in vue js : someone can help me to looping using v-for statement the layout like this. [enter image description here][1] [1]: https://i.stack.imgur.com/bfF5f.png how can i using v-for in this case ?
0debug
c++ vector intialise a vector of agents for a gennetic algorithm : So i have the following c++ code, but i get some errors in mainly stuff like the following (after the block of code) the Agent is just a class that i created in a seperate file vector<Agent> population; for (vector<int>::iterator i = population.begin(); i != population.end(); ++i) { population.push_back(new Agent(generateDna(targetString.size()))); } i get the following errors 1. no suitable user-defined conversion from "__gnu_cxx::__normal_iterator<Agent *, std::vector<Agent, std::allocator<Agent>>>" to "__gnu_cxx::__normal_iterator<int *, std::vector<int, std::allocator<int>>>" exists 2. no operator "!=" matches these operands -- operand types are: __gnu_cxx::__normal_iterator<int *, std::vector<int, std::allocator<int>>> != __gnu_cxx::__normal_iterator<Agent *, std::vector<Agent, std::allocator<Agent>>> 3. no instance of overloaded function "std::vector<_Tp, _Alloc>::push_back [with _Tp=Agent, _Alloc=std::allocator<Agent>]" matches the argument list -- argument types are: (Agent *) -- object type is: std::vector<Agent, std::allocator<Agent>> and im new to c++ so these things might be self exsplanitory, but idk what they mean.
0debug
def reverse_Array_Upto_K(input, k): return (input[k-1::-1] + input[k:])
0debug
How can I print data that i filtered out of my mysql table : I am currently developing a school project and once again require some advice from fellow coders. I basically have a mysql table from which i filter out data (according to conditions). I used to print this filtered data to the console, however I now want to go further and want to print the results. Is there a simple way to maybe write the data to another table and print it? If not is there perhaps a way to just export the data (maybe in the form of a txt.file)? My problem is basically that i am still a beginner who doesn't know most of the Java terms and functions. It would therefore be very helpful if someone could perhaps recommend a simple way to fulfil the above requirements. Thank you for your help :)!!
0debug
"The filename or extension is too long error" using gradle : <p>I have recently updated my code and when I tried to run our application using <strong>g bootRun</strong> in the command line, I encountered this error. </p> <p><strong>Stack Trace:</strong></p> <pre><code>org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':bootRun'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110) at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23) at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43) at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30) at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154) at org.gradle.internal.Factories$1.create(Factories.java:22) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151) at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99) at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93) at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82) at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94) at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28) at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75) at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:45) at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51) at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28) at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43) at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210) at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35) at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169) at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33) at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22) at org.gradle.launcher.Main.doAction(Main.java:33) at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45) at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54) at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35) at org.gradle.launcher.GradleMain.main(GradleMain.java:23) at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) Caused by: org.gradle.process.internal.ExecException: A problem occurred starting process 'command 'C:\Java\jdk1.8.0_77\bin\java.exe'' at org.gradle.process.internal.DefaultExecHandle.setEndStateInfo(DefaultExecHandle.java:197) at org.gradle.process.internal.DefaultExecHandle.failed(DefaultExecHandle.java:327) at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:86) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54) at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40) Caused by: net.rubygrapefruit.platform.NativeException: Could not start 'C:\Java\jdk1.8.0_77\bin\java.exe' at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:27) at net.rubygrapefruit.platform.internal.WindowsProcessLauncher.start(WindowsProcessLauncher.java:22) at net.rubygrapefruit.platform.internal.WrapperProcessLauncher.start(WrapperProcessLauncher.java:36) at org.gradle.process.internal.ExecHandleRunner.run(ExecHandleRunner.java:68) ... 2 more Caused by: java.io.IOException: Cannot run program "C:\Java\jdk1.8.0_77\bin\java.exe" (in directory "D:\Work\FBXX"): CreateProcess error=206, The filename or extension is too long at net.rubygrapefruit.platform.internal.DefaultProcessLauncher.start(DefaultProcessLauncher.java:25) ... 5 more Caused by: java.io.IOException: CreateProcess error=206, The filename or extension is too long ... 6 more </code></pre> <p>Here's the task in gradle: </p> <pre><code> bootRun { if (project.hasProperty('args')) { args project.args.split('\\s+') } } </code></pre> <p>We have tried reducing the directory path of our project but we're looking for another solution. </p> <p>This is the current directory path of our project:</p> <blockquote> <p>D:\Work\FBXX</p> </blockquote>
0debug
How to change chekbox like this? : I need to change checkbox from [1]: http://i.stack.imgur.com/fPqOp.png to [2]: http://i.stack.imgur.com/3hLdB.png please help me to make checkbox like this...
0debug
Visual studio team services build .net core 1.1 : <p>I'm trying to build a .net core 1.1 project on vsts. The project is developed in vs2017 and it uses the csproj instead of project.json. I have tried multiple options to build id on vsts with the hosted agents (windows and linux).</p> <p>i have tried the following build steps</p> <p><strong>Visual studio build</strong></p> <p>Set to use vs 2017 but i get a warning "Visual Studio version '15.0' not found. Looking for the latest version." And then i get errors because it cant include .net core packages.</p> <p><strong>.NET Core (PREVIEW)</strong></p> <p>Cant find project.json. When i set it to use csproj file it gives an error "The file type was not recognized"</p> <p><strong>Command build step</strong></p> <p>I tried to run the commands with command build steps. "dotnet build" gives the error that it cant find the project.json file. </p> <p>Anyone building dotnet 1.1 with csproj on vsts that can help me how to do it?</p>
0debug
static int qcow2_cache_do_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset, void **table, bool read_from_disk) { BDRVQcow2State *s = bs->opaque; int i; int ret; int lookup_index; uint64_t min_lru_counter = UINT64_MAX; int min_lru_index = -1; trace_qcow2_cache_get(qemu_coroutine_self(), c == s->l2_table_cache, offset, read_from_disk); i = lookup_index = (offset / s->cluster_size * 4) % c->size; do { const Qcow2CachedTable *t = &c->entries[i]; if (t->offset == offset) { goto found; if (t->ref == 0 && t->lru_counter < min_lru_counter) { min_lru_counter = t->lru_counter; min_lru_index = i; if (++i == c->size) { i = 0; } while (i != lookup_index); if (min_lru_index == -1) { abort(); i = min_lru_index; trace_qcow2_cache_get_replace_entry(qemu_coroutine_self(), c == s->l2_table_cache, i); ret = qcow2_cache_entry_flush(bs, c, i); if (ret < 0) { return ret; trace_qcow2_cache_get_read(qemu_coroutine_self(), c == s->l2_table_cache, i); c->entries[i].offset = 0; if (read_from_disk) { if (c == s->l2_table_cache) { BLKDBG_EVENT(bs->file, BLKDBG_L2_LOAD); ret = bdrv_pread(bs->file, offset, qcow2_cache_get_table_addr(bs, c, i), s->cluster_size); if (ret < 0) { return ret; c->entries[i].offset = offset; found: c->entries[i].ref++; *table = qcow2_cache_get_table_addr(bs, c, i); trace_qcow2_cache_get_done(qemu_coroutine_self(), c == s->l2_table_cache, i); return 0;
1threat
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
problema esercizio python 2.7 : ho un problema con il mio codice. Devo creare un codice che dica se il numero inserito sia pari o dispari. L'errore è : TypeError: unsupported operand type(s) for %: 'builtin_function_or_method' and 'int' e il codice è print ("inserisci un numero") a=input if a%2 == 0 : print ("pari") else : print ("dispari") cosa devo modificare? Grazie
0debug
How to get the earliest date of a List in Java? : <p>I have an ArrayList which stores 0...4 Dates.</p> <p>The amount of Dates in the list depends on a Business logic.</p> <p>How can I get the earliest date of this list? Of course I can build iterative loops to finally retrieve the earliest date. But is there a 'cleaner'/ quicker way of doing this, especially when considering that this list can grow on a later perspective?</p>
0debug
Google+ login winform c# : i'm working on a simple winform application that allow to user to create an account with his google account , i have check to the documentation of google Api but i don't how it can work with winforms. The idea of the app is sample, i have 2 form: 1. ***Main Menu*** , with a button that show the second form. 2. ***WebBrowserForm***, this form contain a webBrowser to access to googleand get informations. Please can you help me with a tutorial or any thing else. thank you
0debug
I don't understand the purpose of for in loops : <p>I've been working my way through the Javascript development track on Treehouse and am struggling with for in loops. I have been unable to locate any explanation of this loop in everyday language and am subsequently getting confused. What does for in actually do, and why would you use this loop as oppose to another loop? Is it basically just a way to assign a common label to each individual property of an object?</p>
0debug
static int64_t coroutine_fn vpc_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { BDRVVPCState *s = bs->opaque; VHDFooter *footer = (VHDFooter*) s->footer_buf; int64_t start, offset; bool allocated; int n; if (be32_to_cpu(footer->type) == VHD_FIXED) { *pnum = nb_sectors; return BDRV_BLOCK_RAW | BDRV_BLOCK_OFFSET_VALID | BDRV_BLOCK_DATA | (sector_num << BDRV_SECTOR_BITS); } offset = get_sector_offset(bs, sector_num, 0); start = offset; allocated = (offset != -1); *pnum = 0; do { n = ROUND_UP(sector_num + 1, s->block_size / BDRV_SECTOR_SIZE) - sector_num; n = MIN(n, nb_sectors); *pnum += n; sector_num += n; nb_sectors -= n; if (allocated) { return BDRV_BLOCK_DATA | BDRV_BLOCK_OFFSET_VALID | start; } if (nb_sectors == 0) { break; } offset = get_sector_offset(bs, sector_num, 0); } while (offset == -1); return 0; }
1threat
Optimizing GC on EMR cluster : <p>I am running a Spark Job written in Scala on EMR and the stdout of each executor is filled with GC allocation failures. </p> <pre><code>2016-12-07T23:42:20.614+0000: [GC (Allocation Failure) 2016-12-07T23:42:20.614+0000: [ParNew: 909549K-&gt;432K(1022400K), 0.0089234 secs] 2279433K-&gt;1370373K(3294336K), 0.0090530 secs] [Times: user=0.11 sys=0.00, real=0.00 secs] 2016-12-07T23:42:21.572+0000: [GC (Allocation Failure) 2016-12-07T23:42:21.572+0000: [ParNew: 909296K-&gt;435K(1022400K), 0.0089298 secs] 2279237K-&gt;1370376K(3294336K), 0.0091147 secs] [Times: user=0.11 sys=0.01, real=0.00 secs] 2016-12-07T23:42:22.525+0000: [GC (Allocation Failure) 2016-12-07T23:42:22.525+0000: [ParNew: 909299K-&gt;485K(1022400K), 0.0080858 secs] 2279240K-&gt;1370427K(3294336K), 0.0082357 secs] [Times: user=0.12 sys=0.00, real=0.01 secs] 2016-12-07T23:42:23.474+0000: [GC (Allocation Failure) 2016-12-07T23:42:23.474+0000: [ParNew: 909349K-&gt;547K(1022400K), 0.0090641 secs] 2279291K-&gt;1370489K(3294336K), 0.0091965 secs] [Times: user=0.12 sys=0.00, real=0.00 secs] </code></pre> <p>I am reading few TB's of data, (mostly string) so I am worried that the constant GC will slow down processing time.<br> I would appreciate any pointers on how to understand this message and how to optimize GC so that it consumes minimum CPU time.</p>
0debug
Mysql query to retrive data from join of three table : <p>I have tree tables:</p> <p>Persons:</p> <ul> <li>id</li> <li>name</li> </ul> <p>Books</p> <ul> <li>id</li> <li>title</li> </ul> <p>Quantity:</p> <ul> <li>People_id</li> <li>Product_id</li> <li>quantity</li> </ul> <p>I need a result with : in the columns the Book title, in the rows the Persons name, in the cells the quantity take from the cross of peoples and books </p>
0debug
void ff_put_h264_qpel8_mc32_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_midh_qrt_8w_msa(src - (2 * stride) - 2, stride, dst, stride, 8, 1); }
1threat
angular guard not returning data : I'm using google maps API to get maxLat,maxLng,minLat,minLng and then I want to resolve data from the database before create the component, this is for SEO metas and description the problem is, that the guard is resolving the data, but not resolving the component my app-routing.module.ts my GuardService.ts ```` @Injectable({ providedIn: 'root' }) export class BusquedaGuardService implements CanActivate { componentForm = { locality: 'long_name', administrative_area_level_2: 'short_name', administrative_area_level_1: 'short_name' }; ubicacion: string maxLng minLng maxLat minLat constructor(private http: HttpClient, private router: Router, @Inject(PLATFORM_ID) private platformId: Object, private ngZone: NgZone, private mapaService: MapaService, private mapsAPILoader: MapsAPILoader) { } async getBounds() { let promise = new Promise((res, rej) => { this.mapsAPILoader.load().then(() => { this.ngZone.run(() => { let autocompleteService = new google.maps.places.AutocompleteService(); autocompleteService.getPlacePredictions( { 'input': this.ubicacion, 'componentRestrictions': { 'country': 'cl' }, }, (list, status) => { if (list == null || list.length == 0) { // console.log("No results"); } else { let placesService = new google.maps.places.PlacesService(document.createElement('div')); placesService.getDetails( { placeId: list[0].reference }, (detailsResult: google.maps.places.PlaceResult, placesServiceStatus) => { let direccion = '' let contador = 0 for (var i = 0; i < detailsResult.address_components.length; i++) { var addressType = detailsResult.address_components[i].types[0]; if (this.componentForm[addressType]) { var val = detailsResult.address_components[i][this.componentForm[addressType]]; // $(`#${addressType}`).value = val; if (addressType == 'locality') { direccion = direccion + val contador++ } else { if (contador == 0 && addressType == "administrative_area_level_2") { direccion = direccion + val contador++ } else { if (contador == 0 && addressType == "administrative_area_level_1") { direccion = direccion + val } else { direccion = direccion + ", " + val } } } } } this.mapaService.setDireccion(direccion) let e = detailsResult.geometry.viewport let lat = e[Object.keys(e)[0]] let lng = e[Object.keys(e)[1]] // console.log(lat, lng) this.maxLng = lng[Object.keys(lng)[1]] this.minLng = lng[Object.keys(lng)[0]] this.maxLat = lat[Object.keys(lng)[1]] this.minLat = lat[Object.keys(lng)[0]] let bounds = { maxLat: this.maxLat, maxLng: this.maxLng, minLat: this.minLat, minLng: this.minLng } this.mapaService.setBounds(this.maxLng, this.minLng, this.maxLat, this.minLat) this.mapaService.setLatLng(detailsResult.geometry.location.lat(), detailsResult.geometry.location.lng()) console.log('aqui') console.log(`${ipMarco}Instalaciones/Bounds/${this.maxLng}/${this.minLng}/${this.maxLat}/${this.minLat}`) res(bounds) // return this.http.get(`${ipMarco}Instalaciones/Bounds/${this.maxLng}/${this.minLng}/${this.maxLat}/${this.minLat}`).pipe( // map((res: any) => { // console.log(res) // return of(true) // }), // catchError(error => { // console.log('aqui') // console.log(error) // this.router.navigateByUrl('') // return of(false) // }) // ) } ) } } ); }) }) }) let bounds = await promise console.log(bounds) return bounds } canActivate(route: ActivatedRouteSnapshot): Observable<any> { // return of(true) // console.log('aqui') if (route.queryParams['ubicacion']) { this.ubicacion = route.queryParams['ubicacion'] if (this.ubicacion != undefined) { if (this.ubicacion != "") { return from(this.getBounds()).pipe( switchMap((bounds: any) => { return this.http.get(`${ipMarco}Instalaciones/Bounds/${bounds.maxLng}/${bounds.minLng}/${bounds.maxLat}/${bounds.minLat}`).pipe( map((res: any) => { console.log(res) return of(true) }), catchError(error => { console.log('aqui') console.log(error) this.router.navigateByUrl('') return of(false) }) ) }) ) } } } } } ```` ```` const routes: Routes = [ { path: '', component: InicioComponent }, { path: 'busqueda', component: BusquedaComponent, canActivate: [BusquedaGuardService], resolve: { data: BusquedaResolveService } }, ]; @NgModule({ imports: [RouterModule.forRoot(routes, { scrollPositionRestoration: 'enabled', })], exports: [RouterModule] }) export class AppRoutingModule { } ```` my resolve.service.ts ```` @Injectable({ providedIn: 'root' }) export class BusquedaResolveService { constructor(private mapaService:MapaService, private http:HttpClient) { console.log('nose') } resolve(route: ActivatedRouteSnapshot) { let maxLng = this.mapaService.getBoundsUnaVez().maxLng let minLng = this.mapaService.getBoundsUnaVez().minLng let maxLat = this.mapaService.getBoundsUnaVez().maxLat let minLat = this.mapaService.getBoundsUnaVez().minLat console.log(maxLng,minLng,maxLat,minLat) return this.http.get(`${ipMarco}Instalaciones/Bounds/${maxLng}/${minLng}/${maxLat}/${minLat}`); } } ````
0debug
Why JavaScript parses data wrongly? : <p>There are two strange things:</p> <ul> <li>day 30 instead of 31?</li> <li><p>it set 13 as time instead of 00?</p> <pre><code>new Date('Dec 31, 2019').toISOString() // '2019-12-30T13:00:00.000Z' </code></pre></li> </ul> <p>Basically what I'm trying to do is to convert original data format into <code>YYYY-MM-DD</code>.</p>
0debug
static inline void *alloc_code_gen_buffer(void) { void *buf = static_code_gen_buffer; #ifdef __mips__ if (cross_256mb(buf, tcg_ctx.code_gen_buffer_size)) { buf = split_cross_256mb(buf, tcg_ctx.code_gen_buffer_size); } #endif map_exec(buf, tcg_ctx.code_gen_buffer_size); return buf; }
1threat
static void qemu_co_queue_next_bh(void *opaque) { struct unlock_bh *unlock_bh = opaque; Coroutine *next; trace_qemu_co_queue_next_bh(); while ((next = QTAILQ_FIRST(&unlock_bh_queue))) { QTAILQ_REMOVE(&unlock_bh_queue, next, co_queue_next); qemu_coroutine_enter(next, NULL); } qemu_bh_delete(unlock_bh->bh); qemu_free(unlock_bh); }
1threat
Split an array of strings into other array of stings : I`m making a project, which gets an array of strings from a .txt file, which contains the two names of a person. The problem is that when i try to split the elements from the string "line" and try to give other two strings those values, something happens. The text file contains: "Noah Mason Emma Williams Richard Daniel and so on..." I want to split the lines into two separate arrays of stings "firstName" and "secondName". And i want something like this: firstName[0]="Noah"; firstName[1]="Emma"; firstName[2]="Richard"; secondName[0]="Mason"; secondName[0]="Williams"; secondName[0]="Daniel"; Thank you in advance!
0debug
Why do I get no error when running one codes on multiple terminals? : I'm parsing text files with Python code on Linux. I never majored in computer, and I don't know what material to look for and which keyword to search for. Using vim on multiple terminals targeting a file on Linux gives an error. (Maybe because of temporary files?) And When I open a file in Python, the file once read through must reset the pointer. BUT, I am now processing multiple files,same time, using a single piece of code (ex,"a.py"). So suddenly I was curious, why do I get no error when running one codes on multiple terminals? Isn't the code going to be related to pointers? Or do I get a temporary file to which copied the code when using it?
0debug
Fragment Tabs inside Fragment : <p>I have in my Main Activity an Action bar navigation using tabs using Fragments (with Material Design), as below which works well, but now I wish to have Tab navigation within my Fragments...</p> <pre><code>// Add Fragments to Tabs in Main Activity private void setupViewPager(ViewPager viewPager) { Adapter adapter = new Adapter(getSupportFragmentManager()); adapter.addFragment(new FeedsFragment(), "Latest Updates"); adapter.addFragment(new ClubTeamsFragment(), "Club Teams"); adapter.addFragment(new FixturesFragment(), "Fixtures"); adapter.addFragment(new ResultsFragment(), "Results"); adapter.addFragment(new ClubFieldsFragment(), "Club Fields"); viewPager.setAdapter(adapter); } </code></pre> <p>I'm pretty sure that TabHost is now deprecated.</p> <p>I wish to achieve the attached image. The blue tabs are at the Main Activity level and the gray date tabs are in the selected fragment view.</p> <p><a href="https://i.stack.imgur.com/aEN6v.png" rel="noreferrer"><img src="https://i.stack.imgur.com/aEN6v.png" alt="enter image description here"></a> </p> <p>I have read a few post about using Tab Host or Fragment Activity, or do I use Activity that is extended to Fragment?</p>
0debug
Why does this code returns "true"? : <p>I have some weird situation with following code:</p> <pre><code>$string = '///'; var_dump(!stripos($string, '//')); </code></pre> <p>This code section returns <code>true</code>. Now take a look at next code section:</p> <pre><code>$string = 'a//'; var_dump(!stripos($string, '//')); </code></pre> <p>This code section returns <code>false</code>. At my opinion fisrt example should return <code>false</code> too, but it isn't. What am I doing wrong?</p>
0debug
Import GoogleNews-vectors-negative300.bin : <p>I am working on code using the gensim and having a tough time troubleshooting a ValueError within my code. I finally was able to zip GoogleNews-vectors-negative300.bin.gz file so I could implement it in my model. I also tried gzip which the results were unsuccessful. The error in the code occurs in the last line. I would like to know what can be done to fix the error. Is there any workarounds? Finally, is there a website that I could reference? </p> <p>Thank you respectfully for your assistance! </p> <pre><code>import gensim from keras import backend from keras.layers import Dense, Input, Lambda, LSTM, TimeDistributed from keras.layers.merge import concatenate from keras.layers.embeddings import Embedding from keras.models import Mode pretrained_embeddings_path = "GoogleNews-vectors-negative300.bin" word2vec = gensim.models.KeyedVectors.load_word2vec_format(pretrained_embeddings_path, binary=True) --------------------------------------------------------------------------- ValueError Traceback (most recent call last) &lt;ipython-input-3-23bd96c1d6ab&gt; in &lt;module&gt;() 1 pretrained_embeddings_path = "GoogleNews-vectors-negative300.bin" ----&gt; 2 word2vec = gensim.models.KeyedVectors.load_word2vec_format(pretrained_embeddings_path, binary=True) C:\Users\green\Anaconda3\envs\py35\lib\site- packages\gensim\models\keyedvectors.py in load_word2vec_format(cls, fname, fvocab, binary, encoding, unicode_errors, limit, datatype) 244 word.append(ch) 245 word = utils.to_unicode(b''.join(word), encoding=encoding, errors=unicode_errors) --&gt; 246 weights = fromstring(fin.read(binary_len), dtype=REAL) 247 add_word(word, weights) 248 else: ValueError: string size must be a multiple of element size </code></pre>
0debug
Python code example for 'square root' time complexity : <p>I'm learning about the different Big O time complexities, and the last one I have is the 'square root', but I just can't seem to find any useful Python code snippets that uses a <em>simple</em> algorithm for demonstrating this time complexity.</p> <p>I find it easier to understand these complexities when I can see a simple (even if unrealistic) code snippet.</p>
0debug
bool address_space_access_valid(AddressSpace *as, hwaddr addr, int len, bool is_write) { MemoryRegion *mr; hwaddr l, xlat; rcu_read_lock(); while (len > 0) { l = len; mr = address_space_translate(as, addr, &xlat, &l, is_write); if (!memory_access_is_direct(mr, is_write)) { l = memory_access_size(mr, l, addr); if (!memory_region_access_valid(mr, xlat, l, is_write)) { return false; } } len -= l; addr += l; } return true; }
1threat
CSV to JSON using python : I want to populate my json message with data from a CSV file. I want each row to be a "new" json message. I am using python and will connect the the code to an API once done. Some of the data is categorized under "personalinfo" and "carinfo" and I need the correct data to be populated under the right category as under the "expected json message output" Example csv table: FirstName LastName Age gender Car model Price loan Anna Andersson 28 F Audi A8 40 FALSE Bea Bertilsson 27 F WV GT 20 TRUE expected json message output: { "personalinfo": { "firstname": "Anna", "lastname": "Andersson", "age": "28", "gender": "F", "carinfo": [{ "car ": "Audi", "model": "A8" }], "price": 40, "loan": "FALSE" } } { "personalinfo": { "firstname": "Bea", "lastname": "Bertilsson", "age": "27", "gender": "F", "carinfo": [{ "car ": "WV", "model": "GT" }], "price": 20, "loan": "TRUE" } }
0debug
void event_notifier_cleanup(EventNotifier *e) { close(e->fd); }
1threat
void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes, unsigned int *out_bytes, unsigned max_in_bytes, unsigned max_out_bytes) { unsigned int idx; unsigned int total_bufs, in_total, out_total; idx = vq->last_avail_idx; total_bufs = in_total = out_total = 0; while (virtqueue_num_heads(vq, idx)) { unsigned int max, num_bufs, indirect = 0; hwaddr desc_pa; int i; max = vq->vring.num; num_bufs = total_bufs; i = virtqueue_get_head(vq, idx++); desc_pa = vq->vring.desc; if (vring_desc_flags(desc_pa, i) & VRING_DESC_F_INDIRECT) { if (vring_desc_len(desc_pa, i) % sizeof(VRingDesc)) { error_report("Invalid size for indirect buffer table"); exit(1); } if (num_bufs >= max) { error_report("Looped descriptor"); exit(1); } indirect = 1; max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc); num_bufs = i = 0; desc_pa = vring_desc_addr(desc_pa, i); } do { if (++num_bufs > max) { error_report("Looped descriptor"); exit(1); } if (vring_desc_flags(desc_pa, i) & VRING_DESC_F_WRITE) { in_total += vring_desc_len(desc_pa, i); } else { out_total += vring_desc_len(desc_pa, i); } if (in_total >= max_in_bytes && out_total >= max_out_bytes) { goto done; } } while ((i = virtqueue_next_desc(desc_pa, i, max)) != max); if (!indirect) total_bufs = num_bufs; else total_bufs++; } done: if (in_bytes) { *in_bytes = in_total; } if (out_bytes) { *out_bytes = out_total; } }
1threat
dynamic generation of images with js : as a part of coursera exercise, I am trying to show the same photo at 5 different positions of a div tag. Although I used the `img {position: absolute;}`, all photos seem to be stacked above each other. here is the code I am trying to use in the body tag: <div id="leftside"></div> <script type="text/javascript"> var theLeftSide = document.getElementById("leftside"); function generateFaces(){ for (var i = 0; i < 5; i++) { photo = document.createElement("img"); photo.src ="http://home.cse.ust.hk/~rossiter/mooc/matching_game/smile.png"; topPosition = Math.floor(Math.random()*401); leftPosition = Math.floor(Math.random()*401); photo.style.top =topPosition; photo.style.left =leftPosition; theLeftSide.appendChild(photo); console.log(i, topPosition, leftPosition); } // for } // function window.onload = generateFaces(); </script> I don't know what is the problem!
0debug
I'm getting " no match for 'operator[]' 'std::vector<int> []' and 'std::vector<int>')" in C++ : vector<int>g2[10000]; for(int u=0;u<N;u++) //N is the number of vertices { for(vector<int>::iterator it=v[u].begin();it!=v[u].end();it++) {g2[v[*it]].push_back(u);}} //v is of vector<int>v[1000],it consists a adjaceny list representation of a graph Im getting the error-> prog.cpp:74:8: error: no match for 'operator[]' (operand types are 'std::vector<int> [10001]' and 'std::vector<int>') g2[v[*it]].push_back(u); ^ can you guys please help me!
0debug
static int check_protocol_support(bool *has_ipv4, bool *has_ipv6) { #ifdef HAVE_IFADDRS_H struct ifaddrs *ifaddr = NULL, *ifa; struct addrinfo hints = { 0 }; struct addrinfo *ai = NULL; int gaierr; *has_ipv4 = *has_ipv6 = false; if (getifaddrs(&ifaddr) < 0) { g_printerr("Failed to lookup interface addresses: %s\n", strerror(errno)); return -1; } for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next) { if (!ifa->ifa_addr) { continue; } if (ifa->ifa_addr->sa_family == AF_INET) { *has_ipv4 = true; } if (ifa->ifa_addr->sa_family == AF_INET6) { *has_ipv6 = true; } } freeifaddrs(ifaddr); hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG; hints.ai_family = AF_INET6; hints.ai_socktype = SOCK_STREAM; gaierr = getaddrinfo("::1", NULL, &hints, &ai); if (gaierr != 0) { if (gaierr == EAI_ADDRFAMILY || gaierr == EAI_FAMILY || gaierr == EAI_NONAME) { *has_ipv6 = false; } else { g_printerr("Failed to resolve ::1 address: %s\n", gai_strerror(gaierr)); return -1; } } freeaddrinfo(ai); return 0; #else *has_ipv4 = *has_ipv6 = false; return -1; #endif }
1threat
static const char *addr2str(target_phys_addr_t addr) { return nr2str(ehci_mmio_names, ARRAY_SIZE(ehci_mmio_names), addr); }
1threat
Create Git Repo with New Project in Visual Studio 2019 : <p>In Visual Studio 2017, there used to be an option when creating a New Project to "Make a new Git Repository with Solution", or something similar.</p> <p>I can't seem to find the option in Visual Studio 2019. Has it been removed? I was thinking maybe it requires an extension?</p>
0debug
Visitor *validate_test_init(TestInputVisitorData *data, const char *json_string, ...) { Visitor *v; va_list ap; va_start(ap, json_string); v = validate_test_init_internal(data, json_string, &ap); va_end(ap); return v; }
1threat
bool vring_enable_notification(VirtIODevice *vdev, Vring *vring) { if (vdev->guest_features & (1 << VIRTIO_RING_F_EVENT_IDX)) { vring_avail_event(&vring->vr) = vring->vr.avail->idx; } else { vring_clear_used_flags(vdev, vring, VRING_USED_F_NO_NOTIFY); } smp_mb(); return !vring_more_avail(vdev, vring); }
1threat
void avcodec_flush_buffers(AVCodecContext *avctx) { if(HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME) ff_thread_flush(avctx); if(avctx->codec->flush) avctx->codec->flush(avctx); }
1threat
variable re-identification causing an infinite loop : <p>Why does this code cause an infinite loop:</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { int y = 5; while (y &lt; 6) { int y = 7; cout &lt;&lt; y &lt;&lt; endl; } } </code></pre> <p>yet removing the "int" in the while statement makes it run once normally? (</p> <pre><code>#include &lt;iostream&gt; using namespace std; int main() { int y = 5; while (y &lt; 6) { y = 7; cout &lt;&lt; y &lt;&lt; endl; } } </code></pre> <p>)</p>
0debug
html center align the button on media screen : i want to align the button horizontally in same line which is divided in columns in blue color called "Läs mer" in media screen. following is the link http://www.visbyhemtjanst.se/ i added the following media query: @media only screen and (max-width: 1450px) { .home-page-content{ min-height: 260px; } } when i reduce the screen button doesn't align in same line what needs to add more in media query.
0debug
Fixing 'define' is not defined no-undef in react create app third party imports : <p>i have imported momentjs in my react app, after importing react create app is throwing following error restricting the build</p> <blockquote> <p>./src/shared_components/quiz-player/node_modules/moment/moment.js<br> Line 9: 'define' is not defined no-undef</p> </blockquote> <p>when i investigate the issue it is thrown from following line</p> <pre><code>typeof define === 'function' &amp;&amp; define.amd ? define(factory) : global.moment = factory() </code></pre> <p>this is due to amd module definition and since this is a third party library i have no option of resolving the issue, is there any thing that can be done to tell the webpack config to expect amd module definition or some other fix for this? </p>
0debug
I have a csv file with two different formats of date value, how to bring it to a single format : My CSV file looks like this id date 1602 11/23/2015 14:10 1602 11/23/2015 22:45 1602 18/10/2011 09:19:46 AM 1702 18/10/2011 09:07:33 AM 1863 18/10/2011 09:07:35 AM 1436 18/10/2011 09:07:36 AM
0debug
Blue/Green Deployments with Azure ServiceFabric : <p>I'm currently building an application using the ReliableActors framework on Azure ServiceFabric. As we scale up, I'm looking at doing blue/green deployments. I can see how to do this using a stateless system. Is there's a way to do this using statefull actors?</p>
0debug
query = 'SELECT * FROM customers WHERE email = ' + email_input
1threat
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
1threat
What type of ssl certiifcate are acceptable in android? : I found there are three types of ssl certificate, Extended Validation (EV SSL) Certificates,Organization Validated (OV SSL) Certificates,Domain Validated (DV SSL) Certificates, Which of these supported in android?(I am using retrofit to call web services.)
0debug