problem stringlengths 26 131k | labels class label 2 classes |
|---|---|
Form validations in express js with ejs template : I am new in nodejs and i am trying to validate my form using ejs template in express js.How can i do this ? Here is my code.
app.post('/formsubmit', function(req, res)
{
console.log(req.body);
var name =req.body.name;
var email=req.body.email;
var pwd =req.body.pwd;
var age =req.body.age;
var con = mysql.createConnection
({
host: "localhost",
user: "root",
password: "",
database: "demos"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
var sql = "INSERT INTO student (name, email,age) VALUES ('"+name+"','"+email+"','"+age+"')";
con.query(sql, function (err, result)
{
if (err) throw err;
console.log("1 record inserted");
});
});
//console.log(record);
res.send('Record Inserted Successfully');
}); | 0debug |
static ssize_t handle_aiocb_write_zeroes(RawPosixAIOData *aiocb)
{
int ret = -EOPNOTSUPP;
BDRVRawState *s = aiocb->bs->opaque;
if (s->has_write_zeroes == 0) {
return -ENOTSUP;
}
if (aiocb->aio_type & QEMU_AIO_BLKDEV) {
#ifdef BLKZEROOUT
do {
uint64_t range[2] = { aiocb->aio_offset, aiocb->aio_nbytes };
if (ioctl(aiocb->aio_fildes, BLKZEROOUT, range) == 0) {
return 0;
}
} while (errno == EINTR);
ret = -errno;
#endif
} else {
#ifdef CONFIG_XFS
if (s->is_xfs) {
return xfs_write_zeroes(s, aiocb->aio_offset, aiocb->aio_nbytes);
}
#endif
}
ret = translate_err(ret);
if (ret == -ENOTSUP) {
s->has_write_zeroes = false;
}
return ret;
}
| 1threat |
What does boto stand for : <p>What does Boto stand for in the context of AWS? It seems like a random word to choose for an api name. Is it an acronym? I have tried googling around and see no indication of what it could mean.</p>
| 0debug |
Rust Error: no method named `subtractPointFromPoint` found for type `()` in the current scope : So I have started creating a gaming graphics engine using [this](https://gamedevelopment.tutsplus.com/tutorials/lets-build-a-3d-graphics-engine-points-vectors-and-basic-concepts--gamedev-8143) article. I have chosen rust to create it in because I have heard about it and it sounds perfect for creating games. The only problem is I have no experience whatsoever (I have used python, javascript, java and html before).
This is the code I have written so far:
**point.rs**
// Point class
// Operators
struct point {
x: i32,
y: i32,
z: i32
}
// Variables
pub fn new(x: i32, y: i32, z:i32) {
let mut point = (x, y, z);
//return point;
impl point {
fn addVectorToPoint(self: &point, (x, y, z): (i32, i32, i32)) {
let mut x = x + &self.x;
let mut y = y + &self.y;
let mut z = z + &self.z;
let mut point = (x, y, z);
}
fn subtractVectorFromPoint(self: &point, (x, y, z): (i32, i32, i32)) {
let mut x = &self.x - x;
let mut y = &self.y - y;
let mut z = &self.z - z;
let mut point = (x, y, z);
}
fn subtractPointFromPoint(self: &point, (x, y, z): (i32, i32, i32)) {
let mut x = &self.x - x;
let mut y = &self.y - y;
let mut z = &self.z - z;
let mut vector = (x, y, z);
}
}
}
**main.rs**
mod point;
fn main() {
let point1 = point::new(1, 2, 3);
let point2 = point::new(3, 2, 1);
let newPoint = point1.subtractPointFromPoint(point2);
println!("{:?}", newPoint);
}
Anyway, when I run it, I get this:
$ cargo run
Compiling blaze v0.1.0
error[E0599]: no method named `subtractPointFromPoint` found for type `()` in the current scope
--> src/main.rs:6:27
|
6 | let newPoint = point1.subtractPointFromPoint(point2);
| ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
error: Could not compile `blaze`.
To learn more, run the command again with --verbose.
Please tell me what I am doin wrong. Also, if my code is really inefficient, any suggestions will be greatly appreciated!
Thanks in advance! | 0debug |
How to build nginx test envirnment? : I'm a beginner of nginx. I wonder how to build nginx test envirnment~? How do you know your nginx configuration is workable or non-workable?
| 0debug |
static void vp8_idct_dc_add4y_c(uint8_t *dst, int16_t block[4][16], ptrdiff_t stride)
{
vp8_idct_dc_add_c(dst+ 0, block[0], stride);
vp8_idct_dc_add_c(dst+ 4, block[1], stride);
vp8_idct_dc_add_c(dst+ 8, block[2], stride);
vp8_idct_dc_add_c(dst+12, block[3], stride);
}
| 1threat |
first week programing, getting ass kicked by stupid stuff every day : Example:
This is my simple HTML document:
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<section id="left"> Put an image anywhere in this box.</section>
<section id="right"> </section>
<img id="tree" src="file:///home/john/Desktop/javascripts%20basics /ashtree.jpg">
</body>
<footer>
<script src="john.js"></script>
<link href="john.css" text="text/css" rel="stylesheets.css">
</footer>
</html>
This is my simple CSS document:
#left{float:left;
width:250px;
height:250px;
margin:5px;
border: 3px solid blue;}
#right{float:left;
width:250px;
height:250px;
margin:5px;
border: 3px solid green;}
The HTML loads in my firefox web-browser, but the css does not.I downloaded chromium as well and it doest work either. Ive checked many examples and I think I got it right. The question is...where do I look next to solve this problem. I have no clue where to start as I am not very educated with computers.
| 0debug |
How to resynchronize with chrony? : <p>I am looking for an equivalent of 'ntpdate IPaddress' command
in the chrony suite to force chronyd to synchronize time right now.</p>
| 0debug |
How to get class name of the WebElement in Python Selenium? : <p>I use Selenium webdriver to scrap a table taken from web page, written in JavaScript.
I am iterating on a list of table rows. Each row may be of different class. I want to get the name of this class, so that I can choose appropriate action for each row.</p>
<pre><code>table_body=table.find_element_by_tag_name('tbody')
rows=table_body.find_elements_by_tag_name('tr')
for row in rows:
if(row.GetClassName()=="date"):
Action1()
else:
Action2()
</code></pre>
<p>Is this possible with Selenium? Or suggest another approach.</p>
| 0debug |
google chrome app offline database : I'm building starting to learn how to build an app in google chrome.. but if I have this problem which really complicates my way.. I want to my app to be operated offline only and its database is offline, this is because I will just use my app inside our office... is there a database is very simple way to connect to a database(eg: like I'll just copy paste it in my app folder)?I would prefer that the database has a very simple documentation on how to use it.. your recomendations would be of great help . . | 0debug |
float av_int2flt(int32_t v){
if(v+v > 0xFF000000U)
return NAN;
return ldexp(((v&0x7FFFFF) + (1<<23)) * (v>>31|1), (v>>23&0xFF)-150);
}
| 1threat |
Cross origin error in jquery.load() : <p>I want to load html snippets into my html page with the following code:</p>
<pre><code> <div data-include="header"></div>
<script>
$(function(){
var includes = $('[data-include]');
jQuery.each(includes, function(){
var file = '_HTML/' + $(this).data('include') + '.html';
$(this).load(file);
});
});
</script>
</code></pre>
<p>In Firefox and Safari it works perfect, but in Chrome and IE Edge it gives me a cross origin request error:</p>
<blockquote>
<p>XMLHttpRequest cannot load file:///../header.html. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.</p>
</blockquote>
<p>Are there any workarounds for this error which are working in every of the named browsers?</p>
| 0debug |
what is the difference between compile, testCompile and provided in gradle dependency : <p>I am using android studio and in project structure -> dependencies tab following options i can see:</p>
<ol>
<li>Compile</li>
<li>Provided</li>
<li>APK</li>
<li>Test Compile</li>
<li>Debug Compile</li>
<li>Release Compile</li>
</ol>
<p>my question: what is the difference between compile, testCompile and provided in gradle dependency </p>
| 0debug |
Webpack not loading css : <p>This is my first time trying to set up Webpack, so I'm sure I'm missing something here.</p>
<p>I am trying to load my PostCSS files with Webpack, using the ExtractTextPlugin to generate a css file into "dist". The problem is Webpack does not seem to pick up the css files. They are under "client/styles", but I've tried moving them to "shared", with the same result.</p>
<p>I ran Webpack with the --display-modules option, and verified that no css files display there.</p>
<p>I have tried running it without the extract text plugin, and the result is the same: no CSS is built into bundle.js.</p>
<p>Here is my prod config:</p>
<pre><code>var ExtractTextPlugin = require('extract-text-webpack-plugin');
var path = require('path');
module.exports = {
entry: [
'./client'
],
resolve: {
modulesDirectories: ['node_modules', 'shared'],
extensions: ['', '.js', '.jsx', '.css']
},
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js',
chunkFilename: '[id].js',
publicPath: '/'
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['babel']
},
{
test: /\.css?$/,
loader: ExtractTextPlugin.extract(
'style-loader',
'css-loader!postcss-loader'
),
exclude: /node_modules/
}
]
},
plugins: [
new ExtractTextPlugin('[name].css')
],
postcss: (webpack) => [
require('postcss-import')({ addDependencyTo: webpack, path: ['node_modules', 'client'] }),
require('postcss-url')(),
require('precss')(),
require('postcss-fontpath')(),
require('autoprefixer')({ browsers: [ 'last 2 versions' ] })
]
};
</code></pre>
<p>And here's an example of my main css file:
@import 'normalize.css/normalize';</p>
<pre><code>/* Variables */
@import 'variables/colours';
/* Mixins */
/* App */
/* Components */
body {
background-color: $black;
}
</code></pre>
<p>Would anyone have an idea on why this is happening? Am I missing something?</p>
<p>Thank you</p>
| 0debug |
A console full of <FIRInstanceID/WARNING> - Xcode 8 / iOS10 : <p>I am having issues with Firebase within Xcode 8 / iOS 10 / Swift 3.
Trying to just get Firebase Analytics all set up. However in iOS10, the console gets logged with a plethora of WARNING logs from Firebase. These do not happen when I run iOS 9.3 in the simulator. I took the exact steps as noted here: <a href="https://firebase.google.com/docs/analytics/ios/start" rel="noreferrer">https://firebase.google.com/docs/analytics/ios/start</a> </p>
<p>Here is what the log looks like:</p>
<pre><code><FIRAnalytics/INFO> Firebase Analytics v.3402000 started
<FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
<FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
<FIRInstanceID/WARNING> Failed to remove checkin auth credentials from Keychain Error Domain=com.google.iid Code=-34018 "(null)"
<FIRInstanceID/WARNING> Error failed to remove all tokens from keychain Error Domain=com.google.iid Code=-34018 "(null)"
<FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
<FIRInstanceID/WARNING> STOP!! Will reset deviceID from memory.
<FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=6 "(null)"
<FIRInstanceID/WARNING> STOP!! Will reset deviceID from memory.
<FIRInstanceID/WARNING> Error removing keypair status: -34018
<FIRInstanceID/WARNING> Unable to remove RSA keypair
<FIRInstanceID/WARNING> Unable to generate keypair.
<FIRAnalytics/WARNING> Failed to get InstanceID: Error Domain=com.firebase.iid Code=-34018 "(null)"
<FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=501 "(null)" UserInfo={msg=Missing device credentials. Retry later.}
<FIRInstanceID/WARNING> Failed to retrieve the default GCM token after 5 retries
</code></pre>
<p>I also get the following error that pops up about every ~30 seconds (while the errors above all don't repeat):</p>
<pre><code><FIRInstanceID/WARNING> STOP!! Will reset deviceID from memory.
</code></pre>
<p>Before posting this, I did research and found that the WARNING logs can go away if you enable Keychain Sharing within Capabilities. I am weary of this, however, because no other documentation or explanation was given. And I don't know if that's just masking the errors, or if it's a safe solution here.</p>
<p>Please advise on the safest way to remedy all these WARNING logs.
Thanks</p>
| 0debug |
Angular 2 - How to pass URL parameters? : <p>I have created a single page mortgage calculator application in Angular 2, which acts like a learning playground for me (trying to get more accustomed to technology stack currently used at work)... It's running at <a href="http://www.mortgagecalculator123.com">http://www.mortgagecalculator123.com</a> if you want to look at it. I've made it open source with a Fork Me link right on the page if you want to look at it.</p>
<p>Anyhow, what I want to do, is to be able to pass variables to my app, straight from the URL, so they can be consumed by my Angular 2 app. Something like this: <a href="http://www.mortgagecalculator123.com/?var1=ABC&var2=DEF">http://www.mortgagecalculator123.com/?var1=ABC&var2=DEF</a></p>
<p>I've tried following, in my app.component.ts, I've added following:</p>
<pre><code>import { Router, ActivatedRoute, Params } from '@angular/router';
AppComponent {
private var1: string;
private var2: string;
constructor(
private route: ActivatedRoute,
private router: Router
) {}
ngOnInit() {
this.route.params.forEach((params: Params) => {
this.var1 = params['var1'];
this.var2 = params['var2'];
});
console.log(this.var1, this.var2);
}
...
}
</code></pre>
<p>But this won't work, when I run <strong>npm start</strong>, I get following error:</p>
<p><strong>aot/app/app.component.ngfactory.ts(45,30): error TS2346: Supplied parameters do not match any signature of call target.</strong></p>
<p><a href="https://i.stack.imgur.com/Zf0SM.jpg"><img src="https://i.stack.imgur.com/Zf0SM.jpg" alt="enter image description here"></a></p>
<p>Thank you, any help would be much appreciated.</p>
| 0debug |
YUV2RGB(rgb8, uint8_t)
YUV2RGB(rgb16, uint16_t)
static void png_handle_row(PNGDecContext *s)
{
uint8_t *ptr, *last_row;
int got_line;
if (!s->interlace_type) {
ptr = s->image_buf + s->image_linesize * (s->y + s->y_offset) + s->x_offset * s->bpp;
if (s->y == 0)
last_row = s->last_row;
else
last_row = ptr - s->image_linesize;
png_filter_row(&s->dsp, ptr, s->crow_buf[0], s->crow_buf + 1,
last_row, s->row_size, s->bpp);
if (s->filter_type == PNG_FILTER_TYPE_LOCO && s->y > 0) {
if (s->bit_depth == 16) {
deloco_rgb16((uint16_t *)(ptr - s->image_linesize), s->row_size / 2,
s->color_type == PNG_COLOR_TYPE_RGB_ALPHA);
} else {
deloco_rgb8(ptr - s->image_linesize, s->row_size,
s->color_type == PNG_COLOR_TYPE_RGB_ALPHA);
}
}
s->y++;
if (s->y == s->cur_h) {
s->state |= PNG_ALLIMAGE;
if (s->filter_type == PNG_FILTER_TYPE_LOCO) {
if (s->bit_depth == 16) {
deloco_rgb16((uint16_t *)ptr, s->row_size / 2,
s->color_type == PNG_COLOR_TYPE_RGB_ALPHA);
} else {
deloco_rgb8(ptr, s->row_size,
s->color_type == PNG_COLOR_TYPE_RGB_ALPHA);
}
}
}
} else {
got_line = 0;
for (;;) {
ptr = s->image_buf + s->image_linesize * (s->y + s->y_offset) + s->x_offset * s->bpp;
if ((ff_png_pass_ymask[s->pass] << (s->y & 7)) & 0x80) {
if (got_line)
break;
png_filter_row(&s->dsp, s->tmp_row, s->crow_buf[0], s->crow_buf + 1,
s->last_row, s->pass_row_size, s->bpp);
FFSWAP(uint8_t *, s->last_row, s->tmp_row);
FFSWAP(unsigned int, s->last_row_size, s->tmp_row_size);
got_line = 1;
}
if ((png_pass_dsp_ymask[s->pass] << (s->y & 7)) & 0x80) {
png_put_interlaced_row(ptr, s->cur_w, s->bits_per_pixel, s->pass,
s->color_type, s->last_row);
}
s->y++;
if (s->y == s->cur_h) {
memset(s->last_row, 0, s->row_size);
for (;;) {
if (s->pass == NB_PASSES - 1) {
s->state |= PNG_ALLIMAGE;
goto the_end;
} else {
s->pass++;
s->y = 0;
s->pass_row_size = ff_png_pass_row_size(s->pass,
s->bits_per_pixel,
s->cur_w);
s->crow_size = s->pass_row_size + 1;
if (s->pass_row_size != 0)
break;
}
}
}
}
the_end:;
}
}
| 1threat |
Is Java Servlet Container also a class? : <p>Is the container a set of environment or just a Java class that can call methods in servlets?
What's the component of servlets container?</p>
| 0debug |
Is it possible for AWS Lambda to run a Windows binary via Wine? : <p>I have a Python script with a Windows <code>.exe</code> dependency, which in return relies on a (closed-source) Windows DLL. The Python script runs just fine in Ubuntu via a call to Wine.</p>
<p>Is it possible (and practical) to run this on AWS Lambda?</p>
<p>What would be involved in preparing the code package?</p>
| 0debug |
static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
int parse_extradata)
{
AVCodecContext *const avctx = h->avctx;
H264SliceContext *sl;
int buf_index;
unsigned context_count;
int next_avc;
int nals_needed = 0;
int nal_index;
int idr_cleared=0;
int ret = 0;
h->nal_unit_type= 0;
if(!h->slice_context_count)
h->slice_context_count= 1;
h->max_contexts = h->slice_context_count;
if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS)) {
h->current_slice = 0;
if (!h->first_field)
h->cur_pic_ptr = NULL;
ff_h264_reset_sei(h);
if (h->nal_length_size == 4) {
if (buf_size > 8 && AV_RB32(buf) == 1 && AV_RB32(buf+5) > (unsigned)buf_size) {
h->is_avc = 0;
}else if(buf_size > 3 && AV_RB32(buf) > 1 && AV_RB32(buf) <= (unsigned)buf_size)
h->is_avc = 1;
if (avctx->active_thread_type & FF_THREAD_FRAME)
nals_needed = get_last_needed_nal(h, buf, buf_size);
{
buf_index = 0;
next_avc = h->is_avc ? 0 : buf_size;
nal_index = 0;
for (;;) {
int consumed;
int dst_length;
int bit_length;
const uint8_t *ptr;
int nalsize = 0;
int err;
if (buf_index >= next_avc) {
nalsize = get_avc_nalsize(h, buf, buf_size, &buf_index);
if (nalsize < 0)
break;
next_avc = buf_index + nalsize;
} else {
buf_index = find_start_code(buf, buf_size, buf_index, next_avc);
if (buf_index >= buf_size)
break;
if (buf_index >= next_avc)
continue;
sl = &h->slice_ctx[context_count];
ptr = ff_h264_decode_nal(h, sl, buf + buf_index, &dst_length,
&consumed, next_avc - buf_index);
if (!ptr || dst_length < 0) {
ret = -1;
bit_length = get_bit_length(h, buf, ptr, dst_length,
buf_index + consumed, next_avc);
if (h->avctx->debug & FF_DEBUG_STARTCODE)
av_log(h->avctx, AV_LOG_DEBUG,
"NAL %d/%d at %d/%d length %d\n",
h->nal_unit_type, h->nal_ref_idc, buf_index, buf_size, dst_length);
if (h->is_avc && (nalsize != consumed) && nalsize)
av_log(h->avctx, AV_LOG_DEBUG,
"AVC: Consumed only %d bytes instead of %d\n",
consumed, nalsize);
buf_index += consumed;
nal_index++;
if (avctx->skip_frame >= AVDISCARD_NONREF &&
h->nal_ref_idc == 0 &&
h->nal_unit_type != NAL_SEI)
continue;
again:
if ( (!(avctx->active_thread_type & FF_THREAD_FRAME) || nals_needed >= nal_index)
&& !h->current_slice)
h->au_pps_id = -1;
if (parse_extradata) {
switch (h->nal_unit_type) {
case NAL_IDR_SLICE:
case NAL_SLICE:
case NAL_DPA:
case NAL_DPB:
case NAL_DPC:
av_log(h->avctx, AV_LOG_WARNING,
"Ignoring NAL %d in global header/extradata\n",
h->nal_unit_type);
case NAL_AUXILIARY_SLICE:
h->nal_unit_type = NAL_FF_IGNORE;
err = 0;
switch (h->nal_unit_type) {
case NAL_IDR_SLICE:
if ((ptr[0] & 0xFC) == 0x98) {
av_log(h->avctx, AV_LOG_ERROR, "Invalid inter IDR frame\n");
h->next_outputed_poc = INT_MIN;
ret = -1;
if (h->nal_unit_type != NAL_IDR_SLICE) {
av_log(h->avctx, AV_LOG_ERROR,
"Invalid mix of idr and non-idr slices\n");
ret = -1;
if(!idr_cleared) {
if (h->current_slice && (avctx->active_thread_type & FF_THREAD_SLICE)) {
av_log(h, AV_LOG_ERROR, "invalid mixed IDR / non IDR frames cannot be decoded in slice multithreading mode\n");
ret = AVERROR_INVALIDDATA;
idr(h);
idr_cleared = 1;
h->has_recovery_point = 1;
case NAL_SLICE:
init_get_bits(&sl->gb, ptr, bit_length);
if ((err = ff_h264_decode_slice_header(h, sl)))
break;
if (h->sei_recovery_frame_cnt >= 0) {
if (h->frame_num != h->sei_recovery_frame_cnt || sl->slice_type_nos != AV_PICTURE_TYPE_I)
h->valid_recovery_point = 1;
if ( h->recovery_frame < 0
|| ((h->recovery_frame - h->frame_num) & ((1 << h->sps.log2_max_frame_num)-1)) > h->sei_recovery_frame_cnt) {
h->recovery_frame = (h->frame_num + h->sei_recovery_frame_cnt) &
((1 << h->sps.log2_max_frame_num) - 1);
if (!h->valid_recovery_point)
h->recovery_frame = h->frame_num;
h->cur_pic_ptr->f.key_frame |=
(h->nal_unit_type == NAL_IDR_SLICE);
if (h->nal_unit_type == NAL_IDR_SLICE ||
h->recovery_frame == h->frame_num) {
h->recovery_frame = -1;
h->cur_pic_ptr->recovered = 1;
if (h->nal_unit_type == NAL_IDR_SLICE)
h->frame_recovered |= FRAME_RECOVERED_IDR;
h->frame_recovered |= 3*!!(avctx->flags2 & CODEC_FLAG2_SHOW_ALL);
h->frame_recovered |= 3*!!(avctx->flags & CODEC_FLAG_OUTPUT_CORRUPT);
#if 1
h->cur_pic_ptr->recovered |= h->frame_recovered;
#else
h->cur_pic_ptr->recovered |= !!(h->frame_recovered & FRAME_RECOVERED_IDR);
#endif
if (h->current_slice == 1) {
if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS))
decode_postinit(h, nal_index >= nals_needed);
if (h->avctx->hwaccel &&
(ret = h->avctx->hwaccel->start_frame(h->avctx, buf, buf_size)) < 0)
if (CONFIG_H264_VDPAU_DECODER &&
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
ff_vdpau_h264_picture_start(h);
if (sl->redundant_pic_count == 0) {
if (avctx->hwaccel) {
ret = avctx->hwaccel->decode_slice(avctx,
&buf[buf_index - consumed],
consumed);
if (ret < 0)
} else if (CONFIG_H264_VDPAU_DECODER &&
h->avctx->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) {
ff_vdpau_add_data_chunk(h->cur_pic_ptr->f.data[0],
start_code,
sizeof(start_code));
ff_vdpau_add_data_chunk(h->cur_pic_ptr->f.data[0],
&buf[buf_index - consumed],
consumed);
} else
context_count++;
break;
case NAL_DPA:
case NAL_DPB:
case NAL_DPC:
avpriv_request_sample(avctx, "data partitioning");
ret = AVERROR(ENOSYS);
break;
case NAL_SEI:
init_get_bits(&h->gb, ptr, bit_length);
ret = ff_h264_decode_sei(h);
break;
case NAL_SPS:
init_get_bits(&h->gb, ptr, bit_length);
if (ff_h264_decode_seq_parameter_set(h) < 0 && (h->is_avc ? nalsize : 1)) {
av_log(h->avctx, AV_LOG_DEBUG,
"SPS decoding failure, trying again with the complete NAL\n");
if (h->is_avc)
av_assert0(next_avc - buf_index + consumed == nalsize);
if ((next_avc - buf_index + consumed - 1) >= INT_MAX/8)
break;
init_get_bits(&h->gb, &buf[buf_index + 1 - consumed],
8*(next_avc - buf_index + consumed - 1));
ff_h264_decode_seq_parameter_set(h);
break;
case NAL_PPS:
init_get_bits(&h->gb, ptr, bit_length);
ret = ff_h264_decode_picture_parameter_set(h, bit_length);
break;
case NAL_AUD:
case NAL_END_SEQUENCE:
case NAL_END_STREAM:
case NAL_FILLER_DATA:
case NAL_SPS_EXT:
case NAL_AUXILIARY_SLICE:
break;
case NAL_FF_IGNORE:
break;
default:
av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n",
h->nal_unit_type, bit_length);
if (context_count == h->max_contexts) {
ret = ff_h264_execute_decode_slices(h, context_count);
if (err < 0 || err == SLICE_SKIPED) {
if (err < 0)
av_log(h->avctx, AV_LOG_ERROR, "decode_slice_header error\n");
sl->ref_count[0] = sl->ref_count[1] = sl->list_count = 0;
} else if (err == SLICE_SINGLETHREAD) {
sl = &h->slice_ctx[0];
goto again;
if (context_count) {
ret = ff_h264_execute_decode_slices(h, context_count);
ret = 0;
end:
if (h->cur_pic_ptr && !h->droppable) {
ff_thread_report_progress(&h->cur_pic_ptr->tf, INT_MAX,
h->picture_structure == PICT_BOTTOM_FIELD);
return (ret < 0) ? ret : buf_index;
| 1threat |
Java 11 HTTP client asynchronous execution : <p>I'm trying the new HTTP client API from JDK 11, specifically its asynchronous way of executing requests. But there is something that I'm not sure I understand (sort of an implementation aspect). In the <a href="http://cr.openjdk.java.net/~chegar/httpclient/02/javadoc/api/java.net.http/java/net/http/package-summary.html" rel="noreferrer">documentation</a>, it says:</p>
<blockquote>
<p>Asynchronous tasks and dependent actions of returned <code>CompletableFuture</code> instances are executed on the threads supplied by the client's <code>Executor</code>, where practical.</p>
</blockquote>
<p>As I understand this, it means that if I set a custom executor when creating the <code>HttpClient</code> object:</p>
<pre><code>ExecutorService executor = Executors.newFixedThreadPool(3);
HttpClient httpClient = HttpClient.newBuilder()
.executor(executor) // custom executor
.build();
</code></pre>
<p>then if I send a request asynchronously and add dependent actions on the returned <code>CompletableFuture</code>, the dependent action should execute on the specified executor.</p>
<pre><code>httpClient.sendAsync(request, BodyHandlers.ofString())
.thenAccept(response -> {
System.out.println("Thread is: " + Thread.currentThread().getName());
// do something when the response is received
});
</code></pre>
<p>However, in the dependent action above (the consumer in <code>thenAccept</code>), I see that the thread doing it is from the common pool and not the custom executor, since it prints <code>Thread is: ForkJoinPool.commonPool-worker-5</code>.</p>
<p>Is this a bug in the implementation? Or something I'm missing? I notice it says "instances are executed on the threads supplied by the client's Executor, <strong>where practical</strong>", so is this a case where this is not applied?</p>
<p>Note that I also tried <code>thenAcceptAsync</code> as well and it's the same result.</p>
| 0debug |
Passing vector by reference: Segmentation fault : <p>I'm trying to get the following code for merge sort work with vectors instead of C style arrays and I'm having a hard time figuring out why it crashes with segmentation fault. Can someone help me out in understanding the problem here?</p>
<pre><code>#include <bits/stdc++.h>
using namespace std;
void merge(vector<int>& a, int l, int m, int r) {
vector<int> L;
vector<int> R;
for (int i = 0; i <= m; i++)
L.push_back(a[i]);
for (int i = m+1; i <= r; i++)
R.push_back(a[i]);
int i = 0, j = 0; // Initial index of first and second subarray
int k = l; // Initial index of merged subarray
while (i < L.size() && j < R.size()) {
if (L[i] <= R[j]) {
a[k] = L[i];
i++;
}
else {
a[k] = R[j];
j++;
}
k++;
}
// Filling leftovers
while (i < L.size()) {
a[k] = L[i];
k++;
i++;
}
while (j < R.size()) {
a[k] = R[j];
k++;
j++;
}
}
void merge_sort(vector<int>& a, int l, int r) {
if (l < r) {
int m = l + (r-l) / 2; // Avoids integer overflow.
merge_sort(a, l, m);
merge_sort(a, m+1, r);
merge(a, l, m, r);
}
}
int main()
{
vector<int> a = {2, 4, 1, 5, 3, 9};
int size = a.size();
merge_sort(a, 0, size-1);
for (int i = 0; i < size; i++)
cout << a[i] << ' ';
cout << endl;
return 0;
}
</code></pre>
| 0debug |
How to create stack bar chart using ggplot : <p>I have a data-set as below:</p>
<pre><code>A B C
1 1 1
0 1 1
1 0 1
1 0 1
</code></pre>
<p>I want to have a stack bar chart that shows percentage of 1 and 0 in each column next to other column all in one figure.</p>
| 0debug |
StringInputVisitor *string_input_visitor_new(const char *str)
{
StringInputVisitor *v;
v = g_malloc0(sizeof(*v));
v->visitor.type = VISITOR_INPUT;
v->visitor.type_int64 = parse_type_int64;
v->visitor.type_uint64 = parse_type_uint64;
v->visitor.type_size = parse_type_size;
v->visitor.type_bool = parse_type_bool;
v->visitor.type_str = parse_type_str;
v->visitor.type_number = parse_type_number;
v->visitor.start_list = start_list;
v->visitor.next_list = next_list;
v->visitor.end_list = end_list;
v->visitor.optional = parse_optional;
v->string = str;
v->head = true;
return v;
}
| 1threat |
I dont get rxjs 6 with angular 6 with interval, switchMap, and map : <p>I want to update my rxjs code to 6 got I don't get it.</p>
<p>Before I had the below that wouth poll for new data every 5 seconds:</p>
<pre><code>import { Observable, interval } from 'rxjs';
import { switchMap, map } from 'rxjs/operators';
var result = interval(5000).switchMap(() => this._authHttp.get(url)).map(res => res.json().results);
</code></pre>
<p>Now...of course, it's broken and the documentation leaves me nowhere to go.</p>
<p>How do I write the above to conform to rxjs 6?</p>
<p>Thanks</p>
| 0debug |
Ubuntu 18.04 /var/lib/snapd has 'other' write 40777 : <p>Tried to start Calculator in Ubuntu, but received the following message:</p>
<pre><code>/var/lib/snapd has 'other' write 40777
</code></pre>
<p>Not sure what that means. I just want to start Calculator. Weird. Any ideas?</p>
| 0debug |
static void tc6393xb_gpio_handler_update(TC6393xbState *s)
{
uint32_t level, diff;
int bit;
level = s->gpio_level & s->gpio_dir;
for (diff = s->prev_level ^ level; diff; diff ^= 1 << bit) {
bit = ffs(diff) - 1;
qemu_set_irq(s->handler[bit], (level >> bit) & 1);
}
s->prev_level = level;
}
| 1threat |
static hwaddr ppc_hash32_htab_lookup(PowerPCCPU *cpu,
target_ulong sr, target_ulong eaddr,
ppc_hash_pte32_t *pte)
{
CPUPPCState *env = &cpu->env;
hwaddr pteg_off, pte_offset;
hwaddr hash;
uint32_t vsid, pgidx, ptem;
vsid = sr & SR32_VSID;
pgidx = (eaddr & ~SEGMENT_MASK_256M) >> TARGET_PAGE_BITS;
hash = vsid ^ pgidx;
ptem = (vsid << 7) | (pgidx >> 10);
qemu_log_mask(CPU_LOG_MMU, "htab_base " TARGET_FMT_plx
" htab_mask " TARGET_FMT_plx
" hash " TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, hash);
qemu_log_mask(CPU_LOG_MMU, "0 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=%" PRIx32 " ptem=%" PRIx32
" hash=" TARGET_FMT_plx "\n",
env->htab_base, env->htab_mask, vsid, ptem, hash);
pteg_off = get_pteg_offset32(cpu, hash);
pte_offset = ppc_hash32_pteg_search(cpu, pteg_off, 0, ptem, pte);
if (pte_offset == -1) {
qemu_log_mask(CPU_LOG_MMU, "1 htab=" TARGET_FMT_plx "/" TARGET_FMT_plx
" vsid=%" PRIx32 " api=%" PRIx32
" hash=" TARGET_FMT_plx "\n", env->htab_base,
env->htab_mask, vsid, ptem, ~hash);
pteg_off = get_pteg_offset32(cpu, ~hash);
pte_offset = ppc_hash32_pteg_search(cpu, pteg_off, 1, ptem, pte);
}
return pte_offset;
}
| 1threat |
Math and PHP to find and print permutation sets : <p>I have a quiz of 6 questions that must be answered either yes (y) or no (n). So the set of answers might be</p>
<blockquote>
<p>yynynn</p>
</blockquote>
<p>For another quiz of 6 questions the answers might be</p>
<blockquote>
<p>nnnynn</p>
</blockquote>
<p>For another,</p>
<blockquote>
<p>ynynyn</p>
</blockquote>
<p>I need a script to find and print the unique permutations of answer sets.</p>
| 0debug |
static void qemu_tcg_wait_io_event(void)
{
CPUState *env;
while (all_cpu_threads_idle()) {
qemu_clock_warp(vm_clock);
qemu_cond_wait(tcg_halt_cond, &qemu_global_mutex);
}
qemu_mutex_unlock(&qemu_global_mutex);
qemu_mutex_lock(&qemu_fair_mutex);
qemu_mutex_unlock(&qemu_fair_mutex);
qemu_mutex_lock(&qemu_global_mutex);
for (env = first_cpu; env != NULL; env = env->next_cpu) {
qemu_wait_io_event_common(env);
}
}
| 1threat |
Image Taking Full Width Of Container : <p>really basic question, but I do marketing for a client so don't know too much besides basics HTML, CSS. </p>
<p>I've got an image slider in the URL below, what should I do so the image occupies the full space of the container (as there are bars on either side of the image). Do I just remove the padding or is there something more efficient to put in the stylesheet. Thanks heaps for your help</p>
<p><a href="https://www.vibrantrealestate.com.au/property/outstanding-warehouse-space-style-on-the-citys-edge/" rel="nofollow noreferrer">https://www.vibrantrealestate.com.au/property/outstanding-warehouse-space-style-on-the-citys-edge/</a></p>
<p><a href="https://i.stack.imgur.com/cn2qy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cn2qy.jpg" alt="enter image description here"></a></p>
| 0debug |
static void avc_luma_hv_qrt_16w_msa(const uint8_t *src_x, const uint8_t *src_y,
int32_t src_stride, uint8_t *dst,
int32_t dst_stride, int32_t height)
{
uint32_t multiple8_cnt;
for (multiple8_cnt = 2; multiple8_cnt--;) {
avc_luma_hv_qrt_8w_msa(src_x, src_y, src_stride, dst, dst_stride,
height);
src_x += 8;
src_y += 8;
dst += 8;
}
}
| 1threat |
int float32_is_nan( float32 a1 )
{
float32u u;
uint64_t a;
u.f = a1;
a = u.i;
return ( 0xFF800000 < ( a<<1 ) );
}
| 1threat |
Enter data from form into mongodb using nodejs : <p>I am having trouble to enter data in my database based on the option selected from the form
Here is my form- </p>
<pre><code> <div class="input">
<label for="fever">Fever</label>
<input type="radio" id="fever" name="fever" value="0">No
<input type="radio" id="fever" name="fever" value="1">Yes<br><br>
</div>
<div class="input">
<label for="eyesight">Eyesight</label>
<input type="radio" id="eyesight" name="eyesight" value="0">Long Sightedness
<input type="radio" id="eyesight" name="eyesight" value="1">Short Sightedness<br><br>
</div>
</code></pre>
<p>How can I know which option the user has selected and enter that in my database</p>
| 0debug |
Wordpress Fullscreen site : <p>I'm using the theme IsleMag. How to set full screen site? There are margins now.
Site: <a href="https://namedycyne.net.pl/" rel="nofollow noreferrer">https://namedycyne.net.pl/</a></p>
| 0debug |
static BlockBackend *img_open_opts(const char *optstr,
QemuOpts *opts, int flags, bool writethrough,
bool quiet, bool force_share)
{
QDict *options;
Error *local_err = NULL;
BlockBackend *blk;
options = qemu_opts_to_qdict(opts, NULL);
if (force_share) {
if (qdict_haskey(options, BDRV_OPT_FORCE_SHARE)
&& !qdict_get_bool(options, BDRV_OPT_FORCE_SHARE)) {
error_report("--force-share/-U conflicts with image options");
return NULL;
}
qdict_put(options, BDRV_OPT_FORCE_SHARE, qbool_from_bool(true));
}
blk = blk_new_open(NULL, NULL, options, flags, &local_err);
if (!blk) {
error_reportf_err(local_err, "Could not open '%s': ", optstr);
return NULL;
}
blk_set_enable_write_cache(blk, !writethrough);
if (img_open_password(blk, optstr, flags, quiet) < 0) {
blk_unref(blk);
return NULL;
}
return blk;
} | 1threat |
java, quartz and multiple tasks triggered at certain times saved in a database : <p>I'm building a system where users can set a future date(down to hours and minutes) in calendar. At that date a trigger is calling a certain task, unique for every user.</p>
<p>Every user can set a different date. The system will have 10k+ from the start and a user can create more than one trigger.</p>
<p>So assuming I have 10k users each user create on average 3 triggers => 30k triggers with 30k different dates.</p>
<p>All dates are saved in a database.</p>
<p>I'm new to quartz, can this be done in a more optimized way?</p>
<p>I was thinking about making a task run every minute that will get the tasks that will suppose to run in the next hour and remove them from database.</p>
<p>Do you have any better ideas? Did someone used quartz for a large number of triggers.</p>
| 0debug |
I need halp, It says some weird erroris there but i can't find it : function wpnChs(){
var p1 = prompt("Do you take a SWORD or a CLUB to battle?").toUpperCase();
var HP = 1;
var EHP = 1;
var dmg = Math.floor(Math.random()* 1);
var dmgT = Math.floor(Math.random()* 1);
var first = Math.floor(Math.random()* 1);
if(p1 === "SWORD"){
HP = 10;
EHP = 9;
dmg = Math.floor(Math.random()* 8);
dmgT = Math.floor(Math.random()* 6);
first = Math.floor(Math.random()* 3);
}else if(p1 === "CLUB"){
HP = 11;
EHP = 9;
dmg = Math.floor(Math.random()* 6);
dmgT = Math.floor(Math.random()* 5);
first = Math.floor(Math.random()* 3);
}else{
wpnChs();
}}
function dmgD1(){
EHP -= dmg;
}
function dmgD2(){
HP -= dmgT;
}
function fR(){
if(p1 === "SWORD"){
dmg = Math.floor(Math.random()* 8);
dmgT = Math.floor(Math.random()* 6);
first = Math.floor(Math.random()* 3);
}else{
dmg = Math.floor(Math.random()* 6);
dmgT = Math.floor(Math.random()* 5);
first = Math.floor(Math.random()* 3);
}}
var fight = function(){
if(first === 0 || 2){
dmgD1();
if(dmg === 0){
alert("You attacked, but the enemy dodged it!");
fR();
fight();
}else{
alert("You attacked and did " + dmg + " damage. The enemy now has " + EHP
+ " health");
if(EHP <= 0){
alert("You killed the enemy!")
}else{
fR();
fight();
}
}
}else{
dmgD2();
if(dmgT === 0){
alert("The enemy attacked, but you dodged it!");
fR();
fight();
}else{
alert("The enemy attacked and did " + dmgT + " damage. You now have "+ HP
+ " health.");
if(HP <= 0){
alert("You died!");
}else{
fR();
fight();
}
}
}
};
wpnChs();
fight(); | 0debug |
static inline int16_t mipsdsp_add_i16(int16_t a, int16_t b, CPUMIPSState *env)
{
int16_t tempI;
tempI = a + b;
if (MIPSDSP_OVERFLOW(a, b, tempI, 0x8000)) {
set_DSPControl_overflow_flag(1, 20, env);
}
return tempI;
}
| 1threat |
What is the real difference between ACTION_GET_CONTENT and ACTION_OPEN_DOCUMENT? : <p>I'm having a hard time understanding the difference between <code>ACTION_OPEN_DOCUMENT</code> and <code>ACTION_GET_CONTENT</code> intents <strong>when they are used to open an openable document</strong>. If I am supporting Andriod before KitKat, which does not support <code>ACTION_OPEN_DOCUMENT</code>, should I just settle with <code>ACTION_GET_CONTENT</code>?</p>
<p>The <a href="http://developer.android.com/guide/topics/providers/document-provider.html#client" rel="noreferrer">documentation</a> says this:</p>
<blockquote>
<p><a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_OPEN_DOCUMENT" rel="noreferrer"><code>ACTION_OPEN_DOCUMENT</code></a> is not intended to be a replacement for
<a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_GET_CONTENT" rel="noreferrer"><code>ACTION_GET_CONTENT</code></a>. The one you should use depends on the needs of
your app:</p>
<ul>
<li>Use <a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_GET_CONTENT" rel="noreferrer"><code>ACTION_GET_CONTENT</code></a> if you want your app to simply read/import
data. With this approach, the app imports a copy of the data, such as
an image file.</li>
<li>Use <a href="http://developer.android.com/reference/android/content/Intent.html#ACTION_OPEN_DOCUMENT" rel="noreferrer"><code>ACTION_OPEN_DOCUMENT</code></a> if you want your app to have
long term, persistent access to documents owned by a document
provider. An example would be a photo-editing app that lets users edit
images stored in a document provider.</li>
</ul>
</blockquote>
<p>Doesn't <code>ACTION_GET_CONTENT</code> also use document providers in KitKat? What would prevent me from having "long term, persistent access" and what exactly does that mean?</p>
<p>Basically, what is the difference between the following two snippets?</p>
<p><strong>ACTION_GET_CONTENT</strong></p>
<pre><code>Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("*/*");
</code></pre>
<p><strong>ACTION_OPEN_DOCUMENT</strong></p>
<pre><code>Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.setType("*/*");
</code></pre>
| 0debug |
Missing "key" prop for element. (ReactJS and TypeScript) : <p>I am using below code for reactJS and typescript. While executing the commands I get below error.</p>
<p>I also added the import statement
import 'bootstrap/dist/css/bootstrap.min.css';
in Index.tsx. </p>
<p>Is there a way to fix this issue?</p>
<pre><code>npm start
client/src/Results.tsx
(32,21): Missing "key" prop for element.
</code></pre>
<p>The file is as below "Results.tsx"</p>
<pre><code>import * as React from 'react';
class Results extends React.Component<{}, any> {
constructor(props: any) {
super(props);
this.state = {
topics: [],
isLoading: false
};
}
componentDidMount() {
this.setState({isLoading: true});
fetch('http://localhost:8080/topics')
.then(response => response.json())
.then(data => this.setState({topics: data, isLoading: false}));
}
render() {
const {topics, isLoading} = this.state;
if (isLoading) {
return <p>Loading...</p>;
}
return (
<div>
<h2>Results List</h2>
{topics.map((topic: any) =>
<div className="panel panel-default">
<div className="panel-heading" key={topic.id}>{topic.name}</div>
<div className="panel-body" key={topic.id}>{topic.description}</div>
</div>
)}
</div>
);
}
}
export default Results;
</code></pre>
| 0debug |
Is it possible to set up a VPN server on Debian 8 while keeping my web services (php/apache)? : <p>I would like to set up a VPN server, however it means ipv4 forwarding. Is it possible to set up a VPN without shutting down web services or should i use 2 separate servers ?</p>
<p>Thanks for reading ;)</p>
| 0debug |
sql query taking so much time, need optimization : SELECT LM.user_id,LM.users_lineup_id, min( LM.total_score ) AS total_score FROM vi_lineup_master LM JOIN vi_contest AS C ON C.contest_unique_id=LM.contest_unique_id join ( SELECT min( total_score ) as total_score FROM vi_lineup_master GROUP BY group_unique_id ) as preq ON LM.total_score = preq.total_score WHERE LM.contest_unique_id = 'iledhSBDO' AND C.league_contest_type=1 GROUP BY group_unique_id
Above query is to find the loser per group of game, query return accurate result but its not responding with large data.Needed optimization please share your solution. Thanks in advance.
| 0debug |
View POST request body in Application Insights : <p>Is it possible to view POST request body in Application Insights?</p>
<p>I can see request details, but not the payload being posted in application insights. Do I have to track this with some coding?</p>
<p>I am building a MVC core 1.1 Web Api. </p>
<p><a href="https://i.stack.imgur.com/M9fjF.png" rel="noreferrer"><img src="https://i.stack.imgur.com/M9fjF.png" alt="POST request"></a></p>
| 0debug |
C# Split String - Split String into Array : <p>I am trying to split a string that the user tiped in. For example:
He types in "Hello". So I want to split this up into an array: ["H","E","L",...]. So how do I use this .split() function? </p>
<p>And how do I save it into an Array?</p>
<p>Thank you guys.</p>
| 0debug |
Find a linear run-time strategy to place all records for females before any records for males? : <ol start="3">
<li>Some problems related to sorting can be solved in less than the Θ(n log n) lower bound of sorting. Consider the following scenario. A set of N records containing personnel records has a field indicating gender, male or female. Find a linear run-time strategy to place all records for females before any records for males. That is, females will be at the front of the list and males at the end. </li>
</ol>
| 0debug |
AngularJs dependency Injection difference : <p>Is the array necessary ? </p>
<pre><code> app.controller('myController', ['$scope', function($scope){
}])
</code></pre>
<p>Will this work like the code above? </p>
<pre><code> app.controller('myController', function($scope){
})
</code></pre>
| 0debug |
PHP Warning: mail(): Found numeric header : <p>I am using following script to send email through PHP. However, I am getting error <code>"PHP Warning: mail(): Found numeric header (4) in /home/....public_html/.../sendemail.php on line 16"</code> Any help please.</p>
<p><strong>PHP Script</strong></p>
<pre><code><?php
$name = @trim(stripslashes($_POST['name']));
$from = @trim(stripslashes($_POST['email']));
$subject = @trim(stripslashes($_POST['subject']));
$message = @trim(stripslashes($_POST['message']));
$to = 'xxxxx@xmail.com';
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=UTF-8";
$headers[] = "From: {$name} <{$from}>";
$headers[] = "Reply-To: <{$from}>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
mail($to, $subject, $message, $headers);
die;
</code></pre>
| 0debug |
How can I call a stored procedure from another stored procedure in oracle? : <p>can I call a stored procedure from another stored procedure in oracle?give me examples.</p>
| 0debug |
void ff_put_h264_qpel8_mc22_msa(uint8_t *dst, const uint8_t *src,
ptrdiff_t stride)
{
avc_luma_mid_8w_msa(src - (2 * stride) - 2, stride, dst, stride, 8);
}
| 1threat |
static void musicpal_init(ram_addr_t ram_size,
const char *boot_device,
const char *kernel_filename, const char *kernel_cmdline,
const char *initrd_filename, const char *cpu_model)
{
CPUState *env;
qemu_irq *cpu_pic;
qemu_irq pic[32];
DeviceState *dev;
DeviceState *i2c_dev;
DeviceState *lcd_dev;
DeviceState *key_dev;
#ifdef HAS_AUDIO
DeviceState *wm8750_dev;
SysBusDevice *s;
#endif
i2c_bus *i2c;
int i;
unsigned long flash_size;
DriveInfo *dinfo;
ram_addr_t sram_off;
if (!cpu_model) {
cpu_model = "arm926";
}
env = cpu_init(cpu_model);
if (!env) {
fprintf(stderr, "Unable to find CPU definition\n");
exit(1);
}
cpu_pic = arm_pic_init_cpu(env);
cpu_register_physical_memory(0, MP_RAM_DEFAULT_SIZE,
qemu_ram_alloc(MP_RAM_DEFAULT_SIZE));
sram_off = qemu_ram_alloc(MP_SRAM_SIZE);
cpu_register_physical_memory(MP_SRAM_BASE, MP_SRAM_SIZE, sram_off);
dev = sysbus_create_simple("mv88w8618_pic", MP_PIC_BASE,
cpu_pic[ARM_PIC_CPU_IRQ]);
for (i = 0; i < 32; i++) {
pic[i] = qdev_get_gpio_in(dev, i);
}
sysbus_create_varargs("mv88w8618_pit", MP_PIT_BASE, pic[MP_TIMER1_IRQ],
pic[MP_TIMER2_IRQ], pic[MP_TIMER3_IRQ],
pic[MP_TIMER4_IRQ], NULL);
if (serial_hds[0]) {
serial_mm_init(MP_UART1_BASE, 2, pic[MP_UART1_IRQ], 1825000,
serial_hds[0], 1);
}
if (serial_hds[1]) {
serial_mm_init(MP_UART2_BASE, 2, pic[MP_UART2_IRQ], 1825000,
serial_hds[1], 1);
}
dinfo = drive_get(IF_PFLASH, 0, 0);
if (dinfo) {
flash_size = bdrv_getlength(dinfo->bdrv);
if (flash_size != 8*1024*1024 && flash_size != 16*1024*1024 &&
flash_size != 32*1024*1024) {
fprintf(stderr, "Invalid flash image size\n");
exit(1);
}
pflash_cfi02_register(0-MP_FLASH_SIZE_MAX, qemu_ram_alloc(flash_size),
dinfo->bdrv, 0x10000,
(flash_size + 0xffff) >> 16,
MP_FLASH_SIZE_MAX / flash_size,
2, 0x00BF, 0x236D, 0x0000, 0x0000,
0x5555, 0x2AAA);
}
sysbus_create_simple("mv88w8618_flashcfg", MP_FLASHCFG_BASE, NULL);
qemu_check_nic_model(&nd_table[0], "mv88w8618");
dev = qdev_create(NULL, "mv88w8618_eth");
dev->nd = &nd_table[0];
qdev_init(dev);
sysbus_mmio_map(sysbus_from_qdev(dev), 0, MP_ETH_BASE);
sysbus_connect_irq(sysbus_from_qdev(dev), 0, pic[MP_ETH_IRQ]);
sysbus_create_simple("mv88w8618_wlan", MP_WLAN_BASE, NULL);
musicpal_misc_init();
dev = sysbus_create_simple("musicpal_gpio", MP_GPIO_BASE, pic[MP_GPIO_IRQ]);
i2c_dev = sysbus_create_simple("bitbang_i2c", 0, NULL);
i2c = (i2c_bus *)qdev_get_child_bus(i2c_dev, "i2c");
lcd_dev = sysbus_create_simple("musicpal_lcd", MP_LCD_BASE, NULL);
key_dev = sysbus_create_simple("musicpal_key", 0, NULL);
qdev_connect_gpio_out(i2c_dev, 0,
qdev_get_gpio_in(dev, MP_GPIO_I2C_DATA_BIT));
qdev_connect_gpio_out(dev, 3, qdev_get_gpio_in(i2c_dev, 0));
qdev_connect_gpio_out(dev, 4, qdev_get_gpio_in(i2c_dev, 1));
for (i = 0; i < 3; i++) {
qdev_connect_gpio_out(dev, i, qdev_get_gpio_in(lcd_dev, i));
}
for (i = 0; i < 4; i++) {
qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 8));
}
for (i = 4; i < 8; i++) {
qdev_connect_gpio_out(key_dev, i, qdev_get_gpio_in(dev, i + 15));
}
#ifdef HAS_AUDIO
wm8750_dev = i2c_create_slave(i2c, "wm8750", MP_WM_ADDR);
dev = qdev_create(NULL, "mv88w8618_audio");
s = sysbus_from_qdev(dev);
qdev_prop_set_ptr(dev, "wm8750", wm8750_dev);
qdev_init(dev);
sysbus_mmio_map(s, 0, MP_AUDIO_BASE);
sysbus_connect_irq(s, 0, pic[MP_AUDIO_IRQ]);
#endif
musicpal_binfo.ram_size = MP_RAM_DEFAULT_SIZE;
musicpal_binfo.kernel_filename = kernel_filename;
musicpal_binfo.kernel_cmdline = kernel_cmdline;
musicpal_binfo.initrd_filename = initrd_filename;
arm_load_kernel(env, &musicpal_binfo);
}
| 1threat |
static int pxa2xx_i2c_slave_init(I2CSlave *i2c)
{
return 0;
}
| 1threat |
angular2 pass ngModel to a child component : <p>I have ParentComponent and a ChildComponent, and I need to pass the ngModel in ParentComponent to ChildComponent.</p>
<pre><code>// the below is in ParentComponent template
<child-component [(ngModel)]="valueInParentComponent"></child-component>
</code></pre>
<p>how can I get the value of ngModel in ChildComponent and manipulate it?</p>
| 0debug |
Move item to a list without copying : <p>Given </p>
<pre><code>std::list<std::vector<float>> foo;
std::vector<float> bar;
</code></pre>
<p>How should I move <code>bar</code> to the end of <code>foo</code> without copying data? </p>
<p>Is this ok?</p>
<pre><code>foo.emplace_back(std::move(bar));
</code></pre>
| 0debug |
C2084 error when calling function in same file in a diffrent function : <p>So, I'm trying to make a combinatorics library in a .h file. I have a function that calculates the factorial of a number n, followed by a function (in the same file) that uses the factorial function to calculate the combination of n choose k for a given n and k. But when I try to compile the code it throws this error at me: C2048 function 'long factorial(int)' already has a body. (I'm using VS 2015)</p>
<p>Here's the code:</p>
<pre><code>long int factorial(int n) // factorial of n
{
int summation = n;
for (int i = 1; i < n; i++)
{
summation *= i;
}
return summation;
}
double combination(int n, int k) // n choose k
{
return (factorial(n) / (factorial(k) * factorial(n - k)));
}
double permutation(int n, int k) // n permutation k
{
if (k != n)
return (factorial(n) / factorial(n - k));
else
return factorial(n);
}
double repetitiveCombination(int n, int k) // repetitive combination of n choose k
{
return combination(n - 1 + k, k);
}
double orderEquals(int n, int p) // order n objects of wich p are equal
{
return (factorial(n) / factorial(p));
}
</code></pre>
| 0debug |
Replace NA with average of the case before and after the NA, unless row starts or ends with NA : <p>Say I have a data.frame:</p>
<pre><code>t<-c(1,1,2,4,NA,3)
u<-c(1,3,4,6,4,2)
v<-c(2,3,4,NA,3,2)
w<-c(2,3,4,5,2,3)
x<-c(2,3,4,5,6,NA)
df<-data.frame(t,u,v,w,x)
df
t u v w x
1 1 1 2 2 2
2 1 3 3 3 3
3 2 4 4 4 4
4 4 6 NA 5 5
5 NA 4 3 2 6
6 3 2 2 3 NA
</code></pre>
<p>I would like to change the NAs so that the NA becomes replaced by the average of the one value before the NA and the one value after the NA. However, if a row starts with an NA I would like it to be replaced by the value that follows it. When a row ends with NA, I would like it to be replaced by the value before the NA. Thus, I would like to get the following result:</p>
<pre><code> t u v w x
1 1 1 2 2 2
2 1 3 3 3 3
3 2 4 4 4 4
4 4 6 5.5 5 5 --> NA becomes average of 6 and 5
5 4 4 3 2 6 --> NA becomes value of next case
6 3 2 2 3 3 --> NA becomes value of previous case
</code></pre>
<p>I have thousands of rows, so any help is very much appreciated!</p>
| 0debug |
keyboard image coding android studio : my code is image of a keyboard coding when i did the touch on the caps, i had two letters one upper-case and one lower-case
public boolean onTouch(View v, final MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
final float x = event.getX();
final float y = event.getY();
if (imagepassword.getDrawable().getConstantState() == getResources().getDrawable( R.drawable.keyboardpfe2).getConstantState()) /*test on an image*/ {
if (x > 0 && x < 100 && y > 170 && y < 310) {
login.setText(login.getText() + "Q");
imagepassword.setImageResource(R.drawable.keyboardpfe);}
if (imagepassword.getDrawable().getConstantState() == getResources().getDrawable( R.drawable.keyboardpfe).getConstantState()) {
if (x > 0 && x < 100 && y > 170 && y < 310) {
login.setText(login.getText() + "q");}}
| 0debug |
static uint64_t malta_fpga_read(void *opaque, target_phys_addr_t addr,
unsigned size)
{
MaltaFPGAState *s = opaque;
uint32_t val = 0;
uint32_t saddr;
saddr = (addr & 0xfffff);
switch (saddr) {
case 0x00200:
val = 0x00000000;
break;
case 0x00208:
#ifdef TARGET_WORDS_BIGENDIAN
val = 0x00000012;
#else
val = 0x00000010;
#endif
break;
case 0x00210:
val = 0x00;
break;
case 0x00408:
val = s->leds;
break;
case 0x00508:
val = s->brk;
break;
case 0x00a00:
val = s->gpout;
break;
case 0x00a08:
if (s->i2csel)
val = s->i2cout;
else
val = 0x00;
break;
case 0x00b00:
val = ((s->i2cin & ~1) | eeprom24c0x_read());
break;
case 0x00b08:
val = s->i2coe;
break;
case 0x00b10:
val = s->i2cout;
break;
case 0x00b18:
val = s->i2csel;
break;
default:
#if 0
printf ("malta_fpga_read: Bad register offset 0x" TARGET_FMT_lx "\n",
addr);
#endif
break;
}
return val;
}
| 1threat |
How do I compile grails project using grails command line? I want to compile it to get .war file so I can deploy it on server : How do I compile my grails project? I want to get a .war file so I can deploy it.
First I installed Jdk then I installed grails and I have properly set environment variables for both and checked it.Now I want to compile this grails project using grails command line.how can I do it?
Thanks in advance | 0debug |
How can I find the greatest common divisor of two numbers using a for loop? : <p>I'm a beginner in java and I can't figure out how to find the GCD. I also need to use a for loop and the variables, int one and int two, as the numbers. I'm really lost, any help will be appreciated. This is the method format that I was given.</p>
<pre><code>public long getGCD( )
{
long gcd=0;
return 1;
}
</code></pre>
| 0debug |
if_output(struct socket *so, struct mbuf *ifm)
{
struct mbuf *ifq;
int on_fastq = 1;
DEBUG_CALL("if_output");
DEBUG_ARG("so = %lx", (long)so);
DEBUG_ARG("ifm = %lx", (long)ifm);
if (ifm->m_flags & M_USEDLIST) {
remque(ifm);
ifm->m_flags &= ~M_USEDLIST;
}
for (ifq = if_batchq.ifq_prev; ifq != &if_batchq; ifq = ifq->ifq_prev) {
if (so == ifq->ifq_so) {
ifm->ifq_so = so;
ifs_insque(ifm, ifq->ifs_prev);
goto diddit;
}
}
if (so && (so->so_iptos & IPTOS_LOWDELAY)) {
ifq = if_fastq.ifq_prev;
on_fastq = 1;
if (ifq->ifq_so == so) {
ifm->ifq_so = so;
ifs_insque(ifm, ifq->ifs_prev);
goto diddit;
}
} else
ifq = if_batchq.ifq_prev;
ifm->ifq_so = so;
ifs_init(ifm);
insque(ifm, ifq);
diddit:
++if_queued;
if (so) {
so->so_queued++;
so->so_nqueued++;
if (on_fastq && ((so->so_nqueued >= 6) &&
(so->so_nqueued - so->so_queued) >= 3)) {
remque(ifm->ifs_next);
insque(ifm->ifs_next, &if_batchq);
}
}
#ifndef FULL_BOLT
if (link_up) {
if_start();
}
#endif
}
| 1threat |
Haskell extracting from tuples within a list : <p>I'm a beginner, any help will be appreciated. My goal is to be able to extract the ratings from any given <strong>Film</strong> as a <strong>Float</strong> so I can then manipulate the data properly, for instance give the "average rating" for a film.</p>
<pre><code>type Title = String
type Director = String
type Year = Int
type Mark = Int
type Rating = (String, Float)
-- Define Film type here
type Film = (Title, Director, Year, [Rating])
</code></pre>
<p>A typical <strong>Film</strong> looks like </p>
<pre><code>("True Lies", "James Cameron", 1994, [("Dave",3), ("Kevin",10), ("Jo",0)])
</code></pre>
<p>I have tried </p>
<pre><code>extractRating :: Film -> [(String, Float)]
extractRating (_, _, _, rating) = rating
</code></pre>
<p>Then calling the function like this</p>
<pre><code>putStrLn (extractRating "True Lies")
</code></pre>
<p>If it helps you help me here this the error dump</p>
<pre><code>haskell.hs:82:21:
Couldn't match type ‘(String, Float)’ with ‘Char’
Expected type: String
Actual type: [(String, Float)]
In the first argument of ‘putStrLn’, namely
‘(extractRating "True Lies")’
In a stmt of a 'do' block: putStrLn (extractRating "True Lies")
haskell.hs:82:35:
Couldn't match type ‘[Char]’
with ‘(Title, Director, Year, [Rating])’
Expected type: Film
Actual type: [Char]
In the first argument of ‘extractRating’, namely ‘"True Lies"’
In the first argument of ‘putStrLn’, namely
‘(extractRating "True Lies")’
In a stmt of a 'do' block: putStrLn (extractRating "True Lies")
</code></pre>
| 0debug |
static void ff_h264_idct_add16intra_mmx(uint8_t *dst, const int *block_offset, DCTELEM *block, int stride, const uint8_t nnzc[6*8]){
int i;
for(i=0; i<16; i++){
if(nnzc[ scan8[i] ] || block[i*16])
ff_h264_idct_add_mmx(dst + block_offset[i], block + i*16, stride);
}
}
| 1threat |
How can I talk only to one ECU in a two ECU Car with ELM237 and OBDII : <p>I am sending following ELM237 commands to a Porsche Cayenne.
There are two ECU on the Bus 7E9 and 7E8. I would like to address only one at a time. I thought I can do that by using atsh7E8 to
talk only to one but then the answers contain only the string 'NODATA'.
I guess I miss something here to filter one ECU at a time. Does somebody have an idea?</p>
<pre><code>Request/Response
[atd, OK],
[atl0, atl0OK],
[ate0, ate0OK],
[ath1, OK],
[atsp0, OK],
[ats0, OK],
[atat1, OK],
[ate0, OK],
[0100, 7E9064100981880017E8064100BFBEA893],
[0120, 7E8064120A007B1197E906412000000001],
[0140, 7E8064140FED085007E9064140E0800000],
[atdp, AUTO,ISO15765-4(CAN11/500)],
[0900, 7E9064900144000007E806490055400000],
[0902, 7E810144902015750317E821414332413231477E8224C413839303838],
[010C, 7E904410C09607E804410C095C],
[010D, 7E903410D007E803410D00]
</code></pre>
| 0debug |
assertNull J Unit, fails with null pointer (JAVA) : For my project one of the returns has to be null. When testing using assertNull(Null Object here) it fails with a null pointer exception.
Can someone please tell my why?? I thought assertNull is suppose to test for null.
Heres part of my code.
public static UVI calculateUVI(double[] radiation)
{
double calculation = 0.0;
double[] copyRad = new double[radiation.length];
for (int i = 0; i < radiation.length; i++)
{
copyRad[i] = radiation[i];
if (radiation[i] > RADIATION_MAXIMUM)
copyRad[i] = RADIATION_MAXIMUM;
if (radiation[i] < RADIATION_MINIMUM)
copyRad[i] = 0.0;
calculation += (copyRad[i] * MD_WEIGHTS[i]);
}
if (radiation.length != MD_WEIGHTS.length || radiation == null)
{
UVI nulled = null;
return nulled;
}
calculation /= B;
UVI result = new UVI(calculation, true);
return result;
}
My test case is:
double[] test1 = {4., 26., 30., 17., 2.};
double[] test2 = {0., 0., 0., 0., 0.};
double[] test3 = {4., 26., 30., 100., 2.};
double[] test4 = {4., 26., 30., 200., 2.};
double[] test5 = {3.4, 0., 17., 17., 2.};
double[] test6 = {3.4, -10., 17., 17., 2.};
double[] test7 = {1.0};
double[] test8 = {};
double[] test9 = null;
UVI testOne = UVICalculator.calculateUVI(test1);
UVI testTwo = UVICalculator.calculateUVI(test2);
UVI testThree = UVICalculator.calculateUVI(test3);
UVI testFour = UVICalculator.calculateUVI(test4);
UVI testFive = UVICalculator.calculateUVI(test5);
UVI testSix = UVICalculator.calculateUVI(test6);
UVI testSeven = UVICalculator.calculateUVI(test7);
UVI testEight = UVICalculator.calculateUVI(test8);
UVI testNine= UVICalculator.calculateUVI(test9);
assertTrue(8.8956 == testOne.getValue());
assertTrue(0 == testTwo.getValue());
assertTrue(8.9952 == testThree.getValue());
assertTrue(8.9952 == testFour.getValue());
assertTrue(4.027200000000001 == testFive.getValue());
assertTrue(4.027200000000001 == testSix.getValue());
assertNull(testSeven);
assertNull(testEight);
assertNull(testNine);
| 0debug |
My maximum and minimum marks show 0. Please help me to solve this problem using function but not max() and min().Thank you : mark = 0
a = 0
student = 0
a = int(input("Enter Marks :"))
def maxx():
maxx = 0
for i in range(1,a):
if a> maxx :
maxx = a
return maxx
def minn():
minn = 0
for i in range(1,a):
if a< minn :
minn = a
return minn
while (a>=0):
mark = mark + a
student = student +1
a = int(input("Enter Marks :"))
print("Exit")
print("Total students :",student)
print ("The total marks is:",mark)
average = mark/student
print ("The average marks is:",average)
print("The max marks is :",maxx())
print("The min marks is :",minn())
| 0debug |
static void qio_channel_websock_handshake_send_res_ok(QIOChannelWebsock *ioc,
const char *key,
Error **errp)
{
char combined_key[QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +
QIO_CHANNEL_WEBSOCK_GUID_LEN + 1];
char *accept = NULL;
char *date = qio_channel_websock_date_str();
g_strlcpy(combined_key, key, QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN + 1);
g_strlcat(combined_key, QIO_CHANNEL_WEBSOCK_GUID,
QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +
QIO_CHANNEL_WEBSOCK_GUID_LEN + 1);
if (qcrypto_hash_base64(QCRYPTO_HASH_ALG_SHA1,
combined_key,
QIO_CHANNEL_WEBSOCK_CLIENT_KEY_LEN +
QIO_CHANNEL_WEBSOCK_GUID_LEN,
&accept,
errp) < 0) {
qio_channel_websock_handshake_send_res_err(
ioc, QIO_CHANNEL_WEBSOCK_HANDSHAKE_RES_SERVER_ERR);
return;
}
qio_channel_websock_handshake_send_res(
ioc, QIO_CHANNEL_WEBSOCK_HANDSHAKE_RES_OK, date, accept);
g_free(date);
g_free(accept);
}
| 1threat |
SQL injection will occur only when there is a form to submit? : <p>I am confused about sql injection how about the $_GET or other instance that it can happen like the things I don't know?..</p>
| 0debug |
static void fft(AC3MDCTContext *mdct, IComplex *z, int ln)
{
int j, l, np, np2;
int nblocks, nloops;
register IComplex *p,*q;
int tmp_re, tmp_im;
np = 1 << ln;
for (j = 0; j < np; j++) {
int k = av_reverse[j] >> (8 - ln);
if (k < j)
FFSWAP(IComplex, z[k], z[j]);
}
p = &z[0];
j = np >> 1;
do {
BF(p[0].re, p[0].im, p[1].re, p[1].im,
p[0].re, p[0].im, p[1].re, p[1].im);
p += 2;
} while (--j);
p = &z[0];
j = np >> 2;
do {
BF(p[0].re, p[0].im, p[2].re, p[2].im,
p[0].re, p[0].im, p[2].re, p[2].im);
BF(p[1].re, p[1].im, p[3].re, p[3].im,
p[1].re, p[1].im, p[3].im, -p[3].re);
p+=4;
} while (--j);
nblocks = np >> 3;
nloops = 1 << 2;
np2 = np >> 1;
do {
p = z;
q = z + nloops;
for (j = 0; j < nblocks; j++) {
BF(p->re, p->im, q->re, q->im,
p->re, p->im, q->re, q->im);
p++;
q++;
for(l = nblocks; l < np2; l += nblocks) {
CMUL(tmp_re, tmp_im, mdct->costab[l], -mdct->sintab[l], q->re, q->im, 15);
BF(p->re, p->im, q->re, q->im,
p->re, p->im, tmp_re, tmp_im);
p++;
q++;
}
p += nloops;
q += nloops;
}
nblocks = nblocks >> 1;
nloops = nloops << 1;
} while (nblocks);
}
| 1threat |
How to make circular button in android : <p>I have an app in which i have to make circular button which i successfully made but what i want when i click button then change background drawable but when i do that circular button gets invisible. How do i do that</p>
<p>code:-</p>
<pre><code><selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<stroke android:color="@color/colorPrimary" android:width="5dp" />
<solid android:color="@color/colorPrimaryDark"/>
<size android:width="150dp" android:height="150dp"/>
</shape>
</item>
</code></pre>
<p></p>
| 0debug |
static mode_t v9mode_to_mode(uint32_t mode, V9fsString *extension)
{
mode_t ret;
ret = mode & 0777;
if (mode & P9_STAT_MODE_DIR) {
ret |= S_IFDIR;
}
if (mode & P9_STAT_MODE_SYMLINK) {
ret |= S_IFLNK;
}
if (mode & P9_STAT_MODE_SOCKET) {
ret |= S_IFSOCK;
}
if (mode & P9_STAT_MODE_NAMED_PIPE) {
ret |= S_IFIFO;
}
if (mode & P9_STAT_MODE_DEVICE) {
if (extension && extension->data[0] == 'c') {
ret |= S_IFCHR;
} else {
ret |= S_IFBLK;
}
}
if (!(ret&~0777)) {
ret |= S_IFREG;
}
if (mode & P9_STAT_MODE_SETUID) {
ret |= S_ISUID;
}
if (mode & P9_STAT_MODE_SETGID) {
ret |= S_ISGID;
}
if (mode & P9_STAT_MODE_SETVTX) {
ret |= S_ISVTX;
}
return ret;
}
| 1threat |
Open a website URL and login to the that website using username and password in C# : <p>I have a wpf window and there is a textbox and a button in it. I manually enter a website url into that textbox (ex. www.abc.com/index.html). </p>
<p>This website page contains a login panel (in normal case, user has to enter the username and password to login). </p>
<p>I am looking for a way to read that URL and send the login credentials through c# code to login into that site and read the content of that particular html page (the page after the logged in).</p>
<p>Please help since i am new to this.</p>
| 0debug |
android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.facebook.flatbuffers.helpers.FlatBufferModelHelper$LazyHolder : <p>I'm seeing this crash in Crashlytics for an app that's currently in production:</p>
<pre><code>Caused by android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.facebook.flatbuffers.helpers.FlatBufferModelHelper$LazyHolder
at android.os.Parcel.readParcelableCreator(Parcel.java:2295)
at android.os.Parcel.readParcelable(Parcel.java:2245)
at android.os.Parcel.readValue(Parcel.java:2152)
at android.os.Parcel.readArrayMapInternal(Parcel.java:2485)
at android.os.BaseBundle.unparcel(BaseBundle.java:221)
at android.os.BaseBundle.containsKey(BaseBundle.java:269)
at android.content.Intent.hasExtra(Intent.java:5632)
...
</code></pre>
<p>I'm really unsure of what could be causing this issue. I can't even find a <code>FlatBufferModelHelper</code> class in the <a href="https://github.com/facebook/facebook-android-sdk" rel="noreferrer">facebook-android-sdk</a>.</p>
<p>Unfortunately, I don't really have any more information than this. This crash does seem to affect all devices of all API levels.</p>
<p>Thanks for any info!</p>
| 0debug |
static void qobject_input_type_int64(Visitor *v, const char *name, int64_t *obj,
Error **errp)
{
QObjectInputVisitor *qiv = to_qiv(v);
QObject *qobj = qobject_input_get_object(qiv, name, true, errp);
QInt *qint;
if (!qobj) {
return;
}
qint = qobject_to_qint(qobj);
if (!qint) {
error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name ? name : "null",
"integer");
return;
}
*obj = qint_get_int(qint);
}
| 1threat |
void ff_h264_filter_mb(H264Context *h, H264SliceContext *sl,
int mb_x, int mb_y,
uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr,
unsigned int linesize, unsigned int uvlinesize)
{
const int mb_xy= mb_x + mb_y*h->mb_stride;
const int mb_type = h->cur_pic.mb_type[mb_xy];
const int mvy_limit = IS_INTERLACED(mb_type) ? 2 : 4;
int first_vertical_edge_done = 0;
int chroma = !(CONFIG_GRAY && (h->flags&CODEC_FLAG_GRAY));
int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset;
int b = 52 + h->slice_beta_offset - qp_bd_offset;
if (FRAME_MBAFF(h)
&& IS_INTERLACED(mb_type ^ sl->left_type[LTOP])
&& sl->left_type[LTOP]) {
DECLARE_ALIGNED(8, int16_t, bS)[8];
int qp[2];
int bqp[2];
int rqp[2];
int mb_qp, mbn0_qp, mbn1_qp;
int i;
first_vertical_edge_done = 1;
if( IS_INTRA(mb_type) ) {
AV_WN64A(&bS[0], 0x0004000400040004ULL);
AV_WN64A(&bS[4], 0x0004000400040004ULL);
} else {
static const uint8_t offset[2][2][8]={
{
{3+4*0, 3+4*0, 3+4*0, 3+4*0, 3+4*1, 3+4*1, 3+4*1, 3+4*1},
{3+4*2, 3+4*2, 3+4*2, 3+4*2, 3+4*3, 3+4*3, 3+4*3, 3+4*3},
},{
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
{3+4*0, 3+4*1, 3+4*2, 3+4*3, 3+4*0, 3+4*1, 3+4*2, 3+4*3},
}
};
const uint8_t *off= offset[MB_FIELD(h)][mb_y&1];
for( i = 0; i < 8; i++ ) {
int j= MB_FIELD(h) ? i>>2 : i&1;
int mbn_xy = sl->left_mb_xy[LEFT(j)];
int mbn_type = sl->left_type[LEFT(j)];
if( IS_INTRA( mbn_type ) )
bS[i] = 4;
else{
bS[i] = 1 + !!(sl->non_zero_count_cache[12+8*(i>>1)] |
((!h->pps.cabac && IS_8x8DCT(mbn_type)) ?
(h->cbp_table[mbn_xy] & (((MB_FIELD(h) ? (i&2) : (mb_y&1)) ? 8 : 2) << 12))
:
h->non_zero_count[mbn_xy][ off[i] ]));
}
}
}
mb_qp = h->cur_pic.qscale_table[mb_xy];
mbn0_qp = h->cur_pic.qscale_table[sl->left_mb_xy[0]];
mbn1_qp = h->cur_pic.qscale_table[sl->left_mb_xy[1]];
qp[0] = ( mb_qp + mbn0_qp + 1 ) >> 1;
bqp[0] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn0_qp ) + 1 ) >> 1;
rqp[0] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn0_qp ) + 1 ) >> 1;
qp[1] = ( mb_qp + mbn1_qp + 1 ) >> 1;
bqp[1] = ( get_chroma_qp( h, 0, mb_qp ) +
get_chroma_qp( h, 0, mbn1_qp ) + 1 ) >> 1;
rqp[1] = ( get_chroma_qp( h, 1, mb_qp ) +
get_chroma_qp( h, 1, mbn1_qp ) + 1 ) >> 1;
tprintf(h->avctx, "filter mb:%d/%d MBAFF, QPy:%d/%d, QPb:%d/%d QPr:%d/%d ls:%d uvls:%d", mb_x, mb_y, qp[0], qp[1], bqp[0], bqp[1], rqp[0], rqp[1], linesize, uvlinesize);
{ int i; for (i = 0; i < 8; i++) tprintf(h->avctx, " bS[%d]:%d", i, bS[i]); tprintf(h->avctx, "\n"); }
if (MB_FIELD(h)) {
filter_mb_mbaff_edgev ( h, img_y , linesize, bS , 1, qp [0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_y + 8* linesize, linesize, bS+4, 1, qp [1], a, b, 1 );
if (chroma){
if (CHROMA444(h)) {
filter_mb_mbaff_edgev ( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
} else if (CHROMA422(h)) {
filter_mb_mbaff_edgecv(h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cb + 8*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1);
filter_mb_mbaff_edgecv(h, img_cr + 8*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1);
}else{
filter_mb_mbaff_edgecv( h, img_cb, uvlinesize, bS , 1, bqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cb + 4*uvlinesize, uvlinesize, bS+4, 1, bqp[1], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr, uvlinesize, bS , 1, rqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr + 4*uvlinesize, uvlinesize, bS+4, 1, rqp[1], a, b, 1 );
}
}
}else{
filter_mb_mbaff_edgev ( h, img_y , 2* linesize, bS , 2, qp [0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_y + linesize, 2* linesize, bS+1, 2, qp [1], a, b, 1 );
if (chroma){
if (CHROMA444(h)) {
filter_mb_mbaff_edgev ( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
filter_mb_mbaff_edgev ( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
}else{
filter_mb_mbaff_edgecv( h, img_cb, 2*uvlinesize, bS , 2, bqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cb + uvlinesize, 2*uvlinesize, bS+1, 2, bqp[1], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr, 2*uvlinesize, bS , 2, rqp[0], a, b, 1 );
filter_mb_mbaff_edgecv( h, img_cr + uvlinesize, 2*uvlinesize, bS+1, 2, rqp[1], a, b, 1 );
}
}
}
}
#if CONFIG_SMALL
{
int dir;
for (dir = 0; dir < 2; dir++)
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize,
uvlinesize, mb_xy, mb_type, mvy_limit,
dir ? 0 : first_vertical_edge_done, a, b,
chroma, dir);
}
#else
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, first_vertical_edge_done, a, b, chroma, 0);
filter_mb_dir(h, sl, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize, mb_xy, mb_type, mvy_limit, 0, a, b, chroma, 1);
#endif
}
| 1threat |
Select id and name of users having their birthday this week from database with mysql and php : <p>I have a script that stores user information in a database table. I want to output all users celeberating their birthday in each week of the year (monday - sunday), and I have this already.</p>
<pre><code><table>
<tr>
<th>Id</th>
<th>Surname</th>
<th>Firstname</th>
</tr>
<?php
$req = mysql_query( "SELECT * FROM elementary WHERE birthday BETWEEN CURDATE() - INTERVAL 1 WEEK AND CURDATE() + INTERVAL 1 WEEK" );
while($dnn = mysql_fetch_array($req)){
?>
<tr>
<td><?php echo $dnn["id"] ?></td>
<td><?php echo $dnn["surname"] ?></td>
<td><?php echo $dnn["firstname"] ?></td>
</tr>
<?php
}
?>
</code></pre>
<p>Thanks in advance.
</p>
| 0debug |
c++ print number in some digits : I want to print number according to input N.
As the range of N increases, I'll be so fucked up.
Is there another solution easier than this?
If someone helps me, i'll really appreciate it. Thanks!
if (N == 3) {
for (int a = 0; a < N; a++) {
for (int b = 0; b < 3; b++) {
printf("%03d ",y[a][b]);
}
cout << endl;
}
}
else if (N == 4) {
for (int a = 0; a < N; a++) {
for (int b = 0; b < 3; b++) {
printf("%04d ", y[a][b]);
}
cout << endl;
}
}
else if (N == 5) {
for (int a = 0; a < N; a++) {
for (int b = 0; b < 3; b++) {
printf("%05d ", y[a][b]);
}
cout << endl;
}
}
else if (N == 6) {
for (int a = 0; a < N; a++) {
for (int b = 0; b < 3; b++) {
printf("%06d ", y[a][b]);
}
cout << endl;
}
}
else {
for (int a = 0; a < N; a++) {
for (int b = 0; b < 3; b++) {
printf("%07d ", y[a][b]);
}
cout << endl;
}
} | 0debug |
Can someone explain why the program shows me 6 and 4? : <p>In this problem,which is an easy and a simple one, i do the sum and the product. I wanted to do with a "for" instruction to understand how this thing is working.</p>
<pre><code>#include < iostream >
using namespace std;
int main()
{
int n,i,s=0,p=1;
cin>>n;
for (i=1;i<=n;i++)
s=s+i;
p=p*i;
cout<<s<<" "<<p;
}
</code></pre>
<p>I can't explain why the result is "6" for sum and "4" for product...</p>
<p>Can someone explain me why the code is showing this?
If i put the instructions from the "for" structure between of braces,it is showing "6" for sum and "6" for product.</p>
| 0debug |
static QIOChannelSocket *nbd_establish_connection(SocketAddress *saddr_flat,
Error **errp)
{
SocketAddressLegacy *saddr = socket_address_crumple(saddr_flat);
QIOChannelSocket *sioc;
Error *local_err = NULL;
sioc = qio_channel_socket_new();
qio_channel_set_name(QIO_CHANNEL(sioc), "nbd-client");
qio_channel_socket_connect_sync(sioc,
saddr,
&local_err);
qapi_free_SocketAddressLegacy(saddr);
if (local_err) {
object_unref(OBJECT(sioc));
error_propagate(errp, local_err);
return NULL;
}
qio_channel_set_delay(QIO_CHANNEL(sioc), false);
return sioc;
}
| 1threat |
static void fft_ref_init(int nbits, int inverse)
{
int i, n = 1 << nbits;
exptab = av_malloc((n / 2) * sizeof(*exptab));
for (i = 0; i < (n/2); i++) {
double alpha = 2 * M_PI * (float)i / (float)n;
double c1 = cos(alpha), s1 = sin(alpha);
if (!inverse)
s1 = -s1;
exptab[i].re = c1;
exptab[i].im = s1;
}
}
| 1threat |
How do I turn a string into a maths equation? : <p>A user will give me a string as their input, which will be a maths equation. E.g. <em>(21 + 3) / 4.</em> </p>
<p>I want to turn that string into a double that is equal to the answer (6.0) Is there any way to do this in swift 3, XCode 8?</p>
| 0debug |
Difference between execution policies and when to use them : <p>I noticed that a majority (if not all) functions in <code><algorithm></code> are getting one or more extra overloads. All of these extra overloads add a specific new parameter, for example, <code>std::for_each</code> goes from:</p>
<pre><code>template< class InputIt, class UnaryFunction >
UnaryFunction for_each( InputIt first, InputIt last, UnaryFunction f );
</code></pre>
<p>to:</p>
<pre><code>template< class ExecutionPolicy, class InputIt, class UnaryFunction2 >
void for_each( ExecutionPolicy&& policy, InputIt first, InputIt last, UnaryFunction2 f );
</code></pre>
<p>What effect does this extra <code>ExecutionPolicy</code> have on these functions?</p>
<p>What are the differences between:</p>
<ul>
<li><code>std::execution::seq</code></li>
<li><code>std::execution::par</code></li>
<li><code>std::execution::par_unseq</code></li>
</ul>
<p>And when to use one or the other?</p>
| 0debug |
void HELPER(set_cp_reg)(CPUARMState *env, void *rip, uint32_t value)
{
const ARMCPRegInfo *ri = rip;
ri->writefn(env, ri, value);
}
| 1threat |
Android: GridLayout spacing between items : <p>I have a grid layout which is filled with buttons, now i want the buttons to be more distant from each other, what code should i write? i tried to search it but only found a solution for GridView, not GridLayout.</p>
| 0debug |
aiohttp: rate limiting parallel requests : <p>APIs often have rate limits that users have to follow. As an example let's take 50 requests/second. Sequential requests take 0.5-1 second and thus are too slow to come close to that limit. Parallel requests with aiohttp, however, exceed the rate limit.</p>
<p>To poll the API as fast as allowed, one needs to rate limit parallel calls.</p>
<p>Examples that I found so far decorate <code>session.get</code>, approximately like so:</p>
<pre><code>session.get = rate_limited(max_calls_per_second)(session.get)
</code></pre>
<p>This works well for sequential calls. Trying to implement this in parallel calls does not work as intended.</p>
<p>Here's some code as example:</p>
<pre><code>async with aiohttp.ClientSession() as session:
session.get = rate_limited(max_calls_per_second)(session.get)
tasks = (asyncio.ensure_future(download_coroutine(
timeout, session, url)) for url in urls)
process_responses_function(await asyncio.gather(*tasks))
</code></pre>
<p>The problem with this is that it will rate-limit the <strong>queueing</strong> of the tasks. The execution with <code>gather</code> will still happen more or less at the same time. Worst of both worlds ;-).</p>
<p>Yes, I found a similar question right here <a href="https://stackoverflow.com/questions/35196974/aiohttp-set-maximum-number-of-requests-per-second">aiohttp: set maximum number of requests per second</a>, but neither replies answer the actual question of limiting the rate of requests. Also <a href="https://quentin.pradet.me/blog/how-do-you-rate-limit-calls-with-aiohttp.html" rel="noreferrer">the blog post from Quentin Pradet</a> works only on rate-limiting the queueing.</p>
<p>To wrap it up: How can one limit the <em>number of requests per second</em> for parallel <code>aiohttp</code> requests?</p>
| 0debug |
static uint32_t sd_wpbits(SDState *sd, uint64_t addr)
{
uint32_t i, wpnum;
uint32_t ret = 0;
wpnum = addr >> (HWBLOCK_SHIFT + SECTOR_SHIFT + WPGROUP_SHIFT);
for (i = 0; i < 32; i ++, wpnum ++, addr += WPGROUP_SIZE)
if (addr < sd->size && sd->wp_groups[wpnum])
ret |= (1 << i);
return ret;
}
| 1threat |
static int qcow2_create2(const char *filename, int64_t total_size,
const char *backing_file, const char *backing_format,
int flags, size_t cluster_size, int prealloc,
QEMUOptionParameter *options, int version,
Error **errp)
{
int cluster_bits;
cluster_bits = ffs(cluster_size) - 1;
if (cluster_bits < MIN_CLUSTER_BITS || cluster_bits > MAX_CLUSTER_BITS ||
(1 << cluster_bits) != cluster_size)
{
error_setg(errp, "Cluster size must be a power of two between %d and "
"%dk", 1 << MIN_CLUSTER_BITS, 1 << (MAX_CLUSTER_BITS - 10));
return -EINVAL;
}
BlockDriverState* bs;
QCowHeader header;
uint8_t* refcount_table;
Error *local_err = NULL;
int ret;
ret = bdrv_create_file(filename, options, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return ret;
}
ret = bdrv_file_open(&bs, filename, NULL, BDRV_O_RDWR, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
return ret;
}
memset(&header, 0, sizeof(header));
header.magic = cpu_to_be32(QCOW_MAGIC);
header.version = cpu_to_be32(version);
header.cluster_bits = cpu_to_be32(cluster_bits);
header.size = cpu_to_be64(0);
header.l1_table_offset = cpu_to_be64(0);
header.l1_size = cpu_to_be32(0);
header.refcount_table_offset = cpu_to_be64(cluster_size);
header.refcount_table_clusters = cpu_to_be32(1);
header.refcount_order = cpu_to_be32(3 + REFCOUNT_SHIFT);
header.header_length = cpu_to_be32(sizeof(header));
if (flags & BLOCK_FLAG_ENCRYPT) {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
} else {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
}
if (flags & BLOCK_FLAG_LAZY_REFCOUNTS) {
header.compatible_features |=
cpu_to_be64(QCOW2_COMPAT_LAZY_REFCOUNTS);
}
ret = bdrv_pwrite(bs, 0, &header, sizeof(header));
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not write qcow2 header");
goto out;
}
refcount_table = g_malloc0(cluster_size);
ret = bdrv_pwrite(bs, cluster_size, refcount_table, cluster_size);
g_free(refcount_table);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not write refcount table");
goto out;
}
bdrv_close(bs);
BlockDriver* drv = bdrv_find_format("qcow2");
assert(drv != NULL);
ret = bdrv_open(bs, filename, NULL,
BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH, drv, &local_err);
if (ret < 0) {
error_propagate(errp, local_err);
goto out;
}
ret = qcow2_alloc_clusters(bs, 2 * cluster_size);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not allocate clusters for qcow2 "
"header and refcount table");
goto out;
} else if (ret != 0) {
error_report("Huh, first cluster in empty image is already in use?");
abort();
}
ret = bdrv_truncate(bs, total_size * BDRV_SECTOR_SIZE);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not resize image");
goto out;
}
if (backing_file) {
ret = bdrv_change_backing_file(bs, backing_file, backing_format);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not assign backing file '%s' "
"with format '%s'", backing_file, backing_format);
goto out;
}
}
if (prealloc) {
BDRVQcowState *s = bs->opaque;
qemu_co_mutex_lock(&s->lock);
ret = preallocate(bs);
qemu_co_mutex_unlock(&s->lock);
if (ret < 0) {
error_setg_errno(errp, -ret, "Could not preallocate metadata");
goto out;
}
}
bdrv_close(bs);
ret = bdrv_open(bs, filename, NULL,
BDRV_O_RDWR | BDRV_O_CACHE_WB, drv, &local_err);
if (error_is_set(&local_err)) {
error_propagate(errp, local_err);
goto out;
}
ret = 0;
out:
bdrv_unref(bs);
return ret;
}
| 1threat |
There is no viewcontroller.swift file when I start the project : <p>I tried to start the project and play around with viewcontroller but I do not see it.
Only appdelegate and scenedelegeate and contentview.
The code below was supposed to be added to viewcontroller but I do not know where to add.
It keeps giving me a error message saying unresolved identifier present and action.
please help.</p>
<pre><code> @IBAction func hello() {
// add alert
let alert = UIAlertController(title: "hello", message: "daaaammmmmn", preferredStyle: .alert)
let okAction = UIAlertAction(title: "ok", style: .default, handler: nil)
alert.addAction(action)
present(alert, animated: true, completion: nil)
}
</code></pre>
<p><a href="https://i.stack.imgur.com/CxDJH.jpg" rel="nofollow noreferrer"> </a></p>
| 0debug |
Why are my API Calls failing - Swift 3 : So I have the following code,
func convert(currencyToConvert:String,amount:Double,currencyToConvertTo:String,date:String)->Double{
makeConnection(date: date)
usleep(80000)
if let x = currencyRates[currencyToConvert]{
var a = 0.00
if currencyToConvert == "USD"{
a = amount*currencyRates["SGD"]!
}
else {
a = (amount*currencyRates[currencyToConvertTo]!)/x
}
return a
}
else {
print("currency not available")
return 0.00
}
}
func makeConnection(date:String){
currencyRates.removeAll()
let url = URL(string: "https://openexchangerates.org/api/historical/\(date).json?app_id=376fa06c3a104a21a0f94bd901a1e79f")
let task = URLSession.shared.dataTask(with: url!) { (data, response, error) in
if error != nil
{
print ("ERROR")
// ADD SEVERAL URL'S HERE FOR ACCESS HERE
}
else
{
if let content = data
{
do
{
let myJson = try JSONSerialization.jsonObject(with: content, options: JSONSerialization.ReadingOptions.mutableContainers) as AnyObject
if let rates = myJson["rates"] as? NSDictionary
{
for (key, value) in rates
{
self.currencyRates[(key as? String)!] = value as? Double
}
}
}
catch
{
}
}
}
}
task.resume()
}
Sometimes when I make a call to this function it prints out "currency not available") but other times the call works and it converts the currency. What can I make sure to do so that the call doesn't fail? I have even added a delay to make sure that the currencies have enough time to fetch before the call is made. | 0debug |
c++ vector type function implemetation : class City
{
private:
int id;
string name;
int populations;
int nooftourist;
vector<Attraction*>&attractions;
public:
City(int id,string name,int populations,int nooftourist):id(id),name(name),populations(populations),nooftourist(nooftourist){}
void setId(int _id);
void setName(string _name);
int getId();
string getName();
void display(){}
vector<Attraction*>getAttractions() { return attractions;}
};
what wrong with my program,i dont understand the vector type function
| 0debug |
static void qemu_rbd_aio_event_reader(void *opaque)
{
BDRVRBDState *s = opaque;
ssize_t ret;
do {
char *p = (char *)&s->event_rcb;
if ((ret = read(s->fds[RBD_FD_READ], p + s->event_reader_pos,
sizeof(s->event_rcb) - s->event_reader_pos)) > 0) {
if (ret > 0) {
s->event_reader_pos += ret;
if (s->event_reader_pos == sizeof(s->event_rcb)) {
s->event_reader_pos = 0;
qemu_rbd_complete_aio(s->event_rcb);
s->qemu_aio_count--;
}
}
}
} while (ret < 0 && errno == EINTR);
}
| 1threat |
How to select rows, and nearby rows : <p><a href="http://sqlfiddle.com/#!18/5bdce/1" rel="noreferrer"><strong>SQL Fiddle</strong></a></p>
<h2>Background</h2>
<p>I have a table of values that some need attention:</p>
<pre><code>| ID | AddedDate |
|---------|-------------|
| 1 | 2010-04-01 |
| 2 | 2010-04-01 |
| 3 | 2010-04-02 |
| 4 | 2010-04-02 |
| 5 | NULL | <----------- needs attention
| 6 | 2010-04-02 |
| 7 | 2010-04-03 |
| 8 | 2010-04-04 |
| 9 | 2010-04-04 |
| 2432659 | 2016-06-15 |
| 2432650 | 2016-06-16 |
| 2432651 | 2016-06-17 |
| 2432672 | 2016-06-18 |
| 2432673 | NULL | <----------- needs attention
| 2432674 | 2016-06-20 |
| 2432685 | 2016-06-21 |
</code></pre>
<p>I want to select the rows where <code>AddedDate</code> is null, and i want to select rows around it. In this example question it would be sufficient to say rows where the <code>ID</code> is ±3. This means i want:</p>
<pre><code>| ID | AddedDate |
|---------|-------------|
| 2 | 2010-04-01 | ─╮
| 3 | 2010-04-02 | │
| 4 | 2010-04-02 | │
| 5 | NULL | ├──ID values ±3
| 6 | 2010-04-02 | │
| 7 | 2010-04-03 | │
| 8 | 2010-04-04 | ─╯
| 2432672 | 2016-06-18 | ─╮
| 2432673 | NULL | ├──ID values ±3
| 2432674 | 2016-06-20 | ─╯
</code></pre>
<blockquote>
<p><strong>Note</strong>: In reality it's a table of 9M rows, and 15k need attention.</p>
</blockquote>
<h2>Attempts</h2>
<p>First i create a query that builds the ranges i'm interested in returning:</p>
<pre><code>SELECT
ID-3 AS [Low ID],
ID+3 AS [High ID]
FROM Items
WHERE AddedDate IS NULL
Low ID High ID
------- -------
2 8
2432670 2432676
</code></pre>
<p>So my initial attempt to use this does work:</p>
<pre><code>WITH dt AS (
SELECT ID-3 AS Low, ID+3 AS High
FROM Items
WHERE AddedDate IS NULL
)
SELECT * FROM Items
WHERE EXISTS(
SELECT 1 FROM dt
WHERE Items.ID BETWEEN dt.Low AND dt.High)
</code></pre>
<p>But when i try it on real data:</p>
<ul>
<li>9 million total rows</li>
<li>15,000 <em>interesting</em> rows</li>
<li>subtree cost of 63,318,400</li>
<li>it takes hours (before i give up and cancel it)</li>
</ul>
<p><a href="https://i.stack.imgur.com/2YfPW.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2YfPW.png" alt="enter image description here"></a></p>
<p>There's probably a more efficient way.</p>
<h2>Bonus Reading</h2>
<ul>
<li><a href="https://stackoverflow.com/questions/1813641/select-a-row-and-rows-around-it">Select a row and rows around it</a></li>
<li><a href="https://stackoverflow.com/questions/15101457/select-rows-with-matching-columns-from-sql-server">Select Rows with matching columns from SQL Server</a></li>
<li><a href="https://stackoverflow.com/questions/9320485/how-can-i-search-for-rows-around-a-given-string-value">How can I search for rows "around" a given string value?</a></li>
<li><a href="https://stackoverflow.com/questions/758186/how-to-get-n-rows-starting-from-row-m-from-sorted-table-in-t-sql">How to get N rows starting from row M from sorted table in T-SQL</a></li>
</ul>
| 0debug |
static int yop_read_packet(AVFormatContext *s, AVPacket *pkt)
{
YopDecContext *yop = s->priv_data;
AVIOContext *pb = s->pb;
int ret;
int actual_video_data_size = yop->frame_size -
yop->audio_block_length - yop->palette_size;
yop->video_packet.stream_index = 1;
if (yop->video_packet.data) {
*pkt = yop->video_packet;
yop->video_packet.data = NULL;
yop->video_packet.size = 0;
pkt->data[0] = yop->odd_frame;
pkt->flags |= AV_PKT_FLAG_KEY;
yop->odd_frame ^= 1;
return pkt->size;
}
ret = av_new_packet(&yop->video_packet,
yop->frame_size - yop->audio_block_length);
if (ret < 0)
return ret;
yop->video_packet.pos = avio_tell(pb);
ret = avio_read(pb, yop->video_packet.data, yop->palette_size);
if (ret < 0) {
goto err_out;
}else if (ret < yop->palette_size) {
ret = AVERROR_EOF;
goto err_out;
}
ret = av_get_packet(pb, pkt, 920);
if (ret < 0)
goto err_out;
pkt->pos = yop->video_packet.pos;
avio_skip(pb, yop->audio_block_length - ret);
ret = avio_read(pb, yop->video_packet.data + yop->palette_size,
actual_video_data_size);
if (ret < 0)
goto err_out;
else if (ret < actual_video_data_size)
av_shrink_packet(&yop->video_packet, yop->palette_size + ret);
return yop->audio_block_length;
err_out:
av_free_packet(&yop->video_packet);
return ret;
}
| 1threat |
Find name of a table in SQL : I wonder how to find a particular database by name.
Example:
Find database with name 'database1' in the current server.
| 0debug |
How to capture botocore's NoSuchKey exception? : <p>I'm trying to write "good" python and capture a S3 no such key error with this:</p>
<pre><code>session = botocore.session.get_session()
client = session.create_client('s3')
try:
client.get_object(Bucket=BUCKET, Key=FILE)
except NoSuchKey as e:
print >> sys.stderr, "no such key in bucket"
</code></pre>
<p>But NoSuchKey isn't defined and I can't trace it to the import I need to have it defined.</p>
<p><code>e.__class__</code> is <code>botocore.errorfactory.NoSuchKey</code> but <code>from botocore.errorfactory import NoSuchKey</code> gives an error and <code>from botocore.errorfactory import *</code> doesn't work either and I don't want to capture a generic error. </p>
| 0debug |
lex/yacc multiples outputs files : I am working with lex and yacc, and I need to create two output files. What do I need to do (if there is any function to make multiple files), and how do I name each file?
If someone could provide a simple example of how to generate two output files. | 0debug |
Flutter How to handle text selection? : <p>I need to display a styled text for reading and some actions. User should be able <strong>to select piece of text</strong> and mark it with color, save it or expand it (show an additional information, for example a translation to another language).</p>
<p>I can display text by using RichText widget.</p>
<p>1) How to make it selectable and how/where to add onTextSelected listener? There is a class TextSelection but I can't see how/where its used.</p>
<p>2) What is a simplest way to expand text? I can reload full text (with changes added) and totally update widget, but this will result to scrolling to the top of a text and I think there should be a better approach.</p>
| 0debug |
static void rtas_event_log_queue(int log_type, void *data, bool exception)
{
sPAPRMachineState *spapr = SPAPR_MACHINE(qdev_get_machine());
sPAPREventLogEntry *entry = g_new(sPAPREventLogEntry, 1);
g_assert(data);
entry->log_type = log_type;
entry->exception = exception;
entry->data = data;
QTAILQ_INSERT_TAIL(&spapr->pending_events, entry, next);
}
| 1threat |
pandas dataframe Shape of passed values is (1, 4), indices imply (4, 4) : <p>I am trying to create a pandas dataframe with one row using and ended up testing the following simple line of code:</p>
<pre><code>df = pd.DataFrame([1,2,3,4], columns=['a', 'b', 'v', 'w'])
</code></pre>
<p>Although this seems very simple i get the following error</p>
<pre><code>Shape of passed values is (1, 4), indices imply (4, 4)
</code></pre>
<p>I have seen a few answers on this issues but all provide a way around it that doesn't explain why this happens and does not apply in my case.</p>
<p>Thanks is advance.</p>
| 0debug |
What is the core difference between asyncio and trio? : <p>Today, I found a library named <a href="http://trio.readthedocs.io/en/latest/index.html" rel="noreferrer">trio</a> which says itself is an asynchronous API for humans. These words are a little similar with <code>requests</code>'. As <code>requests</code> is really a good library, I am wondering what is the advantages of <code>trio</code>.</p>
<p>There aren't many articles about it, I just find an <a href="https://vorpus.org/blog/some-thoughts-on-asynchronous-api-design-in-a-post-asyncawait-world/#the-curious-effectiveness-of-curio" rel="noreferrer">article</a> discussing <code>curio</code> and <code>asyncio</code>. To my surprise, <code>trio</code> says itself is even better than <code>curio</code>(next-generation curio).</p>
<p>After reading half of the article, I cannot find the core difference between these two asynchronous framework. It just gives some examples that <code>curio</code>'s implementation is more convenient than <code>asyncio</code>'s. But the underlying structure is almost the same(callback-based, I think all asynchronous IO framework are based on callback without any exception.)</p>
<p>So could someone give me a reason I have to accept that <code>trio</code> or <code>curio</code> is better than <code>asyncio</code>? Or explain more about why I should choose <code>trio</code> instead of built-in <code>asyncio</code>?</p>
| 0debug |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.