problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
len() of a numpy array in python : <p>If I use <code>len(np.array([[2,3,1,0], [2,3,1,0], [3,2,1,1]]))</code>, I get back 3. </p>
<p>Why is there no argument for <code>len()</code> about which axis I want the length of in multidimensional arrays? This is alarming. Is there an alternative?</p>
| 0debug
|
Python While Loop with Multiple Conditions not Exiting : <p>I have a code in which exits only when anyone of the 3 variables cross 7</p>
<pre><code>while(a!=7 or b!=7 or c!=7):
#My algorithm to increase values based on input
#end of while
</code></pre>
<p>My code never exits the while loop when anyone of of the variables cross 7.
However when I change the code to</p>
<pre><code>while(a!-7):
#Algorithm
#End of while
</code></pre>
<p>and on providing inputs to increase a to 7, the loop exits.</p>
<p>Is there some mistake in my syntax for while loop with multiple condition or is it something else?</p>
<p><strong>The algorithm that I have written in works perfectly, only the while loop cannot exit on reaching the condition for anyone of the variable</strong></p>
| 0debug
|
How i can get the first match in regex and import this match in a string? : <p>For example using a regex expression <strong>del(.*?)del</strong> get delcatdel
and save the result in string or in text</p>
<p>word1word2<strong>delcatdel</strong>word3word4<strong>deldogdel</strong>word5 </p>
<p>in my text (or string) i need obtain <strong>delcatdel</strong></p>
<p>USING c sharp </p>
<p>please anybody help me</p>
| 0debug
|
How to do CSS :hover function in JSX ? : <p>Hi and thanks for the great job here. I am using react.js for my project to build my components and I feel a little bit stuck in my project right now. I am trying to style a button with a hover function and I don't know how to apply this to react.</p>
<p>Here is the code : </p>
<pre><code>let button = {
backgroundColor: colorPalette.white,
border: "1px solid rgb(12,106,145)",
color: colorPalette.brandCol1,
textAlign: 'center',
textDecoration: 'none',
fontSize : 'inherit',
fontWeight : 600,
padding : "5px 8px 5px 8px"
}
</code></pre>
<p>and I would like to add a hover style to it just like we do in css with </p>
<pre><code>button:hover {
style here.......
}
</code></pre>
<p>What is the correct syntax ? </p>
| 0debug
|
explanation of the output of the following program : <pre><code>#include<stdio.h>
void main()
{
printf(5+"good morning");/*need explanation for this line
return 0;
}
</code></pre>
<p>The output of the program is - morning
can anyone explain how?</p>
| 0debug
|
Convert a protobuf to JSON using Jackson? : <p>I get the following error while converting a protobuf to JSON using Jackson's ObjectMapper:</p>
<pre><code>com.fasterxml.jackson.databind.exc.InvalidDefinitionException:
Direct self-reference leading to cycle (through reference chain:
MyObjectPb$MyObject["unknownFields"]->
com.google.protobuf.UnknownFieldSet["defaultInstanceForType"])
</code></pre>
<p>MyObjectPb has the following field: </p>
<pre><code>protected com.google.protobuf.UnknownFieldSet unknownFields
</code></pre>
<p>As I am working on an existing codebase, I have the following constraints:</p>
<ol>
<li>I can't modify the source code for MyObjectPb, so I can't use Jackson's ignore annotations in MyObjectPb.</li>
<li>Neither can I use Gson's libraries to convert the object, as the codebase already uses Jackson for serialization. Adding a new dependency is not recommended. </li>
</ol>
<p>How do I tell Jackson to ignore (de)serializing the UnknownFieldSet object inside MyObjectPb?</p>
<hr>
<p>I have tried the following, but these approaches do not seem to solve the problem:</p>
<p>a) Configuring the ObjectMapper:</p>
<pre><code>myObjectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
myObjectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
</code></pre>
<p>b) Using a Jackson Mixin:</p>
<pre><code>@JsonIgnoreType
private abstract class UnknownFieldSetIgnoreMixIn {}
myObjectMapper.addMixIn(UnknownFieldSet.class, UnknownFieldSetIgnoreMixIn.class)
</code></pre>
| 0debug
|
convert month name to number in unix : Input :
01-DEC-18|"0308"|"RUB"
01-DEC-18|"0308"|"RUB"
01-DEC-18|"0308"|"RUB"
01-DEC-18|"0308"|"RUB"
Expected output :
01-12-18|"0308"|"RUB"
01-12-18|"0308"|"RUB"
01-12-18|"0308"|"RUB"
01-12-18|"0308"|"RUB"
| 0debug
|
What are the steps involved in the execution of an Android program? : <p>I was just reading about the Dalvik Virtual Machine. It got me all confused. I know there is a build tool called gradle in Android Studio. However, these are bits and pieces of information.
I want to know where they fit in i.e. the steps involved in execution of an Android program.</p>
<p>Thank you</p>
| 0debug
|
So, I just started coding in the book, "Think Java", and I couldn't figure out what was wrong with my code. Please help me out and thanks :
// So the problem arises in the line "String pls = printABCS("A", "B", "c", "D", "E", "F,", "G");", and I have no idea why, I've tried for the past hour and nothing seems to be working. Is there any fix to why when I run the code, the result is "Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method printABCS(Time3) in the type Time3 is not applicable for the arguments (String, String, String, String, String, String, String)
at chapter11.Time3.main(Time3.java:16)"
Thanks for taking your time to help.
public class Time3 {
String a, b, c, d, e, f, g;
public Time3(String a, String b, String c, String d, String e, String f, String g) {
this.a = a;
this.b = b;
this.c = c;
this.d = d;
this.e = e;
this.f = f;
this.g = g;
}
public static void main(String[] args) {
String pls = printABCS("A", "B", "c", "D", "E", "F,", "G");
}
public static String printABCS(Time3 p) {
return (p.a + p.b + p.c + p.d + p.e + p.f + p.g);
}
}
| 0debug
|
void omap_uwire_attach(struct omap_uwire_s *s,
uWireSlave *slave, int chipselect)
{
if (chipselect < 0 || chipselect > 3) {
fprintf(stderr, "%s: Bad chipselect %i\n", __FUNCTION__, chipselect);
exit(-1);
}
s->chip[chipselect] = slave;
}
| 1threat
|
Difference between org.mockito.Mockito.any and org.mockito.matchers.any? : <p>I am realizing that in my project I am using two libraries that, essentially, do the same thing:</p>
<p>1) <strong>org.mockito.Mockito.any</strong></p>
<p>2) <strong>org.mockito.Matchers.any</strong></p>
<p>I'd like to use just one of them to be clearer, which one should I stick to? </p>
<p>Thanks! </p>
| 0debug
|
void HELPER(diag)(CPUS390XState *env, uint32_t r1, uint32_t r3, uint32_t num)
{
uint64_t r;
switch (num) {
case 0x500:
r = s390_virtio_hypercall(env);
break;
case 0x44:
r = 0;
break;
case 0x308:
handle_diag_308(env, r1, r3);
r = 0;
break;
case 0x288:
r = handle_diag_288(env, r1, r3);
break;
default:
r = -1;
break;
}
if (r) {
program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO);
}
}
| 1threat
|
int unix_listen_opts(QemuOpts *opts)
{
struct sockaddr_un un;
const char *path = qemu_opt_get(opts, "path");
int sock, fd;
sock = socket(PF_UNIX, SOCK_STREAM, 0);
if (sock < 0) {
perror("socket(unix)");
return -1;
}
memset(&un, 0, sizeof(un));
un.sun_family = AF_UNIX;
if (path && strlen(path)) {
snprintf(un.sun_path, sizeof(un.sun_path), "%s", path);
} else {
char *tmpdir = getenv("TMPDIR");
snprintf(un.sun_path, sizeof(un.sun_path), "%s/qemu-socket-XXXXXX",
tmpdir ? tmpdir : "/tmp");
fd = mkstemp(un.sun_path); close(fd);
qemu_opt_set(opts, "path", un.sun_path);
}
unlink(un.sun_path);
if (bind(sock, (struct sockaddr*) &un, sizeof(un)) < 0) {
fprintf(stderr, "bind(unix:%s): %s\n", un.sun_path, strerror(errno));
goto err;
}
if (listen(sock, 1) < 0) {
fprintf(stderr, "listen(unix:%s): %s\n", un.sun_path, strerror(errno));
goto err;
}
if (sockets_debug)
fprintf(stderr, "bind(unix:%s): OK\n", un.sun_path);
return sock;
err:
closesocket(sock);
return -1;
}
| 1threat
|
How Do I Encrypt and Decrypt a file from Disk rather than doing that from memory? : [enter image description here][1]::
When I am trying to encrypt and decrypt a 250MB file y=using AES algorithm, I am getting the following error. When I am trying with datasets less than 250, I am able to get the output.
[1]: https://i.stack.imgur.com/YsPBn.png
| 0debug
|
static void RENAME(extract_even2avg)(const uint8_t *src0, const uint8_t *src1, uint8_t *dst0, uint8_t *dst1, x86_reg count)
{
dst0 += count;
dst1 += count;
src0 += 4*count;
src1 += 4*count;
count= - count;
#ifdef PAVGB
if(count <= -8) {
count += 7;
__asm__ volatile(
"pcmpeqw %%mm7, %%mm7 \n\t"
"psrlw $8, %%mm7 \n\t"
"1: \n\t"
"movq -28(%1, %0, 4), %%mm0 \n\t"
"movq -20(%1, %0, 4), %%mm1 \n\t"
"movq -12(%1, %0, 4), %%mm2 \n\t"
"movq -4(%1, %0, 4), %%mm3 \n\t"
PAVGB" -28(%2, %0, 4), %%mm0 \n\t"
PAVGB" -20(%2, %0, 4), %%mm1 \n\t"
PAVGB" -12(%2, %0, 4), %%mm2 \n\t"
PAVGB" - 4(%2, %0, 4), %%mm3 \n\t"
"pand %%mm7, %%mm0 \n\t"
"pand %%mm7, %%mm1 \n\t"
"pand %%mm7, %%mm2 \n\t"
"pand %%mm7, %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"packuswb %%mm3, %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"psrlw $8, %%mm0 \n\t"
"psrlw $8, %%mm2 \n\t"
"pand %%mm7, %%mm1 \n\t"
"pand %%mm7, %%mm3 \n\t"
"packuswb %%mm2, %%mm0 \n\t"
"packuswb %%mm3, %%mm1 \n\t"
MOVNTQ" %%mm0,- 7(%4, %0) \n\t"
MOVNTQ" %%mm1,- 7(%3, %0) \n\t"
"add $8, %0 \n\t"
" js 1b \n\t"
: "+r"(count)
: "r"(src0), "r"(src1), "r"(dst0), "r"(dst1)
);
count -= 7;
}
#endif
while(count<0) {
dst0[count]= (src0[4*count+0]+src1[4*count+0])>>1;
dst1[count]= (src0[4*count+2]+src1[4*count+2])>>1;
count++;
}
}
| 1threat
|
static int kvm_log_stop(CPUPhysMemoryClient *client,
target_phys_addr_t phys_addr, ram_addr_t size)
{
return kvm_dirty_pages_log_change(phys_addr, size, false);
}
| 1threat
|
How to insert Null Values of type double in ANDROID : <p>I created a table with six cloumns as described below when am i putting the null vales in second row of type double it shows error.</p>
<p>How to put empty values in double place </p>
<pre><code>myDB.insert("Hotel MidCity",16.5048,80.6338,"Vijayawada",16.251,80.666);
myDB.insert("Minerva Hyderabad",16.5024,80.6432,"Null", , );
</code></pre>
<p>Thank you..</p>
| 0debug
|
What are practical use-cases for the HTTP verb REPORT and why is it neglected over time? : <p>Whenever I have to create a RESTful web service and the use case implies on getting data based on a set of search criteria, I always opted for a POST request with the parameters in the body instead of a GET request for all the obvious reasons. I've seen it a dozen of times so I figured is was best practice.</p>
<p>Most recently I stumbled upon <a href="https://evertpot.com/dropbox-post-api" rel="noreferrer">this interesting blog article by Evert Pot</a> where he comments on the downsides of the POST verb and simply notes on using the <strong>REPORT</strong> verb instead. He also states that <em>"its semantics are well defined and it works everywhere"</em>.
After reading the post I've been trying to find some more information on this REPORT verb but not much can be found. I know it was part of <a href="https://tools.ietf.org/html/rfc3253#section-3.6" rel="noreferrer">RFC-3253</a> as a way to obtain information about a resource but other than that I am clueless.</p>
<p>My question are the following:</p>
<ol>
<li>Is REPORT really a better alternative than POST in the case of requesting a resource based on a set of search criteria?</li>
<li>Is it wise to start using it or is it too risky? I'm seeing lots of
<code>HTTP Method REPORT not supported</code> issues from various tools and frameworks.</li>
<li>Why does it seem like it is neglected over the years and why do we
know so little about it?</li>
<li>What could other valid use-cases be for using this verb?</li>
</ol>
<p>Thank you in advance.</p>
| 0debug
|
static int mpeg1_decode_sequence(AVCodecContext *avctx,
const uint8_t *buf, int buf_size)
{
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
int width, height;
int i, v, j;
init_get_bits(&s->gb, buf, buf_size * 8);
width = get_bits(&s->gb, 12);
height = get_bits(&s->gb, 12);
if (width == 0 || height == 0) {
av_log(avctx, AV_LOG_WARNING,
"Invalid horizontal or vertical size value.\n");
if (avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_COMPLIANT))
return AVERROR_INVALIDDATA;
}
s->aspect_ratio_info = get_bits(&s->gb, 4);
if (s->aspect_ratio_info == 0) {
av_log(avctx, AV_LOG_ERROR, "aspect ratio has forbidden 0 value\n");
if (avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_COMPLIANT))
return AVERROR_INVALIDDATA;
}
s->frame_rate_index = get_bits(&s->gb, 4);
if (s->frame_rate_index == 0 || s->frame_rate_index > 13) {
av_log(avctx, AV_LOG_WARNING,
"frame_rate_index %d is invalid\n", s->frame_rate_index);
s->frame_rate_index = 1;
}
s->bit_rate = get_bits(&s->gb, 18) * 400;
if (check_marker(&s->gb, "in sequence header") == 0) {
return AVERROR_INVALIDDATA;
}
s->avctx->rc_buffer_size = get_bits(&s->gb, 10) * 1024 * 16;
skip_bits(&s->gb, 1);
if (get_bits1(&s->gb)) {
load_matrix(s, s->chroma_intra_matrix, s->intra_matrix, 1);
} else {
for (i = 0; i < 64; i++) {
j = s->idsp.idct_permutation[i];
v = ff_mpeg1_default_intra_matrix[i];
s->intra_matrix[j] = v;
s->chroma_intra_matrix[j] = v;
}
}
if (get_bits1(&s->gb)) {
load_matrix(s, s->chroma_inter_matrix, s->inter_matrix, 0);
} else {
for (i = 0; i < 64; i++) {
int j = s->idsp.idct_permutation[i];
v = ff_mpeg1_default_non_intra_matrix[i];
s->inter_matrix[j] = v;
s->chroma_inter_matrix[j] = v;
}
}
if (show_bits(&s->gb, 23) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "sequence header damaged\n");
return AVERROR_INVALIDDATA;
}
s->width = width;
s->height = height;
s->progressive_sequence = 1;
s->progressive_frame = 1;
s->picture_structure = PICT_FRAME;
s->first_field = 0;
s->frame_pred_frame_dct = 1;
s->chroma_format = 1;
s->codec_id =
s->avctx->codec_id = AV_CODEC_ID_MPEG1VIDEO;
s->out_format = FMT_MPEG1;
s->swap_uv = 0;
if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY)
s->low_delay = 1;
if (s->avctx->debug & FF_DEBUG_PICT_INFO)
av_log(s->avctx, AV_LOG_DEBUG, "vbv buffer: %d, bitrate:%"PRId64", aspect_ratio_info: %d \n",
s->avctx->rc_buffer_size, s->bit_rate, s->aspect_ratio_info);
return 0;
}
| 1threat
|
how to image set my layout...please help me : i need help i am not frontend developer please help me.... i am using bootstrap i want image like below image..
[enter image description here][1]
<div class="panel-body">
<img src="\images\blank.jpg" alt="\images\blank.jpg" >
<form action="">
<div class="form-group">
<label class="col-md-2 control-label" for="inputDefault">Full Name</label>
<div class="col-md-4">
<input type="text" class="form-control" id="inputDefault" ng-model='Profile.full_name ' name='full_name' readonly>
</div>
<label class="col-md-2 control-label">Email</label>
<div class="col-md-4">
<input type="text" ng-model='Profile.email' id="email" name='email' readonly class="form-control ng-pristine ng-untouched ng-valid ng-empty" aria-invalid="false">
</div>
</div>
but its show like below...how to show above like image
[enter image description here][2]
[1]: https://i.stack.imgur.com/M6EkW.jpg
[2]: https://i.stack.imgur.com/Pj8Bw.jpg
| 0debug
|
int ff_rate_control_init(MpegEncContext *s)
{
RateControlContext *rcc= &s->rc_context;
int i;
const char *error = NULL;
static const char * const const_names[]={
"PI",
"E",
"iTex",
"pTex",
"tex",
"mv",
"fCode",
"iCount",
"mcVar",
"var",
"isI",
"isP",
"isB",
"avgQP",
"qComp",
"avgIITex",
"avgPITex",
"avgPPTex",
"avgBPTex",
"avgTex",
NULL
};
static double (*func1[])(void *, double)={
(void *)bits2qp,
(void *)qp2bits,
NULL
};
static const char * const func1_names[]={
"bits2qp",
"qp2bits",
NULL
};
emms_c();
rcc->rc_eq_eval = ff_parse(s->avctx->rc_eq, const_names, func1, func1_names, NULL, NULL, &error);
if (!rcc->rc_eq_eval) {
av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\": %s\n", s->avctx->rc_eq, error? error : "");
return -1;
}
for(i=0; i<5; i++){
rcc->pred[i].coeff= FF_QP2LAMBDA * 7.0;
rcc->pred[i].count= 1.0;
rcc->pred[i].decay= 0.4;
rcc->i_cplx_sum [i]=
rcc->p_cplx_sum [i]=
rcc->mv_bits_sum[i]=
rcc->qscale_sum [i]=
rcc->frame_count[i]= 1;
rcc->last_qscale_for[i]=FF_QP2LAMBDA * 5;
}
rcc->buffer_index= s->avctx->rc_initial_buffer_occupancy;
if(s->flags&CODEC_FLAG_PASS2){
int i;
char *p;
p= s->avctx->stats_in;
for(i=-1; p; i++){
p= strchr(p+1, ';');
}
i+= s->max_b_frames;
if(i<=0 || i>=INT_MAX / sizeof(RateControlEntry))
return -1;
rcc->entry = av_mallocz(i*sizeof(RateControlEntry));
rcc->num_entries= i;
for(i=0; i<rcc->num_entries; i++){
RateControlEntry *rce= &rcc->entry[i];
rce->pict_type= rce->new_pict_type=FF_P_TYPE;
rce->qscale= rce->new_qscale=FF_QP2LAMBDA * 2;
rce->misc_bits= s->mb_num + 10;
rce->mb_var_sum= s->mb_num*100;
}
p= s->avctx->stats_in;
for(i=0; i<rcc->num_entries - s->max_b_frames; i++){
RateControlEntry *rce;
int picture_number;
int e;
char *next;
next= strchr(p, ';');
if(next){
(*next)=0;
next++;
}
e= sscanf(p, " in:%d ", &picture_number);
assert(picture_number >= 0);
assert(picture_number < rcc->num_entries);
rce= &rcc->entry[picture_number];
e+=sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d",
&rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits, &rce->mv_bits, &rce->misc_bits,
&rce->f_code, &rce->b_code, &rce->mc_mb_var_sum, &rce->mb_var_sum, &rce->i_count, &rce->skip_count, &rce->header_bits);
if(e!=14){
av_log(s->avctx, AV_LOG_ERROR, "statistics are damaged at line %d, parser out=%d\n", i, e);
return -1;
}
p= next;
}
if(init_pass2(s) < 0) return -1;
if((s->flags&CODEC_FLAG_PASS2) && s->avctx->rc_strategy == FF_RC_STRATEGY_XVID) {
#ifdef CONFIG_LIBXVID
return ff_xvid_rate_control_init(s);
#else
av_log(s->avctx, AV_LOG_ERROR, "Xvid ratecontrol requires libavcodec compiled with Xvid support.\n");
return -1;
#endif
}
}
if(!(s->flags&CODEC_FLAG_PASS2)){
rcc->short_term_qsum=0.001;
rcc->short_term_qcount=0.001;
rcc->pass1_rc_eq_output_sum= 0.001;
rcc->pass1_wanted_bits=0.001;
if(s->avctx->qblur > 1.0){
av_log(s->avctx, AV_LOG_ERROR, "qblur too large\n");
return -1;
}
if(s->avctx->rc_initial_cplx){
for(i=0; i<60*30; i++){
double bits= s->avctx->rc_initial_cplx * (i/10000.0 + 1.0)*s->mb_num;
RateControlEntry rce;
double q;
if (i%((s->gop_size+3)/4)==0) rce.pict_type= FF_I_TYPE;
else if(i%(s->max_b_frames+1)) rce.pict_type= FF_B_TYPE;
else rce.pict_type= FF_P_TYPE;
rce.new_pict_type= rce.pict_type;
rce.mc_mb_var_sum= bits*s->mb_num/100000;
rce.mb_var_sum = s->mb_num;
rce.qscale = FF_QP2LAMBDA * 2;
rce.f_code = 2;
rce.b_code = 1;
rce.misc_bits= 1;
if(s->pict_type== FF_I_TYPE){
rce.i_count = s->mb_num;
rce.i_tex_bits= bits;
rce.p_tex_bits= 0;
rce.mv_bits= 0;
}else{
rce.i_count = 0;
rce.i_tex_bits= 0;
rce.p_tex_bits= bits*0.9;
rce.mv_bits= bits*0.1;
}
rcc->i_cplx_sum [rce.pict_type] += rce.i_tex_bits*rce.qscale;
rcc->p_cplx_sum [rce.pict_type] += rce.p_tex_bits*rce.qscale;
rcc->mv_bits_sum[rce.pict_type] += rce.mv_bits;
rcc->frame_count[rce.pict_type] ++;
bits= rce.i_tex_bits + rce.p_tex_bits;
q= get_qscale(s, &rce, rcc->pass1_wanted_bits/rcc->pass1_rc_eq_output_sum, i);
rcc->pass1_wanted_bits+= s->bit_rate/(1/av_q2d(s->avctx->time_base));
}
}
}
return 0;
}
| 1threat
|
static int guess_disk_lchs(IDEState *s,
int *pcylinders, int *pheads, int *psectors)
{
uint8_t *buf;
int ret, i, heads, sectors, cylinders;
struct partition *p;
uint32_t nr_sects;
buf = qemu_memalign(512, 512);
if (buf == NULL)
return -1;
ret = bdrv_read(s->bs, 0, buf, 1);
if (ret < 0) {
qemu_free(buf);
return -1;
}
if (buf[510] != 0x55 || buf[511] != 0xaa) {
qemu_free(buf);
return -1;
}
for(i = 0; i < 4; i++) {
p = ((struct partition *)(buf + 0x1be)) + i;
nr_sects = le32_to_cpu(p->nr_sects);
if (nr_sects && p->end_head) {
heads = p->end_head + 1;
sectors = p->end_sector & 63;
if (sectors == 0)
continue;
cylinders = s->nb_sectors / (heads * sectors);
if (cylinders < 1 || cylinders > 16383)
continue;
*pheads = heads;
*psectors = sectors;
*pcylinders = cylinders;
#if 0
printf("guessed geometry: LCHS=%d %d %d\n",
cylinders, heads, sectors);
#endif
qemu_free(buf);
return 0;
}
}
qemu_free(buf);
return -1;
}
| 1threat
|
Unwrap inner type when enum variant is known : <p>I have this enum type:</p>
<pre><code>enum Animal {
Dog(i32),
Cat(u8),
}
</code></pre>
<p>Now I have a function that takes this type as parameter. I <em>know</em> (for some reason) that the input is always a <code>Cat</code>. I want to achieve this:</p>
<pre><code>fn count_legs_of_cat(animal: Animal) -> u8 {
if let Animal::Cat(c) = animal { c } else { unreachable!() }
}
</code></pre>
<p>Can I write this shorter and/or more idiomatic?</p>
| 0debug
|
static void test_dispatch_cmd(void)
{
QDict *req = qdict_new();
QObject *resp;
qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd")));
resp = qmp_dispatch(QOBJECT(req));
assert(resp != NULL);
assert(!qdict_haskey(qobject_to_qdict(resp), "error"));
g_print("\nresp: %s\n", qstring_get_str(qobject_to_json(resp)));
qobject_decref(resp);
QDECREF(req);
}
| 1threat
|
display data from sql database to html table in apache2 server : <p>I'm beginner in php and html so I need your help.
I am trying to display data from my sql database created using phpmyadmin , to a php page.</p>
<p>I've searched the internet and found similar topics , but still have problems</p>
<p>DB: wban ...</p>
<p>Table name: Jack ...</p>
<p>columns to be displayed: Temprature ,pulse , Motion ...</p>
<p>Here is my code , a blank page appear when request "localhost/Jack.php" </p>
<pre><code><?php
$conn=mysql_connect('localhost', 'root', 'MYPASSWORD');
mysql_select_db('wban');
if(! $conn ) {
die('Could not connect: ' . mysql_error());
}
$query = "SELECT * FROM Jack";
$result = mysql_query($query);
?>
<html>
<head> <title> Jack Status </title> </head>
<body>
<table width="600" border="1" cellpadding="1" cellspacing="1">
<tr> <!-- header row -->
<th>Data</th>
<th>Latest Readings</th>
<th>Average</th>
<th>Standard Deviation</th>
<th>Condition</th>
</tr>
<?php
while($row = mysql_fetch_assoc($result)){ //Create a loop to loop through results
echo "<tr>"
echo "<td>.$row['Temprature'].</td>"
echo "<td>.$row['Pulse'].</td>"
echo "<td>.$row['Motion'].</td>"
echo "</tr>"
}//end while
mysql_close(); //close out the database connection
?>
</table>
</body>
</html>
</code></pre>
| 0debug
|
static int ea_read_header(AVFormatContext *s)
{
EaDemuxContext *ea = s->priv_data;
AVStream *st;
if (process_ea_header(s)<=0)
return AVERROR(EIO);
if (init_video_stream(s, &ea->video) || init_video_stream(s, &ea->alpha))
return AVERROR(ENOMEM);
if (ea->audio_codec) {
if (ea->num_channels <= 0 || ea->num_channels > 2) {
av_log(s, AV_LOG_WARNING,
"Unsupported number of channels: %d\n", ea->num_channels);
ea->audio_codec = 0;
return 1;
}
if (ea->sample_rate <= 0) {
av_log(s, AV_LOG_ERROR,
"Unsupported sample rate: %d\n", ea->sample_rate);
ea->audio_codec = 0;
return 1;
}
if (ea->bytes <= 0) {
av_log(s, AV_LOG_ERROR,
"Invalid number of bytes per sample: %d\n", ea->bytes);
ea->audio_codec = AV_CODEC_ID_NONE;
return 1;
}
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 33, 1, ea->sample_rate);
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
st->codecpar->codec_id = ea->audio_codec;
st->codecpar->codec_tag = 0;
st->codecpar->channels = ea->num_channels;
st->codecpar->sample_rate = ea->sample_rate;
st->codecpar->bits_per_coded_sample = ea->bytes * 8;
st->codecpar->bit_rate = (int64_t)st->codecpar->channels *
st->codecpar->sample_rate *
st->codecpar->bits_per_coded_sample / 4;
st->codecpar->block_align = st->codecpar->channels *
st->codecpar->bits_per_coded_sample;
ea->audio_stream_index = st->index;
st->start_time = 0;
}
return 1;
}
| 1threat
|
Insert JSON object using jsonpath in javascript? : <p>Is there any way to insert a JSON object in the middle of another JSON object using jsonPath? I'm using Javascript in the Postman test script after I recieve a JSON object as a response, and I need to insert JSON data in the middle of the response. I can access the part of the response I want using "$..decision[0]". Is there a way to add data using "$..decision[1]" so that this:</p>
<pre><code> ...
"decision": [
{
"var1": 43,
"var2": 1,
}
],...
</code></pre>
<p>becomes this:</p>
<pre><code> ...
"decision": [
{
"var1": 43,
"var2": 1
},
{
"foo1": "true",
"foo2": "false"
}
],...
</code></pre>
<p>If I can't, is there another simple way to append data into the middle of a JSON object?</p>
| 0debug
|
Why I can't declare and run method in main method of Java class : <p>Probably I missed something during checking Java core, but please help me to understand why I cannot use method declared in java main method which is commented</p>
<pre><code>class R {
public int cal(int a, int b) {
return a + b;
}
public int cal3(int a, int b) {
return a * b;
}
}
public class Rect {
public static void main(String arg[]) {
/*public static int cal2 ( int a, int b){
return a + b;
}
int ab2 = cal2(2,2);
System.out.println(ab2);*/
R r = new R();
int ab = r.cal(2, 2);
System.out.println(ab);
int ab3 =r.cal3(2,3);
System.out.println(ab3);
}
}
</code></pre>
| 0debug
|
static av_cold int source_init(AVFilterContext *ctx, const char *args, void *opaque)
{
Frei0rContext *frei0r = ctx->priv;
char dl_name[1024], c;
char frame_size[128] = "";
char frame_rate[128] = "";
AVRational frame_rate_q;
memset(frei0r->params, 0, sizeof(frei0r->params));
if (args)
sscanf(args, "%127[^:]:%127[^:]:%1023[^:=]%c%255c",
frame_size, frame_rate, dl_name, &c, frei0r->params);
if (av_parse_video_size(&frei0r->w, &frei0r->h, frame_size) < 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid frame size: '%s'\n", frame_size);
return AVERROR(EINVAL);
}
if (av_parse_video_rate(&frame_rate_q, frame_rate) < 0 ||
frame_rate_q.den <= 0 || frame_rate_q.num <= 0) {
av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'\n", frame_rate);
return AVERROR(EINVAL);
}
frei0r->time_base.num = frame_rate_q.den;
frei0r->time_base.den = frame_rate_q.num;
return frei0r_init(ctx, dl_name, F0R_PLUGIN_TYPE_SOURCE);
}
| 1threat
|
Is if (condition) try {...} legal in C++? : <p>For example:</p>
<pre><code>if (true) try
{
// works as expected with both true and false, but is it legal?
}
catch (...)
{
// ...
}
</code></pre>
<p>In other words, is it legal to put the try-block <em>right after the if condition</em>?</p>
| 0debug
|
Can't reset list after change : <p>I have 10 elements List with 1 true and 9 false.</p>
<p>I want change last element for true and set rest to false.
I dont know why my code no works, in debug mode I set all for false, but in console i see 2x true.</p>
<p>My code is probably wrong:</p>
<pre><code>public class Test {
private static boolean a = true;
private static boolean b;
private static boolean c;
private static boolean d;
private static boolean e;
private static boolean a2;
private static boolean b2;
private static boolean c2;
private static boolean d2;
private static boolean e2;
private static List<Boolean> listOfBooleans = new LinkedList<>();
public static void main(String[] args) {
listOfBooleans.add(a);
listOfBooleans.add(b);
listOfBooleans.add(c);
listOfBooleans.add(d);
listOfBooleans.add(e);
listOfBooleans.add(a2);
listOfBooleans.add(b2);
listOfBooleans.add(c2);
listOfBooleans.add(d2);
listOfBooleans.add(e2);
for (Boolean listOfBoolean : listOfBooleans) {
System.out.println(listOfBoolean);
}
System.out.println("\n");
setOnlyOne(9);
for (Boolean listOfBoolean : listOfBooleans) {
System.out.println(listOfBoolean);
}
}
private static void setOnlyOne(int index){
for (Boolean listOfBoolean : listOfBooleans) {
listOfBoolean = false;
}
listOfBooleans.set(index, true);
}
}
</code></pre>
<p>What I should change here ?</p>
| 0debug
|
how to see times wrong math in questions : <p>how do i print the number of times the question was answer wrong?</p>
<pre><code>while 1:
math = input("(1) What Is 8 x 4 : ")
if not math.isdigit():
print("It's not number")
elif math == "32":
print("You Got The Question Correct")
break
else:
print("Sorry You Got The Question Wrong Try Again")
</code></pre>
| 0debug
|
static void vp56_decode_mb(VP56Context *s, int row, int col, int is_alpha)
{
AVFrame *frame_current, *frame_ref;
VP56mb mb_type;
VP56Frame ref_frame;
int b, ab, b_max, plane, off;
if (s->frames[VP56_FRAME_CURRENT]->key_frame)
mb_type = VP56_MB_INTRA;
else
mb_type = vp56_decode_mv(s, row, col);
ref_frame = ff_vp56_reference_frame[mb_type];
s->parse_coeff(s);
vp56_add_predictors_dc(s, ref_frame);
frame_current = s->frames[VP56_FRAME_CURRENT];
frame_ref = s->frames[ref_frame];
if (mb_type != VP56_MB_INTRA && !frame_ref->data[0])
return;
ab = 6*is_alpha;
b_max = 6 - 2*is_alpha;
switch (mb_type) {
case VP56_MB_INTRA:
for (b=0; b<b_max; b++) {
plane = ff_vp56_b2p[b+ab];
s->vp3dsp.idct_put(frame_current->data[plane] + s->block_offset[b],
s->stride[plane], s->block_coeff[b]);
}
break;
case VP56_MB_INTER_NOVEC_PF:
case VP56_MB_INTER_NOVEC_GF:
for (b=0; b<b_max; b++) {
plane = ff_vp56_b2p[b+ab];
off = s->block_offset[b];
s->hdsp.put_pixels_tab[1][0](frame_current->data[plane] + off,
frame_ref->data[plane] + off,
s->stride[plane], 8);
s->vp3dsp.idct_add(frame_current->data[plane] + off,
s->stride[plane], s->block_coeff[b]);
}
break;
case VP56_MB_INTER_DELTA_PF:
case VP56_MB_INTER_V1_PF:
case VP56_MB_INTER_V2_PF:
case VP56_MB_INTER_DELTA_GF:
case VP56_MB_INTER_4V:
case VP56_MB_INTER_V1_GF:
case VP56_MB_INTER_V2_GF:
for (b=0; b<b_max; b++) {
int x_off = b==1 || b==3 ? 8 : 0;
int y_off = b==2 || b==3 ? 8 : 0;
plane = ff_vp56_b2p[b+ab];
vp56_mc(s, b, plane, frame_ref->data[plane], s->stride[plane],
16*col+x_off, 16*row+y_off);
s->vp3dsp.idct_add(frame_current->data[plane] + s->block_offset[b],
s->stride[plane], s->block_coeff[b]);
}
break;
}
if (is_alpha) {
s->block_coeff[4][0] = 0;
s->block_coeff[5][0] = 0;
}
}
| 1threat
|
static void hls_decode_neighbour(HEVCContext *s, int x_ctb, int y_ctb,
int ctb_addr_ts)
{
HEVCLocalContext *lc = &s->HEVClc;
int ctb_size = 1 << s->ps.sps->log2_ctb_size;
int ctb_addr_rs = s->ps.pps->ctb_addr_ts_to_rs[ctb_addr_ts];
int ctb_addr_in_slice = ctb_addr_rs - s->sh.slice_addr;
s->tab_slice_address[ctb_addr_rs] = s->sh.slice_addr;
if (s->ps.pps->entropy_coding_sync_enabled_flag) {
if (x_ctb == 0 && (y_ctb & (ctb_size - 1)) == 0)
lc->first_qp_group = 1;
lc->end_of_tiles_x = s->ps.sps->width;
} else if (s->ps.pps->tiles_enabled_flag) {
if (ctb_addr_ts && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[ctb_addr_ts - 1]) {
int idxX = s->ps.pps->col_idxX[x_ctb >> s->ps.sps->log2_ctb_size];
lc->start_of_tiles_x = x_ctb;
lc->end_of_tiles_x = x_ctb + (s->ps.pps->column_width[idxX] << s->ps.sps->log2_ctb_size);
lc->first_qp_group = 1;
}
} else {
lc->end_of_tiles_x = s->ps.sps->width;
}
lc->end_of_tiles_y = FFMIN(y_ctb + ctb_size, s->ps.sps->height);
lc->boundary_flags = 0;
if (s->ps.pps->tiles_enabled_flag) {
if (x_ctb > 0 && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs - 1]])
lc->boundary_flags |= BOUNDARY_LEFT_TILE;
if (x_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - 1])
lc->boundary_flags |= BOUNDARY_LEFT_SLICE;
if (y_ctb > 0 && s->ps.pps->tile_id[ctb_addr_ts] != s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs - s->ps.sps->ctb_width]])
lc->boundary_flags |= BOUNDARY_UPPER_TILE;
if (y_ctb > 0 && s->tab_slice_address[ctb_addr_rs] != s->tab_slice_address[ctb_addr_rs - s->ps.sps->ctb_width])
lc->boundary_flags |= BOUNDARY_UPPER_SLICE;
} else {
if (!ctb_addr_in_slice > 0)
lc->boundary_flags |= BOUNDARY_LEFT_SLICE;
if (ctb_addr_in_slice < s->ps.sps->ctb_width)
lc->boundary_flags |= BOUNDARY_UPPER_SLICE;
}
lc->ctb_left_flag = ((x_ctb > 0) && (ctb_addr_in_slice > 0) && !(lc->boundary_flags & BOUNDARY_LEFT_TILE));
lc->ctb_up_flag = ((y_ctb > 0) && (ctb_addr_in_slice >= s->ps.sps->ctb_width) && !(lc->boundary_flags & BOUNDARY_UPPER_TILE));
lc->ctb_up_right_flag = ((y_ctb > 0) && (ctb_addr_in_slice+1 >= s->ps.sps->ctb_width) && (s->ps.pps->tile_id[ctb_addr_ts] == s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs+1 - s->ps.sps->ctb_width]]));
lc->ctb_up_left_flag = ((x_ctb > 0) && (y_ctb > 0) && (ctb_addr_in_slice-1 >= s->ps.sps->ctb_width) && (s->ps.pps->tile_id[ctb_addr_ts] == s->ps.pps->tile_id[s->ps.pps->ctb_addr_rs_to_ts[ctb_addr_rs-1 - s->ps.sps->ctb_width]]));
}
| 1threat
|
proper way to run kotlin application from gradle task : <p>I've got simple script</p>
<pre><code>package com.lapots.game.journey.ims.example
fun main(args: Array<String>) {
println("Hello, world!")
}
</code></pre>
<p>And here is <code>gradle</code> task </p>
<pre><code>task runExample(type: JavaExec) {
main ='com.lapots.game.journey.ims.example.Example'
classpath = sourceSets.main.runtimeClasspath
}
</code></pre>
<p>But when I try to run task <code>gradle runExample</code> I get error</p>
<p><code>Error: Could not find or load main class com.lapots.game.journey.ims.example.Example</code></p>
<p>What is the proper way to run application?</p>
| 0debug
|
request for member ... which is of non-class type : <p>I get the error </p>
<pre><code>main.cpp: In function 'int main()':
main.cpp:43:16: error: request for member 'getF' in 'cor', which is of non-class type 'corMatrixFermion(MatrixV)'
myfile << cor.getF;
^
</code></pre>
<p>Here is the Header of my class:</p>
<pre><code>class MatrixV{
public:
MatrixV(std::string file);
MatrixV(Eigen::MatrixXd matrix);
MatrixV(double arr[], int arrsize);
Eigen::MatrixXd getV();
Eigen::VectorXd getSigma();
int getr();
Eigen::MatrixXd getO1();
Eigen::MatrixXd getO2();
Eigen::MatrixXd getE();
Eigen::MatrixXd getVStrich();
private:
int size;
Eigen::MatrixXd V;
Eigen::VectorXd Sigma;
int r;
Eigen::JacobiSVD<Eigen::MatrixXd, Eigen::NoQRPreconditioner> svd;
};
</code></pre>
<p>And here the main.cpp</p>
<pre><code>int main(){
std::srand(time(0));
DataFromFile StartValues("StartValues");
double arr[4];
arr[0] = StartValues.get(1);
arr[1] = StartValues.get(2);
arr[2] = StartValues.get(3);
arr[3] = StartValues.get(4);
MatrixV V(arr, 4);
corMatrixFermion cor(MatrixV V);
std::ofstream myfile;
myfile.open ("corfunction.txt");
myfile << cor.getF();
myfile.close();
}
</code></pre>
<p>There are other classes involved, but I dont think, that they cause the problem. Do you see, what I'm doing wrong? If you need more information please tell me. It seems to me, that it is not the usual "request for member"-constructor-problem. But maybe I'm wrong...</p>
| 0debug
|
AJAX request fails when sending FormData() including empty file input in Safari 10.13.4 : <p>I am running a Symfony 2.8 based web app which sends some form data back to a controller using Ajax.</p>
<p>So far everything worked fine, but since the latest macOS update to version 10.13.4 users start to report, that submitting the form does not work anymore in Safari. Other macOS Versions and other browsers on 10.13.4 still work fine, so it seems to be a problem in Safari. Of course I filed a bug report to Apple, but I do not think, that I will ever get feedback from there...</p>
<p>I was able to isolate the source of the problem: Submitting data which includes an empty file input fails:</p>
<pre><code>// safri_bug.html
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<form name="app_booking" method="post" action="/test/submit.php">
<div><input type="text" id="someValue" name="value"></div>
<div><input id="thefile" type="file" name="file"></div>
</form>
<button id="bSubmit" type="button">Submit</button>
<script>
$(document).ready(function() {
$('#bSubmit').click(function() {
var form = $('form');
var data = new FormData(form[0]);
$.ajax({
url : '/submit.php',
type : 'POST',
data : data,
contentType: false,
processData: false,
context : this,
success : function(response) {
alert('success: ' + response);
},
error: function (xhr, ajaxOptions, thrownError) {
alert('error: ' + xhr.responseText + ' - ' + thrownError);
}
});
});
});
</script>
</body>
</html>
// submit.php
<?php
echo "OK";
</code></pre>
<p><strong>Result</strong></p>
<ul>
<li>Submitting the form works fine on all tested browsers and platforms but in Safari in macOS 10.13.4</li>
<li>In Safari on macOS 10.13.4:
<ul>
<li>If not file is selected: The Ajax request runs for about 20 seconds (build in timeout?) and than returns with an empty sucess response. The <code>submit.php</code> does <strong>NOT</strong> get called. </li>
<li>If a file was selected: Everything works fine...</li>
</ul></li>
</ul>
<p><strong>So, this seems to be a bug in the latest Safari update? Or is there anything wrong with my code?</strong></p>
<p>Any idea how to prevent this bug?</p>
| 0debug
|
Does Vue, by default, provide security for or protects against XSS? : <p>I am trying to figure out how to protect,</p>
<ul>
<li>Angular</li>
<li>Vue</li>
<li>React</li>
</ul>
<p>against XSS attacks. When I visit the Angular official docs,</p>
<p><a href="https://angular.io/guide/security" rel="noreferrer">https://angular.io/guide/security</a></p>
<p>, it says:</p>
<blockquote>
<p>To systematically block XSS bugs, Angular treats all values as
untrusted by default. When a value is inserted into the DOM from a
template, via property, attribute, style, class binding, or
interpolation, Angular sanitizes and escapes untrusted values.</p>
</blockquote>
<p>and also:</p>
<blockquote>
<p>Angular sanitizes untrusted values for HTML, styles, and URLs;
sanitizing resource URLs isn't possible because they contain arbitrary
code. In development mode, Angular prints a console warning when it
has to change a value during sanitization.</p>
</blockquote>
<p>and:</p>
<blockquote>
<p>Angular recognizes the value as unsafe and automatically sanitizes it,
which removes the tag but keeps safe content such as the
element.</p>
</blockquote>
<p>When I go to the React official docs,</p>
<p><a href="https://reactjs.org/docs/introducing-jsx.html#jsx-prevents-injection-attacks" rel="noreferrer">https://reactjs.org/docs/introducing-jsx.html#jsx-prevents-injection-attacks</a></p>
<p>,it says the following:</p>
<blockquote>
<p>It is safe to embed user input in JSX:</p>
</blockquote>
<p>and:</p>
<blockquote>
<p>By default, React DOM escapes any values embedded in JSX before
rendering them. Thus it ensures that you can never inject anything
that’s not explicitly written in your application. Everything is
converted to a string before being rendered. This helps prevent XSS
(cross-site-scripting) attacks.</p>
</blockquote>
<p>But for Vue, I cannot find anything in their docs about XSS protection, or anything that they could provide by default. </p>
<p><strong>My question:</strong> Does Vue, by default, deliver any way of protection against XSS attacks, or would I need to look for a 3rd party solution?</p>
<p>When I Google for this subject I get a lot of blog posts sites and articles refering to, for example, this project to sanitize my HTML:</p>
<p><a href="https://github.com/punkave/sanitize-html" rel="noreferrer">https://github.com/punkave/sanitize-html</a></p>
| 0debug
|
How to make connections between windows form application and barcode reader in C# windows form application : I want to get input from barcode reader in specific text box which is disabled I don’t have any idea to do something so I have few problems
1. I need the library name which .Net framework has for barcode scanner
2. how can I get the input from barcode scanner in a specific text box which is already disabled and also it is visibility is false
| 0debug
|
def opposite_Signs(x,y):
return ((x ^ y) < 0);
| 0debug
|
void nbd_client_put(NBDClient *client)
{
if (--client->refcount == 0) {
assert(client->closing);
nbd_unset_handlers(client);
close(client->sock);
client->sock = -1;
if (client->exp) {
QTAILQ_REMOVE(&client->exp->clients, client, next);
nbd_export_put(client->exp);
}
g_free(client);
}
}
| 1threat
|
Why does Spark job fail with "Exit code: 52" : <p>I have had Spark job failing with a trace like this one:</p>
<pre><code>./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr-Container id: container_1455622885057_0016_01_000008
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr-Exit code: 52
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr:Stack trace: ExitCodeException exitCode=52:
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr- at org.apache.hadoop.util.Shell.runCommand(Shell.java:545)
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr- at org.apache.hadoop.util.Shell.run(Shell.java:456)
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr- at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:722)
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr- at org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor.launchContainer(DefaultContainerExecutor.java:211)
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr- at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:302)
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr- at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:82)
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr- at java.util.concurrent.FutureTask.run(FutureTask.java:262)
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr- at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr- at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr- at java.lang.Thread.run(Thread.java:745)
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr-
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr-
./containers/application_1455622885057_0016/container_1455622885057_0016_01_000001/stderr-Container exited with a non-zero exit code 52
</code></pre>
<p>It took me a while to figure out what "exit code 52" means, so I'm putting this up here for the benefit of others who might be searching</p>
| 0debug
|
static int no_init_out (HWVoiceOut *hw, audsettings_t *as)
{
audio_pcm_init_info (&hw->info, as);
hw->samples = 1024;
return 0;
}
| 1threat
|
Android : Window Manager : android view window leaked : <p>Right after I fix my first problem this one comes up :( please help me fix it..</p>
<blockquote>
<p>03-02 12:47:02.785 9439-9439/com.ucu.ccs.classrecord
E/WindowManager﹕ android.view.WindowLeaked: Activity
com.ucu.ccs.classrecord.Login has leaked window
com.android.internal.policy.impl.PhoneWindow$DecorView{6d17cc4
V.E..... R......D 0,0-1002,348} that was originally added here
at android.view.ViewRootImpl.(ViewRootImpl.java:465)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:277)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.app.Dialog.show(Dialog.java:312)
at com.ucu.ccs.classrecord.Login$AttemptLogin.onPreExecute(Login.java:158)
at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587)
at android.os.AsyncTask.execute(AsyncTask.java:535)
at com.ucu.ccs.classrecord.Login.isOnline(Login.java:113)
at com.ucu.ccs.classrecord.Login$1.onClick(Login.java:73)
at android.view.View.performClick(View.java:5197)
at android.view.View$PerformClick.run(View.java:20926)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:5942)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)</p>
</blockquote>
<p>here is my code:</p>
<pre><code>buttonLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String instructor_id = editUser.getText().toString().trim();
String password = editPass.getText().toString().trim();
SharedPreferences preferences = getSharedPreferences("MyApp", MODE_PRIVATE);
preferences.edit().putString("password", password).commit();
preferences.edit().putString("inst_id", instructor_id).commit();
if (editUser.getText().toString().equals("") || editPass.getText().toString().equals("")){
Toast.makeText(getApplicationContext(),"Please enter Instructor ID and Password", Toast.LENGTH_LONG).show();
}else {
isOnline();
}
}
});
public boolean isOnline(){
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.isConnectedOrConnecting()){
new AttemptLogin().execute();
}else {
checkInternet();
}
return false;
}
class AttemptLogin extends AsyncTask<String, String, String> {
boolean failure = false;
String inst_id = editUser.getText().toString();
String password = editPass.getText().toString();
@Override
protected void onPreExecute() {
super.onPreExecute();
pDialog = new ProgressDialog(Login.this);
pDialog.setMessage("Attempting login...");
pDialog.setIndeterminate(false);
pDialog.setCancelable(true);
pDialog.show();
}
@Override
protected String doInBackground(String... params) {
int success;
try{
List<NameValuePair> mList = new ArrayList<NameValuePair>();
mList.add(new BasicNameValuePair("instructor_id", inst_id));
mList.add(new BasicNameValuePair("password", password));
Log.d("request!", "starting");
JSONObject json = jsonParser.makeHttpRequest(LOGIN_URL, "POST", mList);
Log.d("Login attempt", json.toString());
success = json.getInt(TAG_SUCCESS);
if (success == 1) {
Log.d("Login Successful!", json.toString());
Intent i = new Intent(Login.this, MainActivity.class);
startActivity(i);
//finish();
return json.getString(TAG_MESSAGE);
}else{
Log.d("Login Failure!", json.getString(TAG_MESSAGE));
return json.getString(TAG_MESSAGE);
}
}catch (JSONException e){
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
session.setLogin(true);
pDialog.dismiss();
if (s != null){
Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
}
}
}
</code></pre>
| 0debug
|
void av_set_cpu_flags_mask(int mask)
{
checked = 0;
flags = av_get_cpu_flags() & mask;
checked = 1;
}
| 1threat
|
static void x86_cpu_parse_featurestr(CPUState *cs, char *features,
Error **errp)
{
X86CPU *cpu = X86_CPU(cs);
char *featurestr;
FeatureWordArray plus_features = { 0 };
FeatureWordArray minus_features = { 0 };
uint32_t numvalue;
CPUX86State *env = &cpu->env;
Error *local_err = NULL;
featurestr = features ? strtok(features, ",") : NULL;
while (featurestr) {
char *val;
if (featurestr[0] == '+') {
add_flagname_to_bitmaps(featurestr + 1, plus_features);
} else if (featurestr[0] == '-') {
add_flagname_to_bitmaps(featurestr + 1, minus_features);
} else if ((val = strchr(featurestr, '='))) {
*val = 0; val++;
feat2prop(featurestr);
if (!strcmp(featurestr, "xlevel")) {
char *err;
char num[32];
numvalue = strtoul(val, &err, 0);
if (!*val || *err) {
error_setg(&local_err, "bad numerical value %s", val);
goto out;
}
if (numvalue < 0x80000000) {
error_report("xlevel value shall always be >= 0x80000000"
", fixup will be removed in future versions");
numvalue += 0x80000000;
}
snprintf(num, sizeof(num), "%" PRIu32, numvalue);
object_property_parse(OBJECT(cpu), num, featurestr, &local_err);
} else if (!strcmp(featurestr, "tsc-freq")) {
int64_t tsc_freq;
char *err;
char num[32];
tsc_freq = strtosz_suffix_unit(val, &err,
STRTOSZ_DEFSUFFIX_B, 1000);
if (tsc_freq < 0 || *err) {
error_setg(&local_err, "bad numerical value %s", val);
goto out;
}
snprintf(num, sizeof(num), "%" PRId64, tsc_freq);
object_property_parse(OBJECT(cpu), num, "tsc-frequency",
&local_err);
} else if (!strcmp(featurestr, "hv-spinlocks")) {
char *err;
const int min = 0xFFF;
char num[32];
numvalue = strtoul(val, &err, 0);
if (!*val || *err) {
error_setg(&local_err, "bad numerical value %s", val);
goto out;
}
if (numvalue < min) {
error_report("hv-spinlocks value shall always be >= 0x%x"
", fixup will be removed in future versions",
min);
numvalue = min;
}
snprintf(num, sizeof(num), "%" PRId32, numvalue);
object_property_parse(OBJECT(cpu), num, featurestr, &local_err);
} else {
object_property_parse(OBJECT(cpu), val, featurestr, &local_err);
}
} else {
feat2prop(featurestr);
object_property_parse(OBJECT(cpu), "on", featurestr, &local_err);
}
if (local_err) {
error_propagate(errp, local_err);
goto out;
}
featurestr = strtok(NULL, ",");
}
env->features[FEAT_1_EDX] |= plus_features[FEAT_1_EDX];
env->features[FEAT_1_ECX] |= plus_features[FEAT_1_ECX];
env->features[FEAT_8000_0001_EDX] |= plus_features[FEAT_8000_0001_EDX];
env->features[FEAT_8000_0001_ECX] |= plus_features[FEAT_8000_0001_ECX];
env->features[FEAT_C000_0001_EDX] |= plus_features[FEAT_C000_0001_EDX];
env->features[FEAT_KVM] |= plus_features[FEAT_KVM];
env->features[FEAT_SVM] |= plus_features[FEAT_SVM];
env->features[FEAT_7_0_EBX] |= plus_features[FEAT_7_0_EBX];
env->features[FEAT_1_EDX] &= ~minus_features[FEAT_1_EDX];
env->features[FEAT_1_ECX] &= ~minus_features[FEAT_1_ECX];
env->features[FEAT_8000_0001_EDX] &= ~minus_features[FEAT_8000_0001_EDX];
env->features[FEAT_8000_0001_ECX] &= ~minus_features[FEAT_8000_0001_ECX];
env->features[FEAT_C000_0001_EDX] &= ~minus_features[FEAT_C000_0001_EDX];
env->features[FEAT_KVM] &= ~minus_features[FEAT_KVM];
env->features[FEAT_SVM] &= ~minus_features[FEAT_SVM];
env->features[FEAT_7_0_EBX] &= ~minus_features[FEAT_7_0_EBX];
out:
return;
}
| 1threat
|
static void *oss_audio_init (void)
{
OSSConf *conf = g_malloc(sizeof(OSSConf));
*conf = glob_conf;
if (access(conf->devpath_in, R_OK | W_OK) < 0 ||
access(conf->devpath_out, R_OK | W_OK) < 0) {
return NULL;
}
return conf;
}
| 1threat
|
static inline void MPV_motion_lowres(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
int dir, uint8_t **ref_picture,
h264_chroma_mc_func *pix_op)
{
int mx, my;
int mb_x, mb_y, i;
const int lowres= s->avctx->lowres;
const int block_s= 8>>lowres;
mb_x = s->mb_x;
mb_y = s->mb_y;
switch(s->mv_type) {
case MV_TYPE_16X16:
mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
0, 0, 0,
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 2*block_s);
break;
case MV_TYPE_8X8:
mx = 0;
my = 0;
for(i=0;i<4;i++) {
hpel_motion_lowres(s, dest_y + ((i & 1) + (i >> 1) * s->linesize)*block_s,
ref_picture[0], 0, 0,
(2*mb_x + (i & 1))*block_s, (2*mb_y + (i >>1))*block_s,
s->width, s->height, s->linesize,
s->h_edge_pos >> lowres, s->v_edge_pos >> lowres,
block_s, block_s, pix_op,
s->mv[dir][i][0], s->mv[dir][i][1]);
mx += s->mv[dir][i][0];
my += s->mv[dir][i][1];
}
if(!(s->flags&CODEC_FLAG_GRAY))
chroma_4mv_motion_lowres(s, dest_cb, dest_cr, ref_picture, pix_op, mx, my);
break;
case MV_TYPE_FIELD:
if (s->picture_structure == PICT_FRAME) {
mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
1, 0, s->field_select[dir][0],
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], block_s);
mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
1, 1, s->field_select[dir][1],
ref_picture, pix_op,
s->mv[dir][1][0], s->mv[dir][1][1], block_s);
} else {
if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != B_TYPE && !s->first_field){
ref_picture= s->current_picture_ptr->data;
}
mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
0, 0, s->field_select[dir][0],
ref_picture, pix_op,
s->mv[dir][0][0], s->mv[dir][0][1], 2*block_s);
}
break;
case MV_TYPE_16X8:
for(i=0; i<2; i++){
uint8_t ** ref2picture;
if(s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == B_TYPE || s->first_field){
ref2picture= ref_picture;
}else{
ref2picture= s->current_picture_ptr->data;
}
mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
0, 0, s->field_select[dir][i],
ref2picture, pix_op,
s->mv[dir][i][0], s->mv[dir][i][1] + 2*block_s*i, block_s);
dest_y += 2*block_s*s->linesize;
dest_cb+= (2*block_s>>s->chroma_y_shift)*s->uvlinesize;
dest_cr+= (2*block_s>>s->chroma_y_shift)*s->uvlinesize;
}
break;
case MV_TYPE_DMV:
if(s->picture_structure == PICT_FRAME){
for(i=0; i<2; i++){
int j;
for(j=0; j<2; j++){
mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
1, j, j^i,
ref_picture, pix_op,
s->mv[dir][2*i + j][0], s->mv[dir][2*i + j][1], block_s);
}
pix_op = s->dsp.avg_h264_chroma_pixels_tab;
}
}else{
for(i=0; i<2; i++){
mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
0, 0, s->picture_structure != i+1,
ref_picture, pix_op,
s->mv[dir][2*i][0],s->mv[dir][2*i][1],2*block_s);
pix_op = s->dsp.avg_h264_chroma_pixels_tab;
if(!s->first_field){
ref_picture = s->current_picture_ptr->data;
}
}
}
break;
default: assert(0);
}
}
| 1threat
|
In this C Programming language code it throws an error What is the reasons? : #include<stdio.h>
int main(){
int i=0,j=1;
printf("%d",++(i+j));
return 0;
}
In this code i have used increment operator but i don't know why it throws an error. It throws an error lvalue is required.
| 0debug
|
Namespace .AspNetCore.Hosting vs .Extensions.Hosting : <p>In my ASP.NET Core 2.0 project, I've been using IHostingEnvironment and IApplicationLifetime from Microsoft.Extensions.Hosting namespace.</p>
<p>In ASP.NET Core 2.1, these interfaces seem to be in both Microsoft.AspNetCore.Hosting and Microsoft.Extensions.Hosting namespaces. What is the difference and which namespace should I be using?</p>
<p>FYI, I am also using BackgroundService class which is now (Core 2.1) in Microsoft.Extensions.Hosting namespace.</p>
| 0debug
|
static int url_connect(struct variant *var, AVDictionary *opts)
{
AVDictionary *tmp = NULL;
int ret;
av_dict_copy(&tmp, opts, 0);
av_opt_set_dict(var->input, &tmp);
if ((ret = ffurl_connect(var->input, NULL)) < 0) {
ffurl_close(var->input);
var->input = NULL;
}
av_dict_free(&tmp);
return ret;
}
| 1threat
|
refernce variable pointing to another object : There is an interface with Named Bank and it has two implementing classes Named ABC and XYZ and there is a main method
public class Tester2 { public static void main(String[] args) {
// i/f ref can directly refer to ANY concrete imple cls instance Bank ref = new ABC();// up casting
ref.withdraw(123, 345);//DMD
// ref.payBills(); ((ABC) ref).payBills();
ref = new XYZ();
if (ref instanceof ABC) ((ABC) ref).payBills(); else System.out.println("Wrong Bank!!!!"); } } so my question is Now ref has type ABC and the value of ref is overriden by XYZ.so how can the instance of ref be ABC
| 0debug
|
C# | Best way to read file into byte array in selected encoding? : Now i use something like that:
Encoding.UTF8.GetBytes(File.ReadAllText(filename))
Any suggestions how to do that better?
And what encoding uses `File.ReadAllBytes(filename)` method?
P.S. I need utf-8 byte arrays to store files in db
| 0debug
|
static uint64_t pit_ioport_read(void *opaque, hwaddr addr,
unsigned size)
{
PITCommonState *pit = opaque;
int ret, count;
PITChannelState *s;
addr &= 3;
s = &pit->channels[addr];
if (s->status_latched) {
s->status_latched = 0;
ret = s->status;
} else if (s->count_latched) {
switch(s->count_latched) {
default:
case RW_STATE_LSB:
ret = s->latched_count & 0xff;
s->count_latched = 0;
break;
case RW_STATE_MSB:
ret = s->latched_count >> 8;
s->count_latched = 0;
break;
case RW_STATE_WORD0:
ret = s->latched_count & 0xff;
s->count_latched = RW_STATE_MSB;
break;
} else {
switch(s->read_state) {
default:
case RW_STATE_LSB:
count = pit_get_count(s);
ret = count & 0xff;
break;
case RW_STATE_MSB:
count = pit_get_count(s);
ret = (count >> 8) & 0xff;
break;
case RW_STATE_WORD0:
count = pit_get_count(s);
ret = count & 0xff;
s->read_state = RW_STATE_WORD1;
break;
case RW_STATE_WORD1:
count = pit_get_count(s);
ret = (count >> 8) & 0xff;
s->read_state = RW_STATE_WORD0;
break;
return ret;
| 1threat
|
After Importing Spatial datbase to QGIS,How to analyze the data on Google Maps? : I have imported Database
(Point Feature) to QGIS,able to see the points on google Erath.
How to get the each point details with some programming language.
Is there any chance to use C#??
| 0debug
|
PHP preg_match_all hashtags : I'm having problems figuring out the right syntax for the search (preg_match_all("THIS PART", $my_string) )
I need to find all hashtags in my string with the word after the hashtag included aswell.
So, these would be found by the preg :<br>
<b>\#hi im like typing text right here hihih \#asdasdasdasd \#</b>
<br>
\#hi<br>
\#asasdasdasdasd
<br>
<br>
<b>\#asd\#asd xd so fun lol \#lol</b><br>
\#asd\#asd2 would be two seperate matches and \#lol would be matched aswell.
I hope the question made sense and thanks beforehand!
| 0debug
|
I am geeting an error in my code, please help me out : I am trying to write a code for my python programming online course. However, I am getting an error :
*** ERROR: Failed to display hand correctly - be sure 'Current Hand' and the display of the hand are on the same line! ***
Here is my code :
def playHand(hand, wordList, n):
total = 0
while True:
print("\nCurrent Hand:",)
displayHand(hand)
entered = input('Enter word, or a "." to indicate that you are finished: ')
if entered == '.':
print ("Goodbye! Total score: " + str(total) +" points.")
break
if isValidWord(entered, hand, wordList) == False:
print ("Invalid word, please try again.")
else:
total += getWordScore(entered, n)
print (str(entered), "earned", getWordScore(entered,n), "points. Total:", str(total))
hand = updateHand(hand, entered)
if calculateHandlen(hand) == 0:
print ("\nRun out of letters. Total score: " + str(total) +" points.")
break
| 0debug
|
Can someone explain descendantFocusability = afterDescendants? : <p>I'm having hard time understanding <code>descendantFocusability</code>. Very particulary <code>afterDescendants</code>.</p>
<p>Could someone show me an example of when this would be useful?</p>
| 0debug
|
ALGUIN ME PUEDE DECIR EL ERROR AL CREAR EL USUARIO? : CREATE USER PEDRO
IDENTIFIED BY USER BDT02
DEFAULT TABLESPACE CURSOS
TEMPORARY TABLESPACE CURSOS
QUOTA 10M ON CURSOS
QUOTA UNLIMITED ON CURSOS
| 0debug
|
C#, OpenXML and replacing text in the document : I open document and copy to the stream.
How I can replace some text in document before stream?
//wordTemplate - var with path to my word template
byte[] result = null;
byte[] templateBytes = System.IO.File.ReadAllBytes(wordTemplate);
using (MemoryStream templateStream = new MemoryStream())
{
templateStream.Write(templateBytes, 0, (int)templateBytes.Length);
using (WordprocessingDocument doc = WordprocessingDocument.Open(templateStream, true))
{
MainDocumentPart mainPart = doc.MainDocumentPart;
mainPart.Document.Save();
templateStream.Position = 0;
using (MemoryStream memoryStream = new MemoryStream())
{
templateStream.CopyTo(memoryStream);
result = memoryStream.ToArray();
}
}
}
| 0debug
|
React Native - ReactNavigation.addNavigationHelpers in not a function : <p>I was using react-navigation 1.2.1 and every thing was working fine as soon as I updated react-navigation to 2.0.0 it gives the following error. Any idea why it must be happening?</p>
<blockquote>
<p>ReactNavigation.addNavigationHelpers in not a function.</p>
</blockquote>
<pre><code>import * as ReactNavigation from 'react-navigation';
render() {
const { dispatch, nav } = this.props;
const navigation = ReactNavigation.addNavigationHelpers({
dispatch,
state: nav,
addListener,
});
return <AppNavigation navigation={navigation} />;
}
//"react-navigation": "2.0.0",
//"react-native": "0.53.3",
//"redux": "^3.7.2"
</code></pre>
| 0debug
|
static int common_bind(struct common *c)
{
uint64_t mfn;
if (xenstore_read_fe_uint64(&c->xendev, "page-ref", &mfn) == -1)
return -1;
assert(mfn == (xen_pfn_t)mfn);
if (xenstore_read_fe_int(&c->xendev, "event-channel", &c->xendev.remote_port) == -1)
return -1;
c->page = xc_map_foreign_range(xen_xc, c->xendev.dom,
XC_PAGE_SIZE,
PROT_READ | PROT_WRITE, mfn);
if (c->page == NULL)
return -1;
xen_be_bind_evtchn(&c->xendev);
xen_be_printf(&c->xendev, 1, "ring mfn %"PRIx64", remote-port %d, local-port %d\n",
mfn, c->xendev.remote_port, c->xendev.local_port);
return 0;
}
| 1threat
|
static int decode_band(IVI5DecContext *ctx, int plane_num,
IVIBandDesc *band, AVCodecContext *avctx)
{
int result, i, t, idx1, idx2;
IVITile *tile;
uint16_t chksum;
band->buf = band->bufs[ctx->dst_buf];
band->ref_buf = band->bufs[ctx->ref_buf];
band->data_ptr = ctx->frame_data + (get_bits_count(&ctx->gb) >> 3);
result = decode_band_hdr(ctx, band, avctx);
if (result) {
av_log(avctx, AV_LOG_ERROR, "Error while decoding band header: %d\n",
result);
return -1;
}
if (band->is_empty) {
av_log(avctx, AV_LOG_ERROR, "Empty band encountered!\n");
return -1;
}
band->rv_map = &ctx->rvmap_tabs[band->rvmap_sel];
for (i = 0; i < band->num_corr; i++) {
idx1 = band->corr[i*2];
idx2 = band->corr[i*2+1];
FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
}
for (t = 0; t < band->num_tiles; t++) {
tile = &band->tiles[t];
tile->is_empty = get_bits1(&ctx->gb);
if (tile->is_empty) {
ff_ivi_process_empty_tile(avctx, band, tile,
(ctx->planes[0].bands[0].mb_size >> 3) - (band->mb_size >> 3));
align_get_bits(&ctx->gb);
} else {
tile->data_size = ff_ivi_dec_tile_data_size(&ctx->gb);
result = decode_mb_info(ctx, band, tile, avctx);
if (result < 0)
break;
if (band->blk_size == 8) {
band->intra_base = &ivi5_base_quant_8x8_intra[band->quant_mat][0];
band->inter_base = &ivi5_base_quant_8x8_inter[band->quant_mat][0];
band->intra_scale = &ivi5_scale_quant_8x8_intra[band->quant_mat][0];
band->inter_scale = &ivi5_scale_quant_8x8_inter[band->quant_mat][0];
} else {
band->intra_base = ivi5_base_quant_4x4_intra;
band->inter_base = ivi5_base_quant_4x4_inter;
band->intra_scale = ivi5_scale_quant_4x4_intra;
band->inter_scale = ivi5_scale_quant_4x4_inter;
}
result = ff_ivi_decode_blocks(&ctx->gb, band, tile);
if (result < 0) {
av_log(avctx, AV_LOG_ERROR, "Corrupted blocks data encountered!\n");
break;
}
}
}
for (i = band->num_corr-1; i >= 0; i--) {
idx1 = band->corr[i*2];
idx2 = band->corr[i*2+1];
FFSWAP(uint8_t, band->rv_map->runtab[idx1], band->rv_map->runtab[idx2]);
FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
}
if (IVI_DEBUG && band->checksum_present) {
chksum = ivi_calc_band_checksum(band);
if (chksum != band->checksum) {
av_log(avctx, AV_LOG_ERROR,
"Band checksum mismatch! Plane %d, band %d, received: %x, calculated: %x\n",
band->plane, band->band_num, band->checksum, chksum);
}
}
return result;
}
| 1threat
|
static void test_server_free(TestServer *server)
{
int i;
qemu_chr_delete(server->chr);
for (i = 0; i < server->fds_num; i++) {
close(server->fds[i]);
}
if (server->log_fd != -1) {
close(server->log_fd);
}
unlink(server->socket_path);
g_free(server->socket_path);
g_free(server->chr_name);
g_free(server);
}
| 1threat
|
static void vtd_iommu_replay(MemoryRegion *mr, IOMMUNotifier *n)
{
VTDAddressSpace *vtd_as = container_of(mr, VTDAddressSpace, iommu);
IntelIOMMUState *s = vtd_as->iommu_state;
uint8_t bus_n = pci_bus_num(vtd_as->bus);
VTDContextEntry ce;
if (vtd_dev_to_context_entry(s, bus_n, vtd_as->devfn, &ce) == 0) {
trace_vtd_replay_ce_valid(bus_n, PCI_SLOT(vtd_as->devfn),
PCI_FUNC(vtd_as->devfn),
VTD_CONTEXT_ENTRY_DID(ce.hi),
ce.hi, ce.lo);
vtd_page_walk(&ce, 0, ~0ULL, vtd_replay_hook, (void *)n);
} else {
trace_vtd_replay_ce_invalid(bus_n, PCI_SLOT(vtd_as->devfn),
PCI_FUNC(vtd_as->devfn));
}
return;
}
| 1threat
|
static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
{
HLSContext *hls = s->priv_data;
AVFormatContext *oc = NULL;
AVStream *st = s->streams[pkt->stream_index];
int64_t end_pts = 0;
int is_ref_pkt = 1;
int ret = 0, can_split = 1, i, j;
int stream_index = 0;
int range_length = 0;
uint8_t *buffer = NULL;
VariantStream *vs = NULL;
for (i = 0; i < hls->nb_varstreams; i++) {
vs = &hls->var_streams[i];
for (j = 0; j < vs->nb_streams; j++) {
if (vs->streams[j] == st) {
if( st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE ) {
oc = vs->vtt_avf;
stream_index = 0;
} else {
oc = vs->avf;
stream_index = j;
}
break;
}
}
if (oc)
break;
}
if (!oc) {
av_log(s, AV_LOG_ERROR, "Unable to find mapping variant stream\n");
return AVERROR(ENOMEM);
}
end_pts = hls->recording_time * vs->number;
if (vs->sequence - vs->nb_entries > hls->start_sequence && hls->init_time > 0) {
int init_list_dur = hls->init_time * vs->nb_entries * AV_TIME_BASE;
int after_init_list_dur = (vs->sequence - vs->nb_entries ) * hls->time * AV_TIME_BASE;
hls->recording_time = hls->time * AV_TIME_BASE;
end_pts = init_list_dur + after_init_list_dur ;
}
if (vs->start_pts == AV_NOPTS_VALUE) {
vs->start_pts = pkt->pts;
vs->end_pts = pkt->pts;
}
if (vs->has_video) {
can_split = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
((pkt->flags & AV_PKT_FLAG_KEY) || (hls->flags & HLS_SPLIT_BY_TIME));
is_ref_pkt = st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO;
}
if (pkt->pts == AV_NOPTS_VALUE)
is_ref_pkt = can_split = 0;
if (is_ref_pkt) {
if (vs->new_start) {
vs->new_start = 0;
vs->duration = (double)(pkt->pts - vs->end_pts)
* st->time_base.num / st->time_base.den;
vs->dpp = (double)(pkt->duration) * st->time_base.num / st->time_base.den;
} else {
if (pkt->duration) {
vs->duration += (double)(pkt->duration) * st->time_base.num / st->time_base.den;
} else {
av_log(s, AV_LOG_WARNING, "pkt->duration = 0, maybe the hls segment duration will not precise\n");
vs->duration = (double)(pkt->pts - vs->end_pts) * st->time_base.num / st->time_base.den;
}
}
}
if (vs->packets_written && can_split && av_compare_ts(pkt->pts - vs->start_pts, st->time_base,
end_pts, AV_TIME_BASE_Q) >= 0) {
int64_t new_start_pos;
char *old_filename = av_strdup(vs->avf->filename);
int byterange_mode = (hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size > 0);
if (!old_filename) {
return AVERROR(ENOMEM);
}
av_write_frame(vs->avf, NULL);
new_start_pos = avio_tell(vs->avf->pb);
vs->size = new_start_pos - vs->start_pos;
if (!byterange_mode) {
if (hls->segment_type == SEGMENT_TYPE_FMP4 && !vs->init_range_length) {
avio_flush(oc->pb);
range_length = avio_close_dyn_buf(oc->pb, &buffer);
avio_write(vs->out, buffer, range_length);
vs->init_range_length = range_length;
avio_open_dyn_buf(&oc->pb);
vs->packets_written = 0;
ff_format_io_close(s, &vs->out);
} else {
ff_format_io_close(s, &oc->pb);
}
if (vs->vtt_avf) {
ff_format_io_close(s, &vs->vtt_avf->pb);
}
}
if ((hls->flags & HLS_TEMP_FILE) && oc->filename[0]) {
if (!(hls->flags & HLS_SINGLE_FILE) || (hls->max_seg_size <= 0))
if ((vs->avf->oformat->priv_class && vs->avf->priv_data) && hls->segment_type != SEGMENT_TYPE_FMP4)
av_opt_set(vs->avf->priv_data, "mpegts_flags", "resend_headers", 0);
hls_rename_temp_file(s, oc);
}
if (vs->fmp4_init_mode) {
vs->number--;
}
if (!vs->fmp4_init_mode || byterange_mode)
ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, vs->size);
vs->start_pos = new_start_pos;
if (ret < 0) {
av_free(old_filename);
return ret;
}
vs->end_pts = pkt->pts;
vs->duration = 0;
vs->fmp4_init_mode = 0;
if (hls->flags & HLS_SINGLE_FILE) {
vs->number++;
} else if (hls->max_seg_size > 0) {
if (vs->start_pos >= hls->max_seg_size) {
vs->sequence++;
sls_flag_file_rename(hls, vs, old_filename);
ret = hls_start(s, vs);
vs->start_pos = 0;
vs->number--;
}
vs->number++;
} else {
sls_flag_file_rename(hls, vs, old_filename);
ret = hls_start(s, vs);
}
av_free(old_filename);
if (ret < 0) {
return ret;
}
if (!vs->fmp4_init_mode || byterange_mode)
if ((ret = hls_window(s, 0, vs)) < 0) {
return ret;
}
}
vs->packets_written++;
ret = ff_write_chained(oc, stream_index, pkt, s, 0);
return ret;
}
| 1threat
|
static int vma_add_mapping(struct mm_struct *mm, abi_ulong start,
abi_ulong end, abi_ulong flags)
{
struct vm_area_struct *vma;
if ((vma = qemu_mallocz(sizeof (*vma))) == NULL)
return (-1);
vma->vma_start = start;
vma->vma_end = end;
vma->vma_flags = flags;
TAILQ_INSERT_TAIL(&mm->mm_mmap, vma, vma_link);
mm->mm_count++;
return (0);
}
| 1threat
|
Bug reporting regarding HTML and JavaScript : <p>I believe I have found a bug in HTML / JavaScript, but I have no idea where to post this bug. Any information on where to post such bugs is appreciated.</p>
<p>The bug can be recreated as follows:</p>
<ol>
<li>Go to <a href="https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onblur_html" rel="nofollow noreferrer">W3Schools Tryit Editor</a></li>
<li>Make sure you have some other tab open in the same window</li>
<li>Click on the input field to focus it</li>
<li>Click on a different tab in your browser</li>
<li>Depending on your browser, different effects will occur (all unwanted)</li>
</ol>
<p>This has been tested in Chrome (it will give an infinitely repeating alert), on Firefox (it will give the alert, but not switch tabs when clicking the alert away), and on Edge (it will show that the new tab is selected in the tabs bar, but the rest of the page doesn't switchenter link description here).</p>
<p>Since this bug occurs in multiple browsers, and also since the bug occurs with sample code from w3schools, I believe that this bug is related to HTML / JavaScript more than to a specific browser.</p>
| 0debug
|
Is this structure valid? : <p>I want to create a compact method tu calculate the summ of the first 20 even numbers and the multiplication of the first 20 odd numbers. is this correct?</p>
<pre><code>for(int i=0; i<=20; i++) {
(i % 2 == 0) ? (sumEven +=i;) : (productoImpares *= i;)
}
</code></pre>
| 0debug
|
Why compilation fails? :
interface Rideable {
String getGait();
}
public class Camel implements Rideable {
int weight = 2;
public static void main(String[] args) {
new Camel().go(8);
}
void go(int speed) {
++speed;
weight++;
int walkrate = speed * weight;
System.out.print(walkrate + getGait());
}
String getGait() {
return " mph, lope";
}
}
Why does the compilation fails?
I really don't know why the compile error? Please help.
| 0debug
|
static int pmp_header(AVFormatContext *s)
{
PMPContext *pmp = s->priv_data;
AVIOContext *pb = s->pb;
int tb_num, tb_den;
uint32_t index_cnt;
int audio_codec_id = AV_CODEC_ID_NONE;
int srate, channels;
int i;
uint64_t pos;
int64_t fsize = avio_size(pb);
AVStream *vst = avformat_new_stream(s, NULL);
if (!vst)
return AVERROR(ENOMEM);
vst->codec->codec_type = AVMEDIA_TYPE_VIDEO;
avio_skip(pb, 8);
switch (avio_rl32(pb)) {
case 0:
vst->codec->codec_id = AV_CODEC_ID_MPEG4;
break;
case 1:
vst->codec->codec_id = AV_CODEC_ID_H264;
break;
default:
av_log(s, AV_LOG_ERROR, "Unsupported video format\n");
break;
}
index_cnt = avio_rl32(pb);
vst->codec->width = avio_rl32(pb);
vst->codec->height = avio_rl32(pb);
tb_num = avio_rl32(pb);
tb_den = avio_rl32(pb);
avpriv_set_pts_info(vst, 32, tb_num, tb_den);
vst->nb_frames = index_cnt;
vst->duration = index_cnt;
switch (avio_rl32(pb)) {
case 0:
audio_codec_id = AV_CODEC_ID_MP3;
break;
case 1:
av_log(s, AV_LOG_ERROR, "AAC not yet correctly supported\n");
audio_codec_id = AV_CODEC_ID_AAC;
break;
default:
av_log(s, AV_LOG_ERROR, "Unsupported audio format\n");
break;
}
pmp->num_streams = avio_rl16(pb) + 1;
avio_skip(pb, 10);
srate = avio_rl32(pb);
channels = avio_rl32(pb) + 1;
pos = avio_tell(pb) + 4*index_cnt;
for (i = 0; i < index_cnt; i++) {
uint32_t size = avio_rl32(pb);
int flags = size & 1 ? AVINDEX_KEYFRAME : 0;
if (url_feof(pb)) {
av_log(s, AV_LOG_FATAL, "Encountered EOF while reading index.\n");
return AVERROR_INVALIDDATA;
}
size >>= 1;
if (size < 9 + 4*pmp->num_streams) {
av_log(s, AV_LOG_ERROR, "Packet too small\n");
return AVERROR_INVALIDDATA;
}
av_add_index_entry(vst, pos, i, size, 0, flags);
pos += size;
if (fsize > 0 && i == 0 && pos > fsize) {
av_log(s, AV_LOG_ERROR, "File ends before first packet\n");
return AVERROR_INVALIDDATA;
}
}
for (i = 1; i < pmp->num_streams; i++) {
AVStream *ast = avformat_new_stream(s, NULL);
if (!ast)
return AVERROR(ENOMEM);
ast->codec->codec_type = AVMEDIA_TYPE_AUDIO;
ast->codec->codec_id = audio_codec_id;
ast->codec->channels = channels;
ast->codec->sample_rate = srate;
avpriv_set_pts_info(ast, 32, 1, srate);
}
return 0;
}
| 1threat
|
long do_sigreturn(CPUM68KState *env)
{
struct target_sigframe *frame;
abi_ulong frame_addr = env->aregs[7] - 4;
target_sigset_t target_set;
sigset_t set;
int d0, i;
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
if (__get_user(target_set.sig[0], &frame->sc.sc_mask))
goto badframe;
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
if (__get_user(target_set.sig[i], &frame->extramask[i - 1]))
goto badframe;
}
target_to_host_sigset_internal(&set, &target_set);
sigprocmask(SIG_SETMASK, &set, NULL);
if (restore_sigcontext(env, &frame->sc, &d0))
goto badframe;
unlock_user_struct(frame, frame_addr, 0);
return d0;
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| 1threat
|
static int kvm_recommended_vcpus(KVMState *s)
{
int ret = kvm_check_extension(s, KVM_CAP_NR_VCPUS);
return (ret) ? ret : 4;
}
| 1threat
|
Text file not showing up in document. Java : I'm having trouble displaying the score from my game in a text file, I have two text files, one for player details which works perfect but the other text file for scores is not appearing, after I enter the scores the time of the date modified in the scores text file is the same time I finish the game, its just the scores are not coming up. Here is my code:
import java.util.Scanner;
import java.io.*;
public class Project
{
public static void main (String[]args) throws FileNotFoundException // This shows that the programme might encounter a file which is not there.
{
String outputFileName ="players.txt";
//Storing the name of the text file
PrintWriter writeToFile = new PrintWriter(outputFileName);
//This allows me to write to the text file that I've called outputFileName
Scanner playerStringInput = new Scanner(System.in);
Scanner playerIntInput = new Scanner(System.in);
//Taking info from the keyboard, one is for Integers and the other is for String
String name = " ";
String nickName = " ";
String homeTown = " ";
int age = 0;
int previousGamesPlayed = 0;
//Declaring the variables that I'm going to use to store the inputs from the programme
int amtOfPlayers = 2; //The amount of players we have
for(int i = 0; i < amtOfPlayers; i++) //Loop for both players
{
System.out.println("1.Please Enter Name");//Prints out instructitions for user.
name = playerStringInput.nextLine();//Taking the input to store in name.
writeToFile.println(name); //Outputs the data into the text file.
System.out.println("2.Please Enter Nickname");//Printing out the nickname entered onto the screen.
nickName = playerStringInput.nextLine(); //Taking the input to store in name.
writeToFile.println(nickName); //Outputs the data into the text file.
System.out.println("3.Please Enter Home Towm");//Printing out the hometown entered onto the screen.
homeTown = playerStringInput.nextLine();//Taking the input to store in name.
writeToFile.println(homeTown);//Outputs the data into the text file.
System.out.println("4.Please Enter Age, this must be a number.");//Printing out the age entered onto the screen.
age = playerIntInput.nextInt();//Taking the input to store in name.
writeToFile.println(age);//Outputs the data into the text file.
System.out.println("5.Please Enter Previous Games Played");//Printing out the previous games played entered onto the screen.
previousGamesPlayed = playerIntInput.nextInt();//Taking the input to store in name.
writeToFile.println(previousGamesPlayed);//Outputs the data into the text file.
System.out.println("The name entered is: " + name); //Printing out the name entered onto the screen.
System.out.println("The nickname entered is: " + nickName);//Printing out the nickname entered onto the screen.
System.out.println("The hometown entered is: " + homeTown);//Printing out the hometown entered onto the screen.
System.out.println("Age entered is: " + age);//Printing out the age entered onto the screen.
System.out.println(previousGamesPlayed);//Printing out the name entered onto the screen.
}
writeToFile.close(); //Close the file writer so it can write the text into the file
Scanner scan = new Scanner(System.in);//Allows us to take input from game
String userInput1 = " ";
char player1Input;
String userInput2 = " ";
char player2Input;
//Declaring our variables for game
for(int i = 0; i < 7; i++) //Loop for game which will loop 7 times
{
System.out.println("Player 1: Please Enter e.g R for Rock:");
System.out.println("R.Rock");//Printing out Rock as choice for game
System.out.println("P.Paper");//Printing out Paper as choice for game
System.out.println("S.Scissors");//Printing out Scissors as choice for game
userInput1 = scan.next();
player1Input = userInput1.charAt(0);
System.out.println("Player 2: Please Enter e.g S for Scissors");
System.out.println("R.Rock");//Printing out Rock as choice for game
System.out.println("P.Paper");//Printing out Paper as choice for game
System.out.println("S.Scissors");//Printing out Scissors as choice for game
userInput2 = scan.next();
player2Input = userInput2.charAt(0);
switch(player1Input)//beginning of switch statement
{
case 'R': System.out.println ("Player 1:Rock");//
switch(player2Input)
{
//declaring possible outcomes if player 1 choses paper
case'R' : System.out.println("Player 2:Rock");//
System.out.println("The Game Result is Draw");
break;
case'P' :System.out.println("Player 2:Paper");
System.out.println("The Game Result is: Player 2 Wins");
break;
case'S' :System.out.println("Player 2:Scissors");
System.out.println("The Game Result is: Player 1 Wins");
break;
default: System.out.println("Invalid Option");
break;
}
break;//Terminating the loop before it goes onto the next statement
case 'P' : System.out.println ("Player 1:Paper");
switch(player2Input)
{
//declaring possible outcomes if player 1 choses Paper
case'R' : System.out.println("Player 2:Rock");
System.out.println("The game result is: Player 1 Wins");
break;
case'P' :System.out.println("Player 2:Paper");
System.out.println("The game result is: Draw");
break;
case'S' :System.out.println("Player 2:Scissors");
System.out.println("The Game Result is: Player 2 Wins2");
break;
default: System.out.println("Invalid Option");
break;
}
break;//Terminating the loop before it goes onto the next statement
//declaring possible outcomes if player 1 choses Scissors
case 'S' : System.out.println ("Player 1:Scissors");
switch(player2Input)
{
case'R' : System.out.println("Player 2:Rock");
System.out.println("The Game Result is: Player 2 Wins");
break;
case'P' :System.out.println("Player 2:Paper");
System.out.println("The game result is: Player 1 Wins");
break;
case'S' :System.out.println("Player 2:Scissors");
System.out.println ("The Game Result is: Draw");
break;
default: System.out.println("Invalid Option");
break;
}
break;//Terminating the loop before it goes onto the next statement
}//Ending of loop for game
for(int h = 0; i < 2;i++);//for loop for scores, I also needed to call this int h as I already declared int I as a variable in my main method string.
}
int [] arrPlayer = new int[2];//using arrays to gather players score
System.out.println("Player 1 Please Enter Your Score");//Player 1 printing out their score
arrPlayer[0]=scan.nextInt();
System.out.println("Player 2 Please Enter Your Score");//Player 2 printing out their score
arrPlayer[1]=scan.nextInt();
System.out.println("Player 1 : Score: " + arrPlayer[0]);//Player 1 score
System.out.println("Player 2 : Score: " + arrPlayer[1]);//Player 2 score
String outputFileName2 ="scores.txt";
//Storing the name of the text file
PrintWriter writeToFile2 = new PrintWriter(outputFileName2);
//This allows me to write to the text file that I've called outputFileName
writeToFile.close(); //Close the file writer so it can write the text into the file
}//End of method
}//End of class
| 0debug
|
cannot find the type of ComboPooledDataSource : [my project structure][1]
[1]: https://i.stack.imgur.com/i6q1v.png
When I try to write a database connection pool, it cannot find the type of ComboPooledDataSource,it confuse me one day
| 0debug
|
How to get the "host" object java : <p>I need to get the "host" object of another object. Here an example</p>
<p>Suppose I have the </p>
<pre><code>class Peer {
final Service service;
public Peer(Service service) {
this.service = service;
}
public void ping() {
service.ping();
}
}
</code></pre>
<p>and </p>
<pre><code>class Service {
public String hola() {
this.getPeer()? //HERE I NEED SOME COMMAND TO GET the Peer object, is this possible?
}
}
</code></pre>
<p>Then in Service class, I need to get the peer object. Is this possible?</p>
| 0debug
|
av_cold void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt,
int bps)
{
#if HAVE_YASM
int cpu_flags = av_get_cpu_flags();
if (EXTERNAL_SSE4(cpu_flags)) {
if (bps > 16 && CONFIG_FLAC_DECODER)
c->lpc = ff_flac_lpc_32_sse4;
}
if (EXTERNAL_XOP(cpu_flags)) {
if (bps > 16)
c->lpc = ff_flac_lpc_32_xop;
}
#endif
}
| 1threat
|
What does Fast 3G actually mean? : <p>In the Chrome browser's developer tools, there are various ways to throttle your network connection to emulate different connection types.</p>
<p>Those menus for selecting a connection type used to show the speeds and latency that would be used to simulate each connection type.<br>
<a href="https://i.stack.imgur.com/aHe7X.png" rel="noreferrer"><img src="https://i.stack.imgur.com/aHe7X.png" alt="Throttling menu with informative labels"></a></p>
<p>Now, as of at least Chrome 64, the useful information about speed and latency has been removed.<br>
<a href="https://i.stack.imgur.com/U6QuC.png" rel="noreferrer"><img src="https://i.stack.imgur.com/U6QuC.png" alt="Throttling menu with uninformative labels"></a></p>
<p>I tried duplicating the numbers from the first image for Regular 3G and Good 3G in my own custom profiles to see if they matched the Slow 3G and Fast 3G presets from the first image but I got significantly different results for the DOMContentLoaded and Load event times between the presets and my custom profiles.</p>
| 0debug
|
static void init_proc_book3s_64(CPUPPCState *env, int version)
{
gen_spr_ne_601(env);
gen_tbl(env);
gen_spr_book3s_altivec(env);
gen_spr_book3s_pmu_sup(env);
gen_spr_book3s_pmu_user(env);
gen_spr_book3s_common(env);
switch (version) {
case BOOK3S_CPU_970:
case BOOK3S_CPU_POWER5PLUS:
gen_spr_970_hid(env);
gen_spr_970_hior(env);
gen_low_BATs(env);
gen_spr_970_pmu_sup(env);
gen_spr_970_pmu_user(env);
break;
case BOOK3S_CPU_POWER7:
case BOOK3S_CPU_POWER8:
gen_spr_book3s_ids(env);
gen_spr_amr(env, version >= BOOK3S_CPU_POWER8);
gen_spr_book3s_purr(env);
env->ci_large_pages = true;
break;
default:
g_assert_not_reached();
}
if (version >= BOOK3S_CPU_POWER5PLUS) {
gen_spr_power5p_common(env);
gen_spr_power5p_lpar(env);
gen_spr_power5p_ear(env);
} else {
gen_spr_970_lpar(env);
}
if (version == BOOK3S_CPU_970) {
gen_spr_970_dbg(env);
}
if (version >= BOOK3S_CPU_POWER6) {
gen_spr_power6_common(env);
gen_spr_power6_dbg(env);
}
if (version == BOOK3S_CPU_POWER7) {
gen_spr_power7_book4(env);
}
if (version >= BOOK3S_CPU_POWER8) {
gen_spr_power8_tce_address_control(env);
gen_spr_power8_ids(env);
gen_spr_power8_ebb(env);
gen_spr_power8_fscr(env);
gen_spr_power8_pmu_sup(env);
gen_spr_power8_pmu_user(env);
gen_spr_power8_tm(env);
gen_spr_power8_pspb(env);
gen_spr_vtb(env);
gen_spr_power8_ic(env);
gen_spr_power8_book4(env);
}
if (version < BOOK3S_CPU_POWER8) {
gen_spr_book3s_dbg(env);
} else {
gen_spr_book3s_207_dbg(env);
}
#if !defined(CONFIG_USER_ONLY)
switch (version) {
case BOOK3S_CPU_970:
case BOOK3S_CPU_POWER5PLUS:
env->slb_nr = 64;
break;
case BOOK3S_CPU_POWER7:
case BOOK3S_CPU_POWER8:
default:
env->slb_nr = 32;
break;
}
#endif
switch (version) {
case BOOK3S_CPU_970:
case BOOK3S_CPU_POWER5PLUS:
init_excp_970(env);
ppc970_irq_init(ppc_env_get_cpu(env));
break;
case BOOK3S_CPU_POWER7:
case BOOK3S_CPU_POWER8:
init_excp_POWER7(env);
ppcPOWER7_irq_init(ppc_env_get_cpu(env));
break;
default:
g_assert_not_reached();
}
env->dcache_line_size = 128;
env->icache_line_size = 128;
}
| 1threat
|
XOR between string and int in Python : <p>How to do a XOR operation between a string with an integer in Python?
Below is what I type:</p>
<pre><code>x = 'a'
y = x^5
print(y)
</code></pre>
<p>It show me this error: <code>TypeError: unsupported operand type(s) for ^: 'str' and 'int'</code></p>
<p>Any idea how to solve it?</p>
| 0debug
|
static int dmg_read(BlockDriverState *bs, int64_t sector_num,
uint8_t *buf, int nb_sectors)
{
BDRVDMGState *s = bs->opaque;
int i;
for(i=0;i<nb_sectors;i++) {
uint32_t sector_offset_in_chunk;
if(dmg_read_chunk(bs, sector_num+i) != 0)
return -1;
sector_offset_in_chunk = sector_num+i-s->sectors[s->current_chunk];
memcpy(buf+i*512,s->uncompressed_chunk+sector_offset_in_chunk*512,512);
}
return 0;
}
| 1threat
|
Explanation for ddepth parameter in cv2.filter2d() opencv? : <pre><code>import cv2
import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread('logo.png')
kernel = np.ones((5, 5), np.float32) / 25
dst = cv2.filter2D(img, -1, kernel)
plt.subplot(121), plt.imshow(img), plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122), plt.imshow(dst), plt.title('Averaging')
plt.xticks([]), plt.yticks([])
plt.show()
</code></pre>
<p>I was trying smoothing a picture and i didnt understand the ddepth parameter of cv2.filter2d() where the value is -1. So what does -1 do and also what does ddpeth mean ? </p>
| 0debug
|
static int mtv_read_header(AVFormatContext *s)
{
MTVDemuxContext *mtv = s->priv_data;
AVIOContext *pb = s->pb;
AVStream *st;
unsigned int audio_subsegments;
avio_skip(pb, 3);
mtv->file_size = avio_rl32(pb);
mtv->segments = avio_rl32(pb);
avio_skip(pb, 32);
mtv->audio_identifier = avio_rl24(pb);
mtv->audio_br = avio_rl16(pb);
mtv->img_colorfmt = avio_rl24(pb);
mtv->img_bpp = avio_r8(pb);
mtv->img_width = avio_rl16(pb);
mtv->img_height = avio_rl16(pb);
mtv->img_segment_size = avio_rl16(pb);
if(!mtv->img_width)
mtv->img_width=mtv->img_segment_size / (mtv->img_bpp>>3)
/ mtv->img_height;
if(!mtv->img_height)
mtv->img_height=mtv->img_segment_size / (mtv->img_bpp>>3)
/ mtv->img_width;
avio_skip(pb, 4);
audio_subsegments = avio_rl16(pb);
if (audio_subsegments == 0) {
avpriv_request_sample(s, "MTV files without audio");
return AVERROR_PATCHWELCOME;
}
mtv->full_segment_size =
audio_subsegments * (MTV_AUDIO_PADDING_SIZE + MTV_ASUBCHUNK_DATA_SIZE) +
mtv->img_segment_size;
mtv->video_fps = (mtv->audio_br / 4) / audio_subsegments;
st = avformat_new_stream(s, NULL);
if(!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, mtv->video_fps);
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = AV_CODEC_ID_RAWVIDEO;
st->codec->pix_fmt = AV_PIX_FMT_RGB565BE;
st->codec->width = mtv->img_width;
st->codec->height = mtv->img_height;
st->codec->extradata = av_strdup("BottomUp");
st->codec->extradata_size = 9;
st = avformat_new_stream(s, NULL);
if(!st)
return AVERROR(ENOMEM);
avpriv_set_pts_info(st, 64, 1, AUDIO_SAMPLING_RATE);
st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
st->codec->codec_id = AV_CODEC_ID_MP3;
st->codec->bit_rate = mtv->audio_br;
st->need_parsing = AVSTREAM_PARSE_FULL;
if(avio_seek(pb, MTV_HEADER_SIZE, SEEK_SET) != MTV_HEADER_SIZE)
return AVERROR(EIO);
return 0;
}
| 1threat
|
alert('Hello ' + user_input);
| 1threat
|
static int vnc_refresh_server_surface(VncDisplay *vd)
{
int width = MIN(pixman_image_get_width(vd->guest.fb),
pixman_image_get_width(vd->server));
int height = MIN(pixman_image_get_height(vd->guest.fb),
pixman_image_get_height(vd->server));
int cmp_bytes, server_stride, min_stride, guest_stride, y = 0;
uint8_t *guest_row0 = NULL, *server_row0;
VncState *vs;
int has_dirty = 0;
pixman_image_t *tmpbuf = NULL;
struct timeval tv = { 0, 0 };
if (!vd->non_adaptive) {
gettimeofday(&tv, NULL);
has_dirty = vnc_update_stats(vd, &tv);
}
server_row0 = (uint8_t *)pixman_image_get_data(vd->server);
server_stride = guest_stride = pixman_image_get_stride(vd->server);
cmp_bytes = MIN(VNC_DIRTY_PIXELS_PER_BIT * VNC_SERVER_FB_BYTES,
server_stride);
if (vd->guest.format != VNC_SERVER_FB_FORMAT) {
int width = pixman_image_get_width(vd->server);
tmpbuf = qemu_pixman_linebuf_create(VNC_SERVER_FB_FORMAT, width);
} else {
guest_row0 = (uint8_t *)pixman_image_get_data(vd->guest.fb);
guest_stride = pixman_image_get_stride(vd->guest.fb);
}
min_stride = MIN(server_stride, guest_stride);
for (;;) {
int x;
uint8_t *guest_ptr, *server_ptr;
unsigned long offset = find_next_bit((unsigned long *) &vd->guest.dirty,
height * VNC_DIRTY_BPL(&vd->guest),
y * VNC_DIRTY_BPL(&vd->guest));
if (offset == height * VNC_DIRTY_BPL(&vd->guest)) {
break;
}
y = offset / VNC_DIRTY_BPL(&vd->guest);
x = offset % VNC_DIRTY_BPL(&vd->guest);
server_ptr = server_row0 + y * server_stride + x * cmp_bytes;
if (vd->guest.format != VNC_SERVER_FB_FORMAT) {
qemu_pixman_linebuf_fill(tmpbuf, vd->guest.fb, width, 0, y);
guest_ptr = (uint8_t *)pixman_image_get_data(tmpbuf);
} else {
guest_ptr = guest_row0 + y * guest_stride;
}
guest_ptr += x * cmp_bytes;
for (; x < DIV_ROUND_UP(width, VNC_DIRTY_PIXELS_PER_BIT);
x++, guest_ptr += cmp_bytes, server_ptr += cmp_bytes) {
int _cmp_bytes = cmp_bytes;
if (!test_and_clear_bit(x, vd->guest.dirty[y])) {
continue;
}
if ((x + 1) * cmp_bytes > min_stride) {
_cmp_bytes = min_stride - x * cmp_bytes;
}
if (memcmp(server_ptr, guest_ptr, _cmp_bytes) == 0) {
continue;
}
memcpy(server_ptr, guest_ptr, _cmp_bytes);
if (!vd->non_adaptive) {
vnc_rect_updated(vd, x * VNC_DIRTY_PIXELS_PER_BIT,
y, &tv);
}
QTAILQ_FOREACH(vs, &vd->clients, next) {
set_bit(x, vs->dirty[y]);
}
has_dirty++;
}
y++;
}
qemu_pixman_image_unref(tmpbuf);
return has_dirty;
}
| 1threat
|
def sort_sublists(input_list):
result = [sorted(x, key = lambda x:x[0]) for x in input_list]
return result
| 0debug
|
def rearrange_bigger(n):
nums = list(str(n))
for i in range(len(nums)-2,-1,-1):
if nums[i] < nums[i+1]:
z = nums[i:]
y = min(filter(lambda x: x > z[0], z))
z.remove(y)
z.sort()
nums[i:] = [y] + z
return int("".join(nums))
return False
| 0debug
|
How to print float as string in Golang without scientific notation : <p>Suppose I have an array with 2 items whose type is string / float.
How should I print them together without scientific notation for float item.</p>
<p>For example:</p>
<pre><code>package main
import (
"fmt"
)
func main() {
values := []interface{}{"mydata", 1234567890.123}
for _, v := range values{
fmt.Printf("%v\n", v)
}
}
</code></pre>
<p>The output will be</p>
<blockquote>
<p>mydata</p>
<p>1.234567890123e+09</p>
</blockquote>
<p>What I want is</p>
<blockquote>
<p>mydata</p>
<p>1234567890.123</p>
</blockquote>
| 0debug
|
static struct omap_rtc_s *omap_rtc_init(target_phys_addr_t base,
qemu_irq *irq, omap_clk clk)
{
int iomemtype;
struct omap_rtc_s *s = (struct omap_rtc_s *)
qemu_mallocz(sizeof(struct omap_rtc_s));
s->irq = irq[0];
s->alarm = irq[1];
s->clk = qemu_new_timer(rt_clock, omap_rtc_tick, s);
omap_rtc_reset(s);
iomemtype = cpu_register_io_memory(omap_rtc_readfn,
omap_rtc_writefn, s, DEVICE_NATIVE_ENDIAN);
cpu_register_physical_memory(base, 0x800, iomemtype);
return s;
}
| 1threat
|
void ide_data_writel(void *opaque, uint32_t addr, uint32_t val)
{
IDEBus *bus = opaque;
IDEState *s = idebus_active_if(bus);
uint8_t *p;
if (!(s->status & DRQ_STAT) || ide_is_pio_out(s)) {
p = s->data_ptr;
*(uint32_t *)p = le32_to_cpu(val);
p += 4;
s->data_ptr = p;
if (p >= s->data_end)
s->end_transfer_func(s);
| 1threat
|
how can resolve it error in Targetpath : 4 and I am developing a small script that creates a chrome shortcut but, I want to put it at the end of the path "www.facebook.com so that when there will be that shortcut I will have facebook as homepage
desktop = winshell.desktop()
path = os.path.join(desktop, "Chrome.lnk")
target = r'C:\Program Files\Google\Chrome\Application\chrome.exe ' '"www.facebook.com'
wDir = r"%ProgramFiles%\Google\Chrome\Application"
icon = r"%ProgramFiles%\Google\Chrome\Application\chrome.exe"
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(path)
shortcut.Targetpath = target
shortcut.WorkingDirectory = wDir
shortcut.IconLocation = icon
shortcut.save()
the IDE show:
File "C:\Python34\lib\site-packages\win32com\client\dynamic.py", line 581, in __setattr__
raise AttributeError("Property '%s.%s' can not be set." % (self._username_, attr))
AttributeError: Property '<unknown>.Targetpath' can not be set.
| 0debug
|
def check_K(test_tup, K):
res = False
for ele in test_tup:
if ele == K:
res = True
break
return (res)
| 0debug
|
I am gettig this error while excecuting Chef Mixlib::ShellOut::ShellCommandFailed : When I execute Chef recipe through the Work Station I always get this error and not able to understand what is missing ?
knife bootstrap 10.192.74.59 --ssh-user scs --ssh-password 'cisco123' --sudo --use-sudo-password --node-name webserver10.192.74.59 --run-list 'recipe[f5-node-initiator]'
Node webserver10.192.74.59 exists, overwrite it? (Y/N) Y
Client webserver10.192.74.59 exists, overwrite it? (Y/N) Y
Creating new client for webserver10.192.74.59
Creating new node for webserver10.192.74.59
Connecting to 10.192.74.59
10.192.74.59 [sudo] password for scs: -----> Existing Chef installation detected
10.192.74.59 Starting the first Chef Client run...
10.192.74.59 Starting Chef Client, version 12.15.19
10.192.74.59 resolving cookbooks for run list: ["f5-node-initiator"]
10.192.74.59 Synchronizing Cookbooks:
10.192.74.59 - f5-node-initiator (0.0.1)
10.192.74.59 Installing Cookbook Gems:
10.192.74.59 Compiling Cookbooks...
10.192.74.59 Converging 4 resources
10.192.74.59 Recipe: f5-node-initiator::default
10.192.74.59 * cookbook_file[/var/chef/cache/f5-icontrol-10.2.0.2.gem] action create (up to date)
10.192.74.59 * cookbook_file[/usr/local/bin/f5-node-initiator] action create (up to date)
10.192.74.59 * gem_package[f5-icontrol] action install (up to date)
10.192.74.59 * execute[f5-node-initiator] action run
10.192.74.59
10.192.74.59 ================================================================================
10.192.74.59 Error executing action `run` on resource 'execute[f5-node-initiator]'
10.192.74.59 ================================================================================
10.192.74.59
10.192.74.59 Mixlib::ShellOut::ShellCommandFailed
10.192.74.59 ------------------------------------
10.192.74.59 Expected process to exit with [0], but received '1'
10.192.74.59 ---- Begin output of f5-node-initiator -b 10.192.73.79 -u -p -n -d 10.192.74.59:80 ----
10.192.74.59 STDOUT:
10.192.74.59 STDERR: /var/lib/gems/2.3.0/gems/soap4r-1.5.8/lib/xsd/charset.rb:13: warning: variable $KCODE is no longer effective
10.192.74.59 /var/lib/gems/2.3.0/gems/soap4r-1.5.8/lib/xsd/xmlparser.rb:74:in `<top (required)>': XML processor module not found. (RuntimeError)
10.192.74.59 from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
10.192.74.59 from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
10.192.74.59 from /var/lib/gems/2.3.0/gems/soap4r-1.5.8/lib/wsdl/parser.rb:12:in `<top (required)>'
10.192.74.59 from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
10.192.74.59 from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
10.192.74.59 from /var/lib/gems/2.3.0/gems/soap4r-1.5.8/lib/soap/wsdlDriver.rb:9:in `<top (required)>'
10.192.74.59 from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
10.192.74.59 from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
10.192.74.59 from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
10.192.74.59 from /var/lib/gems/2.3.0/gems/f5-icontrol-10.2.0.2/lib/f5-icontrol.rb:2:in `<top (required)>'
10.192.74.59 from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
10.192.74.59 from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
10.192.74.59 from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
10.192.74.59 from /usr/local/bin/f5-node-initiator:31:in `<main>'
10.192.74.59 ---- End output of f5-node-initiator -b 10.192.73.79 -u -p -n -d 10.192.74.59:80 ----
10.192.74.59 Ran f5-node-initiator -b 10.192.73.79 -u -p -n -d 10.192.74.59:80 returned 1
10.192.74.59
10.192.74.59 Resource Declaration:
10.192.74.59 ---------------------
10.192.74.59 # In /var/chef/cache/cookbooks/f5-node-initiator/recipes/default.rb
10.192.74.59
10.192.74.59 25: execute "f5-node-initiator" do
10.192.74.59 26: command "f5-node-initiator -b #{node[:bigip][:address]} -u #{node[:bigip][:user]} -p #{node[:bigip][:pass]} -n #{node[:bigip][:pool_name]} -d #{node[:bigip][:node_address]}:#{node[:bigip][:node_port]}"
10.192.74.59 27: # action :nothing
10.192.74.59 28: end
10.192.74.59
10.192.74.59 Compiled Resource:
10.192.74.59 ------------------
10.192.74.59 # Declared in /var/chef/cache/cookbooks/f5-node-initiator/recipes/default.rb:25:in `from_file'
10.192.74.59
10.192.74.59 execute("f5-node-initiator") do
10.192.74.59 action [:run]
10.192.74.59 retries 0
10.192.74.59 retry_delay 2
10.192.74.59 default_guard_interpreter :execute
10.192.74.59 command "f5-node-initiator -b 10.192.73.79 -u -p -n -d 10.192.74.59:80"
10.192.74.59 backup 5
10.192.74.59 returns 0
10.192.74.59 declared_type :execute
10.192.74.59 cookbook_name "f5-node-initiator"
10.192.74.59 recipe_name "default"
10.192.74.59 end
10.192.74.59
10.192.74.59 Platform:
| 0debug
|
Adjust collectionView.scrollToItem to consider inset? : <p>I'm sometimes scroll to the left of a cell like this:</p>
<pre><code>collectionView.scrollToItem(
at: IndexPath(row: 5, section: 0),
at: .left, // TODO: Left ignores inset
animated: true
)
</code></pre>
<p>This is how it starts out before <code>scrollToItem</code> implemented:</p>
<p><a href="https://i.stack.imgur.com/rPv5g.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rPv5g.png" alt="enter image description here"></a></p>
<p>However, when I try to use scroll to item, it sticks the cell to the edge instead of considering the inset:</p>
<p><a href="https://i.stack.imgur.com/OvbAT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OvbAT.png" alt="enter image description here"></a></p>
<p>Is there an easy way to fix <code>collectionView.scrollToItem</code> to accommodate the insets?</p>
| 0debug
|
Can I export a Sqlite db using RedBean PHP ORM and Import to MySQL? : <p>I have a simple web app that I've been building using <code>redbean</code> PHP which has a really simple structure with three bean types:</p>
<p>areas
buildings
persons</p>
<p>All relationships are exclusive 1:Many. So, a <code>Person</code> belongs to only 1 <code>Building</code>, and a <code>Building</code> belongs to 1 <code>Area</code>. </p>
<pre><code>Area
BuildingList
PersonList
</code></pre>
<p>Currently, I have been developing it using <code>Sqlite3</code> for ease of development, but I want to move the data to <code>mySQL</code>. I have a lot of data that I've already added.</p>
<p>Is there an easy way to use RedBean to Export ALL beans to the new MySql Database?</p>
<p>I know I can search for a <code>sqlite</code> -> <code>MySQL</code>/<code>MariaDB</code> converter, but I also potentially want to be able to use this in reverse to make migrating the site super easy to move/backup/change DBs.</p>
<p>What I've tried below:</p>
<pre><code>R::setup('sqlite:/' . __DIR__ . '/data/database.db');
R::addDatabase('mysql', $MySqlConn );
$old_datas = R::findAll( 'area' );
R::selectDatabase( 'mysql' );
foreach ($old_datas as $bean) {
$new_area = R::dispense('area');
$new_area->importFrom( $bean );
$id = R::store( $new_area );
var_dump( $new_area ); // shows new data
}
var_dump( R::findAll( 'area' ) ); // returns empty array
</code></pre>
| 0debug
|
static void sysbus_mmio_map_common(SysBusDevice *dev, int n, hwaddr addr,
bool may_overlap, unsigned priority)
{
assert(n >= 0 && n < dev->num_mmio);
if (dev->mmio[n].addr == addr) {
return;
}
if (dev->mmio[n].addr != (hwaddr)-1) {
memory_region_del_subregion(get_system_memory(), dev->mmio[n].memory);
}
dev->mmio[n].addr = addr;
if (may_overlap) {
memory_region_add_subregion_overlap(get_system_memory(),
addr,
dev->mmio[n].memory,
priority);
}
else {
memory_region_add_subregion(get_system_memory(),
addr,
dev->mmio[n].memory);
}
}
| 1threat
|
Angular: How to show right and cross symbol conditionally with ng-repeat : i am new in angular.suppose i am showing employee info through **ng-repeat** in tabular format. suppose employee info has one property called **isDeveloper**. if **isDeveloper value is 1** then i will show right symbol in row and **if isDeveloper is 0** then i will show cross symbol in row. how to do it.
the trick is not coming to my head.do i need to achieve it by custom filter or custom directive ? please share the idea with bit of code sample if possible. thanks
| 0debug
|
Can't call Auth::user() on controller's constructor : <p>I'm trying to check if the user has permission to a certain model. Up until now (with Laravel 5.2), I added this code at the constructor:</p>
<pre><code>public function __construct()
{
if (!Auth::user()->hasPermission('usergroups')) {
abort(404);
}
}
</code></pre>
<p>Now, after upgrading to Laravel 5.3, <code>Auth::user()</code> returns <code>null</code> when being called from the controller's constructor. If I call it within any other method of the class, it returns the currently logged in user.</p>
<p>Any Ideas why?</p>
| 0debug
|
#R Sample function with prob applied to a multivariable matrix : Currently, I am attempting to bootstrap a dataset with 114 obs and 16 variables.
I have used the sample function as follows x[sample(nrow(x),size=114,replace=TRUE),] where x is my dataset.
However, I would like to sample with probabilities assigned to specific columns as the sample function contains this possibility. For example I would like to sample the 5th column with probability of numbers between 1-5 0.1 and numbers 5-200 0.9.
How would I go about this and thanks for your help in advance.
| 0debug
|
how to select tag inside of a tag using jquery? : i am trying to select "leftcolumn1". what is the correct approach?
<div class="leftcolumn">
<div class="card">
<div class="fakeimg" style="height:200px;">
<div class="leftcolumn1">
<div class="card">
<img src="rField.jpg" />
</div>
</div>
<div class="rightcolumn1">
<div class="card">
<img src="rField.jpg" />
</div>
</div>
<!--<img src="rField.jpg" />-->
</div>
<p>Some text..</p>
<p>Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.</p>
</div>
</div>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.