problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
C - How to print roman numbers? : <p>Given a natural number less or equal to 99, print it as a roman number.</p>
<p>Is there a method for this? How do I solve this assignment? Noob question here.</p>
| 0debug
|
Why this java can run? : JAVA If should have {} except there is only one line under if.
But why this code can run on my computer?
int x=1;
int y=1;
if(x<=4)
if(y>=4)
System.out.println("%%%");
else
System.out.println("+++");
System.out.println("***");
[Here is what it looks like on my IDE][1]
.
And everything runs good. Here is the result.(under it loading other resources don't care about that. I just modified some of my code to try out the code as soon as possible.)
[here is the result][2]
[1]: https://i.stack.imgur.com/6QnA5.png
[2]: https://i.stack.imgur.com/KWvKQ.png
| 0debug
|
C: Why allocate string length in powers of 2? : <p>Why do C programmers often allocate strings (char arrays) in powers of two?</p>
<p>You often see...</p>
<pre><code>char str[128]
char str[512]
char str[2048]
</code></pre>
<p>Less often, you see...</p>
<pre><code>char str[100]
char str[500]
char str[2000]
</code></pre>
<p>Why is that?</p>
<p>I understand the answer will involve memory being addressed in binary... But why don't we often see <code>char str[384]</code>, which is 128+256 (multiple of two).</p>
<p>Why are <em>multiples</em> of two not used? Why do C programmers use <em>powers</em> of two?</p>
| 0debug
|
VBA EXCEL, I need copy Cell Comment to past as isolated Cells for Each line : [enter image description here][1]
I need to to Copy **comments** from each rows, then paste them as this Down Picture
[enter image description here][2]
First we need to create NEW Work Sheet that Name as same as first Cell1 IN selected **ROW**
[1]: https://i.stack.imgur.com/je0j7.png
[2]: https://i.stack.imgur.com/K6wnn.png
| 0debug
|
C++ Programming function : gets() function : #include<stdio.h>
void main()
{
char name[20];
printf("Enter your name : ");
scanf("%s",&name);
printf("your name is %s\n",name);
getch();
}
why in dev c++ program ,its say to declare getch()
| 0debug
|
static int ism_write_header(AVFormatContext *s)
{
SmoothStreamingContext *c = s->priv_data;
int ret = 0, i;
AVOutputFormat *oformat;
mkdir(s->filename, 0777);
oformat = av_guess_format("ismv", NULL, NULL);
if (!oformat) {
ret = AVERROR_MUXER_NOT_FOUND;
goto fail;
}
c->streams = av_mallocz(sizeof(*c->streams) * s->nb_streams);
if (!c->streams) {
ret = AVERROR(ENOMEM);
goto fail;
}
for (i = 0; i < s->nb_streams; i++) {
OutputStream *os = &c->streams[i];
AVFormatContext *ctx;
AVStream *st;
AVDictionary *opts = NULL;
char buf[10];
if (!s->streams[i]->codec->bit_rate) {
av_log(s, AV_LOG_ERROR, "No bit rate set for stream %d\n", i);
ret = AVERROR(EINVAL);
goto fail;
}
snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%d)", s->filename, s->streams[i]->codec->bit_rate);
mkdir(os->dirname, 0777);
ctx = avformat_alloc_context();
if (!ctx) {
ret = AVERROR(ENOMEM);
goto fail;
}
os->ctx = ctx;
ctx->oformat = oformat;
ctx->interrupt_callback = s->interrupt_callback;
if (!(st = avformat_new_stream(ctx, NULL))) {
ret = AVERROR(ENOMEM);
goto fail;
}
avcodec_copy_context(st->codec, s->streams[i]->codec);
st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf), AVIO_FLAG_WRITE, os, NULL, ism_write, ism_seek);
if (!ctx->pb) {
ret = AVERROR(ENOMEM);
goto fail;
}
snprintf(buf, sizeof(buf), "%d", c->lookahead_count);
av_dict_set(&opts, "ism_lookahead", buf, 0);
av_dict_set(&opts, "movflags", "frag_custom", 0);
if ((ret = avformat_write_header(ctx, &opts)) < 0) {
goto fail;
}
os->ctx_inited = 1;
avio_flush(ctx->pb);
av_dict_free(&opts);
s->streams[i]->time_base = st->time_base;
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
c->has_video = 1;
os->stream_type_tag = "video";
if (st->codec->codec_id == AV_CODEC_ID_H264) {
os->fourcc = "H264";
} else if (st->codec->codec_id == AV_CODEC_ID_VC1) {
os->fourcc = "WVC1";
} else {
av_log(s, AV_LOG_ERROR, "Unsupported video codec\n");
ret = AVERROR(EINVAL);
goto fail;
}
} else {
c->has_audio = 1;
os->stream_type_tag = "audio";
if (st->codec->codec_id == AV_CODEC_ID_AAC) {
os->fourcc = "AACL";
os->audio_tag = 0xff;
} else if (st->codec->codec_id == AV_CODEC_ID_WMAPRO) {
os->fourcc = "WMAP";
os->audio_tag = 0x0162;
} else {
av_log(s, AV_LOG_ERROR, "Unsupported audio codec\n");
ret = AVERROR(EINVAL);
goto fail;
}
os->packet_size = st->codec->block_align ? st->codec->block_align : 4;
}
get_private_data(os);
}
if (!c->has_video && c->min_frag_duration <= 0) {
av_log(s, AV_LOG_WARNING, "no video stream and no min frag duration set\n");
ret = AVERROR(EINVAL);
}
ret = write_manifest(s, 0);
fail:
if (ret)
ism_free(s);
return ret;
}
| 1threat
|
Minikube volumes : <p>Minikube is supposed to make it simple to run Kubernetes locally, not only for "getting started" but also for "day-to-day development workflows".</p>
<p>source : <a href="https://github.com/kubernetes/minikube/blob/master/ROADMAP.md#goals" rel="noreferrer">https://github.com/kubernetes/minikube/blob/master/ROADMAP.md#goals</a></p>
<p>But I can also read that : "PersistentVolumes are mapped to a directory inside the minikube VM. The Minikube VM boots into a tmpfs, so most directories will not be persisted across reboots (minikube stop)"</p>
<p>source : <a href="https://kubernetes.io/docs/getting-started-guides/minikube/#persistent-volumes" rel="noreferrer">https://kubernetes.io/docs/getting-started-guides/minikube/#persistent-volumes</a></p>
<p>So what if my developments need persistent storage (MySQL database, mongodb database, ...) ? Do I need to throw my Minikube and install directly the full Kubernetes ?</p>
| 0debug
|
cursor.execute('SELECT * FROM users WHERE username = ' + user_input)
| 1threat
|
Whats the difference when configuring webpack babel-loader vs configuring it within package.json? : <p>Hi please help me understand the differences between setting babel config inside .babelrc vs webpack loader options, vs inserting it in package.json.</p>
<p>For example, Would it make any difference if I put the presets in the webpack babel-loader options vs package.json or a separate .babelrc config file?</p>
<p>In webpack config: </p>
<pre><code> {
test: /\.(js|jsx|mjs)$/,
loader: require.resolve('babel-loader'),
options: {
"presets": [
"react-app"
]
},
},
</code></pre>
<p>In package json: </p>
<pre><code> "babel": {
"presets": [
"react-app"
]
},
</code></pre>
| 0debug
|
how to create registry key in c# : i am trying to create registry but cant,i change the permission and manually i can create but i want to create using c# here is my code
------------------------------------------------------------
RegistryKey key = Registry.ClassesRoot.CreateSubKey(@"CLSID\\{2559a1f2-21d7-11d4-bdaf-00c04f60b9f0}\\Shell\\Unlock\\command");
key.SetValue("", Application.ExecutablePath, RegistryValueKind.String);
------------------------------------------------------------
i add it manually by changing the permission but its not work in c#
[check this][1]
[1]: https://i.stack.imgur.com/JZ4YL.png
| 0debug
|
How to clean a dictionary where the values are equal to a variable : <p>I have a dictionary composed of multiple key. Is has been created by a loop so the keys generated at the beginning don't have values but, I fill them later.
Sometimes, a key is not filled so I want to remove it from the dictionary </p>
<p>The dictionary look like:</p>
<pre><code>{'a' : [1,2,3,4] , 'b' : [5,6,7,8] ,'c': [] ,'d': [9,10,11]}
</code></pre>
<p>I may have multiple values that look like 'c'
i have tried the try/except but still get the "dictionary changed size during iteration"</p>
<pre><code>d= {'a' : [1,2,3,4] , 'b' : [5,6,7,8] ,'c': [] ,'d': [9,10,11]}
dic_key = d.keys()
for key in dic_key:
try:
if len(d[key]) == 0:
del d[key]
except:
pass
</code></pre>
<p>"dictionary changed size during iteration"</p>
| 0debug
|
void blk_resume_after_migration(Error **errp)
{
BlockBackend *blk;
Error *local_err = NULL;
for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) {
if (!blk->disable_perm) {
continue;
}
blk->disable_perm = false;
blk_set_perm(blk, blk->perm, blk->shared_perm, &local_err);
if (local_err) {
error_propagate(errp, local_err);
blk->disable_perm = true;
return;
}
}
}
| 1threat
|
static void write_palette(const char *key, QObject *obj, void *opaque)
{
struct palette_cb_priv *priv = opaque;
VncState *vs = priv->vs;
uint32_t bytes = vs->clientds.pf.bytes_per_pixel;
uint8_t idx = qint_get_int(qobject_to_qint(obj));
if (bytes == 4) {
uint32_t color = tight_palette_buf2rgb(32, (uint8_t *)key);
((uint32_t*)priv->header)[idx] = color;
} else {
uint16_t color = tight_palette_buf2rgb(16, (uint8_t *)key);
((uint16_t*)priv->header)[idx] = color;
}
}
| 1threat
|
static int omap2_gpio_init(SysBusDevice *sbd)
{
DeviceState *dev = DEVICE(sbd);
struct omap2_gpif_s *s = OMAP2_GPIO(dev);
int i;
if (!s->iclk) {
hw_error("omap2-gpio: iclk not connected\n");
}
if (s->mpu_model < omap3430) {
s->modulecount = (s->mpu_model < omap2430) ? 4 : 5;
memory_region_init_io(&s->iomem, OBJECT(s), &omap2_gpif_top_ops, s,
"omap2.gpio", 0x1000);
sysbus_init_mmio(sbd, &s->iomem);
} else {
s->modulecount = 6;
}
s->modules = g_new0(struct omap2_gpio_s, s->modulecount);
s->handler = g_new0(qemu_irq, s->modulecount * 32);
qdev_init_gpio_in(dev, omap2_gpio_set, s->modulecount * 32);
qdev_init_gpio_out(dev, s->handler, s->modulecount * 32);
for (i = 0; i < s->modulecount; i++) {
struct omap2_gpio_s *m = &s->modules[i];
if (!s->fclk[i]) {
hw_error("omap2-gpio: fclk%d not connected\n", i);
}
m->revision = (s->mpu_model < omap3430) ? 0x18 : 0x25;
m->handler = &s->handler[i * 32];
sysbus_init_irq(sbd, &m->irq[0]);
sysbus_init_irq(sbd, &m->irq[1]);
sysbus_init_irq(sbd, &m->wkup);
memory_region_init_io(&m->iomem, OBJECT(s), &omap2_gpio_module_ops, m,
"omap.gpio-module", 0x1000);
sysbus_init_mmio(sbd, &m->iomem);
}
return 0;
}
| 1threat
|
static int init(AVFilterContext *ctx, const char *args, void *opaque)
{
GraphContext *gctx = ctx->priv;
if(!args)
return 0;
if(!(gctx->link_filter = avfilter_open(&vf_graph_dummy, NULL)))
return -1;
if(avfilter_init_filter(gctx->link_filter, NULL, ctx))
goto fail;
return graph_load_chain_from_string(ctx, args, NULL, NULL);
fail:
avfilter_destroy(gctx->link_filter);
return -1;
}
| 1threat
|
can I add some one that have not paid version of GitHub account to my private repository : I do not have premium account of gutHub, and want to know If I have private repository and some one do not have paid version of gitHub account, can I let him to contribute with me on private repository, and all of commit and change that done by that public account remain private for my project.
Thanks.
| 0debug
|
Please help me with a simple apache mod_rewrite : I know it's been asked a hundred times, and I also took my time searching and trying. Somehow I still can't get it to work, only partially.
I have structure of urls like these: (xxxx can be numbers as well)
- index.php?mode=xxxxx
- index.php?category=xxx
- index.php?product=xxxx
- index.php?article=xxxxx
- index.php?blog&post=xxxxx
The url I'd like to see in the end of all variations:
- www.example.com/something
- www.example.com/something/something (in the blog&post case)
I also would like to hide index.php at the end.
I know it shouldn't be complicated, but time is short and I definitely could use a little help. :)
Thanks.
| 0debug
|
cl_program av_opencl_compile(const char *program_name, const char *build_opts)
{
int i;
cl_int status, build_status;
int kernel_code_idx = 0;
const char *kernel_source;
size_t kernel_code_len;
char* ptr = NULL;
cl_program program = NULL;
size_t log_size;
char *log = NULL;
LOCK_OPENCL;
for (i = 0; i < opencl_ctx.kernel_code_count; i++) {
ptr = av_stristr(opencl_ctx.kernel_code[i].kernel_string, program_name);
if (ptr && !opencl_ctx.kernel_code[i].is_compiled) {
kernel_source = opencl_ctx.kernel_code[i].kernel_string;
kernel_code_len = strlen(opencl_ctx.kernel_code[i].kernel_string);
kernel_code_idx = i;
break;
}
}
if (!kernel_source) {
av_log(&opencl_ctx, AV_LOG_ERROR,
"Unable to find OpenCL kernel source '%s'\n", program_name);
goto end;
}
program = clCreateProgramWithSource(opencl_ctx.context, 1, &kernel_source, &kernel_code_len, &status);
if(status != CL_SUCCESS) {
av_log(&opencl_ctx, AV_LOG_ERROR,
"Unable to create OpenCL program '%s': %s\n", program_name, av_opencl_errstr(status));
program = NULL;
goto end;
}
build_status = clBuildProgram(program, 1, &(opencl_ctx.device_id), build_opts, NULL, NULL);
status = clGetProgramBuildInfo(program, opencl_ctx.device_id,
CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
if (status != CL_SUCCESS) {
av_log(&opencl_ctx, AV_LOG_WARNING,
"Failed to get compilation log: %s\n",
av_opencl_errstr(status));
} else {
log = av_malloc(log_size);
if (log) {
status = clGetProgramBuildInfo(program, opencl_ctx.device_id,
CL_PROGRAM_BUILD_LOG, log_size,
log, NULL);
if (status != CL_SUCCESS) {
av_log(&opencl_ctx, AV_LOG_WARNING,
"Failed to get compilation log: %s\n",
av_opencl_errstr(status));
} else {
int level = build_status == CL_SUCCESS ? AV_LOG_DEBUG :
AV_LOG_ERROR;
av_log(&opencl_ctx, level, "Compilation log:\n%s\n", log);
}
}
av_freep(&log);
}
if (build_status != CL_SUCCESS) {
av_log(&opencl_ctx, AV_LOG_ERROR,
"Compilation failed with OpenCL program '%s': %s\n",
program_name, av_opencl_errstr(build_status));
program = NULL;
goto end;
}
opencl_ctx.kernel_code[kernel_code_idx].is_compiled = 1;
end:
UNLOCK_OPENCL;
return program;
}
| 1threat
|
What does jquery selector that start at '>' means? : <p>Hi i saw selector that is 'parent > child', but didn't see selector that start at '>'
What does it means?</p>
<p>below this code..</p>
<pre><code> $cb.on('change', function(e){
e.preventDefault();
$('> tbody > tr > td:first-child > input:checkbox', $bTable).prop('checked', this.checked);
});
</code></pre>
| 0debug
|
Update multiple rows in sequelize with different conditions : <p>I'm trying to perform an update command with sequelize on rows in a postgres database. I need to be able to update multiple rows that have different conditions with the same value.</p>
<p>For example, assume I have a user table that contains the following fields:</p>
<ul>
<li>ID</li>
<li>First Name</li>
<li>Last Name</li>
<li>Gender</li>
<li>Location</li>
<li>createdAt</li>
</ul>
<p>Assume, I have 4 records in this table, I want to update records with ID - 1 and 4 with a new location say Nigeria.</p>
<p>Something like this: <code>SET field1 = 'foo' WHERE id = 1, SET field1 = 'bar' WHERE id = 2</code></p>
<p>How can I achieve that with sequelize?</p>
| 0debug
|
ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true : <p>I am facing this problem </p>
<p><code>Uglifier::Error: Unexpected token: keyword (const). To use ES6 syntax, harmony mode must be enabled with Uglifier.new(:harmony => true).
</code>
while deploying the project through capistrano on production.</p>
<p>I followed this solution </p>
<p><a href="https://github.com/lautis/uglifier/issues/127#issuecomment-352224986" rel="noreferrer">https://github.com/lautis/uglifier/issues/127#issuecomment-352224986</a></p>
<p>which suggests</p>
<p>replacing</p>
<p><code>config.assets.js_compressor = :uglifier</code></p>
<p>with</p>
<p><code>config.assets.js_compressor = Uglifier.new(harmony: true)</code></p>
<p>but even after doing that I am still facing the same error. I dont understand what went wrong. I am using <code>uglifier (4.1.20)</code> version</p>
| 0debug
|
Postgres INSERT ON CONFLICT DO UPDATE vs INSERT or UPDATE : <p>I have <code>stock_price_alert</code> table with 3 columns. <code>stock_price_id</code> is <code>PRIMARY KEY</code> & also <code>FOREIGN KEY</code> to other table. Table definition as below:</p>
<pre><code>create table stock_price_alert (
stock_price_id integer references stock_price (id) on delete cascade not null,
fall_below_alert boolean not null,
rise_above_alert boolean not null,
primary key (stock_price_id)
);
</code></pre>
<p>I need to either:</p>
<p>1) <code>INSERT</code> record if not exist</p>
<pre><code>-- query 1
INSERT INTO stock_price_alert (stock_price_id, fall_below_alert, rise_above_alert)
VALUES (1, true, false);
</code></pre>
<p>2) <code>UPDATE</code> record if exist</p>
<pre><code>-- query 2
UPDATE stock_price_alert SET
fall_below_alert = true,
rise_above_alert = false
WHERE stock_price_id = 1;
</code></pre>
<p>First I need to issue <code>SELECT</code> query on <code>stock_price_alert</code> table, in order to decide whether to perform query (1) or (2).</p>
<p>Postgres supports <code>INSERT INTO TABLE .... ON CONFLICT DO UPDATE ...</code>:</p>
<pre><code>-- query 3
INSERT INTO stock_price_alert (stock_price_id, fall_below_alert, rise_above_alert)
VALUES (1, true, false)
ON CONFLICT (stock_price_id) DO UPDATE SET
fall_below_alert = EXCLUDED.fall_below_alert,
rise_above_alert = EXCLUDED.rise_above_alert;
</code></pre>
<p>Instead of using query (1) or (2), can I always use query (3)? Then I don't need to issue <code>SELECT</code> query in prior & it helps to simplify the code. </p>
<p>But I am wondering, which is the best practice? Will query (3) cause performance issue or unwanted side effect? Thanks.</p>
| 0debug
|
Disable/Hide "Download the React DevTools..." : <p>How do you completely disable or hide the "persistent" console message: <code>Download the React DevTools for a better development experience</code> while in development?</p>
| 0debug
|
what's the difference between these querys? : Following [how to select specific feid using a filter from access in C#][1]
[1]: http://stackoverflow.com/questions/36422084/how-to-select-specific-feid-using-a-filter-from-access-in-c-sharp
I have another question:
I recall this method whit a click event of `SelectFeedbtn_Click` and it works:
public static void GetSelectedFeed(Form2 frm2)
{
string StrCon = System.Configuration.ConfigurationManager.ConnectionStrings["FeedLibraryConnectionString"].ConnectionString;
OleDbConnection Connection = new OleDbConnection(StrCon);
OleDbDataAdapter DataA = new OleDbDataAdapter("Select * from FeedLibrary", Connection);
DataTable DTable = new DataTable();
DataA.Fill(DTable);
frm2.SelectedFeeddataGridView.DataSource = DTable;
}
even this query is working:
public static void GetSelectedFeed(Form2 frm2)
{
string StrCon = System.Configuration.ConfigurationManager.ConnectionStrings["FeedLibraryConnectionString"].ConnectionString;
OleDbConnection Connection = new OleDbConnection(StrCon);
OleDbDataAdapter DataA = new OleDbDataAdapter("Select * from FeedLibrary where Category = 'Plant Protein'", Connection);
DataTable DTable = new DataTable();
DataA.Fill(DTable);
frm2.SelectedFeeddataGridView.DataSource = DTable;
}
but when I want to get an ID from `FeedSelectListBox` that`DisplayMember` is Feed Name / Description and `ValueMember` is ID it doesn't work, the query is:
public static void GetSelectedFeed(Form2 frm2)
{
string StrCon = System.Configuration.ConfigurationManager.ConnectionStrings["FeedLibraryConnectionString"].ConnectionString;
OleDbConnection Connection = new OleDbConnection(StrCon);
OleDbDataAdapter DataA = new OleDbDataAdapter("Select * from FeedLibrary where ID = 'frm2.FeedSelectListBox.SelectedValue'", Connection);
DataTable DTable = new DataTable();
DataA.Fill(DTable);
frm2.SelectedFeeddataGridView.DataSource = DTable;
}
I get ID with a variable like this but still doesn't work:
public static void GetSelectedFeed(Form2 frm2)
{
string StrCon = System.Configuration.ConfigurationManager.ConnectionStrings["FeedLibraryConnectionString"].ConnectionString;
OleDbConnection Connection = new OleDbConnection(StrCon);
string FeedSelectedID = frm2.FeedSelectListBox.SelectedValue.ToString();
OleDbDataAdapter DataA = new OleDbDataAdapter("Select * from FeedLibrary where ID = 'FeedSelectedID'", Connection);
DataTable DTable = new DataTable();
DataA.Fill(DTable);
frm2.SelectedFeeddataGridView.DataSource = DTable;
}
I even inter Id manually and still doesn't work:
public static void GetSelectedFeed(Form2 frm2)
{
string StrCon = System.Configuration.ConfigurationManager.ConnectionStrings["FeedLibraryConnectionString"].ConnectionString;
OleDbConnection Connection = new OleDbConnection(StrCon);
OleDbDataAdapter DataA = new OleDbDataAdapter("Select * from FeedLibrary where ID = '2'", Connection);
DataTable DTable = new DataTable();
DataA.Fill(DTable);
frm2.SelectedFeeddataGridView.DataSource = DTable;
}
what should I do ???
| 0debug
|
static int file_close_dir(URLContext *h)
{
#if HAVE_DIRENT_H
FileContext *c = h->priv_data;
closedir(c->dir);
return 0;
#else
return AVERROR(ENOSYS);
#endif
}
| 1threat
|
How i place 3 links in the same line on html without usinng css : I need to put 3 links in the same line aligned like left , center and right without using CSS
| 0debug
|
when/why would you use QUOTENAME ? : <p>I understand that QUOTENAME function can be used to add square brackets (default behaviour) or some other character wrapper. QUOTENAME doesn't work for longer strings (over 128 characters). So my question is, why/when would you use it instead of the more conventional and far more easily readable string concatenation. Why would you not just concatenate a single quote or a square bracket at the beginning and end of a term and use this function instead? </p>
| 0debug
|
Docker installation on Linux Mint 19.2 doesn't work : <p>Just got a fresh Linux mint 19.2 installed, i needed docker so i went to the docker doc and followed the process.</p>
<p><a href="https://docs.docker.com/install/linux/docker-ce/ubuntu/" rel="noreferrer">https://docs.docker.com/install/linux/docker-ce/ubuntu/</a></p>
<p>everything went well until step 4 of the repository set up.</p>
<p>on the 4 step it says "Malformed input, repository not added."</p>
<p>I've changed "$(lsb_release -cs)" to "tina" and "tara" still doesn't work.</p>
<p>the 4th step to set up the repository:</p>
<p>sudo add-apt-repository "deb [arch=amd64] <a href="https://download.docker.com/linux/ubuntu" rel="noreferrer">https://download.docker.com/linux/ubuntu</a> $(lsb_release -cs) stable"</p>
| 0debug
|
Does entity framework supports multiple ORM databases at a time? : Does entity framework supports multiple ORM databases at a time? I have two databases MYSQL and SQL SERVER in my solution. if i run one at a time it is working ,but both at a time is not working.
| 0debug
|
Postgres 9.5+: UPSERT to return the count of updated and inserted rows : <p>I get the canonical example:</p>
<pre><code> INSERT INTO user_logins (username, logins)
VALUES ('Naomi',1),('James',1)
ON CONFLICT (username)
DO UPDATE SET logins = user_logins.logins + EXCLUDED.logins;
</code></pre>
<p>But now I also need to know:</p>
<ol>
<li>How many rows were inserted</li>
<li>How many rows were updated because existing</li>
<li>How many rows could not be inserted because of constraints</li>
<li>If the constraint is not respected for the last row, will the previous inserted/updated rows be persisted in the DB? </li>
</ol>
| 0debug
|
How to traverse website, get all console : <p>Say I have a website with the following pages:</p>
<p>page1.html,
page2.html,
page3.html</p>
<p>for each one of these pages, load the page, and get the console logs.</p>
| 0debug
|
int ff_mpegts_parse_packet(MpegTSContext *ts, AVPacket *pkt,
const uint8_t *buf, int len)
{
int len1;
len1 = len;
ts->pkt = pkt;
ts->stop_parse = 0;
for(;;) {
if (ts->stop_parse>0)
break;
if (len < TS_PACKET_SIZE)
return -1;
if (buf[0] != 0x47) {
buf++;
len--;
} else {
handle_packet(ts, buf);
buf += TS_PACKET_SIZE;
len -= TS_PACKET_SIZE;
}
}
return len1 - len;
}
| 1threat
|
static int pte32_check (mmu_ctx_t *ctx,
target_ulong pte0, target_ulong pte1, int h, int rw)
{
return _pte_check(ctx, 0, pte0, pte1, h, rw);
}
| 1threat
|
Why does 2 % 3 = 2 and not 1? : <p>Why does 2 mod 3 equal 2 and not 1?</p>
<p>How many ever '2 mod 3' I put in between, it is printing 2 as the answer. Please can anyone explain this behavior</p>
| 0debug
|
read particular xml node using condition c# : i want to read particular node in xml like if any "Log"(root node) node contain "Message" node the it should read all the node under the "Log" node.
Note : Log node is root node and there are many node under "log" node.
for Example :
<TestLogDataSet>
<Log>
<Assembly>TestCase</Assembly>
<TestMethod>Application</TestMethod>
<Status>Passed</Status>
<Trace />
</Log>
<Log>
<Assembly>TestCase</Assembly>
<TestMethod>Application</TestMethod>
<Status>Failed</Status>
<Message>
<pre><![CDATA[ Error while deleting the Project]]>
</pre>
</Message>
<Trace />
</Log>
</TestLogDataSet>
| 0debug
|
Changing x-axis tick labels ggplot2 not working, making axis disappear, scale_x_discrete : <p>I'm trying to change the x-axis tick labels in ggplot but I can't get it to work for some reason. I have the following code and plot:</p>
<pre><code>ggplot(over36mo, aes(x=raceeth,y=pt,fill=factor(year.2cat))) +
geom_bar(stat="identity",position="dodge") +
geom_errorbar(aes(ymax=pt+se, ymin=pt-se), width=0.2, position=position_dodge(0.9)) +
scale_fill_discrete(guide=FALSE) +
scale_y_continuous(breaks=seq(0, 0.26, 0.02), limits=c(0,0.26)) +
labels=c("NHW","NHB","NHNA/PI","NHA","H")) +
theme(axis.line.x=element_line(color="black"),
axis.line.y=element_line(color="black"),
panel.background=element_blank(),
panel.border=element_blank(),
panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
plot.background=element_blank()) +
xlab("All ages") + ylab("")
</code></pre>
<p><a href="https://i.stack.imgur.com/BkTDm.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/BkTDm.jpg" alt="enter image description here"></a></p>
<p>But when I try to change 1, 2, 3, 4, 5 to different labels with <code>scale_x_discrete</code>, the x-axis disappears like so:</p>
<pre><code>ggplot(over36mo, aes(x=raceeth,y=pt,fill=factor(year.2cat))) +
geom_bar(stat="identity",position="dodge") +
geom_errorbar(aes(ymax=pt+se, ymin=pt-se), width=0.2, position=position_dodge(0.9)) +
scale_fill_discrete(guide=FALSE) +
scale_y_continuous(breaks=seq(0, 0.26, 0.02), limits=c(0,0.26)) +
labels=c("NHW","NHB","NHNA/PI","NHA","H")) +
theme(axis.line.x=element_line(color="black"),
axis.line.y=element_line(color="black"),
panel.background=element_blank(),
panel.border=element_blank(),
panel.grid.major=element_blank(),
panel.grid.minor=element_blank(),
plot.background=element_blank()) +
xlab("All ages") + ylab("") +
scale_x_discrete(breaks=c("1","2","3","4","5"), labels=c("NHW","NHB","NHNA/PI","NHA","H")) +
</code></pre>
<p><a href="https://i.stack.imgur.com/ZaDoj.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/ZaDoj.jpg" alt="enter image description here"></a></p>
<p>It's probably obvious what's wrong but I can't figure it out. Here's a dput of my data if someone wants to give it a shot!</p>
<pre><code>dput(over36mo)
structure(list(z.surv.mos = c(36, 36, 36, 36, 36, 36, 36, 36,
36, 36), raceeth = c(1, 1, 2, 2, 3, 3, 4, 4, 5, 5), year.2cat = c(1,
2, 1, 2, 1, 2, 1, 2, 1, 2), pt = c(0.10896243930756, 0.12919986395988,
0.10763696166101, 0.0918969557367, 0.14186152615109, 0.12701814940611,
0.05405405405405, 0.09393141727008, 0.08880901672474, 0.11716939090588
), nevent = c(9, 3, 0, 0, 2, 1, 0, 0, 1, 1), ncensor = c(0, 9,
0, 1, 0, 2, 0, 1, 0, 0), nrisk = c(311, 96, 33, 9, 72, 21, 2,
2, 48, 20), cum.ev = c(2474, 2469, 287, 342, 440, 496, 35, 40,
505, 616), cum.cen = c(1, 958, 4, 107, 12, 198, 0, 13, 19, 239
), pointflg = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), pe = c(0.89103756069243,
0.87080013604011, 0.89236303833898, 0.90810304426329, 0.8581384738489,
0.87298185059388, 0.94594594594594, 0.90606858272991, 0.91119098327525,
0.88283060909411), se = c(0.00591553159512, 0.00860912091676,
0.01746946721576, 0.01975702415208, 0.01550071018085, 0.01904081251339,
0.03717461110299, 0.05797150600236, 0.01228353765126, 0.01608823714602
), lower.cl = c(0.09796374785164, 0.11338170396883, 0.07830897003442,
0.06029765195198, 0.11451353670001, 0.09468155080317, 0.01404207131432,
0.02802051731609, 0.06772108402588, 0.08952365586359), upper.cl = c(0.12119598770184,
0.14722485430136, 0.14794876641234, 0.1400560419898, 0.17574073058836,
0.17039866945242, 0.20807761862723, 0.31488038035974, 0.11646360310182,
0.15335238527538)), .Names = c("z.surv.mos", "raceeth", "year.2cat",
"pt", "nevent", "ncensor", "nrisk", "cum.ev", "cum.cen", "pointflg",
"pe", "se", "lower.cl", "upper.cl"), row.names = c("38", "134",
"183", "246", "289", "366", "412", "452", "491", "563"), class = "data.frame")
</code></pre>
| 0debug
|
Parse Space Delimited Files With Spaces In Fields : <p>I have a CSV file that uses a space as the delimiter. But some of the fields contain a space and those fields are wrapped with double quotes. Any field with a null/empty value is represented as "-". Fields that are not null/empty and do not contain spaces are not wrapped in double quotes. Here's an example of one row in the CSV file.</p>
<pre><code>foobar "foo bar" "-" "-" "-" fizzbuzz "fizz buzz" fizz buzz
</code></pre>
<p>Also there are no headers for the CSV file. I was going to use a simple solution such as this one <a href="https://stackoverflow.com/a/20769342/3299397">https://stackoverflow.com/a/20769342/3299397</a> but using <code>strings.Split(csvInput, " ")</code> wouldn't handle the spaces inside the fields. I've also looked into this library <a href="https://github.com/gocarina/gocsv" rel="nofollow noreferrer">https://github.com/gocarina/gocsv</a> but I'm curious if there's a solution that doesn't use a third-party library.</p>
| 0debug
|
5th heighest salary from Employee Table and Salary Table using LINQ query : Table1: EmolyeeTable
Eid Ename
1 Jonh
2 James
3 Raj
4 Tisan
5 Jack
Table2: SalaryTable
Sid Salary Eid
1 10000 1
2 20000 2
3 30000 3
4 40000 4
5 50000 5
I want output: 5th heighest Ename, salary using LINQ query
O/P:
Ename Salary
Jack 50000
| 0debug
|
How to Clear() all elements from Entity Framework ICollection? : <p>I have problems removing all elements from a collection in entity framework using Clear()</p>
<p>Consider the often used example with Blogs and Posts.</p>
<pre><code>public class Blog
{
public int Id {get; set;}
public string Name {get; set;}
public virtual ICollection<Post> Posts { get; set; }
}
public class Post
{
public int Id { get; set; }
// foreign key to Blog:
public int BlogId { get; set; }
public virtual Blog Blog { get; set; }
public string Title { get; set; }
public string Text { get; set; }
}
public class BlogContext : DbContext
{
public DbSet<Blog> Blogs {get; set;}
public DbSet<Post> Posts {get; set;}
}
</code></pre>
<p>A Blog has many Posts. A Blog has an ICollection of Posts. There is a straightforward one-to-many relation between Blogs and Posts.</p>
<p>Suppose I want to remove all Posts from a Blog</p>
<p>Of course I could do the following:</p>
<pre><code>Blog myBlog = ...
var postsToRemove = dbContext.Posts.Where(post => post.BlogId == myBlog.Id);
dbContext.RemoveRange(postsToRemove);
dbContext.SaveChanges();
</code></pre>
<p>However, the following seems easier:</p>
<pre><code>Blog myBlog = ...
myBlog.Posts.Clear();
dbContext.SaveChanges();
</code></pre>
<p>However this leads to an InvalidOperationException:</p>
<p><em>The operation failed: The relationship could not be changed because one or more of the foreign-key properties is non-nullable. When a change is made to a relationship, the related foreign-key property is set to a null value. If the foreign-key does not support null values, a new relationship must be defined, the foreign-key property must be assigned another non-null value, or the unrelated object must be deleted.</em></p>
<p>What is the proper way to clear the collection? Is there a fluent API statement for this?</p>
| 0debug
|
DeviceState *qdev_try_create(BusState *bus, const char *type)
{
DeviceState *dev;
if (object_class_by_name(type) == NULL) {
return NULL;
}
dev = DEVICE(object_new(type));
if (!dev) {
return NULL;
}
if (!bus) {
bus = sysbus_get_default();
}
qdev_set_parent_bus(dev, bus);
object_unref(OBJECT(dev));
return dev;
}
| 1threat
|
Webpack plugin: how can I modify and re-parse a module after compilation? : <p>I'm working on a webpack plugin and can't figure out how to modify a module during the build. What I'm trying to do:</p>
<ul>
<li>Collect data via a custom loader (fine)</li>
<li>After all modules have been loaded, collect data gathered by my loader (fine)</li>
<li>Insert code I generate into an existing module in the build (doing this as described below, not sure if it's the best way)</li>
<li>'update' that module so that the code I added gets parsed and has its 'require's turned into webpack require calls (can't figure out how to do this correctly)</li>
</ul>
<p>Currently I'm hooking into 'this-compilation' on the compiler, then 'additional-chunk-assets' on the compilation. Grabbing the first chunk (the only one, currently, as I'm still in development), iterating through the modules in that chunk to find the one I want to modify. Then:</p>
<ul>
<li>Appending my generated source to the module's _cachedSource.source._source._value (I also tried appending to the module's ._source._value)</li>
<li>setting the ._cachedSource.hash to an empty string (as this seems to be necessary for the next step to work)</li>
<li>I pass the module to .rebuildModule() </li>
</ul>
<p>It looks like rebuildModule should re-parse the source, re-establish dependencies, etc. etc., but it's not parsing my require statements and changing them to webpack requires. The built file includes my modified source but the require('...') statements are unmodified.</p>
<p>How can I make the module I modified 'update' so that webpack will treat my added source the same as the originally parsed source? Is there something I need to do in addition to rebuildModule()? Am I doing this work too late in the build process? Or am I going about it the wrong way?</p>
| 0debug
|
av_cold int ff_intrax8_common_init(AVCodecContext *avctx,
IntraX8Context *w, IDCTDSPContext *idsp,
int16_t (*block)[64],
int block_last_index[12],
int mb_width, int mb_height)
{
int ret = x8_vlc_init();
if (ret < 0)
return ret;
w->avctx = avctx;
w->idsp = *idsp;
w->mb_width = mb_width;
w->mb_height = mb_height;
w->block = block;
w->block_last_index = block_last_index;
w->prediction_table = av_mallocz(w->mb_width * 2 * 2);
if (!w->prediction_table)
return AVERROR(ENOMEM);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[0],
ff_wmv1_scantable[0]);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[1],
ff_wmv1_scantable[2]);
ff_init_scantable(w->idsp.idct_permutation, &w->scantable[2],
ff_wmv1_scantable[3]);
ff_intrax8dsp_init(&w->dsp);
ff_blockdsp_init(&w->bdsp, avctx);
return 0;
}
| 1threat
|
how to download sample text file when i click the link in d3.js? :
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<a href="">Please Download Sample file</a>
<!-- end snippet -->
<!-- begin snippet: js hide: false console: true babel: false -->
i have to download following sample.txt file when i click the link..
how to add download option in d3.js
<!-- language: lang-html -->
sample.txt:
hello world...
<!-- end snippet -->
| 0debug
|
how to secure an excel file so that the form and code is secure against copying? : <p>I have an Excel file that has a form and macros.
I will give this Excel file to users.
However, the form and the code must be protected against copying.
I thought to break the Excel macros into DLL so that the VBA code can not be recovered.</p>
<p>Would you know if from the DLL we can recover the original VBA code?</p>
<p>Do you have other ideas to protect against copying?</p>
<p>Thanks</p>
| 0debug
|
Which RAM type should I get for my laptop? : <p>My Laptop is Sony Vaio model no SVE1511AENB and my RAM is of 2gb and its type is "1Rx8 PC3-12800S-11-11-B2". I want to exand my RAM so which RAM should I buy for laptop?</p>
| 0debug
|
static int handle_alloc(BlockDriverState *bs, uint64_t guest_offset,
uint64_t *host_offset, uint64_t *bytes, QCowL2Meta **m)
{
BDRVQcow2State *s = bs->opaque;
int l2_index;
uint64_t *l2_table;
uint64_t entry;
unsigned int nb_clusters;
int ret;
uint64_t alloc_cluster_offset;
trace_qcow2_handle_alloc(qemu_coroutine_self(), guest_offset, *host_offset,
*bytes);
assert(*bytes > 0);
nb_clusters =
size_to_clusters(s, offset_into_cluster(s, guest_offset) + *bytes);
l2_index = offset_to_l2_index(s, guest_offset);
nb_clusters = MIN(nb_clusters, s->l2_size - l2_index);
ret = get_cluster_table(bs, guest_offset, &l2_table, &l2_index);
if (ret < 0) {
return ret;
}
entry = be64_to_cpu(l2_table[l2_index]);
if (entry & QCOW_OFLAG_COMPRESSED) {
nb_clusters = 1;
} else {
nb_clusters = count_cow_clusters(s, nb_clusters, l2_table, l2_index);
}
assert(nb_clusters > 0);
qcow2_cache_put(bs, s->l2_table_cache, (void **) &l2_table);
alloc_cluster_offset = start_of_cluster(s, *host_offset);
ret = do_alloc_cluster_offset(bs, guest_offset, &alloc_cluster_offset,
&nb_clusters);
if (ret < 0) {
goto fail;
}
if (nb_clusters == 0) {
*bytes = 0;
return 0;
}
if (!alloc_cluster_offset) {
ret = qcow2_pre_write_overlap_check(bs, 0, alloc_cluster_offset,
nb_clusters * s->cluster_size);
assert(ret < 0);
goto fail;
}
int requested_sectors =
(*bytes + offset_into_cluster(s, guest_offset))
>> BDRV_SECTOR_BITS;
int avail_sectors = nb_clusters
<< (s->cluster_bits - BDRV_SECTOR_BITS);
int alloc_n_start = offset_into_cluster(s, guest_offset)
>> BDRV_SECTOR_BITS;
int nb_sectors = MIN(requested_sectors, avail_sectors);
QCowL2Meta *old_m = *m;
*m = g_malloc0(sizeof(**m));
**m = (QCowL2Meta) {
.next = old_m,
.alloc_offset = alloc_cluster_offset,
.offset = start_of_cluster(s, guest_offset),
.nb_clusters = nb_clusters,
.nb_available = nb_sectors,
.cow_start = {
.offset = 0,
.nb_sectors = alloc_n_start,
},
.cow_end = {
.offset = nb_sectors * BDRV_SECTOR_SIZE,
.nb_sectors = avail_sectors - nb_sectors,
},
};
qemu_co_queue_init(&(*m)->dependent_requests);
QLIST_INSERT_HEAD(&s->cluster_allocs, *m, next_in_flight);
*host_offset = alloc_cluster_offset + offset_into_cluster(s, guest_offset);
*bytes = MIN(*bytes, (nb_sectors * BDRV_SECTOR_SIZE)
- offset_into_cluster(s, guest_offset));
assert(*bytes != 0);
return 1;
fail:
if (*m && (*m)->nb_clusters > 0) {
QLIST_REMOVE(*m, next_in_flight);
}
return ret;
}
| 1threat
|
static int64_t scene_sad16(FrameRateContext *s, const uint16_t *p1, int p1_linesize, const uint16_t* p2, int p2_linesize, int height)
{
int64_t sad;
int x, y;
for (sad = y = 0; y < height; y += 8) {
for (x = 0; x < p1_linesize; x += 8) {
sad += sad_8x8_16(p1 + y * p1_linesize + x,
p1_linesize,
p2 + y * p2_linesize + x,
p2_linesize);
}
}
return sad;
}
| 1threat
|
Image won't show up on website : <p>So I'm helping my friend with her website. The website is currently up and running but two images won't show up using lightbox on a specific page.</p>
<p>The first two images will load properly when clicking the thumbnails. But the two on the bottom won't. I tried to access the images directly and found out that when i tried this <a href="http://www.containerwest.com/extensions/gallery/grandeprairie1.jpg" rel="nofollow">http://www.containerwest.com/extensions/gallery/grandeprairie1.jpg</a> (the link of the first image) it worked but not <a href="http://www.containerwest.com/extensions/gallery/grandeprairie4.jpg" rel="nofollow">http://www.containerwest.com/extensions/gallery/grandeprairie4.jpg</a> (the 3rd image that is supposed to work as well).</p>
<p>The html code is like this:</p>
<pre><code><table width="240" border="0" cellpadding="0" cellspacing="4">
<col width="240">
<col width="240">
<col width="240">
<tr valign="top">
<td width="200" style="border:2px solid #FFFFFF; padding: 3px; margin: 2.5px;">
<p align="center"><a href="../extensions/gallery/grandeprairie4.jpg" rel="lightbox[cnrl]">
<img src="../extensions/gallery/grandeprairie4_200x200.jpg" alt="20' used container" style="width:200px;height:200px;" />
</td>
<td width="200" style="border:2px solid #FFFFFF; padding: 3px; margin: 2.5px;">
<p align="center"><a href="../extensions/gallery/grandeprairie5.jpg" rel="lightbox[cnrl]">
<img src="../extensions/gallery/grandeprairie5_200x200.jpg" alt="20' used container" style="width:200px;height:200px;" />
</td>
</code></pre>
<p>The two images are in two cells in a table. And all the paths should be correct since all the images are under the same folder with the same dimensions(slightly different sizes though but nothing huge). The only difference is the numbers in their names.And the first two images are displayed using the same code. </p>
<p>I can't figure out what is wrong here since the code seems right to me. I suspect the web host and not the lightbox.</p>
<p>Any help would be appreciated! </p>
<p>Thanks a lot!</p>
| 0debug
|
static void setup_frame(int sig, struct target_sigaction *ka,
target_sigset_t *set, CPUX86State *env)
{
abi_ulong frame_addr;
struct sigframe *frame;
int i, err = 0;
frame_addr = get_sigframe(ka, env, sizeof(*frame));
if (!lock_user_struct(VERIFY_WRITE, frame, frame_addr, 0))
goto give_sigsegv;
__put_user(current_exec_domain_sig(sig),
&frame->sig);
if (err)
goto give_sigsegv;
setup_sigcontext(&frame->sc, &frame->fpstate, env, set->sig[0],
frame_addr + offsetof(struct sigframe, fpstate));
if (err)
goto give_sigsegv;
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
if (__put_user(set->sig[i], &frame->extramask[i - 1]))
goto give_sigsegv;
}
if (ka->sa_flags & TARGET_SA_RESTORER) {
__put_user(ka->sa_restorer, &frame->pretcode);
} else {
uint16_t val16;
abi_ulong retcode_addr;
retcode_addr = frame_addr + offsetof(struct sigframe, retcode);
__put_user(retcode_addr, &frame->pretcode);
val16 = 0xb858;
__put_user(val16, (uint16_t *)(frame->retcode+0));
__put_user(TARGET_NR_sigreturn, (int *)(frame->retcode+2));
val16 = 0x80cd;
__put_user(val16, (uint16_t *)(frame->retcode+6));
}
if (err)
goto give_sigsegv;
env->regs[R_ESP] = frame_addr;
env->eip = ka->_sa_handler;
cpu_x86_load_seg(env, R_DS, __USER_DS);
cpu_x86_load_seg(env, R_ES, __USER_DS);
cpu_x86_load_seg(env, R_SS, __USER_DS);
cpu_x86_load_seg(env, R_CS, __USER_CS);
env->eflags &= ~TF_MASK;
unlock_user_struct(frame, frame_addr, 1);
return;
give_sigsegv:
unlock_user_struct(frame, frame_addr, 1);
if (sig == TARGET_SIGSEGV)
ka->_sa_handler = TARGET_SIG_DFL;
force_sig(TARGET_SIGSEGV );
}
| 1threat
|
learn C# for Xamarin : <p>I want to build apps using Xamarin in C#. But unfortunately I don't know C#. I have tried looking around on Google but nothing really helpful comes along. If anyone uses Xamarin to make C# apps can you please tell me where you learn it. Thank you. </p>
| 0debug
|
Why the following error is generating ? : I am writing PHP code in Netbeans. Program is generating the correct output but the following notice is generating on the browser.
Notice:
Notice: Undefined index: name in C:\xampp\htdocs\PhpProject3\index.php
on line 2
Notice: Undefined index: name in C:\xampp\htdocs\PhpProject3\index.php
on line 3
Notice: Undefined index: name in C:\xampp\htdocs\PhpProject3\index.php
on line 4
Notice: Undefined index: name in C:\xampp\htdocs\PhpProject3\index.php
on line 5
Here is my code:
<?php
echo $name=$_FILES['name']['name'].'<br>';
echo $size=$_FILES['name']['size'].'<br>';
echo $type=$_FILES['name']['type'].'<br>';
echo $tmp_name=$_FILES['name']['tmp_name'];
?>
<form action="index.php" method="POST" enctype="multipart/form-data">
<input type="file" name="name"><br/><br/>
<input type="submit" value="Submit">
</form>
[![Screen shot of the output][1]][1]
[1]: https://i.stack.imgur.com/C8vzC.jpg
| 0debug
|
Execution failed for task ':app:compileDebugJavaWithJavac': : <p>When I try <code>$ react-native run-android</code> on android emulator, I get this error:</p>
<pre><code>:app:compileDebugJavaWithJavac
/home/user/app/android/app/src/main/java/com/package/MainApplication.java:8: error: a type with the same simple name is already defined by the single-type-import of RNAWSCognitoPackage
import com.airlabsinc.RNAWSCognitoPackage;
^
1 error
Incremental compilation of 1 classes completed in 0.448 secs.
:app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 10.964 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
</code></pre>
<p>Then I have 2 imports with the same name in my <code>/home/user/app/android/app/src/main/java/com/package/MainApplication.java</code>
May this cause the issue?
Is this the issue with RN?</p>
<pre><code>package com.package;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.amazonaws.RNAWSCognitoPackage; // 1
import com.amazonaws.amplify.pushnotification.RNPushNotificationPackage;
import com.airlabsinc.RNAWSCognitoPackage; // 2
import com.horcrux.svg.SvgPackage;
import com.toast.ToastPackage;
import com.vdi.VDIPackage;
import com.BV.LinearGradient.LinearGradientPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
</code></pre>
<p>My env:</p>
<pre><code>**Environment**:
* OS: Linux 4.13
* Node: 8.9.4
* Yarn: Not Found
* npm: 5.6.0
* Watchman: Not Found
* Xcode: N/A
* Android Studio: Not Found
**Packages**: (wanted => installed)
* react: 16.3.0-alpha.2 => 16.3.0-alpha.2
* react-native: 0.54.2 => 0.54.2
</code></pre>
| 0debug
|
Can I install selenium webdriver into Visual Studio Code? : <p>I would like to start writing some selenium scripts using Visual Studio Code.</p>
<p>Can I install the webdriver(s) and how?</p>
<p>In the demonstration video's that I have seen Visual Studio was used, not VSC.</p>
<p>Please guide me since I am not familiar with the VSC editor.</p>
| 0debug
|
how do i delete the first, third, fifth and sixth column of a text file in python : So I want to delete the first and third column of this text file my text file Looks like this:
10 11 12 46 48 39
20 21 22 34 23 24
30 31 32 78 29 38
40 41 42 21 43 12
My Code Looks like this:
`f = open("Exercise2.txt", "r")
g = open("Output.txt", "w")
for line in f:
if line.strip():
g.write("\t".join(line.split()[1:-1]) + "\n")
f.close()
g.close()`
But i cant delete a column in between two columns that i want to stay. How do i do that?
| 0debug
|
How do we set environmental variable in java for windows 10? : <p>Can anyone let me know how to do it in windows 10?</p>
<p>I want to ad classpath and path in both user and system variables.</p>
| 0debug
|
"How to pass String value in between URL in C/C++?" : <p>I've one variable in which i get string value from user.
Now i want to use that string value in URL.
like my string value is "Indore". so it should pass like
URL="awe/Indore/ddsd".
Please tell me how to solve?</p>
| 0debug
|
Python - most accurate time, timezone, calendar library/module : <p>What is the most accurate library or module for python for time zone conversions, i.e. local time to UTC conversions, calendar day conversions that address many historic wartime time zone changes, timezone adoptions and splits, etc over the last couple of centuries? </p>
| 0debug
|
Android alternative to GCM Push Notifications : <p>I develop a messenger application. To deliver messages used GCM and Websockets, when app in background websocket is closed and only gcm can push message to device.<br>
I tested my app on some devices and seems it works fine.<br><br>
But on the Play Market I have many comments about "messages not delivered when app in background". <br></p>
<p><strong>What is the best way to do that messages are always guaranteed delivered when app is background?</strong> <br> <br>
May be I need use background Service that always contains websocket connection? <br>
How it is done in Whatsapp messenger?</p>
| 0debug
|
SSH but not ping : <p>I have an Ubuntu VM (running on MacOS host) and am trying to connect to another box that is running Linux (busybox, IIRC). </p>
<p>I can ssh from machine A (Ubuntu-VM) to machine B (busybox). I can ping from A -> B, but I cannot ping from B -> A.</p>
<p>Machine A has IP of 10.0.2.15, B has IP of 10.1.10.216.</p>
<p>My ultimate goal is to be able to use wget on B to get files from A, and I'm hoping that solving this ping problem will allow B to see A and allow magic to occur.</p>
<p>My network comprehension is near zero, so this is probably trivial, but any help greatly appreciated.</p>
| 0debug
|
Specific questions about gunDB as a standalone DB for a Cordova project : <p>I just found out about gunDB and the concept seems very interesting and I'd like to find out more about it before starting to evaluate it further.</p>
<ul>
<li>If I wanted to build a chat app like the tutorial but implement chat <strong>rooms</strong>. Would there be a way for clients to only "subscribe" to certain chat rooms only, and avoid transferring the content of every other chat room? How does that affect persistence, if not all data is sync'd to all clients? Do we need to run a special client (ie a server?) that will make sure all data is kept alive at all times?</li>
<li>For that same chat room tutorial, if I want to subscribe to multiple chat rooms, would I need to instantiate multiple Gun instances, with each one using "peer" storage?</li>
<li>How should user management/passwords/etc be dealt with in gunDB?
Sending every client a copy of the user DB is interesting from a
replication stand point, but from a security aspect, it seems counter
intuitive.</li>
<li>Is there a way to ask gun to only sync under certain circumstances such as when a WiFi connection is available (think Cordova)?</li>
<li>What about data that's temporal? Is there a way in the chat app, for
instance to tell gunDB that I'm only interested in future messages
and ignore anything that was created prior to a certain
state/timestamp (again to avoid transferring huge amounts of data on
an expensive data plan)?</li>
<li>How do you persist to disk (potentially circular) data in a gunDB and
load the data back in the DB should the need arise?</li>
<li>Can you ask gun to monitor two keys simultaneously? For example if a client needs to display chat data and todo list (both 'keys' from the tutorial) assuming both are 'peered'.</li>
<li>Is there a tutorial for how to use my own server for storage?</li>
</ul>
| 0debug
|
gen_intermediate_code_internal(MIPSCPU *cpu, TranslationBlock *tb,
bool search_pc)
{
CPUState *cs = CPU(cpu);
CPUMIPSState *env = &cpu->env;
DisasContext ctx;
target_ulong pc_start;
uint16_t *gen_opc_end;
CPUBreakpoint *bp;
int j, lj = -1;
int num_insns;
int max_insns;
int insn_bytes;
int is_slot;
if (search_pc)
qemu_log("search pc %d\n", search_pc);
pc_start = tb->pc;
gen_opc_end = tcg_ctx.gen_opc_buf + OPC_MAX_SIZE;
ctx.pc = pc_start;
ctx.saved_pc = -1;
ctx.singlestep_enabled = cs->singlestep_enabled;
ctx.insn_flags = env->insn_flags;
ctx.CP0_Config1 = env->CP0_Config1;
ctx.tb = tb;
ctx.bstate = BS_NONE;
ctx.kscrexist = (env->CP0_Config4 >> CP0C4_KScrExist) & 0xff;
ctx.rxi = (env->CP0_Config3 >> CP0C3_RXI) & 1;
ctx.ie = (env->CP0_Config4 >> CP0C4_IE) & 3;
ctx.bi = (env->CP0_Config3 >> CP0C3_BI) & 1;
ctx.bp = (env->CP0_Config3 >> CP0C3_BP) & 1;
ctx.hflags = (uint32_t)tb->flags;
ctx.ulri = env->CP0_Config3 & (1 << CP0C3_ULRI);
restore_cpu_state(env, &ctx);
#ifdef CONFIG_USER_ONLY
ctx.mem_idx = MIPS_HFLAG_UM;
#else
ctx.mem_idx = ctx.hflags & MIPS_HFLAG_KSU;
#endif
num_insns = 0;
max_insns = tb->cflags & CF_COUNT_MASK;
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
LOG_DISAS("\ntb %p idx %d hflags %04x\n", tb, ctx.mem_idx, ctx.hflags);
gen_tb_start();
while (ctx.bstate == BS_NONE) {
if (unlikely(!QTAILQ_EMPTY(&cs->breakpoints))) {
QTAILQ_FOREACH(bp, &cs->breakpoints, entry) {
if (bp->pc == ctx.pc) {
save_cpu_state(&ctx, 1);
ctx.bstate = BS_BRANCH;
gen_helper_0e0i(raise_exception, EXCP_DEBUG);
ctx.pc += 4;
goto done_generating;
}
}
}
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
if (lj < j) {
lj++;
while (lj < j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
}
tcg_ctx.gen_opc_pc[lj] = ctx.pc;
gen_opc_hflags[lj] = ctx.hflags & MIPS_HFLAG_BMASK;
gen_opc_btarget[lj] = ctx.btarget;
tcg_ctx.gen_opc_instr_start[lj] = 1;
tcg_ctx.gen_opc_icount[lj] = num_insns;
}
if (num_insns + 1 == max_insns && (tb->cflags & CF_LAST_IO))
gen_io_start();
is_slot = ctx.hflags & MIPS_HFLAG_BMASK;
if (!(ctx.hflags & MIPS_HFLAG_M16)) {
ctx.opcode = cpu_ldl_code(env, ctx.pc);
insn_bytes = 4;
decode_opc(env, &ctx);
} else if (ctx.insn_flags & ASE_MICROMIPS) {
ctx.opcode = cpu_lduw_code(env, ctx.pc);
insn_bytes = decode_micromips_opc(env, &ctx);
} else if (ctx.insn_flags & ASE_MIPS16) {
ctx.opcode = cpu_lduw_code(env, ctx.pc);
insn_bytes = decode_mips16_opc(env, &ctx);
} else {
generate_exception(&ctx, EXCP_RI);
ctx.bstate = BS_STOP;
break;
}
if (ctx.hflags & MIPS_HFLAG_BMASK) {
if (!(ctx.hflags & (MIPS_HFLAG_BDS16 | MIPS_HFLAG_BDS32 |
MIPS_HFLAG_FBNSLOT))) {
is_slot = 1;
}
}
if (is_slot) {
gen_branch(&ctx, insn_bytes);
}
ctx.pc += insn_bytes;
num_insns++;
if (cs->singlestep_enabled && (ctx.hflags & MIPS_HFLAG_BMASK) == 0) {
break;
}
if ((ctx.pc & (TARGET_PAGE_SIZE - 1)) == 0)
break;
if (tcg_ctx.gen_opc_ptr >= gen_opc_end) {
break;
}
if (num_insns >= max_insns)
break;
if (singlestep)
break;
}
if (tb->cflags & CF_LAST_IO) {
gen_io_end();
}
if (cs->singlestep_enabled && ctx.bstate != BS_BRANCH) {
save_cpu_state(&ctx, ctx.bstate == BS_NONE);
gen_helper_0e0i(raise_exception, EXCP_DEBUG);
} else {
switch (ctx.bstate) {
case BS_STOP:
gen_goto_tb(&ctx, 0, ctx.pc);
break;
case BS_NONE:
save_cpu_state(&ctx, 0);
gen_goto_tb(&ctx, 0, ctx.pc);
break;
case BS_EXCP:
tcg_gen_exit_tb(0);
break;
case BS_BRANCH:
default:
break;
}
}
done_generating:
gen_tb_end(tb, num_insns);
*tcg_ctx.gen_opc_ptr = INDEX_op_end;
if (search_pc) {
j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
lj++;
while (lj <= j)
tcg_ctx.gen_opc_instr_start[lj++] = 0;
} else {
tb->size = ctx.pc - pc_start;
tb->icount = num_insns;
}
#ifdef DEBUG_DISAS
LOG_DISAS("\n");
if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
qemu_log("IN: %s\n", lookup_symbol(pc_start));
log_target_disas(env, pc_start, ctx.pc - pc_start, 0);
qemu_log("\n");
}
#endif
}
| 1threat
|
How can/could/should I increment a date/time parameter in JMeter? : <p>I am sending post requests which have as parameters time and date (among others).</p>
<p>Is there a way in which after sending a request (that fills in an appointment and displays in the UI a Calendar) the time parameter would increase with 30 minutes? </p>
<p>And to cherry on the cake would be that after sending a number of requests for a certain day to be able to change the date and send another bulk of request without copy pasting and manually filling in date and time for each post?</p>
<p>basically today is 07/19/2019, I would have to send out request with time parameter that would be 00:00:00, 00:30:00 and so on. It would total 48 requests.</p>
<p>after sending those the date parameter would change into 07/20/2019 and the time parameter will continue to update the 30 minute mark.</p>
<p>I am not asking for someone to create a script for me (sure that helps), but some guidance because I find it hard to copy paste so many times.</p>
<p>Thank you in advance!</p>
| 0debug
|
void kqemu_flush(CPUState *env, int global)
{
LOG_INT("kqemu_flush:\n");
nb_pages_to_flush = KQEMU_FLUSH_ALL;
}
| 1threat
|
Syntax Error in Calling a method from another class : <p>How may I call a method in another class from another class in a separate file. The files are in the same directory. I tried calling this SMAMethod method</p>
<pre><code>namespace myBackEnd
{
public class SMA
{
public static Models.DateClose SMAMethod (Queue<Models.DateClose>
queue, int period)
{
decimal average, sum=0;
Models.DateClose dateClose = null;
for (int i = 0; i < period; i++)
{
dateClose = queue.Dequeue();
if (dateClose != null)
sum += dateClose.Close;
}
average = sum/period;
dateClose.Close = average;
return dateClose;
}
}
}
</code></pre>
<p>When I call the SMAMethod in I get the red squiggly line with the hover over text " SMAMethod does not exists in the current context"</p>
<pre><code>SMAMethod(movingAverageQueue, 10);
</code></pre>
| 0debug
|
Javascript to trigger an alert message on a form : <p>I have a PHP page with a form:</p>
<pre><code><form method="POST" action="multimod.php" id="multiple">
<!-- some checkboxes here -->
<input type="image" name="submit" src="img/upd.png" alt="modify" class="multi" />
</form>
</code></pre>
<p>Then I want to trigger an alert on submit. When the image is clicked on, a sweetAlert message is triggered:</p>
<pre><code><script>
$('input.multi').click(function(e){
e.preventDefault();
swal({
title: "a title",
text: "some text",
type: "warning",
confirmButtonText: 'yes',
cancelButtonText: 'no',
showCancelButton: true,
},
function(){
document.forms["multiple"].submit();
});
});
</script>
</code></pre>
<p>As you can see the <code>id</code> of the form ("multiple") is used to reference it in the Javascript function.</p>
<p>It works for me, but I wonder if the syntax of the script is actually correct. I found this workaround online, and maybe there are better ways of doing it.</p>
| 0debug
|
Angular2 implementation : I just stumbled across [this example][1] for SPA and I am wondering if someone has already done something similar in an Angular2 app with TypeScript service/component.
[1]: https://github.com/Azure-Samples/active-directory-javascript-singlepageapp-dotnet-webapi-v2
| 0debug
|
static int send_dma_request(int cmd, uint64_t sector, int nb_sectors,
PrdtEntry *prdt, int prdt_entries,
void(*post_exec)(QPCIDevice *dev, void *ide_base,
uint64_t sector, int nb_sectors))
{
QPCIDevice *dev;
void *bmdma_base;
void *ide_base;
uintptr_t guest_prdt;
size_t len;
bool from_dev;
uint8_t status;
int flags;
dev = get_pci_device(&bmdma_base, &ide_base);
flags = cmd & ~0xff;
cmd &= 0xff;
switch (cmd) {
case CMD_READ_DMA:
case CMD_PACKET:
from_dev = true;
break;
case CMD_WRITE_DMA:
from_dev = false;
break;
default:
g_assert_not_reached();
}
if (flags & CMDF_NO_BM) {
qpci_config_writew(dev, PCI_COMMAND,
PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
}
qpci_io_writeb(dev, ide_base + reg_device, 0 | LBA);
qpci_io_writeb(dev, bmdma_base + bmreg_cmd, 0);
qpci_io_writeb(dev, bmdma_base + bmreg_status, BM_STS_INTR);
len = sizeof(*prdt) * prdt_entries;
guest_prdt = guest_alloc(guest_malloc, len);
memwrite(guest_prdt, prdt, len);
qpci_io_writel(dev, bmdma_base + bmreg_prdt, guest_prdt);
if (cmd == CMD_PACKET) {
qpci_io_writeb(dev, ide_base + reg_feature, 0x01);
} else {
qpci_io_writeb(dev, ide_base + reg_nsectors, nb_sectors);
qpci_io_writeb(dev, ide_base + reg_lba_low, sector & 0xff);
qpci_io_writeb(dev, ide_base + reg_lba_middle, (sector >> 8) & 0xff);
qpci_io_writeb(dev, ide_base + reg_lba_high, (sector >> 16) & 0xff);
}
qpci_io_writeb(dev, ide_base + reg_command, cmd);
if (post_exec) {
post_exec(dev, ide_base, sector, nb_sectors);
}
qpci_io_writeb(dev, bmdma_base + bmreg_cmd,
BM_CMD_START | (from_dev ? BM_CMD_WRITE : 0));
if (flags & CMDF_ABORT) {
qpci_io_writeb(dev, bmdma_base + bmreg_cmd, 0);
}
do {
status = qpci_io_readb(dev, bmdma_base + bmreg_status);
} while ((status & (BM_STS_ACTIVE | BM_STS_INTR)) == BM_STS_ACTIVE);
g_assert_cmpint(get_irq(IDE_PRIMARY_IRQ), ==, !!(status & BM_STS_INTR));
assert_bit_set(qpci_io_readb(dev, ide_base + reg_status), DRDY);
assert_bit_clear(qpci_io_readb(dev, ide_base + reg_status), BSY | DRQ);
g_assert(!get_irq(IDE_PRIMARY_IRQ));
if (status & BM_STS_ACTIVE) {
qpci_io_writeb(dev, bmdma_base + bmreg_cmd, 0);
}
free_pci_device(dev);
return status;
}
| 1threat
|
coroutine_fn iscsi_co_discard(BlockDriverState *bs, int64_t sector_num,
int nb_sectors)
{
IscsiLun *iscsilun = bs->opaque;
struct IscsiTask iTask;
struct unmap_list list;
uint32_t nb_blocks;
uint32_t max_unmap;
if (!is_request_lun_aligned(sector_num, nb_sectors, iscsilun)) {
return -EINVAL;
}
if (!iscsilun->lbp.lbpu) {
return 0;
}
list.lba = sector_qemu2lun(sector_num, iscsilun);
nb_blocks = sector_qemu2lun(nb_sectors, iscsilun);
max_unmap = iscsilun->bl.max_unmap;
if (max_unmap == 0xffffffff) {
max_unmap = ISCSI_MAX_UNMAP;
}
while (nb_blocks > 0) {
iscsi_co_init_iscsitask(iscsilun, &iTask);
list.num = nb_blocks;
if (list.num > max_unmap) {
list.num = max_unmap;
}
retry:
if (iscsi_unmap_task(iscsilun->iscsi, iscsilun->lun, 0, 0, &list, 1,
iscsi_co_generic_cb, &iTask) == NULL) {
return -EIO;
}
while (!iTask.complete) {
iscsi_set_events(iscsilun);
qemu_coroutine_yield();
}
if (iTask.task != NULL) {
scsi_free_scsi_task(iTask.task);
iTask.task = NULL;
}
if (iTask.do_retry) {
goto retry;
}
if (iTask.status == SCSI_STATUS_CHECK_CONDITION) {
return 0;
}
if (iTask.status != SCSI_STATUS_GOOD) {
return -EIO;
}
list.lba += list.num;
nb_blocks -= list.num;
}
return 0;
}
| 1threat
|
pip installing eyeD3 module. Failed to find libmagic : <p>Trying to install eyed3 but it's giving me this error: </p>
<pre><code>>>> import eyed3
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
import eyed3
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\eyed3\__init__.py", line 35, in <module>
from .utils.log import log # noqa
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\eyed3\utils\__init__.py", line 27, in <module>
import magic
File "C:\Users\Dylan\AppData\Local\Programs\Python\Python35-32\lib\site-packages\magic.py", line 176, in <module>
raise ImportError('failed to find libmagic. Check your installation')
ImportError: failed to find libmagic. Check your installation
</code></pre>
<p>Here's the pip install:
<a href="https://i.stack.imgur.com/Ztvjw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Ztvjw.png" alt="pip install"></a></p>
<p>I tried to uninstall with pip and delete all the eyed3 files, then re-install and it still gave the same error. It also does the same thing with easy_install.</p>
| 0debug
|
how to implement un-installation listener for android app : <p>I want to ask for password if someone attempts to uninstall my app. So is there any un-installation listener that I should implement? If not then how can I do this? Please help.</p>
| 0debug
|
This app isn't verified This app hasn't been verified by Google yet. Only proceed if you know and trust the developer : <p>Hi I have developed an web application using google app engine, for <code>google shared domain contact</code>, Its working fine when I am running it in the localhost but when I deploy that application into google app engine it showing warning screen before user conforming for consent(as shown in the image).</p>
<p><a href="https://i.stack.imgur.com/bjBX1.png" rel="noreferrer"><img src="https://i.stack.imgur.com/bjBX1.png" alt="error message before consent"></a></p>
<p>I am using 2 scope <code>http://www.google.com/m8/feeds/contacts/</code> and <code>https://www.googleapis.com/auth/userinfo.email</code>. when I try to add a user information in the google shared contact I am getting a exception message as <code>www.google.com</code>. How can I resolve the problem? am i need to verify my application in the <code>oauth_app_verification</code>. Can any one solve this?</p>
<p>Thank you.,</p>
| 0debug
|
static int write_extradata(FFV1Context *f)
{
RangeCoder *const c = &f->c;
uint8_t state[CONTEXT_SIZE];
int i, j, k;
uint8_t state2[32][CONTEXT_SIZE];
unsigned v;
memset(state2, 128, sizeof(state2));
memset(state, 128, sizeof(state));
f->avctx->extradata_size = 10000 + 4 +
(11 * 11 * 5 * 5 * 5 + 11 * 11 * 11) * 32;
f->avctx->extradata = av_malloc(f->avctx->extradata_size);
ff_init_range_encoder(c, f->avctx->extradata, f->avctx->extradata_size);
ff_build_rac_states(c, 0.05 * (1LL << 32), 256 - 8);
put_symbol(c, state, f->version, 0);
if (f->version > 2) {
if (f->version == 3)
f->minor_version = 4;
put_symbol(c, state, f->minor_version, 0);
}
put_symbol(c, state, f->ac, 0);
if (f->ac > 1)
for (i = 1; i < 256; i++)
put_symbol(c, state, f->state_transition[i] - c->one_state[i], 1);
put_symbol(c, state, f->colorspace, 0);
put_symbol(c, state, f->bits_per_raw_sample, 0);
put_rac(c, state, f->chroma_planes);
put_symbol(c, state, f->chroma_h_shift, 0);
put_symbol(c, state, f->chroma_v_shift, 0);
put_rac(c, state, f->transparency);
put_symbol(c, state, f->num_h_slices - 1, 0);
put_symbol(c, state, f->num_v_slices - 1, 0);
put_symbol(c, state, f->quant_table_count, 0);
for (i = 0; i < f->quant_table_count; i++)
write_quant_tables(c, f->quant_tables[i]);
for (i = 0; i < f->quant_table_count; i++) {
for (j = 0; j < f->context_count[i] * CONTEXT_SIZE; j++)
if (f->initial_states[i] && f->initial_states[i][0][j] != 128)
break;
if (j < f->context_count[i] * CONTEXT_SIZE) {
put_rac(c, state, 1);
for (j = 0; j < f->context_count[i]; j++)
for (k = 0; k < CONTEXT_SIZE; k++) {
int pred = j ? f->initial_states[i][j - 1][k] : 128;
put_symbol(c, state2[k],
(int8_t)(f->initial_states[i][j][k] - pred), 1);
}
} else {
put_rac(c, state, 0);
}
}
if (f->version > 2) {
put_symbol(c, state, f->ec, 0);
put_symbol(c, state, f->intra = (f->avctx->gop_size < 2), 0);
}
f->avctx->extradata_size = ff_rac_terminate(c);
v = av_crc(av_crc_get_table(AV_CRC_32_IEEE), 0, f->avctx->extradata, f->avctx->extradata_size);
AV_WL32(f->avctx->extradata + f->avctx->extradata_size, v);
f->avctx->extradata_size += 4;
return 0;
}
| 1threat
|
Dont know how to update my string : <p>So i have this program that when i press an button it says something. then when i press another button it changes the first buttons outcome. but the outcome dont want to get "updated".</p>
<pre><code>import sys
from Tkinter import *
mGui = Tk()
Answer = "NO"
def Truth():
Answer.replace("NO","YES")
print(Answer)
def Snonk():
print(Answer)
canvas = Canvas(mGui, width=200, height=300, bg="white")
mbutton = Button(mGui,text ="Is Hugo cool?",command = Snonk,).pack()
mbutton2 = Button(mGui,text ="Truth",command = Truth,).pack()
canvas.pack()
mGui.title("PQ")
mGui.mainloop()
</code></pre>
<p>e here</p>
| 0debug
|
How to use inverse of a GenericRelation : <p>I must be really misunderstanding something with the <a href="https://docs.djangoproject.com/en/1.7/ref/contrib/contenttypes/#reverse-generic-relations" rel="noreferrer"><code>GenericRelation</code> field</a> from Django's content types framework.</p>
<p>To create a minimal self contained example, I will use the polls example app from the tutorial. Add a generic foreign key field into the <code>Choice</code> model, and make a new <code>Thing</code> model:</p>
<pre><code>class Choice(models.Model):
...
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
thing = GenericForeignKey('content_type', 'object_id')
class Thing(models.Model):
choices = GenericRelation(Choice, related_query_name='things')
</code></pre>
<p>With a clean db, synced up tables, and create a few instances:</p>
<pre><code>>>> poll = Poll.objects.create(question='the question', pk=123)
>>> thing = Thing.objects.create(pk=456)
>>> choice = Choice.objects.create(choice_text='the choice', pk=789, poll=poll, thing=thing)
>>> choice.thing.pk
456
>>> thing.choices.get().pk
789
</code></pre>
<p>So far so good - the relation works in both directions from an instance. But from a queryset, the reverse relation is very weird:</p>
<pre><code>>>> Choice.objects.values_list('things', flat=1)
[456]
>>> Thing.objects.values_list('choices', flat=1)
[456]
</code></pre>
<p>Why the inverse relation gives me again the id from the <code>thing</code>? I expected instead the primary key of the choice, equivalent to the following result:</p>
<pre><code>>>> Thing.objects.values_list('choices__pk', flat=1)
[789]
</code></pre>
<p>Those ORM queries generate SQL like this:</p>
<pre><code>>>> print Thing.objects.values_list('choices__pk', flat=1).query
SELECT "polls_choice"."id" FROM "polls_thing" LEFT OUTER JOIN "polls_choice" ON ( "polls_thing"."id" = "polls_choice"."object_id" AND ("polls_choice"."content_type_id" = 10))
>>> print Thing.objects.values_list('choices', flat=1).query
SELECT "polls_choice"."object_id" FROM "polls_thing" LEFT OUTER JOIN "polls_choice" ON ( "polls_thing"."id" = "polls_choice"."object_id" AND ("polls_choice"."content_type_id" = 10))
</code></pre>
<p>The Django docs are generally excellent, but I can't understand why the second query or find any documentation of that behaviour - it seems to return data from the wrong table completely?</p>
| 0debug
|
No super method getLifecycle() after migrating to androidx : <p>I have been trying to migrate my app to use androidx but I seem to encounter a strange error. From my activity which extends AppCompatActivity when I call <code>getLifeCycle()</code> it throws the following exception </p>
<pre><code> Caused by: java.lang.NoSuchMethodError: No super method getLifecycle()Landroidx/lifecycle/Lifecycle; in class Landroidx/core/app/ComponentActivity; or its super classes
at androidx.fragment.app.FragmentActivity.getLifecycle(FragmentActivity.java:324)
</code></pre>
<p>I believe that AppCompatActivity should be implementing LifecycleOwner but its not. Am I doing something wrong?
Here's my gradle dependencies</p>
<pre><code>implementation files("libs/jsoup-1.8.3.jar")
implementation "com.github.philjay:MPAndroidChart:v3.0.2"
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.1.0-alpha01'
implementation "androidx.constraintlayout:constraintlayout:2.0.0-alpha2"
implementation 'androidx.constraintlayout:constraintlayout-solver:2.0.0-alpha2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation "com.google.firebase:firebase-messaging:17.3.4"
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
implementation "androidx.lifecycle:lifecycle-runtime:2.0.0"
annotationProcessor "androidx.lifecycle:lifecycle-compiler:2.0.0" // use kapt for Kotlin
implementation "de.hdodenhof:circleimageview:2.2.0"
implementation 'androidx.core:core:1.1.0-alpha01'
implementation "com.thoughtbot:expandablerecyclerview:1.0"
implementation "androidx.lifecycle:lifecycle-livedata:2.0.0"
implementation "androidx.lifecycle:lifecycle-viewmodel:2.0.0"
implementation "com.github.franmontiel:FullScreenDialog:1.0.1"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "com.github.apl-devs:appintro:v4.2.3"
implementation "com.google.firebase:firebase-crash:16.2.1"
implementation "com.google.firebase:firebase-core:16.0.5"
</code></pre>
| 0debug
|
Which is better: storing objects vs storing pointers? : <p>I want to store elements (let's call it E), but I don't know that I should store them as objects or as pointers pointing to the dynamically allocated objects.</p>
<p><em>(A,B,C,etc. objects store the reference of the wanted E)</em></p>
<p><strong>version A:</strong></p>
<pre><code>E e;
store.Add(e); //This time the store contains objects.
</code></pre>
<p>In this version the element will be copied to the store, but it's easier to handle. (The objects will be destroyed when the parent object is destroyed)</p>
<p><strong>version B:</strong></p>
<pre><code>E* e = new E();
store.Add(*e); //This time the store contains references.
/*I chose references instead of pointers,
so I have to use pointers only at allocating and deallocating.*/
</code></pre>
<p>In this version there is no copy constr. but I have to delete the objects in the parent object's destructor.</p>
<p>Which is better and why? Which can cause more mistakes and which is more efficient?</p>
| 0debug
|
void acpi_pm1_cnt_init(ACPIREGS *ar, MemoryRegion *parent)
{
ar->wakeup.notify = acpi_notify_wakeup;
qemu_register_wakeup_notifier(&ar->wakeup);
memory_region_init_io(&ar->pm1.cnt.io, &acpi_pm_cnt_ops, ar, "acpi-cnt", 2);
memory_region_add_subregion(parent, 4, &ar->pm1.cnt.io);
}
| 1threat
|
Getting 404 even when the link works JSON : <p>I'm trying to use OpenWeatherMap and get the JSON for the weather.
In the console i see 404 message, but when i visit the url manually it gives me the correct JSON</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>var latitude;
var longitude;
var apiId = "c440e3f473378f9705827ed71efe5dcc";
var request = new XMLHttpRequest();
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function getPosition(position) {
latitude = position.coords.latitude;
longitude = position.coords.longitude;
getJson();
});
} else {
alert('Geo location not working or not supported by your browser.');
}
}
function getJson() {
request.open('GET', "api.openweathermap.org/data/2.5/weather?lat=" + latitude + "&lon=" + longitude + "&APPID=" + apiId + "");
request.onload = function(data) {
console.log(data);
};
request.send();
}
getLocation();</code></pre>
</div>
</div>
</p>
| 0debug
|
Grouping array of objects and do a calculation and create a new common value : HI I'm using lodash to group my objects in my array.
`var grouped = _.groupBy(this.tableData, function(obj) {
return obj.key
});`
it giving me an object with key value pairs.
`{mykey1: [{obj1}, {obj2}], mykey2: [obj1]}`
My question is how can i loop through the objects inside each key and do a calculation. for example if i have an attribute in my object, cost, i want to sum up all the cost inside each object in my key? Wasted my 2 days for this. can please someone tell me a solution? Thanks in advance
| 0debug
|
Show/hide BottomNavigationView on scroll in CoordinatorLayout with AppBarLayout : <p>I am trying to use both <code>AppBarLayout</code> and <code>BottomNavigationLayout</code> in a single <code>CoordinatorLayout</code> and I'm having difficulties hiding the <code>BottomNavigationLayout</code> as required by the <a href="https://material.io/guidelines/components/bottom-navigation.html#bottom-navigation-behavior" rel="noreferrer">material guideline</a>.</p>
<p>I mean something like this:</p>
<pre><code><android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="false">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_insetEdge="top"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_nav"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_gravity="bottom"
app:menu="@menu/menu_bottom_navigation"/>
<FrameLayout
android:id="@+id/content_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
</code></pre>
<p>As you can see, I also have a <code>FrameLayout</code> that's used to contain a fragment with the actual content. Currently there are no default/built-in behaviors for the <code>BottomNavigationView</code> - neither for the view itself, nor for its siblings. The existing <code>appbar_scrolling_view_behavior</code> handles the content view in coordination with the appbar but ignores other siblings. </p>
<p>I am looking for a solution to hide and show both the appbar and the bottom navigation view on scroll.</p>
| 0debug
|
static QemuOpts *opts_parse(QemuOptsList *list, const char *params,
int permit_abbrev, bool defaults)
{
const char *firstname;
char value[1024], *id = NULL;
const char *p;
QemuOpts *opts;
Error *local_err = NULL;
assert(!permit_abbrev || list->implied_opt_name);
firstname = permit_abbrev ? list->implied_opt_name : NULL;
if (strncmp(params, "id=", 3) == 0) {
get_opt_value(value, sizeof(value), params+3);
id = value;
} else if ((p = strstr(params, ",id=")) != NULL) {
get_opt_value(value, sizeof(value), p+4);
id = value;
}
opts = qemu_opts_create(list, id, !defaults, &local_err);
if (opts == NULL) {
if (error_is_set(&local_err)) {
qerror_report_err(local_err);
error_free(local_err);
}
return NULL;
}
if (opts_do_parse(opts, params, firstname, defaults) != 0) {
qemu_opts_del(opts);
return NULL;
}
return opts;
}
| 1threat
|
SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c)
{
int cpu_flags = av_get_cpu_flags();
if (c->srcFormat != PIX_FMT_YUV420P &&
c->srcFormat != PIX_FMT_YUVA420P)
return NULL;
#if HAVE_MMX2
if (cpu_flags & AV_CPU_FLAG_MMX2) {
switch (c->dstFormat) {
case PIX_FMT_RGB24: return yuv420_rgb24_MMX2;
case PIX_FMT_BGR24: return yuv420_bgr24_MMX2;
}
}
#endif
if (cpu_flags & AV_CPU_FLAG_MMX) {
switch (c->dstFormat) {
case PIX_FMT_RGB32:
if (c->srcFormat == PIX_FMT_YUVA420P) {
#if HAVE_7REGS && CONFIG_SWSCALE_ALPHA
return yuva420_rgb32_MMX;
#endif
break;
} else return yuv420_rgb32_MMX;
case PIX_FMT_BGR32:
if (c->srcFormat == PIX_FMT_YUVA420P) {
#if HAVE_7REGS && CONFIG_SWSCALE_ALPHA
return yuva420_bgr32_MMX;
#endif
break;
} else return yuv420_bgr32_MMX;
case PIX_FMT_RGB24: return yuv420_rgb24_MMX;
case PIX_FMT_BGR24: return yuv420_bgr24_MMX;
case PIX_FMT_RGB565: return yuv420_rgb16_MMX;
case PIX_FMT_RGB555: return yuv420_rgb15_MMX;
}
}
return NULL;
}
| 1threat
|
I want result in horizontal format in pl sql. : `V_RES varchar2(100)
BEGIN
FOR I IN 1..5 LOOP
FOR J IN 65..70 LOOP
V_RES := V_RES ||' '||I||CHR(J);
END LOOP;
DBMS_OUTPUT.PUT_LINE(V_RES);
V_RES :='';
END LOOP;
END;
/
` I use this Code Below
*Result is Below*
'1A 1B 1C 1D 1E 1F
2A 2B 2C 2D 2E 2F
3A 3B 3C 3D 3E 3F
4A 4B 4C 4D 4E 4F
5A 5B 5C 5D 5E 5F'
*But i want Result in this format*
'1A 2A 3A
1B 2B 3B
1C 2C 3C'
| 0debug
|
STATIC void DEF(avg, pixels8_xy2)(uint8_t *block, const uint8_t *pixels,
ptrdiff_t line_size, int h)
{
MOVQ_ZERO(mm7);
SET_RND(mm6);
__asm__ volatile(
"movq (%1), %%mm0 \n\t"
"movq 1(%1), %%mm4 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm4, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpckhbw %%mm7, %%mm1 \n\t"
"punpckhbw %%mm7, %%mm5 \n\t"
"paddusw %%mm0, %%mm4 \n\t"
"paddusw %%mm1, %%mm5 \n\t"
"xor %%"REG_a", %%"REG_a" \n\t"
"add %3, %1 \n\t"
".p2align 3 \n\t"
"1: \n\t"
"movq (%1, %%"REG_a"), %%mm0 \n\t"
"movq 1(%1, %%"REG_a"), %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"movq %%mm2, %%mm3 \n\t"
"punpcklbw %%mm7, %%mm0 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpckhbw %%mm7, %%mm1 \n\t"
"punpckhbw %%mm7, %%mm3 \n\t"
"paddusw %%mm2, %%mm0 \n\t"
"paddusw %%mm3, %%mm1 \n\t"
"paddusw %%mm6, %%mm4 \n\t"
"paddusw %%mm6, %%mm5 \n\t"
"paddusw %%mm0, %%mm4 \n\t"
"paddusw %%mm1, %%mm5 \n\t"
"psrlw $2, %%mm4 \n\t"
"psrlw $2, %%mm5 \n\t"
"movq (%2, %%"REG_a"), %%mm3 \n\t"
"packuswb %%mm5, %%mm4 \n\t"
"pcmpeqd %%mm2, %%mm2 \n\t"
"paddb %%mm2, %%mm2 \n\t"
PAVGB_MMX(%%mm3, %%mm4, %%mm5, %%mm2)
"movq %%mm5, (%2, %%"REG_a") \n\t"
"add %3, %%"REG_a" \n\t"
"movq (%1, %%"REG_a"), %%mm2 \n\t"
"movq 1(%1, %%"REG_a"), %%mm4 \n\t"
"movq %%mm2, %%mm3 \n\t"
"movq %%mm4, %%mm5 \n\t"
"punpcklbw %%mm7, %%mm2 \n\t"
"punpcklbw %%mm7, %%mm4 \n\t"
"punpckhbw %%mm7, %%mm3 \n\t"
"punpckhbw %%mm7, %%mm5 \n\t"
"paddusw %%mm2, %%mm4 \n\t"
"paddusw %%mm3, %%mm5 \n\t"
"paddusw %%mm6, %%mm0 \n\t"
"paddusw %%mm6, %%mm1 \n\t"
"paddusw %%mm4, %%mm0 \n\t"
"paddusw %%mm5, %%mm1 \n\t"
"psrlw $2, %%mm0 \n\t"
"psrlw $2, %%mm1 \n\t"
"movq (%2, %%"REG_a"), %%mm3 \n\t"
"packuswb %%mm1, %%mm0 \n\t"
"pcmpeqd %%mm2, %%mm2 \n\t"
"paddb %%mm2, %%mm2 \n\t"
PAVGB_MMX(%%mm3, %%mm0, %%mm1, %%mm2)
"movq %%mm1, (%2, %%"REG_a") \n\t"
"add %3, %%"REG_a" \n\t"
"subl $2, %0 \n\t"
"jnz 1b \n\t"
:"+g"(h), "+S"(pixels)
:"D"(block), "r"((x86_reg)line_size)
:REG_a, "memory");
}
| 1threat
|
void virtio_irq(VirtQueue *vq)
{
trace_virtio_irq(vq);
virtio_set_isr(vq->vdev, 0x1);
virtio_notify_vector(vq->vdev, vq->vector);
}
| 1threat
|
How do I force an expo app to update : <p>I have an app written in expo, and can't figure out how to push a new build. On the expo site if I run the app from the QR code the app is correct, but the native app from the app store doesn't update.</p>
<p>The steps I've been using are
1) exp build:android
2) exp publish</p>
<p>How do I make the app actually update?</p>
| 0debug
|
Post Variable to php script : I am able to post a string to a php script by sending it as xmlhttp data.
What I am really trying to do is reading that data which I am sending now as a hardcoded string, from another variable.
example:
what I have now is the following code:
xmlhttp.open("POST", "test.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("name=testname");
this post requests executes well and the php script receives the content of the name parameter ($stringData = $_POST["name"]);
I am trying to replace the 'testname' string with dynamic content from a variable. So
VARIABLE= "someContentNotHardCoded";
xmlhttp.send("name="+ VARIABLE);
but this doesn't seem to work. Is it possible what I am trying to do here, to append/replace the 'testname' string with dynamic content loaded from a variable?
| 0debug
|
static int dxtory_decode_v2_444(AVCodecContext *avctx, AVFrame *pic,
const uint8_t *src, int src_size)
{
GetByteContext gb;
GetBitContext gb2;
int nslices, slice, slice_height;
uint32_t off, slice_size;
uint8_t *Y, *U, *V;
int ret;
bytestream2_init(&gb, src, src_size);
nslices = bytestream2_get_le16(&gb);
off = FFALIGN(nslices * 4 + 2, 16);
if (src_size < off) {
av_log(avctx, AV_LOG_ERROR, "no slice data\n");
return AVERROR_INVALIDDATA;
}
if (!nslices || avctx->height % nslices) {
avpriv_request_sample(avctx, "%d slices for %dx%d", nslices,
avctx->width, avctx->height);
return AVERROR_PATCHWELCOME;
}
slice_height = avctx->height / nslices;
avctx->pix_fmt = AV_PIX_FMT_YUV444P;
if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
return ret;
Y = pic->data[0];
U = pic->data[1];
V = pic->data[2];
for (slice = 0; slice < nslices; slice++) {
slice_size = bytestream2_get_le32(&gb);
ret = check_slice_size(avctx, src, src_size, slice_size, off);
if (ret < 0)
return ret;
init_get_bits(&gb2, src + off + 16, (slice_size - 16) * 8);
dx2_decode_slice_444(&gb2, avctx->width, slice_height, Y, U, V,
pic->linesize[0], pic->linesize[1],
pic->linesize[2]);
Y += pic->linesize[0] * slice_height;
U += pic->linesize[1] * slice_height;
V += pic->linesize[2] * slice_height;
off += slice_size;
}
return 0;
}
| 1threat
|
Move assignment operator vs copy assignment operator : <p>I saw this: <a href="https://stackoverflow.com/questions/26772146/which-to-use-move-assignment-operator-vs-copy-assignment-operator">question</a></p>
<p>But the answers there are <strong>very</strong> complicated for a C++ newbie like me. I would like it if someone could help me out.</p>
<pre><code>CLASSA & operator=(CLASSA && other); //move assignment operator
CLASSA & operator=(CLASSA other); //copy assignment operator
</code></pre>
<p>I am still failing to see why we require both of these? They basically do the same thing? So what is the difference and where would you use one over the other? </p>
| 0debug
|
static int tiff_decode_tag(TiffContext *s, const uint8_t *start,
const uint8_t *buf, const uint8_t *end_buf)
{
unsigned tag, type, count, off, value = 0;
int i;
uint32_t *pal;
const uint8_t *rp, *gp, *bp;
if (end_buf - buf < 12)
return AVERROR_INVALIDDATA;
tag = tget_short(&buf, s->le);
type = tget_short(&buf, s->le);
count = tget_long(&buf, s->le);
off = tget_long(&buf, s->le);
if (type == 0 || type >= FF_ARRAY_ELEMS(type_sizes)) {
av_log(s->avctx, AV_LOG_DEBUG, "Unknown tiff type (%u) encountered\n",
type);
return 0;
}
if (count == 1) {
switch (type) {
case TIFF_BYTE:
case TIFF_SHORT:
buf -= 4;
value = tget(&buf, type, s->le);
buf = NULL;
break;
case TIFF_LONG:
value = off;
buf = NULL;
break;
case TIFF_STRING:
if (count <= 4) {
buf -= 4;
break;
}
default:
value = UINT_MAX;
buf = start + off;
}
} else {
if (count <= 4 && type_sizes[type] * count <= 4)
buf -= 4;
else
buf = start + off;
}
if (buf && (buf < start || buf > end_buf)) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return AVERROR_INVALIDDATA;
}
switch (tag) {
case TIFF_WIDTH:
s->width = value;
break;
case TIFF_HEIGHT:
s->height = value;
break;
case TIFF_BPP:
s->bppcount = count;
if (count > 4) {
av_log(s->avctx, AV_LOG_ERROR,
"This format is not supported (bpp=%d, %d components)\n",
s->bpp, count);
return AVERROR_INVALIDDATA;
}
if (count == 1)
s->bpp = value;
else {
switch (type) {
case TIFF_BYTE:
s->bpp = (off & 0xFF) + ((off >> 8) & 0xFF) +
((off >> 16) & 0xFF) + ((off >> 24) & 0xFF);
break;
case TIFF_SHORT:
case TIFF_LONG:
s->bpp = 0;
for (i = 0; i < count && buf < end_buf; i++)
s->bpp += tget(&buf, type, s->le);
break;
default:
s->bpp = -1;
}
}
break;
case TIFF_SAMPLES_PER_PIXEL:
if (count != 1) {
av_log(s->avctx, AV_LOG_ERROR,
"Samples per pixel requires a single value, many provided\n");
return AVERROR_INVALIDDATA;
}
if (s->bppcount == 1)
s->bpp *= value;
s->bppcount = value;
break;
case TIFF_COMPR:
s->compr = value;
s->predictor = 0;
switch (s->compr) {
case TIFF_RAW:
case TIFF_PACKBITS:
case TIFF_LZW:
case TIFF_CCITT_RLE:
break;
case TIFF_G3:
case TIFF_G4:
s->fax_opts = 0;
break;
case TIFF_DEFLATE:
case TIFF_ADOBE_DEFLATE:
#if CONFIG_ZLIB
break;
#else
av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n");
return AVERROR(ENOSYS);
#endif
case TIFF_JPEG:
case TIFF_NEWJPEG:
avpriv_report_missing_feature(s->avctx, "JPEG compression");
return AVERROR_PATCHWELCOME;
default:
av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n",
s->compr);
return AVERROR_INVALIDDATA;
}
break;
case TIFF_ROWSPERSTRIP:
if (type == TIFF_LONG && value == UINT_MAX)
value = s->avctx->height;
if (value < 1) {
av_log(s->avctx, AV_LOG_ERROR,
"Incorrect value of rows per strip\n");
return AVERROR_INVALIDDATA;
}
s->rps = value;
break;
case TIFF_STRIP_OFFS:
if (count == 1) {
s->stripdata = NULL;
s->stripoff = value;
} else
s->stripdata = start + off;
s->strips = count;
if (s->strips == 1)
s->rps = s->height;
s->sot = type;
if (s->stripdata > end_buf) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return AVERROR_INVALIDDATA;
}
break;
case TIFF_STRIP_SIZE:
if (count == 1) {
s->stripsizes = NULL;
s->stripsize = value;
s->strips = 1;
} else {
s->stripsizes = start + off;
}
s->strips = count;
s->sstype = type;
if (s->stripsizes > end_buf) {
av_log(s->avctx, AV_LOG_ERROR,
"Tag referencing position outside the image\n");
return AVERROR_INVALIDDATA;
}
break;
case TIFF_PREDICTOR:
s->predictor = value;
break;
case TIFF_INVERT:
switch (value) {
case 0:
s->invert = 1;
break;
case 1:
s->invert = 0;
break;
case 2:
case 3:
break;
default:
av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n",
value);
return AVERROR_INVALIDDATA;
}
break;
case TIFF_FILL_ORDER:
if (value < 1 || value > 2) {
av_log(s->avctx, AV_LOG_ERROR,
"Unknown FillOrder value %d, trying default one\n", value);
value = 1;
}
s->fill_order = value - 1;
break;
case TIFF_PAL:
pal = (uint32_t *) s->palette;
off = type_sizes[type];
if (count / 3 > 256 || end_buf - buf < count / 3 * off * 3)
return AVERROR_INVALIDDATA;
rp = buf;
gp = buf + count / 3 * off;
bp = buf + count / 3 * off * 2;
off = (type_sizes[type] - 1) << 3;
for (i = 0; i < count / 3; i++) {
uint32_t p = 0xFF000000;
p |= (tget(&rp, type, s->le) >> off) << 16;
p |= (tget(&gp, type, s->le) >> off) << 8;
p |= tget(&bp, type, s->le) >> off;
pal[i] = p;
}
s->palette_is_set = 1;
break;
case TIFF_PLANAR:
if (value == 2) {
avpriv_report_missing_feature(s->avctx, "Planar format");
return AVERROR_PATCHWELCOME;
}
break;
case TIFF_T4OPTIONS:
if (s->compr == TIFF_G3)
s->fax_opts = value;
break;
case TIFF_T6OPTIONS:
if (s->compr == TIFF_G4)
s->fax_opts = value;
break;
default:
if (s->avctx->err_recognition & AV_EF_EXPLODE) {
av_log(s->avctx, AV_LOG_ERROR,
"Unknown or unsupported tag %d/0X%0X\n",
tag, tag);
return AVERROR_INVALIDDATA;
}
}
return 0;
}
| 1threat
|
int ff_h264_decode_mb_cabac(H264Context *h) {
MpegEncContext * const s = &h->s;
int mb_xy;
int mb_type, partition_count, cbp = 0;
int dct8x8_allowed= h->pps.transform_8x8_mode;
int decode_chroma = h->sps.chroma_format_idc == 1 || h->sps.chroma_format_idc == 2;
const int pixel_shift = h->pixel_shift;
mb_xy = h->mb_xy = s->mb_x + s->mb_y*s->mb_stride;
tprintf(s->avctx, "pic:%d mb:%d/%d\n", h->frame_num, s->mb_x, s->mb_y);
if( h->slice_type_nos != AV_PICTURE_TYPE_I ) {
int skip;
if( FRAME_MBAFF && (s->mb_y&1)==1 && h->prev_mb_skipped )
skip = h->next_mb_skipped;
else
skip = decode_cabac_mb_skip( h, s->mb_x, s->mb_y );
if( skip ) {
if( FRAME_MBAFF && (s->mb_y&1)==0 ){
s->current_picture.f.mb_type[mb_xy] = MB_TYPE_SKIP;
h->next_mb_skipped = decode_cabac_mb_skip( h, s->mb_x, s->mb_y+1 );
if(!h->next_mb_skipped)
h->mb_mbaff = h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h);
}
decode_mb_skip(h);
h->cbp_table[mb_xy] = 0;
h->chroma_pred_mode_table[mb_xy] = 0;
h->last_qscale_diff = 0;
return 0;
}
}
if(FRAME_MBAFF){
if( (s->mb_y&1) == 0 )
h->mb_mbaff =
h->mb_field_decoding_flag = decode_cabac_field_decoding_flag(h);
}
h->prev_mb_skipped = 0;
fill_decode_neighbors(h, -(MB_FIELD));
if( h->slice_type_nos == AV_PICTURE_TYPE_B ) {
int ctx = 0;
assert(h->slice_type_nos == AV_PICTURE_TYPE_B);
if( !IS_DIRECT( h->left_type[LTOP]-1 ) )
ctx++;
if( !IS_DIRECT( h->top_type-1 ) )
ctx++;
if( !get_cabac_noinline( &h->cabac, &h->cabac_state[27+ctx] ) ){
mb_type= 0;
}else if( !get_cabac_noinline( &h->cabac, &h->cabac_state[27+3] ) ) {
mb_type= 1 + get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] );
}else{
int bits;
bits = get_cabac_noinline( &h->cabac, &h->cabac_state[27+4] ) << 3;
bits+= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << 2;
bits+= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] ) << 1;
bits+= get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] );
if( bits < 8 ){
mb_type= bits + 3;
}else if( bits == 13 ){
mb_type= decode_cabac_intra_mb_type(h, 32, 0);
goto decode_intra_mb;
}else if( bits == 14 ){
mb_type= 11;
}else if( bits == 15 ){
mb_type= 22;
}else{
bits= ( bits<<1 ) + get_cabac_noinline( &h->cabac, &h->cabac_state[27+5] );
mb_type= bits - 4;
}
}
partition_count= b_mb_type_info[mb_type].partition_count;
mb_type= b_mb_type_info[mb_type].type;
} else if( h->slice_type_nos == AV_PICTURE_TYPE_P ) {
if( get_cabac_noinline( &h->cabac, &h->cabac_state[14] ) == 0 ) {
if( get_cabac_noinline( &h->cabac, &h->cabac_state[15] ) == 0 ) {
mb_type= 3 * get_cabac_noinline( &h->cabac, &h->cabac_state[16] );
} else {
mb_type= 2 - get_cabac_noinline( &h->cabac, &h->cabac_state[17] );
}
partition_count= p_mb_type_info[mb_type].partition_count;
mb_type= p_mb_type_info[mb_type].type;
} else {
mb_type= decode_cabac_intra_mb_type(h, 17, 0);
goto decode_intra_mb;
}
} else {
mb_type= decode_cabac_intra_mb_type(h, 3, 1);
if(h->slice_type == AV_PICTURE_TYPE_SI && mb_type)
mb_type--;
assert(h->slice_type_nos == AV_PICTURE_TYPE_I);
decode_intra_mb:
partition_count = 0;
cbp= i_mb_type_info[mb_type].cbp;
h->intra16x16_pred_mode= i_mb_type_info[mb_type].pred_mode;
mb_type= i_mb_type_info[mb_type].type;
}
if(MB_FIELD)
mb_type |= MB_TYPE_INTERLACED;
h->slice_table[ mb_xy ]= h->slice_num;
if(IS_INTRA_PCM(mb_type)) {
static const uint16_t mb_sizes[4] = {256,384,512,768};
const int mb_size = mb_sizes[h->sps.chroma_format_idc]*h->sps.bit_depth_luma >> 3;
const uint8_t *ptr;
ptr= h->cabac.bytestream;
if(h->cabac.low&0x1) ptr--;
if(CABAC_BITS==16){
if(h->cabac.low&0x1FF) ptr--;
}
memcpy(h->mb, ptr, mb_size); ptr+=mb_size;
ff_init_cabac_decoder(&h->cabac, ptr, h->cabac.bytestream_end - ptr);
h->cbp_table[mb_xy] = 0xf7ef;
h->chroma_pred_mode_table[mb_xy] = 0;
s->current_picture.f.qscale_table[mb_xy] = 0;
memset(h->non_zero_count[mb_xy], 16, 48);
s->current_picture.f.mb_type[mb_xy] = mb_type;
h->last_qscale_diff = 0;
return 0;
}
if(MB_MBAFF){
h->ref_count[0] <<= 1;
h->ref_count[1] <<= 1;
}
fill_decode_caches(h, mb_type);
if( IS_INTRA( mb_type ) ) {
int i, pred_mode;
if( IS_INTRA4x4( mb_type ) ) {
if( dct8x8_allowed && get_cabac_noinline( &h->cabac, &h->cabac_state[399 + h->neighbor_transform_size] ) ) {
mb_type |= MB_TYPE_8x8DCT;
for( i = 0; i < 16; i+=4 ) {
int pred = pred_intra_mode( h, i );
int mode = decode_cabac_mb_intra4x4_pred_mode( h, pred );
fill_rectangle( &h->intra4x4_pred_mode_cache[ scan8[i] ], 2, 2, 8, mode, 1 );
}
} else {
for( i = 0; i < 16; i++ ) {
int pred = pred_intra_mode( h, i );
h->intra4x4_pred_mode_cache[ scan8[i] ] = decode_cabac_mb_intra4x4_pred_mode( h, pred );
}
}
write_back_intra_pred_mode(h);
if( ff_h264_check_intra4x4_pred_mode(h) < 0 ) return -1;
} else {
h->intra16x16_pred_mode= ff_h264_check_intra_pred_mode( h, h->intra16x16_pred_mode, 0 );
if( h->intra16x16_pred_mode < 0 ) return -1;
}
if(decode_chroma){
h->chroma_pred_mode_table[mb_xy] =
pred_mode = decode_cabac_mb_chroma_pre_mode( h );
pred_mode= ff_h264_check_intra_pred_mode( h, pred_mode, 1 );
if( pred_mode < 0 ) return -1;
h->chroma_pred_mode= pred_mode;
} else {
h->chroma_pred_mode= DC_128_PRED8x8;
}
} else if( partition_count == 4 ) {
int i, j, sub_partition_count[4], list, ref[2][4];
if( h->slice_type_nos == AV_PICTURE_TYPE_B ) {
for( i = 0; i < 4; i++ ) {
h->sub_mb_type[i] = decode_cabac_b_mb_sub_type( h );
sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
h->sub_mb_type[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].type;
}
if( IS_DIRECT(h->sub_mb_type[0] | h->sub_mb_type[1] |
h->sub_mb_type[2] | h->sub_mb_type[3]) ) {
ff_h264_pred_direct_motion(h, &mb_type);
h->ref_cache[0][scan8[4]] =
h->ref_cache[1][scan8[4]] =
h->ref_cache[0][scan8[12]] =
h->ref_cache[1][scan8[12]] = PART_NOT_AVAILABLE;
for( i = 0; i < 4; i++ )
fill_rectangle( &h->direct_cache[scan8[4*i]], 2, 2, 8, (h->sub_mb_type[i]>>1)&0xFF, 1 );
}
} else {
for( i = 0; i < 4; i++ ) {
h->sub_mb_type[i] = decode_cabac_p_mb_sub_type( h );
sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
h->sub_mb_type[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].type;
}
}
for( list = 0; list < h->list_count; list++ ) {
for( i = 0; i < 4; i++ ) {
if(IS_DIRECT(h->sub_mb_type[i])) continue;
if(IS_DIR(h->sub_mb_type[i], 0, list)){
if( h->ref_count[list] > 1 ){
ref[list][i] = decode_cabac_mb_ref( h, list, 4*i );
if(ref[list][i] >= (unsigned)h->ref_count[list]){
av_log(s->avctx, AV_LOG_ERROR, "Reference %d >= %d\n", ref[list][i], h->ref_count[list]);
}
}else
ref[list][i] = 0;
} else {
ref[list][i] = -1;
}
h->ref_cache[list][ scan8[4*i]+1 ]=
h->ref_cache[list][ scan8[4*i]+8 ]=h->ref_cache[list][ scan8[4*i]+9 ]= ref[list][i];
}
}
if(dct8x8_allowed)
dct8x8_allowed = get_dct8x8_allowed(h);
for(list=0; list<h->list_count; list++){
for(i=0; i<4; i++){
h->ref_cache[list][ scan8[4*i] ]=h->ref_cache[list][ scan8[4*i]+1 ];
if(IS_DIRECT(h->sub_mb_type[i])){
fill_rectangle(h->mvd_cache[list][scan8[4*i]], 2, 2, 8, 0, 2);
continue;
}
if(IS_DIR(h->sub_mb_type[i], 0, list) && !IS_DIRECT(h->sub_mb_type[i])){
const int sub_mb_type= h->sub_mb_type[i];
const int block_width= (sub_mb_type & (MB_TYPE_16x16|MB_TYPE_16x8)) ? 2 : 1;
for(j=0; j<sub_partition_count[i]; j++){
int mpx, mpy;
int mx, my;
const int index= 4*i + block_width*j;
int16_t (* mv_cache)[2]= &h->mv_cache[list][ scan8[index] ];
uint8_t (* mvd_cache)[2]= &h->mvd_cache[list][ scan8[index] ];
pred_motion(h, index, block_width, list, h->ref_cache[list][ scan8[index] ], &mx, &my);
DECODE_CABAC_MB_MVD( h, list, index)
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
if(IS_SUB_8X8(sub_mb_type)){
mv_cache[ 1 ][0]=
mv_cache[ 8 ][0]= mv_cache[ 9 ][0]= mx;
mv_cache[ 1 ][1]=
mv_cache[ 8 ][1]= mv_cache[ 9 ][1]= my;
mvd_cache[ 1 ][0]=
mvd_cache[ 8 ][0]= mvd_cache[ 9 ][0]= mpx;
mvd_cache[ 1 ][1]=
mvd_cache[ 8 ][1]= mvd_cache[ 9 ][1]= mpy;
}else if(IS_SUB_8X4(sub_mb_type)){
mv_cache[ 1 ][0]= mx;
mv_cache[ 1 ][1]= my;
mvd_cache[ 1 ][0]= mpx;
mvd_cache[ 1 ][1]= mpy;
}else if(IS_SUB_4X8(sub_mb_type)){
mv_cache[ 8 ][0]= mx;
mv_cache[ 8 ][1]= my;
mvd_cache[ 8 ][0]= mpx;
mvd_cache[ 8 ][1]= mpy;
}
mv_cache[ 0 ][0]= mx;
mv_cache[ 0 ][1]= my;
mvd_cache[ 0 ][0]= mpx;
mvd_cache[ 0 ][1]= mpy;
}
}else{
fill_rectangle(h->mv_cache [list][ scan8[4*i] ], 2, 2, 8, 0, 4);
fill_rectangle(h->mvd_cache[list][ scan8[4*i] ], 2, 2, 8, 0, 2);
}
}
}
} else if( IS_DIRECT(mb_type) ) {
ff_h264_pred_direct_motion(h, &mb_type);
fill_rectangle(h->mvd_cache[0][scan8[0]], 4, 4, 8, 0, 2);
fill_rectangle(h->mvd_cache[1][scan8[0]], 4, 4, 8, 0, 2);
dct8x8_allowed &= h->sps.direct_8x8_inference_flag;
} else {
int list, i;
if(IS_16X16(mb_type)){
for(list=0; list<h->list_count; list++){
if(IS_DIR(mb_type, 0, list)){
int ref;
if(h->ref_count[list] > 1){
ref= decode_cabac_mb_ref(h, list, 0);
if(ref >= (unsigned)h->ref_count[list]){
av_log(s->avctx, AV_LOG_ERROR, "Reference %d >= %d\n", ref, h->ref_count[list]);
}
}else
ref=0;
fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, ref, 1);
}
}
for(list=0; list<h->list_count; list++){
if(IS_DIR(mb_type, 0, list)){
int mx,my,mpx,mpy;
pred_motion(h, 0, 4, list, h->ref_cache[list][ scan8[0] ], &mx, &my);
DECODE_CABAC_MB_MVD( h, list, 0)
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] ], 4, 4, 8, pack8to16(mpx,mpy), 2);
fill_rectangle(h->mv_cache[list][ scan8[0] ], 4, 4, 8, pack16to32(mx,my), 4);
}
}
}
else if(IS_16X8(mb_type)){
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
int ref;
if(h->ref_count[list] > 1){
ref= decode_cabac_mb_ref( h, list, 8*i );
if(ref >= (unsigned)h->ref_count[list]){
av_log(s->avctx, AV_LOG_ERROR, "Reference %d >= %d\n", ref, h->ref_count[list]);
}
}else
ref=0;
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, ref, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);
}
}
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
int mx,my,mpx,mpy;
pred_16x8_motion(h, 8*i, list, h->ref_cache[list][scan8[0] + 16*i], &mx, &my);
DECODE_CABAC_MB_MVD( h, list, 8*i)
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack8to16(mpx,mpy), 2);
fill_rectangle(h->mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, pack16to32(mx,my), 4);
}else{
fill_rectangle(h->mvd_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 2);
fill_rectangle(h-> mv_cache[list][ scan8[0] + 16*i ], 4, 2, 8, 0, 4);
}
}
}
}else{
assert(IS_8X16(mb_type));
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
int ref;
if(h->ref_count[list] > 1){
ref= decode_cabac_mb_ref( h, list, 4*i );
if(ref >= (unsigned)h->ref_count[list]){
av_log(s->avctx, AV_LOG_ERROR, "Reference %d >= %d\n", ref, h->ref_count[list]);
}
}else
ref=0;
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, ref, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);
}
}
for(list=0; list<h->list_count; list++){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
int mx,my,mpx,mpy;
pred_8x16_motion(h, i*4, list, h->ref_cache[list][ scan8[0] + 2*i ], &mx, &my);
DECODE_CABAC_MB_MVD( h, list, 4*i)
tprintf(s->avctx, "final mv:%d %d\n", mx, my);
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack8to16(mpx,mpy), 2);
fill_rectangle(h->mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, pack16to32(mx,my), 4);
}else{
fill_rectangle(h->mvd_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 2);
fill_rectangle(h-> mv_cache[list][ scan8[0] + 2*i ], 2, 4, 8, 0, 4);
}
}
}
}
}
if( IS_INTER( mb_type ) ) {
h->chroma_pred_mode_table[mb_xy] = 0;
write_back_motion( h, mb_type );
}
if( !IS_INTRA16x16( mb_type ) ) {
cbp = decode_cabac_mb_cbp_luma( h );
if(decode_chroma)
cbp |= decode_cabac_mb_cbp_chroma( h ) << 4;
}
h->cbp_table[mb_xy] = h->cbp = cbp;
if( dct8x8_allowed && (cbp&15) && !IS_INTRA( mb_type ) ) {
mb_type |= MB_TYPE_8x8DCT * get_cabac_noinline( &h->cabac, &h->cabac_state[399 + h->neighbor_transform_size] );
}
if (CHROMA444 && IS_8x8DCT(mb_type)){
int i;
uint8_t *nnz_cache = h->non_zero_count_cache;
for (i = 0; i < 2; i++){
if (h->left_type[LEFT(i)] && !IS_8x8DCT(h->left_type[LEFT(i)])){
nnz_cache[3+8* 1 + 2*8*i]=
nnz_cache[3+8* 2 + 2*8*i]=
nnz_cache[3+8* 6 + 2*8*i]=
nnz_cache[3+8* 7 + 2*8*i]=
nnz_cache[3+8*11 + 2*8*i]=
nnz_cache[3+8*12 + 2*8*i]= IS_INTRA(mb_type) ? 64 : 0;
}
}
if (h->top_type && !IS_8x8DCT(h->top_type)){
uint32_t top_empty = CABAC && !IS_INTRA(mb_type) ? 0 : 0x40404040;
AV_WN32A(&nnz_cache[4+8* 0], top_empty);
AV_WN32A(&nnz_cache[4+8* 5], top_empty);
AV_WN32A(&nnz_cache[4+8*10], top_empty);
}
}
s->current_picture.f.mb_type[mb_xy] = mb_type;
if( cbp || IS_INTRA16x16( mb_type ) ) {
const uint8_t *scan, *scan8x8;
const uint32_t *qmul;
if(IS_INTERLACED(mb_type)){
scan8x8= s->qscale ? h->field_scan8x8 : h->field_scan8x8_q0;
scan= s->qscale ? h->field_scan : h->field_scan_q0;
}else{
scan8x8= s->qscale ? h->zigzag_scan8x8 : h->zigzag_scan8x8_q0;
scan= s->qscale ? h->zigzag_scan : h->zigzag_scan_q0;
}
if(get_cabac_noinline( &h->cabac, &h->cabac_state[60 + (h->last_qscale_diff != 0)])){
int val = 1;
int ctx= 2;
const int max_qp = 51 + 6*(h->sps.bit_depth_luma-8);
while( get_cabac_noinline( &h->cabac, &h->cabac_state[60 + ctx] ) ) {
ctx= 3;
val++;
if(val > 2*max_qp){
av_log(h->s.avctx, AV_LOG_ERROR, "cabac decode of qscale diff failed at %d %d\n", s->mb_x, s->mb_y);
}
}
if( val&0x01 )
val= (val + 1)>>1 ;
else
val= -((val + 1)>>1);
h->last_qscale_diff = val;
s->qscale += val;
if(((unsigned)s->qscale) > max_qp){
if(s->qscale<0) s->qscale+= max_qp+1;
else s->qscale-= max_qp+1;
}
h->chroma_qp[0] = get_chroma_qp(h, 0, s->qscale);
h->chroma_qp[1] = get_chroma_qp(h, 1, s->qscale);
}else
h->last_qscale_diff=0;
decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 0);
if(CHROMA444){
decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 1);
decode_cabac_luma_residual(h, scan, scan8x8, pixel_shift, mb_type, cbp, 2);
} else if (CHROMA422) {
if( cbp&0x30 ){
int c;
for( c = 0; c < 2; c++ ) {
decode_cabac_residual_dc_422(h, h->mb + ((256 + 16*16*c) << pixel_shift), 3,
CHROMA_DC_BLOCK_INDEX + c,
chroma422_dc_scan, 8);
}
}
if( cbp&0x20 ) {
int c, i, i8x8;
for( c = 0; c < 2; c++ ) {
DCTELEM *mb = h->mb + (16*(16 + 16*c) << pixel_shift);
qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]];
for (i8x8 = 0; i8x8 < 2; i8x8++) {
for (i = 0; i < 4; i++) {
const int index = 16 + 16 * c + 8*i8x8 + i;
decode_cabac_residual_nondc(h, mb, 4, index, scan + 1, qmul, 15);
mb += 16<<pixel_shift;
}
}
}
} else {
fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1);
fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1);
}
} else {
if( cbp&0x30 ){
int c;
for( c = 0; c < 2; c++ ) {
decode_cabac_residual_dc(h, h->mb + ((256 + 16*16*c) << pixel_shift), 3, CHROMA_DC_BLOCK_INDEX+c, chroma_dc_scan, 4);
}
}
if( cbp&0x20 ) {
int c, i;
for( c = 0; c < 2; c++ ) {
qmul = h->dequant4_coeff[c+1+(IS_INTRA( mb_type ) ? 0:3)][h->chroma_qp[c]];
for( i = 0; i < 4; i++ ) {
const int index = 16 + 16 * c + i;
decode_cabac_residual_nondc(h, h->mb + (16*index << pixel_shift), 4, index, scan + 1, qmul, 15);
}
}
} else {
fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1);
fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1);
}
}
} else {
fill_rectangle(&h->non_zero_count_cache[scan8[ 0]], 4, 4, 8, 0, 1);
fill_rectangle(&h->non_zero_count_cache[scan8[16]], 4, 4, 8, 0, 1);
fill_rectangle(&h->non_zero_count_cache[scan8[32]], 4, 4, 8, 0, 1);
h->last_qscale_diff = 0;
}
s->current_picture.f.qscale_table[mb_xy] = s->qscale;
write_back_non_zero_count(h);
if(MB_MBAFF){
h->ref_count[0] >>= 1;
h->ref_count[1] >>= 1;
}
return 0;
}
| 1threat
|
Integrate Angular2 project into Tomcat server : <p>I've developed a Spring maven rest api for my project. For the client side, I'm using Angular2 with typescript. As new to Angular, referred angular website for the development, using npm and lite-server.</p>
<p><strong>Now I need to make these two separate projects into a single project</strong>, by integrating the html,js,css files into my maven project, to deploy it in Tomcat server.</p>
<p><strong>Project structure</strong></p>
<p>Client side</p>
<pre><code>Project
|__ app
|_ all app files
|__ node_modules
|__ typings
|__ index.html
|__ package.json
|__ style.css
|__ systemjs.config.js
|__ tsconfig.json
|__ typings.json
</code></pre>
<p>Server side</p>
<pre><code>Project
|__ src/main
|__ java
|__ resources
|__ webapp
|__index.html
|__ pom.xml
</code></pre>
<p><strong>All similar posts/blogs, i found suggest to update pom.xml with node etc. But what i need is,</strong></p>
<ul>
<li>Compile the angular-typescript project to js files. </li>
<li>Produce a set of fully functional html,js,css files. </li>
<li>Copy them to server webapp folder or whereever they must be.</li>
<li>Running Spring maven project in Tomcat must display my client side index page</li>
<li>Client must work (communicating with rest api) same way when they were two separate projects</li>
</ul>
<p>How this can be done?</p>
<p>Run this command, <code>npm run build</code>, in angular project root folder to create a <code>dist</code> folder, containing production ready client side files. But got this error </p>
<blockquote>
<p>missing script build</p>
</blockquote>
<p>.</p>
| 0debug
|
plz help me about react redux react-redux issue~~~ : can somebody help me,
i want to use react redux react-redux in my code,the question is when i click the button ,the color,word and author doesn't chenge?plz help me ,what's wrong with my code???
hello, can somebody help me,
i want to use react redux react-redux in my code,the question is when i click the button ,the color,word and author doesn't chenge?plz help me ,what's wrong with my code???
import React from 'react';
import ReactDOM from 'react-dom';
import 'materialize-css/dist/css/materialize.css';
import 'materialize-css/dist/js/materialize.js';
import {Provider,connect} from 'react-redux';
import {createStore} from 'redux';
//redux
const words=[
'In my dual profession as an educator and health care provider, I have worked with numerous children infected with the virus that causes AIDS. ',
'The relationships that I have had with these special kids have been gifts in my life. They have taught me so many things, but I have especially learned that great courage can be found in the smallest of packages. Let me tell you about Tyler.',
'Tyler was born infected with HIV: his mother was also infected. From the very beginning of his life, he was dependent on medications to enable him to survive. When he was five',
'he had a tube surgically inserted in a vein in his chest. This tube was connected to a pump, which he carried in a small backpack on his back. ',
'Medications were hooked up to this pump and were continuously supplied through this tube to his bloodstream. At times, he also needed supplemented oxygen to support his breathing.',
'Tyler wasn’t willing to give up one single moment of his childhood to this deadly disease. It was not unusual to find him playing and racing around his backyard,',
'wearing his medicine-laden backpack and dragging his tank of oxygen behind him in his little wagon. All of us who knew Tyler marveled at his pure joy in being alive and the energy it gave him. Tyler’s mom often teased him by telling him that he moved so fast she needed to dress him in red.',
'That way, when she peered through the window to check on him playing in the yard, she could quickly spot him.',
'This dreaded disease eventually wore down even the likes of a little dynamo like Tyler. He grew quite ill and, unfortunately',
' When it became apparent that he wasn’t going to survive, Tyler’s mom talked to him about death. She comforted him by telling Tyler that she was dying too,'
];
const colors=[
'red','green','blue','white','purple','yellow','pink','silver','gray','orange'
];
const authors=[
'red','green','blue','white','purple','yellow','pink','silver','gray','orange'
];
let aa=Math.floor(Math.random()*10);
const actionCreator=()=>{
return{
type:'UUU',
word:words[aa],
color:colors[aa],
author:authors[aa]
}
};
const defaultState={
color:'red',
word:' When it became apparent that he wasn’t going to survive, Tyler’s mom talked to him about death. She comforted him by telling Tyler that she was dying too,',
author:'red'
}
const reducer = (state =defaultState , action) => {
switch (action.type) {
case 'UUU':
return {
word:action.word,
color:action.color,
author:action.author
}
default:
return state;
}
}
const store=createStore(reducer);
//react
class Web extends React.Component{
constructor(props) {
super(props);
this.ddd=this.ddd.bind(this);
}
ddd(){
setTimeout(() => {
this.setState({
word:this.props.word,
color:this.props.color,
author:this.props.author
})
},600)
}
render(){
return(
<div id='quote-box' className='container center'>
<section style = {{backgroundColor: this.props.color,width:'100%',height:300}}>
<div style={{paddingTop:20}}>
<blockquote id='text'>“{this.props.word}”</blockquote>
<blockquote id='author'>“{this.props.author}”</blockquote>
</div>
<div>
<a id='tweet-quote' href='twitter.com/intent/tweet' style={{marginTop:120,marginRight:20}} className='waves-effect waves-light btn red'>Twitter</a>
<a style={{marginTop:120,marginRight:20}} className='btn waves-effect waves-light yellow'>b</a>
<a id='new-quote' style={{marginTop:120}} className='btn waves-effect waves-light green' onClick={this.ddd}>NEXT</a>
</div>
</section>
<b>by hutu zhu</b>
</div>
)
}
}
// react-redux
const mapStateToProps = (state=defaultState) => {
return defaultState;
}
const mapDispatchToProps = (dispatch) => {
return {
onClick: () => {
dispatch(actionCreator())
}
}
}
const Contain=connect(mapStateToProps,mapDispatchToProps)(Web);
class Wrapper extends React.Component{
render(){
return(
<Provider store={store}>
<Contain/>
</Provider>)
}
}
ReactDOM.render(<Wrapper/>,document.getElementById('root'));
| 0debug
|
jsonpb, why int64 to json is to string. like int64 str=10 -->str:"10" :
//code:630
`
//jsonpb, why int64 -> json is string. like 10-->"10"
//https://github.com/golang/protobuf/blob/master/jsonpb/jsonpb.go
// Default handling defers to the encoding/json library.
b, err := json.Marshal(v.Interface())
if err != nil {
return err
}
needToQuote := string(b[0]) != `"` && (v.Kind() == reflect.Int64 || v.Kind() == reflect.Uint64)
if needToQuote {
out.write(`"`)
}
out.write(string(b))
if needToQuote {
out.write(`"`)
}
`
| 0debug
|
Deleting an item from the business layer : <p>Is there any logic that should go in deleting a row in the database from the business layer? For example, should I check if the object has an <code>id > 0</code> before proceeding with delete?</p>
<pre><code> /// <summary>
/// Delete a task
/// </summary>
/// <param name="task">Task object to be deleted</param>
/// <returns></returns>
public int Delete(Task task)
{
return _taskData.Delete(task);
}
</code></pre>
| 0debug
|
static int mpegts_read_close(AVFormatContext *s)
{
MpegTSContext *ts = s->priv_data;
int i;
clear_programs(ts);
for(i=0;i<NB_PID_MAX;i++)
if (ts->pids[i]) mpegts_close_filter(ts, ts->pids[i]);
return 0;
}
| 1threat
|
No Module Named '_pywrap_tensorflow_internal' : <p>While trying to validate the installation of tensorflow-gpu, I get an ImportError when trying to execute "import tensorflow as tf". I am using a Quadro K620 on Windows 7. Tensorflow was installed using pip. </p>
<p>The following is the stack trace:</p>
<pre><code>Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\aagarwal>python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_hel
per
return importlib.import_module(mname)
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\importlib\_
_init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_hel
per
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\importlib\_
_init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_hel
per
return importlib.import_module(mname)
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\importlib\_
_init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_hel
per
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\aagarwal\AppData\Local\Programs\Python\Python35\lib\importlib\_
_init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
>>>
</code></pre>
<p>I have looked at multiple other stack overflow posts which things like correcting the path but I have not been able to solve this issue. </p>
| 0debug
|
i aint getting why I m getting two outputs in place of a single one? : I m solving a simple program and i am getting 2 outputs of the same data with a single cout statement...probably something went wrong with my loop , which i am not able to find where is the problem...also...if possible please answer acc. to my code and my logic or if not then atleast specify why my logic is wrong...
My code:-
`
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n ;
cin >> n;
vector<int> arr(n);
vector<int> a(n);
for(int arr_i = 0;arr_i < n;arr_i++){
cin >> arr[arr_i];
a[arr_i]=1;
}
int i,least,flag,count=n;
do{
cout<<count<<endl;
count=0;
flag=1;
for(i=0;i<n;i++){ //for getting least number
if(a[i]){
if(flag){
least=arr[i];
flag=0;
}
if(arr[i]<least){
least=arr[i];
}
}
}
for(i=0;i<n;i++){ // for actual logic
if(arr[i]<=0||!a[i]){
a[i]=0;
//continue;
}
else{
arr[i]-=least;
count++;
}
}
}while(count);
return 0;
}
`
**Sample input:-**
`
6
5 4 4 2 2 8
`
**Sample output:- (Expected Output)**
6
4
2
1
`
**Output I 'm getting in this Sample input**:-
6
6
4
4
2
2
1
1
`
**Problem statement:-**
You are given N sticks, where the length of each stick is a positive integer. A cut operation is performed on the sticks such that all of them are reduced by the length of the smallest stick.
Suppose we have six sticks of the following lengths:
5 4 4 2 2 8
Then, in one cut operation we make a cut of length 2 from each of the six sticks. For the next cut operation four sticks are left (of non-zero length), whose lengths are the following:
3 2 2 6
The above step is repeated until no sticks are left.
Given the length of N sticks, print the number of sticks that are left before each subsequent cut operations.
**Note:** For each cut operation, you have to recalcuate the length of smallest sticks (excluding zero-length sticks).
| 0debug
|
how can I define static var in android? : <p>I know this code must be so simple. But I couldn't understand it well.</p>
<pre><code>public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
</code></pre>
<p>I know <code>public final static String EXTRA_MESSAGE</code> define an static var.</p>
<p>But what is "com.example.myfirstapp.MESSAGE"?</p>
<p>code is <a href="https://developer.android.com/training/basics/firstapp/starting-activity.html?" rel="nofollow noreferrer">here</a>.</p>
| 0debug
|
int coroutine_fn bdrv_co_discard(BlockDriverState *bs, int64_t sector_num,
int nb_sectors)
{
BdrvTrackedRequest req;
int max_discard, ret;
if (!bs->drv) {
return -ENOMEDIUM;
}
ret = bdrv_check_request(bs, sector_num, nb_sectors);
if (ret < 0) {
return ret;
} else if (bs->read_only) {
return -EPERM;
}
assert(!(bs->open_flags & BDRV_O_INACTIVE));
if (!(bs->open_flags & BDRV_O_UNMAP)) {
return 0;
}
if (!bs->drv->bdrv_co_discard && !bs->drv->bdrv_aio_discard) {
return 0;
}
tracked_request_begin(&req, bs, sector_num << BDRV_SECTOR_BITS,
nb_sectors << BDRV_SECTOR_BITS, BDRV_TRACKED_DISCARD);
ret = notifier_with_return_list_notify(&bs->before_write_notifiers, &req);
if (ret < 0) {
goto out;
}
max_discard = MIN_NON_ZERO(bs->bl.max_pdiscard >> BDRV_SECTOR_BITS,
BDRV_REQUEST_MAX_SECTORS);
while (nb_sectors > 0) {
int ret;
int num = nb_sectors;
int discard_alignment = bs->bl.pdiscard_alignment >> BDRV_SECTOR_BITS;
if (discard_alignment &&
num >= discard_alignment &&
sector_num % discard_alignment) {
if (num > discard_alignment) {
num = discard_alignment;
}
num -= sector_num % discard_alignment;
}
if (num > max_discard) {
num = max_discard;
}
if (bs->drv->bdrv_co_discard) {
ret = bs->drv->bdrv_co_discard(bs, sector_num, num);
} else {
BlockAIOCB *acb;
CoroutineIOCompletion co = {
.coroutine = qemu_coroutine_self(),
};
acb = bs->drv->bdrv_aio_discard(bs, sector_num, nb_sectors,
bdrv_co_io_em_complete, &co);
if (acb == NULL) {
ret = -EIO;
goto out;
} else {
qemu_coroutine_yield();
ret = co.ret;
}
}
if (ret && ret != -ENOTSUP) {
goto out;
}
sector_num += num;
nb_sectors -= num;
}
ret = 0;
out:
bdrv_set_dirty(bs, req.offset >> BDRV_SECTOR_BITS,
req.bytes >> BDRV_SECTOR_BITS);
tracked_request_end(&req);
return ret;
}
| 1threat
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.